From patchwork Wed Mar 23 21:07:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12790148 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 93E8EC433F5 for ; Wed, 23 Mar 2022 21:07:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240959AbiCWVJF (ORCPT ); Wed, 23 Mar 2022 17:09:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240953AbiCWVI6 (ORCPT ); Wed, 23 Mar 2022 17:08:58 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 51E878E1BA for ; Wed, 23 Mar 2022 14:07:26 -0700 (PDT) Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 22NKYAvY001478 for ; Wed, 23 Mar 2022 21:07:25 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2021-07-09; bh=a4n5szR4ar5CW6cUfu8a6RCOic85ieRG4y4Jem+qoro=; b=W42IL84+SbLSecofvJZV+FF7fHaul7Gc01eMCRgTopEjqrjClIJKg2vyJDrcuFxwc0Yi IObzJFIOQjRvVnEoPdSG7riBCXbnMjcA63ED0freqcdpZ/Ws8F99XKsOqjFjg1UWJ8fj bw4csfQ4Nm1MFg6bOBf7XuSOZcVqwp0wGbVP+0d3mUHqXXRw0hjmi+Ie18FIOQ75CaWp /dhGAWgVqjAIlRoIE4yWwwI8jxz49c3Zpu/60ELJacgGFcJd0u6zVH0pM1vX+/jWw6Sw sN8tqJtgjcmJexVdwld0aoud9p5s3zT3eXAi992jWSJcdlb4lAN3dVS1Bcfw7dZpDvx7 cg== Received: from aserp3030.oracle.com ([141.146.126.71]) by mx0b-00069f02.pphosted.com with ESMTP id 3ew5y22tcm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 23 Mar 2022 21:07:25 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 22NL6Ld8082870 for ; Wed, 23 Mar 2022 21:07:24 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2168.outbound.protection.outlook.com [104.47.59.168]) by aserp3030.oracle.com with ESMTP id 3ew578y1wr-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 23 Mar 2022 21:07:24 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZiN6pW/pShjRa5whyN4NyQhJDK3EceOGd+SosYqpNcnRDGIWitlBFDFrxlJjdAqyuovT49ICReOrHicj2Q7mb8nkxSz76woGH/DS0TFU3M645pjbXZ7obr7oLbSJDstvG+GUEsqQ47objCiaVY06Qzu5ZWX/Y6vvjk6q2LUnpqNqqsUnJyjhfluyX+v9+F/Q2WDQrvRCiju+yxMxyponFagNby1Tb/ZxH1wuEU2lKeyqSWHr54rjfkfKaegzGCCOzxjANjxqGdD4y6sPbinSGZd1wc8KaJzS9NGJ942c2x7LIM/5Ku6jyXyoUzYlVdvJJj2MtPO2RtfotpmaH5KEhw== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=a4n5szR4ar5CW6cUfu8a6RCOic85ieRG4y4Jem+qoro=; b=AKCqgzj1ce0XhTmWd1LtE4Ehvvr+7lxwOdE7nTMiVy1WpBN18Zhc5tS+/yjkBS4f9rOlrQgxtvswh3pY3TgkpyC2kqtQnqKf741+6kJM/qT7PhqUMkTW14QYhoQ2X4MB5Apk71RX0C6c6J6JIFdlnS6dsyUj917q7jM0fxScq6pUKSj3ZuBCt696f4bh6WoYEGwOETubOianFKR3rohv6GK9YA3gJDwCtF9W+EXTAm1C9q4JwGU6fZW45OTckvnLdLYKCtv8Edj7v0yt95qqzwm1DedGRbrdPLIZw8pjdKzxmeRdZ1SGl+9YmlnJI1Vp+9pQ/GRq80LAjoy6rKpItg== 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=a4n5szR4ar5CW6cUfu8a6RCOic85ieRG4y4Jem+qoro=; b=RlAdk1jCYo1mJ00YSLMwMeX9feRpIKckPYJi+3MYENqJUFdHrTVhj3Jt6NHxbQWrPO8NpynCg69l1mgpCxLlHpbBQqGMPDjIpzRppikSu5vwTGQo2XMY0oJnqLU8aCH0UDi1fl3Nqpizdo7gYlH6xNpYdQNsZyZtYJCUvpL6OOI= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by PH0PR10MB4744.namprd10.prod.outlook.com (2603:10b6:510:3c::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5102.17; Wed, 23 Mar 2022 21:07:22 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::c517:eb23:bb2f:4b23]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::c517:eb23:bb2f:4b23%6]) with mapi id 15.20.5102.017; Wed, 23 Mar 2022 21:07:22 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v29 01/15] xfs: Fix double unlock in defer capture code Date: Wed, 23 Mar 2022 14:07:01 -0700 Message-Id: <20220323210715.201009-2-allison.henderson@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220323210715.201009-1-allison.henderson@oracle.com> References: <20220323210715.201009-1-allison.henderson@oracle.com> X-ClientProxiedBy: PH0PR07CA0084.namprd07.prod.outlook.com (2603:10b6:510:f::29) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a82bdc1b-9113-4393-8c83-08da0d111fdf X-MS-TrafficTypeDiagnostic: PH0PR10MB4744:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: vW+iaQmYW8lFllgZE+Zg2mwSFxZIlHUhtN/f1t1Fr9vV3OACXl62C131SjhM5ZT0stCtxB8uHcR2VjnCQbf9lFZN3CMwVNTuvOewut3DYybikncfLKee4XR6RfLgq6gvSS0n+2N/8JahtVPY0edQaypr/UWvFAUJSLrWz0Vx21zGmFrSdd/sXS2TXKwkzx3QLQbaIeuHH5USrVzkGaLeWuG+YtG5A2O8uJuu5jcAyHttgTVIxuZh5jVvM5WCmhHAz1MLmURuRIe1G1egZ+d3j6Ds0NC6Z+UEHufzgFR4eyLuwNKAiYzWulxJmHz3zGTgGBPUC8g3P0XJ+Gjyl2vzpFOR6UTNREQ5mlE3qeKE42jj/IlF0HZwL6C61saygADDeu0BILXTDkUzo/pkDSAUac/chuEV8ccBD7Ob/Jowr4W5xdG1NYNMZJ8qbutyB7DhPXPjehMaUTw4cfBblicBN0A3b+WWFNl8W6lFbp1wukFJJadc1HZBKHT9htYGSI0awA/12mQFCKpKl9NA8dk2Ounx/+BPCNtJ1+Q/oXh5FXjZSBhsmC92hNAEF7zN6+ya5WRz9X/Qv/celLCUftsvd2GAiO+oAsYnh8MaWEuiLCntg3Zn/cK+XglVSWhSCrtAyGrBM4xu60n/KWMp5Q/ZQ/jDjbMANgh7iPB4pXKho4/ZxqWvRBYWsrhiB7tqfLiDYBfgIxSPr1quTlrNrl317w== 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:(13230001)(366004)(6666004)(44832011)(2906002)(508600001)(26005)(186003)(36756003)(38100700002)(83380400001)(6506007)(38350700002)(6486002)(52116002)(86362001)(6512007)(5660300002)(66946007)(8676002)(66476007)(66556008)(8936002)(6916009)(316002)(1076003)(2616005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: vqN8fROLtwLbk774rahC/IOdh62Jk+wmITziF7dwzVEJ7xQwpz9m3c3QcMbO+viMFmNcQNVDREXX5PpI60SATLqPicyu2HexNu/K0iAvHYM2LJXPRzCfacHkuHAnIPiXh+jhaJMJOe4jxNsiHv6RogQugHdnPRxCJ3LqW9DmH+3iEgYac4qOPqrtlW7elkFsi3t+dhtlJCDULpEGdXsvrYBLdnm0V6/Jl5km72Zaq3udj/oXvLLryODo6awB8bK1LL+YwjcGCz87I8jtaymlvAHJHeiQSl/Xpkq8XlvNZqw1FdF3MTm1zDT/mviqtx5QBaERyx+rBHSQ4RJSWj3ivBZ7CtmGGfbbomM67JWGlwdgSDR9WQ7Kes9UVj1823ql6Yv9B+EsDT8NPqp8dRIntPRyZv/RKL11q8P5P0UVQ4bwBgCrUhw9CBD4nF+3i0ppyZGRwueq6ble+tFpf0Lakv5eFLB1U+RBL0GbZZ9tMMbQW1k4SdHAWO1pJfgw1W3Rdki2q9Plgdv2JSKdlQsScve1tQ49X0hIdkaIRrEcnVrFjcHoM9CGN9Mt3b0SLnhIHjJttleUxXAAkLnm7tDLXcFHPfNqwDp4dPozWcPhEToLUgNhCnnZ9huj6V67TheWgcuILX2XaJQwKH2JrwR9vXMVi3rDOxgvWrtK5qTQN+rxzYdIwEVw8nsVRDNpiEbDLPAeBb+4lFpGSFqZW06F/ZcJGPKvgkYfe3glHIMO5XCJx+4NLKPdgZW0sVRSFzVhjj6mF/iQ62JyRu5R8wlPm20nHtX1dwnt+FZONDLdjT89yb/BgVIU84/llTTaGaKz7WCu7ARro5vNVCnqbPTzzNdC9Umw5d5TE5YtPwTLDEANrDLXzlqONeiSFrO0QhNH1rbqye83lk8/IpFa99CrWNcQwkmM72WV/LcTOa/4IDJxSTFnvHch16bk9tiIBuYBjwMw4LUiFTH9lafHorbaMq3rpA4jVPERiSdws/SM4Cp8yJczoqdSuFSTmf3MsfXLtYEZdxqVjctorYLnIYbrdAlSaYrEgASEkjQ9HSvwY5qSX1spZhqjSi0mtC5yo61cqrT56nsfZw7vW6xCQdepfdyv7qRWmRY4jZxpJXCYj+s7xqxuEZEKP4v0SXqcdmAys8gOPObULfNymWi2mnhnvynzQHPG6gQnH2h8vfCG6mIxDDyjlaxKAFBEYoUf/1c8Jrxy2dJzenO5ttsyMLrc8iN4KQ5CVSonuejGJKj2VhHhDnS0PsBj1aKnll4FvefG7I81kV08olaJi3USsTJSmn89rQa5nHkfWM1LjH3om3EUW7+oKQZ1jJvAY1ieGTGY9bSShOJzsprb22EiB6hGex9tlqZ23Z3KImpWSwirIDB8xZrYHzUOcpoVlt8nXW/u87MBcTcZ3LI1NApfwY29X0qdtHapnWdZrxE9avow8bHHc8VlaXFpRn97Uce86+3ksvw6nlre0Sa2ps9YRIWU7g== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: a82bdc1b-9113-4393-8c83-08da0d111fdf X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Mar 2022 21:07:22.8258 (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: +6ntHf8CyUt/vdJju15Bs7awYxbWkeM/uHzNYtKIeAMO1VXMfkRVvx5e3tTKCvstuqwNcRDy+6xiEphUHhqsvy4IaVGSxbG6v2kHe/1jhHM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4744 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10295 signatures=694973 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 suspectscore=0 spamscore=0 mlxlogscore=999 phishscore=0 bulkscore=0 malwarescore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2203230111 X-Proofpoint-GUID: 4gLltsLlJ2pxkS4iQymVo4ytltbCGh5X X-Proofpoint-ORIG-GUID: 4gLltsLlJ2pxkS4iQymVo4ytltbCGh5X Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org The new deferred attr patch set uncovered a double unlock in the recent port of the defer ops capture and continue code. During log recovery, we're allowed to hold buffers to a transaction that's being used to replay an intent item. When we capture the resources as part of scheduling a continuation of an intent chain, we call xfs_buf_hold to retain our reference to the buffer beyond the transaction commit, but we do /not/ call xfs_trans_bhold to maintain the buffer lock. This means that xfs_defer_ops_continue needs to relock the buffers before xfs_defer_restore_resources joins then tothe new transaction. Additionally, the buffers should not be passed back via the dres structure since they need to remain locked unlike the inodes. So simply set dr_bufs to zero after populating the dres structure. Signed-off-by: Darrick J. Wong Signed-off-by: Allison Henderson Reviewed-by: Chandan Babu R --- fs/xfs/libxfs/xfs_defer.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/fs/xfs/libxfs/xfs_defer.c b/fs/xfs/libxfs/xfs_defer.c index 0805ade2d300..6dac8d6b8c21 100644 --- a/fs/xfs/libxfs/xfs_defer.c +++ b/fs/xfs/libxfs/xfs_defer.c @@ -22,6 +22,7 @@ #include "xfs_refcount.h" #include "xfs_bmap.h" #include "xfs_alloc.h" +#include "xfs_buf.h" static struct kmem_cache *xfs_defer_pending_cache; @@ -774,17 +775,25 @@ xfs_defer_ops_continue( struct xfs_trans *tp, struct xfs_defer_resources *dres) { + unsigned int i; + ASSERT(tp->t_flags & XFS_TRANS_PERM_LOG_RES); ASSERT(!(tp->t_flags & XFS_TRANS_DIRTY)); - /* Lock and join the captured inode to the new transaction. */ + /* Lock the captured resources to the new transaction. */ if (dfc->dfc_held.dr_inos == 2) xfs_lock_two_inodes(dfc->dfc_held.dr_ip[0], XFS_ILOCK_EXCL, dfc->dfc_held.dr_ip[1], XFS_ILOCK_EXCL); else if (dfc->dfc_held.dr_inos == 1) xfs_ilock(dfc->dfc_held.dr_ip[0], XFS_ILOCK_EXCL); + + for (i = 0; i < dfc->dfc_held.dr_bufs; i++) + xfs_buf_lock(dfc->dfc_held.dr_bp[i]); + + /* Join the captured resources to the new transaction. */ xfs_defer_restore_resources(tp, &dfc->dfc_held); memcpy(dres, &dfc->dfc_held, sizeof(struct xfs_defer_resources)); + dres->dr_bufs = 0; /* Move captured dfops chain and state to the transaction. */ list_splice_init(&dfc->dfc_dfops, &tp->t_dfops); From patchwork Wed Mar 23 21:07:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12790149 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 45FCEC433FE for ; Wed, 23 Mar 2022 21:07:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240953AbiCWVJG (ORCPT ); Wed, 23 Mar 2022 17:09:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38324 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245058AbiCWVI7 (ORCPT ); Wed, 23 Mar 2022 17:08:59 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E04DB8CCF4 for ; Wed, 23 Mar 2022 14:07:26 -0700 (PDT) Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 22NKY5Go001358 for ; Wed, 23 Mar 2022 21:07:26 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2021-07-09; bh=nPI9yaH4OGc+g9W0ZCpRY8Yi/inmc7wmPYCxIYPPVAg=; b=mP0ItyoxyvicsGSe/Xw2eyRH/sGt1oVSHx0egeSG6qPqn79gvQ5B936IXeLJfauRbgOT eE2+469O5GaHuy/kpbdLXAv+n47oBpgP1/k73OoacqIT1mDOvE/nXNnrQrqDZLAbojne xrvcE49EoBi0qAT9D1f8Ch2Ntk1Sp2GCh38ut0SnCFuvkJY7MgyXy4mueQMSqA3pY65l OHrapFlnRsNqSg81QCAgmgPyG21rrdlYx/P4QBT5HYhGVDWUrOH/q/u+hnxYxpJoFBsM AK+M9Q93Cnhlw+S5Tudf28w6gtR2BIRbOtpkMFp7Gb76aIged62CjAZvgEBNCETkSxIa Nw== Received: from aserp3030.oracle.com ([141.146.126.71]) by mx0b-00069f02.pphosted.com with ESMTP id 3ew6ssaqne-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 23 Mar 2022 21:07:25 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 22NL6Ld9082870 for ; Wed, 23 Mar 2022 21:07:25 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2168.outbound.protection.outlook.com [104.47.59.168]) by aserp3030.oracle.com with ESMTP id 3ew578y1wr-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 23 Mar 2022 21:07:24 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Y5f16DrhTaecN0UClPa+AGiA4cYh7g1s54ld2FKtOb2Fyvff36lvAnqKzH+aYZTnIqfVdbTX3Pdb38qzv883IY6B3vK6nj7Qo45jxMzompA48KZlBcQLcrRwaUOcVNSk5TGhbXRtCoHBCvYRIYjQ/0xs4stonpf7r8MUBM7xU/kWypw8k6IKs4ypKXD11/TPs7WOiFCIgwy274b3GgCm/ECq7DIVE1wPtkg+5A/OVfRww9L9rg9Fr1lKdONlNDwxYajfdL/tEmAcnYpOH3GjESPSiXC+6vLkvKq5cuEniszF5G0YfZ/akN4iVEaTzL5fR+qB+sZAnxFQlwAeN3GmHw== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=nPI9yaH4OGc+g9W0ZCpRY8Yi/inmc7wmPYCxIYPPVAg=; b=e4RLPmzUDnu0mXy/aDq7O+NkXdOQQSuE8iuLBbyhMnnv65AoH48940Zf0riiopWlCH2wy6A3IrdR5hqiiAMjaYvo7gPN23OyUpFAeA1gNHf3CSNgQ2ZOvNNigNBULvb3lbioeJ1nEjHS5YBXeVW7aLTqvPtjpAWq+Q05yZ1C5a7twcOdDTMTUwG0gI0+BrCjKM6SXwsUogGjObsNYy3au8z089uGqsNDhYCJ3yIMU8q48bNLu8f3nqNnmdqQvYWfnBK5AHPZtzCyPya2FaeNG89goa25ayJdFz8pUNTeht6iQdA0ImLnhpf336Hb9pmKONNJyp+3ZC4RgyxmfhyNkA== 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=nPI9yaH4OGc+g9W0ZCpRY8Yi/inmc7wmPYCxIYPPVAg=; b=j46StRcUEs0PBQh1mQs5/Pz4v3XEG7kJ1Ws0ZPtK8C6rjnaMbGJX3A9NpYqldP58/bQUb5x9lgQzvN1fGId9x7TK0y+P0VddJc0m9/1OQXl6AgRYNpzr+8D/xp8OvCzq2ByMz7VNenCvp3ZqSxUe/xbTvYH9Eaxvg7Pch9Fvh+E= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by PH0PR10MB4744.namprd10.prod.outlook.com (2603:10b6:510:3c::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5102.17; Wed, 23 Mar 2022 21:07:23 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::c517:eb23:bb2f:4b23]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::c517:eb23:bb2f:4b23%6]) with mapi id 15.20.5102.017; Wed, 23 Mar 2022 21:07:23 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v29 02/15] xfs: don't commit the first deferred transaction without intents Date: Wed, 23 Mar 2022 14:07:02 -0700 Message-Id: <20220323210715.201009-3-allison.henderson@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220323210715.201009-1-allison.henderson@oracle.com> References: <20220323210715.201009-1-allison.henderson@oracle.com> X-ClientProxiedBy: PH0PR07CA0084.namprd07.prod.outlook.com (2603:10b6:510:f::29) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: afa402fb-a5aa-49d3-0fec-08da0d112027 X-MS-TrafficTypeDiagnostic: PH0PR10MB4744:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: FWSQo9IC9KzgyeOQcuqyMYsaz5Y5hzdiaGNwnkd5VO5A+68tVDW1P9izK3N92pGOUa5uyRSqGMqHqzNxtgk8bBEc9yThV9MkiXJeaWXf8kAJy6sERHnkkg/3/gUP6jJbEfN8PTk5CXXwS0xJNyQgWaUjsi90j1uuE21FzPidConNTGcrKYq+vaK+optsvKnksKP5qSFBsHY+dmGGI1/BOcYRhbJTgMBiW8nnTRbiB8jLJVxzekYw7o9t7vRtsidOWpPoY2glgpj8YSmSu3jdtBkV/vwlH8tpXunTyuuNPJTxGomHn7OsX3g/akDWM6bzYMih1PW5MixnE51cDnoVQYKz5vrMJ7zW6LPBeR40K4G7tY99Sb7jzdNLofsVnugmRsHVjAWPVz1JZVu2J5DP2AmWf1o8zge0S3gsFzfhVUXZrU2r7EbUrpBza2T74juz/ZpRfNW0R5IM2iZf1ZPM+Q28Ysq+XAk2/dM/zVAId4o+eFePHXP/rln1ta/0bkVgEFlQ8gmyoB8TJLRahYO3cky0OwA7cxkQpXv9JI2FG0cnl5hADn+huK7U6LQkDMm/U82bmF17abg94JrEG7fksb0jXOv4s66cKf3AQgGz72mseEvddp8Elgdl145xsiisyy5Zbn1RDgS/lh5uaISUBqnIeZhszNyaCPqO4sIyDtJlSgtk7dBr69lo4IZnzCpJynqZpi02WjrlOaOLKPhK2Q== 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:(13230001)(366004)(6666004)(44832011)(2906002)(508600001)(26005)(186003)(36756003)(38100700002)(83380400001)(6506007)(38350700002)(6486002)(52116002)(86362001)(6512007)(5660300002)(66946007)(8676002)(66476007)(66556008)(8936002)(6916009)(316002)(1076003)(2616005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: vdu+F+CPmZ8Cctq3RknsvUmRIBAFXhwDxVp/oPLUIzB1U9+BPukbFhujFhISqlPL5PdNjLz0lvIOPlkPd6dQKREsX5g4DvzqKgs285berCS7STIPj9knCoXFMnoGf6qiNtbaagopCWBpjU6YeePG6xFpz8yt/ilfLJ53axD3XJydOPYojOymcr0uL9r3P678mCc4bvPvidD64IIaN0znvqfmsOfkWznk2D3CiF+pgvxJMjqKsIu4XG9AJmLM5jwikFByXcIPt9YwNwmkvvG0g3CrF29zmHca6FN6bjb+OmVGzNv+EYMq/iaB8CqgBD8UGoxB4OaHjIHrbWgsaOyUTuvlRUl6LOAwf5LxSVEglM5Ub96/xr19LebQNtBbMefy6Ds5mobkRbw426jai82cMkbdi7x17R6PXjwTL1CtKNsrppyWILNAvWDrv97NeCTZzktkyzUeMwpViZDPzmGdwEYbwOakDCnuOnS9lqWDZsA7H4o10bl1qsYsNNzlFi0oJFEici5jl8PWeG2K1LAZPpozh0ZHTx+puDZ1wDzuk0KBb9Qak1rciRSW7UTERB8N1R2vQWt3NJYZ4hKaGOMebIzY6w/bGFb/Juzqy7vZjZ/B8m/Lifodbx1MrsC2T7SRRh3lZbE/FJSHHht2/IybBLvyW52R9e6t7gD5yRnaXWKm/NV1hAD7fVLg5jG7evCECUhUGd9neHNy4lltqhBJp20Nl0+5aEILN/lo9sbCo0NjzTri/Rc3HaW5CQPBMKdo7Az10ACRopWyuB+ptT/lXHScpysZxeURrygbAJGSCaKnoSQTeLEfSwiATch3ma0UJJHgcCAzPUCRe+AfVbgMsI6GvmiqyjGizU+HjpLomqJQAcXayhAmcO2h/U+uRIuPz2nIztvdBJHwp3SggyYaJnhSoZt+48YP7IDqS058i5DAY+IRGcWaz9Gyq9LqCJCZJoqhNXEPK+0Lqta/sCXQZSo6WPob4UhwyvDfeooJCPXsh3panMAH5kZcTRIK07CST/io4UyoYILuypWnjAydD0TmmfdsxTzyIfuvK/mFoJnsOVCn3doEnWvHOk861p/SFyv68kiLQqCsFyOgeoSG5cUhLEXmjnkzN5cp+/wXHG81IgpshkIMzWPMzTTIwyd8Wc6ZB7ML+ERQR4CtvUiIJk9BGgcjgIzIJG7MelT82EDgwGUoETIWr7nDg0DkJ1wAfmfct6qmK+7rMe0G8Abz/gqnft954rUrrOXhQAKLi5NuZuZuyGZ1XmSy4wJosaSqvPIG0RJWs4ISs2JrDK2KhME4Q+TYEWPKDRncoLbtOBUydEEZIItdgnjG/EqR1670Rznd6Pgx9RhRP6jme3rNSIUw8Xuqxr4arpRarRW6TnmEXLWSSniDjE3hjTil5TCN5NPiHKZ8MzlTjLWDsdF1TTOZELuIeHCWIKCn0w7auVKBy2lAtbZQn98eXXF5FulUXMHN2ECdX49GIEB0GR4mwA== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: afa402fb-a5aa-49d3-0fec-08da0d112027 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Mar 2022 21:07:23.2632 (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: dBdW9NnyCXKsRs8N9RxABBpE4fvjTN5Ri2cQtZbr+2T1s3BKl1Stjww8ijQBQ25jmeVPzCrabS5VIVxWSSx9bPp+NXQWo3XbIUu09JBwghg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4744 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10295 signatures=694973 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 suspectscore=0 spamscore=0 mlxlogscore=999 phishscore=0 bulkscore=0 malwarescore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2203230111 X-Proofpoint-ORIG-GUID: vWTm-8uHoN7JOOlgZ7l3Of9pDx71kg0H X-Proofpoint-GUID: vWTm-8uHoN7JOOlgZ7l3Of9pDx71kg0H Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org If the first operation in a string of defer ops has no intents, then there is no reason to commit it before running the first call to xfs_defer_finish_one(). This allows the defer ops to be used effectively for non-intent based operations without requiring an unnecessary extra transaction commit when first called. This fixes a regression in per-attribute modification transaction count when delayed attributes are not being used. Signed-off-by: Dave Chinner Signed-off-by: Allison Henderson Reviewed-by: Darrick J. Wong Reviewed-by: Chandan Babu R --- fs/xfs/libxfs/xfs_defer.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/fs/xfs/libxfs/xfs_defer.c b/fs/xfs/libxfs/xfs_defer.c index 6dac8d6b8c21..5b3f3a7f1f65 100644 --- a/fs/xfs/libxfs/xfs_defer.c +++ b/fs/xfs/libxfs/xfs_defer.c @@ -510,9 +510,16 @@ xfs_defer_finish_noroll( xfs_defer_create_intents(*tp); list_splice_init(&(*tp)->t_dfops, &dop_pending); - error = xfs_defer_trans_roll(tp); - if (error) - goto out_shutdown; + /* + * We must ensure the transaction is clean before we try to + * finish the next deferred item by committing logged intent + * items and anything else that dirtied the transaction. + */ + if ((*tp)->t_flags & XFS_TRANS_DIRTY) { + error = xfs_defer_trans_roll(tp); + if (error) + goto out_shutdown; + } /* Possibly relog intent items to keep the log moving. */ error = xfs_defer_relog(tp, &dop_pending); From patchwork Wed Mar 23 21:07:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12790150 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 874FFC433F5 for ; Wed, 23 Mar 2022 21:07:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245058AbiCWVJJ (ORCPT ); Wed, 23 Mar 2022 17:09:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38450 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344477AbiCWVI7 (ORCPT ); Wed, 23 Mar 2022 17:08:59 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 426198CCEE for ; Wed, 23 Mar 2022 14:07:27 -0700 (PDT) Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 22NKYYtH020573 for ; Wed, 23 Mar 2022 21:07:26 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2021-07-09; bh=hLTFl3bdtlWGt6UMCQpgcnbNsiEqYCv7cGYKd50yvM4=; b=gNDY65Dm46G32QZ8cR64+91586PESZcQ2QGw01HzapX3hyQorWUse9OLwjyQBY47F5rU yUMeExKBwkD68jvKvxTkdD8voMHXoljnO4X36Kz7i7nF13qB5vtJKmlETtBEjedc6Gu0 8WOGRDHirtR4ig4StoRZ3cAPWv5WRz8trsdQA1cQhiti0E3DU5heR8PST12N8z+ND8dy QjlzwlA37Q30IlAeoevegalMQigz089DwMkJqexAnDsYlqr3nqxeq4Cv6e1GJaR7emoR X3lE7ZCELnJlV8XI/zDs6lkNatOlAWXOse6xme5Usl99wh4vMXvqGDpeQL5gQvhfraeY FQ== Received: from aserp3030.oracle.com ([141.146.126.71]) by mx0b-00069f02.pphosted.com with ESMTP id 3ew5kcth7m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 23 Mar 2022 21:07:26 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 22NL6LdA082870 for ; Wed, 23 Mar 2022 21:07:25 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2168.outbound.protection.outlook.com [104.47.59.168]) by aserp3030.oracle.com with ESMTP id 3ew578y1wr-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 23 Mar 2022 21:07:25 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UdBzIun5i078H0qzwg5IQGlBPDU6ESCIznW5rXETaesWdtW2pjn8ykTGmXylpnG+oigXZ03SUSCJRvzDK6GyzBcIk5dxHjQ93J7lFeDZyhGwyjvglBRroJuDwA9ixVPzC6C5jgQamSXR9yiDCj92fLlZRPXVmjJHVGcR9WdaGIgZX0KBhtWm1/0bQKfvMjPxomlV6K4YzkMGeeRL0ruFzZSdCohIGoghKqMMwnwW8J8xWGTCi9nXgdJPiwHkzu6K99/lyT5i8jt91wdkLXn6Mv5wYUpZSf/vmLrjzvKtG8KgUQ01J6F2cQbX8dq7Y9iotafszeRGSsP7I4Ml91k6lQ== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=hLTFl3bdtlWGt6UMCQpgcnbNsiEqYCv7cGYKd50yvM4=; b=XCxBn52W7BohT8+yRdHjoRWHEG16x838qGoT80aIbwhNIYinAwIkNkh9uV/j8Z3NXYUB8RXoSmmCPo1nPbM/f0mIPmSWDoreCz0iSoPfFqZBU9HtJreEdnhwid6yJ9YYRXSkMETMyYsBraOJy89LcUV7C/5GRLjwABGwJqL5H4rSJZtRAgdiYpx37SfaBhL/8/4YwgAqNdHtUDlRPXaxZszMHSE5aJEA5BYVKwPhxhrImJfY7o+r5sDYY+GRfDy6Xny35GG8GT0U0goT4qobmCWCbxwd6Vs+AJ30VXRZoXjLIsok/4p3WhJJDRxCMiHw+pgdAVVqMlJFKk8aDpXtXQ== 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=hLTFl3bdtlWGt6UMCQpgcnbNsiEqYCv7cGYKd50yvM4=; b=K/jT09NHmWSTdNiEpOyCIvXKB2psK/dcuFy+qBv4z6116XWqA6H+L6Dx1fvVa2nrH++jrTbsdtpcWZmyHdUevVJ3ovasbHNuFZv5rqnD+FvkfJqag1O8qHoGphzjA3Az0eiMtmWQN1gguKS8rl0fgpZgezcO8pCq+Obh2TnEBcw= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by PH0PR10MB4744.namprd10.prod.outlook.com (2603:10b6:510:3c::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5102.17; Wed, 23 Mar 2022 21:07:23 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::c517:eb23:bb2f:4b23]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::c517:eb23:bb2f:4b23%6]) with mapi id 15.20.5102.017; Wed, 23 Mar 2022 21:07:23 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v29 03/15] xfs: Return from xfs_attr_set_iter if there are no more rmtblks to process Date: Wed, 23 Mar 2022 14:07:03 -0700 Message-Id: <20220323210715.201009-4-allison.henderson@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220323210715.201009-1-allison.henderson@oracle.com> References: <20220323210715.201009-1-allison.henderson@oracle.com> X-ClientProxiedBy: PH0PR07CA0084.namprd07.prod.outlook.com (2603:10b6:510:f::29) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c2dc0cd9-4d27-4f35-e439-08da0d11205d X-MS-TrafficTypeDiagnostic: PH0PR10MB4744:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: JPlVJFjI9mn8i850Shb5CTe6bEVQ5/pxbKH52hM4FsdM972vQ5j36+6qw7/5FYDlnoiz+bcyEdP9DuPZBpUck2wNdYoVBhmxvJ4M2L0c327h8RGibswrTYl3epXYtq4VKA71B78u5CEQCcJ+/gXo115N3CPWoOhN7AHvTyB2vN25bMJT7ECYGTFXhvW5yYFTIYCrSvXHNaDMnvB/WgIJwsP1Zq+9r9U3adUBj6A3v52epHKaZ9ATf2YSZoYdM4qK7BFFFG/RU+fn7L8xAZ7woJuZQYniCJEBdDBHJHQttvn6EZ2Ac0/vmsC1i6RUcPiXgcRuORwJosoizKBh3iOHX/l5fnb6yTbEmJw9bKSwtIyi+ser7e9IlA+BDvR2GNzJTuYpf1yAMkKYZD8E5t5PhNs8HfpEF17H+BO+VYaouok1QMGKbu/gZtH4gou4Fu6v2km48Izmi733VeoCO0tamaJMPC5zNiH/J/Ms8x5RLgY+HOmsT8rc/9kT8mS5cBCNd7cEFdhZgAsj3YEkfP7FidDIRg2L6jIkF88rxYnPkw2p1luGvqd4Ji0K20J/KeMpDTJxp9yeIkwy5+B/MIjvwPTU/dBnCVFGnh9RpR7wIVa8dCFuZ2kbZK1Ig0MK5vhZFgHOVNZHwsB7MLFta1W7/ULpfGoS3iyULk7UeWIIN3UBBqCnFxrUvGV+pDu/E4TfLAx9U74GQTIA0cqOmR8hOWmKGkz9VXbQE9DO835Oad8U15hJ3DSxLrzwonCI9teAdb3lEfnMKE7o7ATuJXQ1Vg== 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:(13230001)(366004)(6666004)(44832011)(2906002)(508600001)(26005)(186003)(36756003)(38100700002)(83380400001)(6506007)(38350700002)(6486002)(52116002)(86362001)(6512007)(5660300002)(66946007)(8676002)(66476007)(66556008)(8936002)(6916009)(316002)(1076003)(2616005)(29513003)(40753002)(133343001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: s4zI+PxnEwfTejgyz1rJBS5IQXF2CsOlRXUqrY1hSoIWaiUkblHyIP1bGrVH+MWtKDkm7vtgUQabE/blaii7X5zvGYxVT+q9qL1sWPfFjQTrdpIr61a3pUxuBCWvV5Y038FzFWi0jj0Jb3t/LBDDTODgBqAVIbjDbNO6VNOGCaMF6Pl4B29TP6ClefWw+PgMBTfD0u3LEVYTSp/OxMZKSTw3l7w1QvKml8WoxVypTWr5bpM2kUeMpW9gx1SwBxVg3U95drz5HnQi9T9pcKydv6v/f6ZQ7GQ13rBkp4eigmkZZv4aDv7eBYosUe/itiJFHqJIqgHCtyXtSvl9+h6WwvgcFw+Q2hCfBDp6aYnagdfr5YOTb99OpNuI8WD6GHmhBAqKAsVWerb1qBm0Pznossb6AboxNOpJ7JKdOY4fFmScXeJ4x6FKVani6kMEQyxKo9L0RPu8gosJ/goR4fkJUcAQOC/ETbmmQ+Avs1UXrHzRvZ4xhDrVqRUfeDokW+lN76uXkZsoHXX/PBx0/qZytdhHQZhUJzTBuG0LpoX+LagDcNSBnxMehQl7/mzKicv6a7ziM97y+5WK90ycG1sn6FsF9WZcXfF3mc/A5cet3kxacaNrdhVZupwHJsqm1Oc4bsf1z4K16SJdePz9eFq99yhP7PZIsDlYSqKDSO8d3aSRT9x/vd3ql3FD9apg6JMp5KSc7ONI3unHPJHV8anUJyILn2zH6yBMwIrSnSfAwKf5CYaXxLJ2lqRMBf4K2PuRGgK7qMySrznon9SdXB19q6KFmrKH7gn2SWhT4FPjhk5PZXGdSIOzdzsZlgEmtfukxyvSteEJrcr7m+s5HRjxnJsFTBiyGN86CW14keVjtLZzhrMcAMZ2c23+yo4XD6yaElRPEbrX/1VORSoRiIPy0/tQoDjAyNfp145if56EaWEYpzMP9X7WdLI7xHceoc1/jpVC1qC4nJzsLd//NHBd4su+D8MIS3AP79EwNGBqAEQ7hEyikUNfrq3Tv3eiNOPBdipwZEzMmgSYzz1UhUfNL9fL0CyuZ851s80O/lcN39gnHvRpvu2meb5OpqZWGm6bFqLfTZkqyngnR5ReIU7MW3AqwPLmrSBMrGQqJQkN31sb8QIUnUIyOiI9NkczDjszac9XHnG3EcN9wiUvAjdb0KxAbZhYJJHbOi1ZYh7+2Xh/ucYzXQafGn/e/1M5w/7E5lqoA0dbeIFQq+2uEoqOT666hjY7YLlpEIcue36Y+pyqIqPmTJXrByy6h0t0YERoRhtrXTxHjt3pFLzSOvvdO4hAw1PNEWvTabJz+tpwocS+UKYmVMotv2k38brrfqtUxf9X6Is9XzQpXxVX1cqSVnYNLvPj9gIdvNDg8rlTKH4ULwjxhNDmwHY7QjMyALz/Tlfjc26cnqL7sd2HJpYs1l047vwqRtum7a4kweAbvo5QjmamO4vHxGSx/IIvc+2QvTwp9O54sJ1ZbgFNmTCKLQ== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: c2dc0cd9-4d27-4f35-e439-08da0d11205d X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Mar 2022 21:07:23.6069 (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: oo8oOOcyJtIfuSSSA9oXNibnuvTTIqjM2c6ccYZfVlz5itgm1aK4iw9O/IOnCji3kRDBhe6vTR17Vp3Hw+4aX0I+a9yLymkBK8HxnqjjA2I= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4744 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10295 signatures=694973 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 suspectscore=0 spamscore=0 mlxlogscore=999 phishscore=0 bulkscore=0 malwarescore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2203230111 X-Proofpoint-GUID: vVw1PbaXFPi_bM1ZaEXcVRVb1n9DZzNW X-Proofpoint-ORIG-GUID: vVw1PbaXFPi_bM1ZaEXcVRVb1n9DZzNW Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org During an attr rename operation, blocks are saved for later removal as rmtblkno2. The rmtblkno is used in the case of needing to alloc more blocks if not enough were available. However, in the case that no further blocks need to be added or removed, we can return as soon as xfs_attr_node_addname completes, rather than rolling the transaction with an -EAGAIN return. This extra loop does not hurt anything right now, but it will be a problem later when we get into log items because we end up with an empty log transaction. So, add a simple check to cut out the unneeded iteration. Signed-off-by: Allison Henderson Reviewed-by: Chandan Babu R Reviewed-by: Darrick J. Wong --- fs/xfs/libxfs/xfs_attr.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c index 23523b802539..23502a24ce41 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -412,6 +412,14 @@ xfs_attr_set_iter( if (error) return error; + /* + * If addname was successful, and we dont need to alloc + * or remove anymore blks, we're done. + */ + if (!args->rmtblkno && + !(args->op_flags & XFS_DA_OP_RENAME)) + return 0; + dac->dela_state = XFS_DAS_FOUND_NBLK; } trace_xfs_attr_set_iter_return(dac->dela_state, args->dp); From patchwork Wed Mar 23 21:07:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12790151 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4C307C433EF for ; Wed, 23 Mar 2022 21:07:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344477AbiCWVJK (ORCPT ); Wed, 23 Mar 2022 17:09:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38540 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344869AbiCWVJD (ORCPT ); Wed, 23 Mar 2022 17:09:03 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DA8278CD83 for ; Wed, 23 Mar 2022 14:07:27 -0700 (PDT) Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 22NKYFfC019841 for ; Wed, 23 Mar 2022 21:07:27 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2021-07-09; bh=kGezlg8gqla7EuQSkZGImy4A/03G3+dEO9hVIn8OwbY=; b=bYJBkEE6ObpanA14c2c1eeOT950JgiNF6/z7mfeNh0C8PfD2enmFXQ2fuPrHuHjP1arG G+B6AgGNg/sMF5gvkO/QZkgmkTw6nuPLxaFQ79ANal2JNsyTn5Vx4Uky/UP1EDZ5M87Z 6e5YPX4VLKJcHTv4jrWCu8mA63jw/8wpJgxj9IugXRIJIjHo5lwQX5GtJxjjdsfYQb4E tF0FTSFKtlfff/qQSPy1p9VhOjSQX4emCL+8lFZzTjl/lh1TdkhRRN8lD1fvb4ScOwFc w9lRLuuT9haFYDu+8xwINWC2hDVHaBdp92xsdmAJPPwGgC8USnwlfvFsdLT4kNrDp7Bl bQ== Received: from aserp3030.oracle.com ([141.146.126.71]) by mx0b-00069f02.pphosted.com with ESMTP id 3ew5kcth7n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 23 Mar 2022 21:07:26 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 22NL6LdB082870 for ; Wed, 23 Mar 2022 21:07:25 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2168.outbound.protection.outlook.com [104.47.59.168]) by aserp3030.oracle.com with ESMTP id 3ew578y1wr-5 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 23 Mar 2022 21:07:25 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XmksIEka6DAOCThJUwVOo4+ZDcyBPZO7AIdTuwxw36H2WPYdjZr8j04lEga2VfhBfbiBWhsVYQcl6DW5MKtljgrDt82pIWqgvWtUG9fiTRPg4gVWSN0ZxcFDvp9Dxpv0TwuFK498884N2vmpNaydo2eMo/l8nLc5lc0/2U1DdxRkPW7Pon1woEWeU52xW8blY7RQGN0fdS6sioqgZqWUZ/xU5IweS1k76OCqzj1FTGI1EL/MsghPMTkmTDkHbj0KxD++kUlVO3zArtz2ib5qBhrUr3AF/vck5O5gCcGBVQcWw1L9lk6zQct55EmMU8YgRoGIkKix2TMynkPST/r2yg== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=kGezlg8gqla7EuQSkZGImy4A/03G3+dEO9hVIn8OwbY=; b=FEL1JjdTPVptnjVxRyhHqwRuno0QUQfjNwTVjbEq7oM29MGVfDDksp6GSHwCq51+PvgAbpnEo8Rg3/MdGM4mkID6tWxkRTU3mNYbEubD3WpG4BN/kqYH/X3rvJA+buaQL3YQJb4gQAuih5UdW9lT5lDbu8sgPzM7Ccc5CCFuM0LO/HMLGYAKIXv4jprr0S4fKCkWz3IESh5VNgvZArvjzqB0GY+5uKXiUQ8DwJV7waDWdsi4kxOlFRrHPIWFasR+qHg9w9/WyLQycMHVrG97knevJTU4hNvXdc8hL650FNBKMQQIDekFXbZ7+kVDliWmNndBaExm2PSpBlmbrPCrKA== 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=kGezlg8gqla7EuQSkZGImy4A/03G3+dEO9hVIn8OwbY=; b=JNdwbVGpUmYj21X/1AMKgKJ6d5ZWqNYQKxPkO3OvleilXvsw/J/ZhVrgw8s3W2u5Tc0AKbYPVmF0ccDnrZbXKSiCaFooXsQa0wk5txVxfB5gf7pnMwLMRqTSmLCz/hlfWRsPqHKc70QEuuvVynF+CDFccvi8eNmmy2EMn1XOZSs= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by PH0PR10MB4744.namprd10.prod.outlook.com (2603:10b6:510:3c::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5102.17; Wed, 23 Mar 2022 21:07:24 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::c517:eb23:bb2f:4b23]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::c517:eb23:bb2f:4b23%6]) with mapi id 15.20.5102.017; Wed, 23 Mar 2022 21:07:24 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v29 04/15] xfs: Set up infrastructure for log attribute replay Date: Wed, 23 Mar 2022 14:07:04 -0700 Message-Id: <20220323210715.201009-5-allison.henderson@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220323210715.201009-1-allison.henderson@oracle.com> References: <20220323210715.201009-1-allison.henderson@oracle.com> X-ClientProxiedBy: PH0PR07CA0084.namprd07.prod.outlook.com (2603:10b6:510:f::29) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1fb9415a-fd6d-485f-e9b6-08da0d11209b X-MS-TrafficTypeDiagnostic: PH0PR10MB4744:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5567dAhLIzi1Unrf0vPQAyhGCq3vF3OAlC9/2Jjkr6y2z7nY2m82cSJHSe9D9WbQ+ntS3zNElN1CRmK3BHXCaiUeNkvHsArcPcgvM9J9kzH9cc0U1YwRH8IDbkgx/x2KSGJeSbVj1sGMXG3rv2SrTwJy4pdKxoMCNLDzOsxEKtOkmN3KyhgCzWU0QXCKchSQwhLHgHXZeTvvJ0ZTxZVC1eYVdAuCgAAaLmIP1h4Yq7oBsv0DYXaNLKadzVZPLSzL3HRsdVx+y41e/MmMGawWeApdV3BzLf7XVSZ+X/wKeYq5L1MN2/0M/3Ro1NLbHIb+bYgLJXUQ6HMrqMwyYmYghhfpIqTTTI6l8eximQwOscW/I8zIXX/5A5MV+W8+mnH897PjGpoSMH/vqRcoLujdaGkX1TC03ZPA5D2mrWHj/AXQG8/D4hRQm9xB5rV2SqNcO34FlJPzjbZBT5Ac8+fCQTGTW8vQsoE8ErqiD8W1j9ytC3KpaDkRSjLjeHx8/0JGhB9zYTkh6TBJg8U3aWCqpqlAnMMDaGP7a38qpGkZC+v/1CYDsCC0sbdRvo3kKcIz1tg+vlM4d3IAiUNsjMwnIH0Dzo94CVcYEMM++dW26bupLp6Qy7DlHRb9IdT90JnhgTAUkbC5MGotL/vvF33oCI/8j/iOZQ5yOwPWjh2+bfGjV682hI+eF7yISQWh7QpZbFpMjXL4YPlMZpM8iEF5Vg== 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:(13230001)(366004)(6666004)(44832011)(2906002)(508600001)(26005)(186003)(36756003)(38100700002)(83380400001)(6506007)(30864003)(38350700002)(6486002)(52116002)(86362001)(6512007)(5660300002)(66946007)(8676002)(66476007)(66556008)(8936002)(6916009)(316002)(1076003)(2616005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: oI7+suMhBakMXeY0Fdo0ymcx26ChL0fUmPJZ87FoId288QlCYNlRJPpM8zgv+6OHVYOpbfEFRGuEtt1XMOzDHiBniNinmugkiOOJki4JD27FNwjUxL/kOJkBkhXvK3FO/AKvo5VRW7fSeC5DSZSvltV8+BEGbCnzA36pWi1XEztRbJJX8KpUJEzarnk+xKPYeIWbPRvJzFaha4iF2Ja3+JCyKzLLMaFy5B5VMtvNI8DAiGdEY9iObqGWNTKbfmVVsEdjIAZN+IWFD0uWs0OgqNbsIdaHyQXLj+5Uu7wq/Q26/FKzQcfUQWu+9PRHMaY+ouuaxELa1m28itQitd605gX6MhiPfCrVKI6JIKIP2ndvUqWGSEMYgoRJm9MhgW+vEtNkvaPV+cai9EjoWQDw5NhK4zGejDLoNzG4k9Ayba1CWp0UrjDIfIVl4uLRJS5CbTVXfBgVaIsWgPkPKS2Yyp/AaXo6740RUa5SXcdT1J31KroSCqAsqkTSCpBfgiZRw1+5lT15moAvWNwpnu0mMRfVBZx7NYvNLs4Pn5yI7+KtK1giMd301/9jJBzk9PDRBm4wmgta4ejJWGfuhPzKZTRM99xBIp0OzlHhT+2NxavuJb4jD4vFuvEg0lm3rF+sST+x32sGLGm1fhOAOP1uX2Z9PI0hzKoovhxQIFe2PvJbZ7f/JUdnHxk8kMkjaZTjHggtC9JaYVtX5CDtj7kODOo48xte5TOc7Z35E/+I0c+nZs/93z/Arf7ZMCwhGcFsAmVd5bogvznkI5sxcHU5+lAQ2Sz3jZwcPswyXwqG6xRZaLp5L8vmlXWhZMkhZUSe4XQJD0EGkVtO3Woob1cTGilFgckTUY9QGHNcYjBIjxd/zrUTefsctJw97yQH50zCN6vc3T/QACc58vac+MOP+1m7g/j/e6ceKSf89uYul+zGI4/V09OuW1ZTupoGmmniksGrgCu4o+uyutkxhEczmK2sKvItFW4ctzmu3yyjfuTuoznbBtCl6Jvf0+WKYVUGoWkBN5eBr8DPeB8QNNuW5dtGBdiSxaL68xDCwzyzTbQTvv3s+wCEk3PWFOFX6I2oC7nUrGlKv1F3yEy9vSBMWPDIUmwE4ldiYt1xP13E1j1Lhb1GAn0mJLQnFO7VTh8Lhu/4mYny5AlU9grfJzu2MSmRdMnpEPDn9chkP78QVab0yQRgSPc5n7hFF67282NGZyvIumua3UIEvBd8KezRmwTPMsQb8R8/K4jQXSIBu9HNaNEw3JICIYYO/M2akEaK895AmapQo5F2f5FLGSJGVSnEalG1xCzE+l0Cl7U9fENRxnqcVYv/wMkjVTE/tAyRPb0G5tNpVK9lle6UCt0lnlLjdHQI0+jEuXmB+ucVKlByUzNmjiq3rwCVe2gvSyJbW35aR7NvMKxaGaj5ConBMOo1KNkX79Ac+mfX0081glUiOeCu6/gkiZolGt90iIoffU0XpWsmnvkbfp12v0e+kA== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1fb9415a-fd6d-485f-e9b6-08da0d11209b X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Mar 2022 21:07:24.1068 (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: xjbl1n4w2TQaaakIV+aM/soyrydzJLQBkAnlOHR02LnbJvmnr5nDMXfOmYhggYUCY6xbG26wX4cGe8GNRWNtNFrAMdSO9FgbP0Q5qFBvTSA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4744 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10295 signatures=694973 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 suspectscore=0 spamscore=0 mlxlogscore=999 phishscore=0 bulkscore=0 malwarescore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2203230111 X-Proofpoint-GUID: XiUYrVgwhKFmV1WSehZ9i86DAavZjkbA X-Proofpoint-ORIG-GUID: XiUYrVgwhKFmV1WSehZ9i86DAavZjkbA Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org Currently attributes are modified directly across one or more transactions. But they are not logged or replayed in the event of an error. The goal of log attr replay is to enable logging and replaying of attribute operations using the existing delayed operations infrastructure. This will later enable the attributes to become part of larger multi part operations that also must first be recorded to the log. This is mostly of interest in the scheme of parent pointers which would need to maintain an attribute containing parent inode information any time an inode is moved, created, or removed. Parent pointers would then be of interest to any feature that would need to quickly derive an inode path from the mount point. Online scrub, nfs lookups and fs grow or shrink operations are all features that could take advantage of this. This patch adds two new log item types for setting or removing attributes as deferred operations. The xfs_attri_log_item will log an intent to set or remove an attribute. The corresponding xfs_attrd_log_item holds a reference to the xfs_attri_log_item and is freed once the transaction is done. Both log items use a generic xfs_attr_log_format structure that contains the attribute name, value, flags, inode, and an op_flag that indicates if the operations is a set or remove. Signed-off-by: Allison Henderson Reviewed-by: Chandan Babu R Reviewed-by: Darrick J. Wong --- fs/xfs/Makefile | 1 + fs/xfs/libxfs/xfs_attr.c | 42 ++- fs/xfs/libxfs/xfs_attr.h | 38 +++ fs/xfs/libxfs/xfs_defer.c | 10 +- fs/xfs/libxfs/xfs_defer.h | 2 + fs/xfs/libxfs/xfs_log_format.h | 44 ++- fs/xfs/libxfs/xfs_log_recover.h | 2 + fs/xfs/scrub/common.c | 2 + fs/xfs/xfs_attr_item.c | 456 ++++++++++++++++++++++++++++++++ fs/xfs/xfs_attr_item.h | 46 ++++ fs/xfs/xfs_attr_list.c | 1 + fs/xfs/xfs_ioctl32.c | 2 + fs/xfs/xfs_iops.c | 2 + fs/xfs/xfs_log.c | 4 + fs/xfs/xfs_log.h | 11 + fs/xfs/xfs_log_recover.c | 2 + fs/xfs/xfs_ondisk.h | 2 + 17 files changed, 661 insertions(+), 6 deletions(-) diff --git a/fs/xfs/Makefile b/fs/xfs/Makefile index 04611a1068b4..b056cfc6398e 100644 --- a/fs/xfs/Makefile +++ b/fs/xfs/Makefile @@ -102,6 +102,7 @@ xfs-y += xfs_log.o \ xfs_buf_item_recover.o \ xfs_dquot_item_recover.o \ xfs_extfree_item.o \ + xfs_attr_item.o \ xfs_icreate_item.o \ xfs_inode_item.o \ xfs_inode_item_recover.o \ diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c index 23502a24ce41..21594f814685 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -24,6 +24,10 @@ #include "xfs_quota.h" #include "xfs_trans_space.h" #include "xfs_trace.h" +#include "xfs_attr_item.h" + +struct kmem_cache *xfs_attri_cache; +struct kmem_cache *xfs_attrd_cache; /* * xfs_attr.c @@ -61,8 +65,6 @@ 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); STATIC int xfs_attr_node_removename(struct xfs_da_args *args, struct xfs_da_state *state); @@ -166,7 +168,7 @@ xfs_attr_get( /* * Calculate how many blocks we need for the new attribute, */ -STATIC int +int xfs_attr_calc_size( struct xfs_da_args *args, int *local) @@ -837,6 +839,40 @@ xfs_attr_set( goto out_unlock; } +int __init +xfs_attri_init_cache(void) +{ + xfs_attri_cache = kmem_cache_create("xfs_attri", + sizeof(struct xfs_attri_log_item), + 0, 0, NULL); + + return xfs_attri_cache != NULL ? 0 : -ENOMEM; +} + +void +xfs_attri_destroy_cache(void) +{ + kmem_cache_destroy(xfs_attri_cache); + xfs_attri_cache = NULL; +} + +int __init +xfs_attrd_init_cache(void) +{ + xfs_attrd_cache = kmem_cache_create("xfs_attrd", + sizeof(struct xfs_attrd_log_item), + 0, 0, NULL); + + return xfs_attrd_cache != NULL ? 0 : -ENOMEM; +} + +void +xfs_attrd_destroy_cache(void) +{ + kmem_cache_destroy(xfs_attrd_cache); + xfs_attrd_cache = NULL; +} + /*======================================================================== * External routines when attribute list is inside the inode *========================================================================*/ diff --git a/fs/xfs/libxfs/xfs_attr.h b/fs/xfs/libxfs/xfs_attr.h index 5e71f719bdd5..80b6f28b0d1a 100644 --- a/fs/xfs/libxfs/xfs_attr.h +++ b/fs/xfs/libxfs/xfs_attr.h @@ -28,6 +28,11 @@ struct xfs_attr_list_context; */ #define ATTR_MAX_VALUELEN (64*1024) /* max length of a value */ +static inline bool xfs_has_larp(struct xfs_mount *mp) +{ + return false; +} + /* * Kernel-internal version of the attrlist cursor. */ @@ -461,6 +466,11 @@ enum xfs_delattr_state { struct xfs_delattr_context { struct xfs_da_args *da_args; + /* + * Used by xfs_attr_set to hold a leaf buffer across a transaction roll + */ + struct xfs_buf *leaf_bp; + /* Used in xfs_attr_rmtval_set_blk to roll through allocating blocks */ struct xfs_bmbt_irec map; xfs_dablk_t lblkno; @@ -474,6 +484,23 @@ struct xfs_delattr_context { enum xfs_delattr_state dela_state; }; +/* + * List of attrs to commit later. + */ +struct xfs_attr_item { + struct xfs_delattr_context xattri_dac; + + /* + * Indicates if the attr operation is a set or a remove + * XFS_ATTR_OP_FLAGS_{SET,REMOVE} + */ + unsigned int xattri_op_flags; + + /* used to log this item to an intent */ + struct list_head xattri_list; +}; + + /*======================================================================== * Function prototypes for the kernel. *========================================================================*/ @@ -490,10 +517,21 @@ int xfs_attr_get_ilocked(struct xfs_da_args *args); int xfs_attr_get(struct xfs_da_args *args); int xfs_attr_set(struct xfs_da_args *args); int xfs_attr_set_args(struct xfs_da_args *args); +int xfs_attr_set_iter(struct xfs_delattr_context *dac, + struct xfs_buf **leaf_bp); int xfs_attr_remove_args(struct xfs_da_args *args); int xfs_attr_remove_iter(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); +int xfs_attr_calc_size(struct xfs_da_args *args, int *local); + +extern struct kmem_cache *xfs_attri_cache; +extern struct kmem_cache *xfs_attrd_cache; + +int __init xfs_attri_init_cache(void); +void xfs_attri_destroy_cache(void); +int __init xfs_attrd_init_cache(void); +void xfs_attrd_destroy_cache(void); #endif /* __XFS_ATTR_H__ */ diff --git a/fs/xfs/libxfs/xfs_defer.c b/fs/xfs/libxfs/xfs_defer.c index 5b3f3a7f1f65..91adfb01c848 100644 --- a/fs/xfs/libxfs/xfs_defer.c +++ b/fs/xfs/libxfs/xfs_defer.c @@ -23,6 +23,7 @@ #include "xfs_bmap.h" #include "xfs_alloc.h" #include "xfs_buf.h" +#include "xfs_attr.h" static struct kmem_cache *xfs_defer_pending_cache; @@ -870,7 +871,12 @@ xfs_defer_init_item_caches(void) error = xfs_extfree_intent_init_cache(); if (error) goto err; - + error = xfs_attri_init_cache(); + if (error) + goto err; + error = xfs_attrd_init_cache(); + if (error) + goto err; return 0; err: xfs_defer_destroy_item_caches(); @@ -881,6 +887,8 @@ xfs_defer_init_item_caches(void) void xfs_defer_destroy_item_caches(void) { + xfs_attri_destroy_cache(); + xfs_attrd_destroy_cache(); xfs_extfree_intent_destroy_cache(); xfs_bmap_intent_destroy_cache(); xfs_refcount_intent_destroy_cache(); diff --git a/fs/xfs/libxfs/xfs_defer.h b/fs/xfs/libxfs/xfs_defer.h index 7bb8a31ad65b..fcd23e5cf1ee 100644 --- a/fs/xfs/libxfs/xfs_defer.h +++ b/fs/xfs/libxfs/xfs_defer.h @@ -63,6 +63,8 @@ extern const struct xfs_defer_op_type xfs_refcount_update_defer_type; extern const struct xfs_defer_op_type xfs_rmap_update_defer_type; extern const struct xfs_defer_op_type xfs_extent_free_defer_type; extern const struct xfs_defer_op_type xfs_agfl_free_defer_type; +extern const struct xfs_defer_op_type xfs_attr_defer_type; + /* * Deferred operation item relogging limits. diff --git a/fs/xfs/libxfs/xfs_log_format.h b/fs/xfs/libxfs/xfs_log_format.h index b322db523d65..3301c369e815 100644 --- a/fs/xfs/libxfs/xfs_log_format.h +++ b/fs/xfs/libxfs/xfs_log_format.h @@ -114,7 +114,12 @@ struct xfs_unmount_log_format { #define XLOG_REG_TYPE_CUD_FORMAT 24 #define XLOG_REG_TYPE_BUI_FORMAT 25 #define XLOG_REG_TYPE_BUD_FORMAT 26 -#define XLOG_REG_TYPE_MAX 26 +#define XLOG_REG_TYPE_ATTRI_FORMAT 27 +#define XLOG_REG_TYPE_ATTRD_FORMAT 28 +#define XLOG_REG_TYPE_ATTR_NAME 29 +#define XLOG_REG_TYPE_ATTR_VALUE 30 +#define XLOG_REG_TYPE_MAX 30 + /* * Flags to log operation header @@ -237,6 +242,8 @@ typedef struct xfs_trans_header { #define XFS_LI_CUD 0x1243 #define XFS_LI_BUI 0x1244 /* bmbt update intent */ #define XFS_LI_BUD 0x1245 +#define XFS_LI_ATTRI 0x1246 /* attr set/remove intent*/ +#define XFS_LI_ATTRD 0x1247 /* attr set/remove done */ #define XFS_LI_TYPE_DESC \ { XFS_LI_EFI, "XFS_LI_EFI" }, \ @@ -252,7 +259,9 @@ typedef struct xfs_trans_header { { XFS_LI_CUI, "XFS_LI_CUI" }, \ { XFS_LI_CUD, "XFS_LI_CUD" }, \ { XFS_LI_BUI, "XFS_LI_BUI" }, \ - { XFS_LI_BUD, "XFS_LI_BUD" } + { XFS_LI_BUD, "XFS_LI_BUD" }, \ + { XFS_LI_ATTRI, "XFS_LI_ATTRI" }, \ + { XFS_LI_ATTRD, "XFS_LI_ATTRD" } /* * Inode Log Item Format definitions. @@ -869,4 +878,35 @@ struct xfs_icreate_log { __be32 icl_gen; /* inode generation number to use */ }; +/* + * Flags for deferred attribute operations. + * Upper bits are flags, lower byte is type code + */ +#define XFS_ATTR_OP_FLAGS_SET 1 /* Set the attribute */ +#define XFS_ATTR_OP_FLAGS_REMOVE 2 /* Remove the attribute */ +#define XFS_ATTR_OP_FLAGS_TYPE_MASK 0xFF /* Flags type mask */ + +/* + * This is the structure used to lay out an attr log item in the + * log. + */ +struct xfs_attri_log_format { + uint16_t alfi_type; /* attri log item type */ + uint16_t alfi_size; /* size of this item */ + uint32_t __pad; /* pad to 64 bit aligned */ + uint64_t alfi_id; /* attri identifier */ + uint64_t alfi_ino; /* the inode for this attr operation */ + uint32_t alfi_op_flags; /* marks the op as a set or remove */ + uint32_t alfi_name_len; /* attr name length */ + uint32_t alfi_value_len; /* attr value length */ + uint32_t alfi_attr_flags;/* attr flags */ +}; + +struct xfs_attrd_log_format { + uint16_t alfd_type; /* attrd log item type */ + uint16_t alfd_size; /* size of this item */ + uint32_t __pad; /* pad to 64 bit aligned */ + uint64_t alfd_alf_id; /* id of corresponding attri */ +}; + #endif /* __XFS_LOG_FORMAT_H__ */ diff --git a/fs/xfs/libxfs/xfs_log_recover.h b/fs/xfs/libxfs/xfs_log_recover.h index ff69a0000817..32e216255cb0 100644 --- a/fs/xfs/libxfs/xfs_log_recover.h +++ b/fs/xfs/libxfs/xfs_log_recover.h @@ -72,6 +72,8 @@ extern const struct xlog_recover_item_ops xlog_rui_item_ops; extern const struct xlog_recover_item_ops xlog_rud_item_ops; extern const struct xlog_recover_item_ops xlog_cui_item_ops; extern const struct xlog_recover_item_ops xlog_cud_item_ops; +extern const struct xlog_recover_item_ops xlog_attri_item_ops; +extern const struct xlog_recover_item_ops xlog_attrd_item_ops; /* * Macros, structures, prototypes for internal log manager use. diff --git a/fs/xfs/scrub/common.c b/fs/xfs/scrub/common.c index bf1f3607d0b6..97b54ac3075f 100644 --- a/fs/xfs/scrub/common.c +++ b/fs/xfs/scrub/common.c @@ -23,6 +23,8 @@ #include "xfs_rmap_btree.h" #include "xfs_log.h" #include "xfs_trans_priv.h" +#include "xfs_da_format.h" +#include "xfs_da_btree.h" #include "xfs_attr.h" #include "xfs_reflink.h" #include "xfs_ag.h" diff --git a/fs/xfs/xfs_attr_item.c b/fs/xfs/xfs_attr_item.c new file mode 100644 index 000000000000..394ef4497553 --- /dev/null +++ b/fs/xfs/xfs_attr_item.c @@ -0,0 +1,456 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (C) 2022 Oracle. All Rights Reserved. + * Author: Allison Henderson + */ + +#include "xfs.h" +#include "xfs_fs.h" +#include "xfs_format.h" +#include "xfs_trans_resv.h" +#include "xfs_shared.h" +#include "xfs_mount.h" +#include "xfs_defer.h" +#include "xfs_log_format.h" +#include "xfs_trans.h" +#include "xfs_trans_priv.h" +#include "xfs_log.h" +#include "xfs_inode.h" +#include "xfs_da_format.h" +#include "xfs_da_btree.h" +#include "xfs_attr.h" +#include "xfs_attr_item.h" +#include "xfs_trace.h" +#include "xfs_inode.h" +#include "xfs_trans_space.h" +#include "xfs_error.h" +#include "xfs_log_priv.h" +#include "xfs_log_recover.h" + +static const struct xfs_item_ops xfs_attri_item_ops; +static const struct xfs_item_ops xfs_attrd_item_ops; + +static inline struct xfs_attri_log_item *ATTRI_ITEM(struct xfs_log_item *lip) +{ + return container_of(lip, struct xfs_attri_log_item, attri_item); +} + +STATIC void +xfs_attri_item_free( + struct xfs_attri_log_item *attrip) +{ + kmem_free(attrip->attri_item.li_lv_shadow); + kmem_free(attrip); +} + +/* + * Freeing the attrip requires that we remove it from the AIL if it has already + * been placed there. However, the ATTRI may not yet have been placed in the + * AIL when called by xfs_attri_release() from ATTRD processing due to the + * ordering of committed vs unpin operations in bulk insert operations. Hence + * the reference count to ensure only the last caller frees the ATTRI. + */ +STATIC void +xfs_attri_release( + struct xfs_attri_log_item *attrip) +{ + ASSERT(atomic_read(&attrip->attri_refcount) > 0); + if (atomic_dec_and_test(&attrip->attri_refcount)) { + xfs_trans_ail_delete(&attrip->attri_item, + SHUTDOWN_LOG_IO_ERROR); + xfs_attri_item_free(attrip); + } +} + +STATIC void +xfs_attri_item_size( + struct xfs_log_item *lip, + int *nvecs, + int *nbytes) +{ + struct xfs_attri_log_item *attrip = ATTRI_ITEM(lip); + + *nvecs += 2; + *nbytes += sizeof(struct xfs_attri_log_format) + + xlog_calc_iovec_len(attrip->attri_name_len); + + if (!attrip->attri_value_len) + return; + + *nvecs += 1; + *nbytes += xlog_calc_iovec_len(attrip->attri_value_len); +} + +/* + * This is called to fill in the log iovecs for the given attri log + * item. We use 1 iovec for the attri_format_item, 1 for the name, and + * another for the value if it is present + */ +STATIC void +xfs_attri_item_format( + struct xfs_log_item *lip, + struct xfs_log_vec *lv) +{ + struct xfs_attri_log_item *attrip = ATTRI_ITEM(lip); + struct xfs_log_iovec *vecp = NULL; + + attrip->attri_format.alfi_type = XFS_LI_ATTRI; + attrip->attri_format.alfi_size = 1; + + /* + * This size accounting must be done before copying the attrip into the + * iovec. If we do it after, the wrong size will be recorded to the log + * and we trip across assertion checks for bad region sizes later during + * the log recovery. + */ + + ASSERT(attrip->attri_name_len > 0); + attrip->attri_format.alfi_size++; + + if (attrip->attri_value_len > 0) + attrip->attri_format.alfi_size++; + + xlog_copy_iovec(lv, &vecp, XLOG_REG_TYPE_ATTRI_FORMAT, + &attrip->attri_format, + sizeof(struct xfs_attri_log_format)); + xlog_copy_iovec(lv, &vecp, XLOG_REG_TYPE_ATTR_NAME, + attrip->attri_name, + xlog_calc_iovec_len(attrip->attri_name_len)); + if (attrip->attri_value_len > 0) + xlog_copy_iovec(lv, &vecp, XLOG_REG_TYPE_ATTR_VALUE, + attrip->attri_value, + xlog_calc_iovec_len(attrip->attri_value_len)); +} + +/* + * The unpin operation is the last place an ATTRI is manipulated in the log. It + * is either inserted in the AIL or aborted in the event of a log I/O error. In + * either case, the ATTRI transaction has been successfully committed to make + * it this far. Therefore, we expect whoever committed the ATTRI to either + * construct and commit the ATTRD or drop the ATTRD's reference in the event of + * error. Simply drop the log's ATTRI reference now that the log is done with + * it. + */ +STATIC void +xfs_attri_item_unpin( + struct xfs_log_item *lip, + int remove) +{ + xfs_attri_release(ATTRI_ITEM(lip)); +} + + +STATIC void +xfs_attri_item_release( + struct xfs_log_item *lip) +{ + xfs_attri_release(ATTRI_ITEM(lip)); +} + +/* + * Allocate and initialize an attri item. Caller may allocate an additional + * trailing buffer for name and value + */ +STATIC struct xfs_attri_log_item * +xfs_attri_init( + struct xfs_mount *mp, + uint32_t name_len, + uint32_t value_len) + +{ + struct xfs_attri_log_item *attrip; + uint32_t name_vec_len = 0; + uint32_t value_vec_len = 0; + uint32_t buffer_size; + + if (name_len) + name_vec_len = xlog_calc_iovec_len(name_len); + if (value_len) + value_vec_len = xlog_calc_iovec_len(value_len); + + buffer_size = name_vec_len + value_vec_len; + + if (buffer_size) { + attrip = kmem_zalloc(sizeof(struct xfs_attri_log_item) + + buffer_size, KM_NOFS); + if (attrip == NULL) + return NULL; + } else { + attrip = kmem_cache_zalloc(xfs_attri_cache, + GFP_NOFS | __GFP_NOFAIL); + } + + attrip->attri_name_len = name_len; + if (name_len) + attrip->attri_name = ((char *)attrip) + + sizeof(struct xfs_attri_log_item); + else + attrip->attri_name = NULL; + + attrip->attri_value_len = value_len; + if (value_len) + attrip->attri_value = ((char *)attrip) + + sizeof(struct xfs_attri_log_item) + + name_vec_len; + else + attrip->attri_value = NULL; + + xfs_log_item_init(mp, &attrip->attri_item, XFS_LI_ATTRI, + &xfs_attri_item_ops); + attrip->attri_format.alfi_id = (uintptr_t)(void *)attrip; + atomic_set(&attrip->attri_refcount, 2); + + return attrip; +} + +/* + * Copy an attr format buffer from the given buf, and into the destination attr + * format structure. + */ +STATIC int +xfs_attri_copy_format( + struct xfs_log_iovec *buf, + struct xfs_attri_log_format *dst_attr_fmt) +{ + struct xfs_attri_log_format *src_attr_fmt = buf->i_addr; + size_t len; + + len = sizeof(struct xfs_attri_log_format); + if (buf->i_len != len) { + XFS_ERROR_REPORT(__func__, XFS_ERRLEVEL_LOW, NULL); + return -EFSCORRUPTED; + } + + memcpy((char *)dst_attr_fmt, (char *)src_attr_fmt, len); + return 0; +} + +static inline struct xfs_attrd_log_item *ATTRD_ITEM(struct xfs_log_item *lip) +{ + return container_of(lip, struct xfs_attrd_log_item, attrd_item); +} + +STATIC void +xfs_attrd_item_free(struct xfs_attrd_log_item *attrdp) +{ + kmem_free(attrdp->attrd_item.li_lv_shadow); + kmem_free(attrdp); +} + +STATIC void +xfs_attrd_item_size( + struct xfs_log_item *lip, + int *nvecs, + int *nbytes) +{ + *nvecs += 1; + *nbytes += sizeof(struct xfs_attrd_log_format); +} + +/* + * This is called to fill in the log iovecs for the given attrd log item. We use + * only 1 iovec for the attrd_format, and we point that at the attr_log_format + * structure embedded in the attrd item. + */ +STATIC void +xfs_attrd_item_format( + struct xfs_log_item *lip, + struct xfs_log_vec *lv) +{ + struct xfs_attrd_log_item *attrdp = ATTRD_ITEM(lip); + struct xfs_log_iovec *vecp = NULL; + + attrdp->attrd_format.alfd_type = XFS_LI_ATTRD; + attrdp->attrd_format.alfd_size = 1; + + xlog_copy_iovec(lv, &vecp, XLOG_REG_TYPE_ATTRD_FORMAT, + &attrdp->attrd_format, + sizeof(struct xfs_attrd_log_format)); +} + +/* + * The ATTRD is either committed or aborted if the transaction is canceled. If + * the transaction is canceled, drop our reference to the ATTRI and free the + * ATTRD. + */ +STATIC void +xfs_attrd_item_release( + struct xfs_log_item *lip) +{ + struct xfs_attrd_log_item *attrdp = ATTRD_ITEM(lip); + + xfs_attri_release(attrdp->attrd_attrip); + xfs_attrd_item_free(attrdp); +} + +STATIC xfs_lsn_t +xfs_attri_item_committed( + struct xfs_log_item *lip, + xfs_lsn_t lsn) +{ + struct xfs_attri_log_item *attrip = ATTRI_ITEM(lip); + + /* + * The attrip refers to xfs_attr_item memory to log the name and value + * with the intent item. This already occurred when the intent was + * committed so these fields are no longer accessed. Clear them out of + * caution since we're about to free the xfs_attr_item. + */ + attrip->attri_name = NULL; + attrip->attri_value = NULL; + + /* + * The ATTRI is logged only once and cannot be moved in the log, so + * simply return the lsn at which it's been logged. + */ + return lsn; +} + +STATIC bool +xfs_attri_item_match( + struct xfs_log_item *lip, + uint64_t intent_id) +{ + return ATTRI_ITEM(lip)->attri_format.alfi_id == intent_id; +} + +/* Is this recovered ATTRI format ok? */ +static inline bool +xfs_attri_validate( + struct xfs_mount *mp, + struct xfs_attri_log_format *attrp) +{ + unsigned int op = attrp->alfi_op_flags & + XFS_ATTR_OP_FLAGS_TYPE_MASK; + + if (attrp->__pad != 0) + return false; + + /* alfi_op_flags should be either a set or remove */ + if (op != XFS_ATTR_OP_FLAGS_SET && op != XFS_ATTR_OP_FLAGS_REMOVE) + return false; + + if (attrp->alfi_value_len > XATTR_SIZE_MAX) + return false; + + if ((attrp->alfi_name_len > XATTR_NAME_MAX) || + (attrp->alfi_name_len == 0)) + return false; + + return xfs_verify_ino(mp, attrp->alfi_ino); +} + +STATIC int +xlog_recover_attri_commit_pass2( + struct xlog *log, + struct list_head *buffer_list, + struct xlog_recover_item *item, + xfs_lsn_t lsn) +{ + int error; + struct xfs_mount *mp = log->l_mp; + struct xfs_attri_log_item *attrip; + struct xfs_attri_log_format *attri_formatp; + int region = 0; + + attri_formatp = item->ri_buf[region].i_addr; + + /* Validate xfs_attri_log_format */ + if (!xfs_attri_validate(mp, attri_formatp)) { + XFS_ERROR_REPORT(__func__, XFS_ERRLEVEL_LOW, mp); + return -EFSCORRUPTED; + } + + /* memory alloc failure will cause replay to abort */ + attrip = xfs_attri_init(mp, attri_formatp->alfi_name_len, + attri_formatp->alfi_value_len); + if (attrip == NULL) + return -ENOMEM; + + error = xfs_attri_copy_format(&item->ri_buf[region], + &attrip->attri_format); + if (error) + goto out; + + region++; + memcpy(attrip->attri_name, item->ri_buf[region].i_addr, + attrip->attri_name_len); + + if (!xfs_attr_namecheck(attrip->attri_name, attrip->attri_name_len)) { + XFS_ERROR_REPORT(__func__, XFS_ERRLEVEL_LOW, mp); + error = -EFSCORRUPTED; + goto out; + } + + if (attrip->attri_value_len > 0) { + region++; + memcpy(attrip->attri_value, item->ri_buf[region].i_addr, + attrip->attri_value_len); + } + + /* + * The ATTRI has two references. One for the ATTRD and one for ATTRI to + * ensure it makes it into the AIL. Insert the ATTRI into the AIL + * directly and drop the ATTRI reference. Note that + * xfs_trans_ail_update() drops the AIL lock. + */ + xfs_trans_ail_insert(log->l_ailp, &attrip->attri_item, lsn); + xfs_attri_release(attrip); + return 0; +out: + xfs_attri_item_free(attrip); + return error; +} + +/* + * This routine is called when an ATTRD format structure is found in a committed + * transaction in the log. Its purpose is to cancel the corresponding ATTRI if + * it was still in the log. To do this it searches the AIL for the ATTRI with + * an id equal to that in the ATTRD format structure. If we find it we drop + * the ATTRD reference, which removes the ATTRI from the AIL and frees it. + */ +STATIC int +xlog_recover_attrd_commit_pass2( + struct xlog *log, + struct list_head *buffer_list, + struct xlog_recover_item *item, + xfs_lsn_t lsn) +{ + struct xfs_attrd_log_format *attrd_formatp; + + attrd_formatp = item->ri_buf[0].i_addr; + if (item->ri_buf[0].i_len != sizeof(struct xfs_attrd_log_format)) { + XFS_ERROR_REPORT(__func__, XFS_ERRLEVEL_LOW, NULL); + return -EFSCORRUPTED; + } + + xlog_recover_release_intent(log, XFS_LI_ATTRI, + attrd_formatp->alfd_alf_id); + return 0; +} + +static const struct xfs_item_ops xfs_attri_item_ops = { + .iop_size = xfs_attri_item_size, + .iop_format = xfs_attri_item_format, + .iop_unpin = xfs_attri_item_unpin, + .iop_committed = xfs_attri_item_committed, + .iop_release = xfs_attri_item_release, + .iop_match = xfs_attri_item_match, +}; + +const struct xlog_recover_item_ops xlog_attri_item_ops = { + .item_type = XFS_LI_ATTRI, + .commit_pass2 = xlog_recover_attri_commit_pass2, +}; + +static const struct xfs_item_ops xfs_attrd_item_ops = { + .flags = XFS_ITEM_RELEASE_WHEN_COMMITTED, + .iop_size = xfs_attrd_item_size, + .iop_format = xfs_attrd_item_format, + .iop_release = xfs_attrd_item_release, +}; + +const struct xlog_recover_item_ops xlog_attrd_item_ops = { + .item_type = XFS_LI_ATTRD, + .commit_pass2 = xlog_recover_attrd_commit_pass2, +}; diff --git a/fs/xfs/xfs_attr_item.h b/fs/xfs/xfs_attr_item.h new file mode 100644 index 000000000000..c3b779f82adb --- /dev/null +++ b/fs/xfs/xfs_attr_item.h @@ -0,0 +1,46 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later + * + * Copyright (C) 2022 Oracle. All Rights Reserved. + * Author: Allison Henderson + */ +#ifndef __XFS_ATTR_ITEM_H__ +#define __XFS_ATTR_ITEM_H__ + +/* kernel only ATTRI/ATTRD definitions */ + +struct xfs_mount; +struct kmem_zone; + +/* + * This is the "attr intention" log item. It is used to log the fact that some + * extended attribute operations need to be processed. An operation is + * currently either a set or remove. Set or remove operations are described by + * the xfs_attr_item which may be logged to this intent. + * + * During a normal attr operation, name and value point to the name and value + * fields of the caller's xfs_da_args structure. During a recovery, the name + * and value buffers are copied from the log, and stored in a trailing buffer + * attached to the xfs_attr_item until they are committed. They are freed when + * the xfs_attr_item itself is freed when the work is done. + */ +struct xfs_attri_log_item { + struct xfs_log_item attri_item; + atomic_t attri_refcount; + int attri_name_len; + int attri_value_len; + void *attri_name; + void *attri_value; + struct xfs_attri_log_format attri_format; +}; + +/* + * This is the "attr done" log item. It is used to log the fact that some attrs + * earlier mentioned in an attri item have been freed. + */ +struct xfs_attrd_log_item { + struct xfs_log_item attrd_item; + struct xfs_attri_log_item *attrd_attrip; + struct xfs_attrd_log_format attrd_format; +}; + +#endif /* __XFS_ATTR_ITEM_H__ */ diff --git a/fs/xfs/xfs_attr_list.c b/fs/xfs/xfs_attr_list.c index 2d1e5134cebe..90a14e85e76d 100644 --- a/fs/xfs/xfs_attr_list.c +++ b/fs/xfs/xfs_attr_list.c @@ -15,6 +15,7 @@ #include "xfs_inode.h" #include "xfs_trans.h" #include "xfs_bmap.h" +#include "xfs_da_btree.h" #include "xfs_attr.h" #include "xfs_attr_sf.h" #include "xfs_attr_leaf.h" diff --git a/fs/xfs/xfs_ioctl32.c b/fs/xfs/xfs_ioctl32.c index 004ed2a251e8..618a46a1d5fb 100644 --- a/fs/xfs/xfs_ioctl32.c +++ b/fs/xfs/xfs_ioctl32.c @@ -17,6 +17,8 @@ #include "xfs_itable.h" #include "xfs_fsops.h" #include "xfs_rtalloc.h" +#include "xfs_da_format.h" +#include "xfs_da_btree.h" #include "xfs_attr.h" #include "xfs_ioctl.h" #include "xfs_ioctl32.h" diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c index b34e8e4344a8..dbf8acb03c6d 100644 --- a/fs/xfs/xfs_iops.c +++ b/fs/xfs/xfs_iops.c @@ -13,6 +13,8 @@ #include "xfs_inode.h" #include "xfs_acl.h" #include "xfs_quota.h" +#include "xfs_da_format.h" +#include "xfs_da_btree.h" #include "xfs_attr.h" #include "xfs_trans.h" #include "xfs_trace.h" diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c index 5010ce712a3e..0b346162d851 100644 --- a/fs/xfs/xfs_log.c +++ b/fs/xfs/xfs_log.c @@ -2156,6 +2156,10 @@ xlog_print_tic_res( REG_TYPE_STR(CUD_FORMAT, "cud_format"), REG_TYPE_STR(BUI_FORMAT, "bui_format"), REG_TYPE_STR(BUD_FORMAT, "bud_format"), + REG_TYPE_STR(ATTRI_FORMAT, "attri_format"), + REG_TYPE_STR(ATTRD_FORMAT, "attrd_format"), + REG_TYPE_STR(ATTR_NAME, "attr name"), + REG_TYPE_STR(ATTR_VALUE, "attr value"), }; BUILD_BUG_ON(ARRAY_SIZE(res_type_str) != XLOG_REG_TYPE_MAX + 1); #undef REG_TYPE_STR diff --git a/fs/xfs/xfs_log.h b/fs/xfs/xfs_log.h index dc1b77b92fc1..fd945eb66c32 100644 --- a/fs/xfs/xfs_log.h +++ b/fs/xfs/xfs_log.h @@ -21,6 +21,17 @@ struct xfs_log_vec { #define XFS_LOG_VEC_ORDERED (-1) +/* + * Calculate the log iovec length for a given user buffer length. Intended to be + * used by ->iop_size implementations when sizing buffers of arbitrary + * alignments. + */ +static inline int +xlog_calc_iovec_len(int len) +{ + return roundup(len, sizeof(int32_t)); +} + static inline void * xlog_prepare_iovec(struct xfs_log_vec *lv, struct xfs_log_iovec **vecp, uint type) diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c index 96c997ed2ec8..f1edb315e341 100644 --- a/fs/xfs/xfs_log_recover.c +++ b/fs/xfs/xfs_log_recover.c @@ -1800,6 +1800,8 @@ static const struct xlog_recover_item_ops *xlog_recover_item_ops[] = { &xlog_cud_item_ops, &xlog_bui_item_ops, &xlog_bud_item_ops, + &xlog_attri_item_ops, + &xlog_attrd_item_ops, }; static const struct xlog_recover_item_ops * diff --git a/fs/xfs/xfs_ondisk.h b/fs/xfs/xfs_ondisk.h index 25991923c1a8..758702b9495f 100644 --- a/fs/xfs/xfs_ondisk.h +++ b/fs/xfs/xfs_ondisk.h @@ -132,6 +132,8 @@ xfs_check_ondisk_structs(void) XFS_CHECK_STRUCT_SIZE(struct xfs_inode_log_format, 56); XFS_CHECK_STRUCT_SIZE(struct xfs_qoff_logformat, 20); XFS_CHECK_STRUCT_SIZE(struct xfs_trans_header, 16); + XFS_CHECK_STRUCT_SIZE(struct xfs_attri_log_format, 40); + XFS_CHECK_STRUCT_SIZE(struct xfs_attrd_log_format, 16); /* * The v5 superblock format extended several v4 header structures with From patchwork Wed Mar 23 21:07:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12790156 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 72B97C43217 for ; Wed, 23 Mar 2022 21:07:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240992AbiCWVJL (ORCPT ); Wed, 23 Mar 2022 17:09:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38358 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344868AbiCWVJD (ORCPT ); Wed, 23 Mar 2022 17:09:03 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 42B2C8CD8D for ; Wed, 23 Mar 2022 14:07:28 -0700 (PDT) Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 22NKY4qi001345 for ; Wed, 23 Mar 2022 21:07:27 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2021-07-09; bh=rpBcAdx5gg2KlHJmYIOadoaD5bgqFlNSqAf5qmB/CHY=; b=zZ6fMX3Kv0cgqlSjUdl0yVlLxeyO/W9B8VYdfrbphpkP7oJumsMvo+xFwEEK74v304uW CmcBkTz+0ktDJTtA5vqTtIPE7g7kGkvt9buMNXk84IJQCjJhemQad63BkBN3oWU5uNQd QLLmrh/W7Z0xSrOs+WItz9JtBb7vtbnFe92CvJETHIdO2ZePsUT25NhzOK5otlYmEL4l tWFb/u9BiAjrpFqwLmDWmm+e2g7CAbRK7NWVnarkiJnC08rRhNzAjGV8o4yYYu0ONzxQ 83lrmnGMws/K8zidMxctSOBYhH6iWOJwxIVjFTbFnP+UtqWDP2KuBA2VYjsPQbznDlA+ wQ== Received: from aserp3030.oracle.com ([141.146.126.71]) by mx0b-00069f02.pphosted.com with ESMTP id 3ew6ssaqng-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 23 Mar 2022 21:07:27 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 22NL6LdC082870 for ; Wed, 23 Mar 2022 21:07:26 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2168.outbound.protection.outlook.com [104.47.59.168]) by aserp3030.oracle.com with ESMTP id 3ew578y1wr-6 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 23 Mar 2022 21:07:26 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=e1bYM7CbGCcLVJJQFXE4tAVqF/T7qKEO5U/kU0lj5SUx32m3t5+v6JjLuIKLUSOb0pmh5qUkU1Z9AC0s6KzG+w8NVl6Gh22aIQWSkSfflz3YNWPYGHH2RDPtIaaA2eOts+BUoWpThB03iUO2vfce/TbNIT+nwwgJAOFJJDhi9GbzrGscCpu0h7vX9//J8wqXfLIN6zx8MQntMEYGfSmW3ryhpzEwV/loRN10mWiiTDFjXw4u0eOiI8Oeybi7AVZ4goQV6/YFcAahcE3OaVyWkpEtAJcJH1l8cpbJ0FS8ejBdSWDjJNDYhvX8CVN97a9vFkNQY6H83dQCAcBtpsngVg== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=rpBcAdx5gg2KlHJmYIOadoaD5bgqFlNSqAf5qmB/CHY=; b=MFwkr/VLjhdDtLu3gK8HC9Icw39nSzvZeVlhuOEMqa/PzU89FqsynqHPvOIFNtdkp6TGAavbUgFymGCxdiNNAxjhef4GkJmKB1QuE9qBIDmlnZx6jnnd6wpuQ84uPUhzasUc8B/T4413Le/+pwqj/Ml9RSsXeuDs1+53f8Hyvg8UxN/NSoWeCsLKjzxjrNZzsfhHCGogjmpQeKYNKDA2GtLI+73c2NkWbDuybRsvRBuk7VuiHQA/CPPCVnLMLOh02yJeH91az3y4FWQI2T0ZtrnCiTJ9UmpCOMo6CPMUzS7JpZC5VDZBmT+8fBixjXCKPxP+QsISpe/JSIdVEQDIug== 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=rpBcAdx5gg2KlHJmYIOadoaD5bgqFlNSqAf5qmB/CHY=; b=wC0hvjR8YMk7EK+9llGdL+C8tqN3o5A20kqQwMf+GUeMLamqGvWcF6sP63+6jbZLC2SDm95xxxHShhgDtEFkAnvGfU0Mg4IspHN3eNpbNww/BfR+kX/SjjGx97vsjptzK8spQLp6877NloHps/mcY/Hpw6PIvoRhN3adTYA0vso= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by PH0PR10MB4744.namprd10.prod.outlook.com (2603:10b6:510:3c::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5102.17; Wed, 23 Mar 2022 21:07:24 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::c517:eb23:bb2f:4b23]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::c517:eb23:bb2f:4b23%6]) with mapi id 15.20.5102.017; Wed, 23 Mar 2022 21:07:24 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v29 05/15] xfs: Implement attr logging and replay Date: Wed, 23 Mar 2022 14:07:05 -0700 Message-Id: <20220323210715.201009-6-allison.henderson@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220323210715.201009-1-allison.henderson@oracle.com> References: <20220323210715.201009-1-allison.henderson@oracle.com> X-ClientProxiedBy: PH0PR07CA0084.namprd07.prod.outlook.com (2603:10b6:510:f::29) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d41d047f-c5a3-4230-cf85-08da0d1120de X-MS-TrafficTypeDiagnostic: PH0PR10MB4744:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: hDTdEzuH81jozs1aT0FblUEroJxi4zMV6dJ+f9woG4d6j3vEiZ+iVgATvmZqMyNdZCrPeA852oWycvwyrpPiK9VovlomwN9MXKn6IxZaH8jY3/fUt6VRhD8I/02Qig7D3eAHF6VAqxNYFR7DqHet2Zcz9hbdfp+Asb2fGR4UeIKkxluihwYw52ha4axbn7VzT0Xhquice3zlRENiXv8FgmwLDYG2UBhttdF7rHg8TkUmoDPoEcw7aAmz2Xs2tfdMBKQ2VK6KfvMaJuPdsr6WmbUxJfOnMgYC4JfqyChLMuuFG0Q1UxGrZYbEnq2R5O388XHqYWLP52MJmYfSivBA1ZfSK6dnALml+vxma16aerTQojd1D9hQl36inITLIVMqAkRX+3FatQUP/baJ0Szl60RNnQ1SUcL+x2RZ5iJzyh6qwTDxhA8kaf31RFXitW1z2R5OHfDzkqs5oC5IoSoxkYzG+4eaXngODZ+lOdgmBrarWzDk0EcLHSAqyyytwQ1ddgh2kxCH9wmrkHbULmgoWDtThHj309GU6LkR0jzcY28lCsThDdyvE6dA32i/wHPoVltVG2WaHAeGnTpmN8SPdriAuazjmdxsFkNP+YwuLAJdiqUZ7xbxP2r/gsh541dIOy3r9OjXY3FTWDjH9pJBoGTShTj4xZVQCmdDtTWtiPZhI+DbAPQ0JPZv5YdaeNb7bNQkT4bOgwAt6cWPR+6TVQ== 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:(13230001)(366004)(6666004)(44832011)(2906002)(508600001)(26005)(186003)(36756003)(38100700002)(83380400001)(6506007)(30864003)(38350700002)(6486002)(52116002)(86362001)(6512007)(5660300002)(66946007)(8676002)(66476007)(66556008)(8936002)(6916009)(316002)(1076003)(2616005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: R+R/UbZc+X4871vPNQomRJOOtPx25Wd/hRNSvmBJ1oAcT8PJhoE3iuudI2aIO1/ETQZCYgq/QXMdLR0WS9hLPSujxQnWTFgbdmvg68F53b9eRzHzH/9r6dEYKs3MCX1wowX+qJc5wgtuAm4LNVOM+vC5VTdQiFe22bh3top9CbKzHsDKa8eq7nfnGl40TNDuhzb4kZZazr/HoH3EzymeV0whzUFpM3FPifCQeVo0qGQa/oAxldWOPNdDbiHuIqGhHzIziDw3PH9TFYSNl+4tcgWFqFibOE+rdLvZ3eOFdo3+2vXfsmQbnGEExsdeb8wFEub97QvWsmkH2Eyp5DwEWtWAX2N/Xs4gvRwGNUTf95R8Ka86jrE/0/xPH+dZzuvAyAsasNuy3hlfwhTAhK6/YMDJkdnN7ncUm9xg4fOtTWr1fa9map0cD5ZGeBXWl1klkF1kySc0fP6I3U3xgSRx4s3fK4yLygXZiQAZjQiJFvZePlawAxLyydyGfTqEXpCGG2813MrhcHUW2dUEk46BJtSoLujUxE4sy5swpqXgMBQIiyrQdWFVAUCqnbpvqMFF6nhfRlEyw7uSuusgj5z1bl7vduaXsCIyvxQql4Eedk3kZ5qorw+8F7qL/25VB99nenawb18gyjp5ugO/6uw23HAQD8kYgqz8bakdXww1L8wSq2XfIalVid4BZPExXFu8KjNf2IUk++NNJQKNv43w3DCWxCPDuCuAVIiQ2zQ2S9IsE+ZrhF6rA+MvVirp7KkjB+VAuZaSNcvFuarviWjHqnn7wVvalzrO6REuuJmT1kzE8kuV2+7NP1iXipaoxacp1FFc/QkzWyOxQvesUsXP7I0XKDyDPJuSe3Z0lFXB4+0tHJtNNhdp7kd2LrsTkg34Fmw7Vhh41k697D+KCZh7yHONfZvFsb9j3Xluq2w9Pos5Anis/yNabT/DOTahTU9otpD3olIyv/UZNrzBac+kfs3Yrn7Vabb9kAkCxNnkuJ617PkSZU0pRuUtumJc70Uh6nm81DmYcQReUxpWn9Qjp6J59stoih/TXwf3rk8S1NeX7+x6vWxHq1R5CF9RTKB7AzhHxoVpOsfjPPlR/H8A4hXEdY39UQ7h1LyOELRZAoNLOm2becbpjJqy+I0rOsE/14d7MFbIiktNZsVqIN2Z+UziURzduitENSvcDTDPpNWouNKsgCvA+iT7yDJpV3wuq5V3JisSQDg6ZCFAKgI5QUQEKDQN7Wsz/HFhunhRJMX/3yQ0Lj7Qs9y4wemXAK5PIlCVDvqrafAowTdr8azOs0a7PM+XDUkhUhmt4z4aUNHMTvHouutK8GW4fgIiIy8efyTdAPx1z4+VgBbbVAvp9aFssTr/FClSJg+C/gC0pfDtrEKr7UXWprwNMWyz2BO1wLFPK6UAEnkGweO3ZD8lCW1TfZWPlHPvcrnGch3zYfcgy3ZOTCex9uYha3K6eYQHeD42M3XtQYw1+fMFKqYZmw== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: d41d047f-c5a3-4230-cf85-08da0d1120de X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Mar 2022 21:07:24.4830 (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: tzPGBmk55K9eQkM3xoyjRmDx1hD2se9isi6eVEmpDv+cCgA4joeT/jZ1obC7WAq7i/D4nCOMuhVh3FhZwisfMGXULln/OAw3Xofxbc20big= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4744 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10295 signatures=694973 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 suspectscore=0 spamscore=0 mlxlogscore=999 phishscore=0 bulkscore=0 malwarescore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2203230111 X-Proofpoint-ORIG-GUID: USa49l8kSkSNOeaWchmPErqfDbHR5OOm X-Proofpoint-GUID: USa49l8kSkSNOeaWchmPErqfDbHR5OOm Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org This patch adds the needed routines to create, log and recover logged extended attribute intents. Signed-off-by: Allison Henderson Reviewed-by: Chandan Babu R Reviewed-by: Darrick J. Wong --- fs/xfs/libxfs/xfs_defer.c | 1 + fs/xfs/libxfs/xfs_defer.h | 1 + fs/xfs/libxfs/xfs_format.h | 9 +- fs/xfs/xfs_attr_item.c | 360 +++++++++++++++++++++++++++++++++++++ 4 files changed, 370 insertions(+), 1 deletion(-) diff --git a/fs/xfs/libxfs/xfs_defer.c b/fs/xfs/libxfs/xfs_defer.c index 91adfb01c848..d15c39d21e86 100644 --- a/fs/xfs/libxfs/xfs_defer.c +++ b/fs/xfs/libxfs/xfs_defer.c @@ -186,6 +186,7 @@ static const struct xfs_defer_op_type *defer_op_types[] = { [XFS_DEFER_OPS_TYPE_RMAP] = &xfs_rmap_update_defer_type, [XFS_DEFER_OPS_TYPE_FREE] = &xfs_extent_free_defer_type, [XFS_DEFER_OPS_TYPE_AGFL_FREE] = &xfs_agfl_free_defer_type, + [XFS_DEFER_OPS_TYPE_ATTR] = &xfs_attr_defer_type, }; static void diff --git a/fs/xfs/libxfs/xfs_defer.h b/fs/xfs/libxfs/xfs_defer.h index fcd23e5cf1ee..114a3a4930a3 100644 --- a/fs/xfs/libxfs/xfs_defer.h +++ b/fs/xfs/libxfs/xfs_defer.h @@ -19,6 +19,7 @@ enum xfs_defer_ops_type { XFS_DEFER_OPS_TYPE_RMAP, XFS_DEFER_OPS_TYPE_FREE, XFS_DEFER_OPS_TYPE_AGFL_FREE, + XFS_DEFER_OPS_TYPE_ATTR, XFS_DEFER_OPS_TYPE_MAX, }; diff --git a/fs/xfs/libxfs/xfs_format.h b/fs/xfs/libxfs/xfs_format.h index d665c04e69dd..302b50bc5830 100644 --- a/fs/xfs/libxfs/xfs_format.h +++ b/fs/xfs/libxfs/xfs_format.h @@ -388,7 +388,9 @@ xfs_sb_has_incompat_feature( return (sbp->sb_features_incompat & feature) != 0; } -#define XFS_SB_FEAT_INCOMPAT_LOG_ALL 0 +#define XFS_SB_FEAT_INCOMPAT_LOG_XATTRS (1 << 0) /* Delayed Attributes */ +#define XFS_SB_FEAT_INCOMPAT_LOG_ALL \ + (XFS_SB_FEAT_INCOMPAT_LOG_XATTRS) #define XFS_SB_FEAT_INCOMPAT_LOG_UNKNOWN ~XFS_SB_FEAT_INCOMPAT_LOG_ALL static inline bool xfs_sb_has_incompat_log_feature( @@ -413,6 +415,11 @@ xfs_sb_add_incompat_log_features( sbp->sb_features_log_incompat |= features; } +static inline bool xfs_sb_version_haslogxattrs(struct xfs_sb *sbp) +{ + return xfs_sb_is_v5(sbp) && (sbp->sb_features_log_incompat & + XFS_SB_FEAT_INCOMPAT_LOG_XATTRS); +} static inline bool xfs_is_quota_inode(struct xfs_sb *sbp, xfs_ino_t ino) diff --git a/fs/xfs/xfs_attr_item.c b/fs/xfs/xfs_attr_item.c index 394ef4497553..1e2fcc9da340 100644 --- a/fs/xfs/xfs_attr_item.c +++ b/fs/xfs/xfs_attr_item.c @@ -13,6 +13,7 @@ #include "xfs_defer.h" #include "xfs_log_format.h" #include "xfs_trans.h" +#include "xfs_bmap_btree.h" #include "xfs_trans_priv.h" #include "xfs_log.h" #include "xfs_inode.h" @@ -29,6 +30,8 @@ static const struct xfs_item_ops xfs_attri_item_ops; static const struct xfs_item_ops xfs_attrd_item_ops; +static struct xfs_attrd_log_item *xfs_trans_get_attrd(struct xfs_trans *tp, + struct xfs_attri_log_item *attrip); static inline struct xfs_attri_log_item *ATTRI_ITEM(struct xfs_log_item *lip) { @@ -283,6 +286,172 @@ xfs_attrd_item_release( xfs_attrd_item_free(attrdp); } +/* + * Performs one step of an attribute update intent and marks the attrd item + * dirty.. An attr operation may be a set or a remove. Note that the + * transaction is marked dirty regardless of whether the operation succeeds or + * fails to support the ATTRI/ATTRD lifecycle rules. + */ +STATIC int +xfs_xattri_finish_update( + struct xfs_delattr_context *dac, + struct xfs_attrd_log_item *attrdp, + struct xfs_buf **leaf_bp, + uint32_t op_flags) +{ + struct xfs_da_args *args = dac->da_args; + unsigned int op = op_flags & + XFS_ATTR_OP_FLAGS_TYPE_MASK; + int error; + + switch (op) { + case XFS_ATTR_OP_FLAGS_SET: + error = xfs_attr_set_iter(dac, leaf_bp); + break; + case XFS_ATTR_OP_FLAGS_REMOVE: + ASSERT(XFS_IFORK_Q(args->dp)); + error = xfs_attr_remove_iter(dac); + break; + default: + error = -EFSCORRUPTED; + break; + } + + /* + * Mark the transaction dirty, even on error. This ensures the + * transaction is aborted, which: + * + * 1.) releases the ATTRI and frees the ATTRD + * 2.) shuts down the filesystem + */ + args->trans->t_flags |= XFS_TRANS_DIRTY; + + /* + * attr intent/done items are null when logged attributes are disabled + */ + if (attrdp) + set_bit(XFS_LI_DIRTY, &attrdp->attrd_item.li_flags); + + return error; +} + +/* Log an attr to the intent item. */ +STATIC void +xfs_attr_log_item( + struct xfs_trans *tp, + struct xfs_attri_log_item *attrip, + struct xfs_attr_item *attr) +{ + struct xfs_attri_log_format *attrp; + + tp->t_flags |= XFS_TRANS_DIRTY; + set_bit(XFS_LI_DIRTY, &attrip->attri_item.li_flags); + + /* + * At this point the xfs_attr_item has been constructed, and we've + * created the log intent. Fill in the attri log item and log format + * structure with fields from this xfs_attr_item + */ + attrp = &attrip->attri_format; + attrp->alfi_ino = attr->xattri_dac.da_args->dp->i_ino; + attrp->alfi_op_flags = attr->xattri_op_flags; + attrp->alfi_value_len = attr->xattri_dac.da_args->valuelen; + attrp->alfi_name_len = attr->xattri_dac.da_args->namelen; + attrp->alfi_attr_flags = attr->xattri_dac.da_args->attr_filter; + + memcpy(attrip->attri_name, attr->xattri_dac.da_args->name, + attr->xattri_dac.da_args->namelen); + memcpy(attrip->attri_value, attr->xattri_dac.da_args->value, + attr->xattri_dac.da_args->valuelen); + attrip->attri_name_len = attr->xattri_dac.da_args->namelen; + attrip->attri_value_len = attr->xattri_dac.da_args->valuelen; +} + +/* Get an ATTRI. */ +static struct xfs_log_item * +xfs_attr_create_intent( + struct xfs_trans *tp, + struct list_head *items, + unsigned int count, + bool sort) +{ + struct xfs_mount *mp = tp->t_mountp; + struct xfs_attri_log_item *attrip; + struct xfs_attr_item *attr; + + ASSERT(count == 1); + + if (!xfs_sb_version_haslogxattrs(&mp->m_sb)) + return NULL; + + /* + * Each attr item only performs one attribute operation at a time, so + * this is a list of one + */ + list_for_each_entry(attr, items, xattri_list) { + attrip = xfs_attri_init(mp, attr->xattri_dac.da_args->namelen, + attr->xattri_dac.da_args->valuelen); + if (attrip == NULL) + return NULL; + + xfs_trans_add_item(tp, &attrip->attri_item); + xfs_attr_log_item(tp, attrip, attr); + } + + return &attrip->attri_item; +} + +/* Process an attr. */ +STATIC int +xfs_attr_finish_item( + struct xfs_trans *tp, + struct xfs_log_item *done, + struct list_head *item, + struct xfs_btree_cur **state) +{ + struct xfs_attr_item *attr; + struct xfs_attrd_log_item *done_item = NULL; + int error; + struct xfs_delattr_context *dac; + + attr = container_of(item, struct xfs_attr_item, xattri_list); + dac = &attr->xattri_dac; + if (done) + done_item = ATTRD_ITEM(done); + + /* + * Always reset trans after EAGAIN cycle + * since the transaction is new + */ + dac->da_args->trans = tp; + + error = xfs_xattri_finish_update(dac, done_item, &dac->leaf_bp, + attr->xattri_op_flags); + if (error != -EAGAIN) + kmem_free(attr); + + return error; +} + +/* Abort all pending ATTRs. */ +STATIC void +xfs_attr_abort_intent( + struct xfs_log_item *intent) +{ + xfs_attri_release(ATTRI_ITEM(intent)); +} + +/* Cancel an attr */ +STATIC void +xfs_attr_cancel_item( + struct list_head *item) +{ + struct xfs_attr_item *attr; + + attr = container_of(item, struct xfs_attr_item, xattri_list); + kmem_free(attr); +} + STATIC xfs_lsn_t xfs_attri_item_committed( struct xfs_log_item *lip, @@ -340,6 +509,151 @@ xfs_attri_validate( return xfs_verify_ino(mp, attrp->alfi_ino); } +/* + * Process an attr intent item that was recovered from the log. We need to + * delete the attr that it describes. + */ +STATIC int +xfs_attri_item_recover( + struct xfs_log_item *lip, + struct list_head *capture_list) +{ + struct xfs_attri_log_item *attrip = ATTRI_ITEM(lip); + struct xfs_attr_item *attr; + struct xfs_mount *mp = lip->li_log->l_mp; + struct xfs_inode *ip; + struct xfs_da_args *args; + struct xfs_trans *tp; + struct xfs_trans_res tres; + struct xfs_attri_log_format *attrp; + int error, ret = 0; + int total; + int local; + struct xfs_attrd_log_item *done_item = NULL; + + /* + * First check the validity of the attr described by the ATTRI. If any + * are bad, then assume that all are bad and just toss the ATTRI. + */ + attrp = &attrip->attri_format; + if (!xfs_attri_validate(mp, attrp) || + !xfs_attr_namecheck(attrip->attri_name, attrip->attri_name_len)) + return -EFSCORRUPTED; + + error = xlog_recover_iget(mp, attrp->alfi_ino, &ip); + if (error) + return error; + + attr = kmem_zalloc(sizeof(struct xfs_attr_item) + + sizeof(struct xfs_da_args), KM_NOFS); + args = (struct xfs_da_args *)(attr + 1); + + attr->xattri_dac.da_args = args; + attr->xattri_op_flags = attrp->alfi_op_flags; + + args->dp = ip; + args->geo = mp->m_attr_geo; + args->whichfork = XFS_ATTR_FORK; + args->name = attrip->attri_name; + args->namelen = attrp->alfi_name_len; + args->hashval = xfs_da_hashname(args->name, args->namelen); + args->attr_filter = attrp->alfi_attr_flags; + + if (attrp->alfi_op_flags == XFS_ATTR_OP_FLAGS_SET) { + args->value = attrip->attri_value; + args->valuelen = attrp->alfi_value_len; + args->total = xfs_attr_calc_size(args, &local); + + tres.tr_logres = M_RES(mp)->tr_attrsetm.tr_logres + + M_RES(mp)->tr_attrsetrt.tr_logres * + args->total; + tres.tr_logcount = XFS_ATTRSET_LOG_COUNT; + tres.tr_logflags = XFS_TRANS_PERM_LOG_RES; + total = args->total; + } else { + tres = M_RES(mp)->tr_attrrm; + total = XFS_ATTRRM_SPACE_RES(mp); + } + error = xfs_trans_alloc(mp, &tres, total, 0, XFS_TRANS_RESERVE, &tp); + if (error) + goto out; + + args->trans = tp; + done_item = xfs_trans_get_attrd(tp, attrip); + + xfs_ilock(ip, XFS_ILOCK_EXCL); + xfs_trans_ijoin(tp, ip, 0); + + ret = xfs_xattri_finish_update(&attr->xattri_dac, done_item, + &attr->xattri_dac.leaf_bp, + attrp->alfi_op_flags); + if (ret == -EAGAIN) { + /* There's more work to do, so add it to this transaction */ + xfs_defer_add(tp, XFS_DEFER_OPS_TYPE_ATTR, &attr->xattri_list); + } else + error = ret; + + if (error) { + xfs_trans_cancel(tp); + goto out_unlock; + } + + error = xfs_defer_ops_capture_and_commit(tp, capture_list); + +out_unlock: + if (attr->xattri_dac.leaf_bp) + xfs_buf_relse(attr->xattri_dac.leaf_bp); + + xfs_iunlock(ip, XFS_ILOCK_EXCL); + xfs_irele(ip); +out: + if (ret != -EAGAIN) + kmem_free(attr); + return error; +} + +/* Re-log an intent item to push the log tail forward. */ +static struct xfs_log_item * +xfs_attri_item_relog( + struct xfs_log_item *intent, + struct xfs_trans *tp) +{ + struct xfs_attrd_log_item *attrdp; + struct xfs_attri_log_item *old_attrip; + struct xfs_attri_log_item *new_attrip; + struct xfs_attri_log_format *new_attrp; + struct xfs_attri_log_format *old_attrp; + + old_attrip = ATTRI_ITEM(intent); + old_attrp = &old_attrip->attri_format; + + tp->t_flags |= XFS_TRANS_DIRTY; + attrdp = xfs_trans_get_attrd(tp, old_attrip); + set_bit(XFS_LI_DIRTY, &attrdp->attrd_item.li_flags); + + new_attrip = xfs_attri_init(tp->t_mountp, old_attrp->alfi_name_len, + old_attrp->alfi_value_len); + new_attrp = &new_attrip->attri_format; + + new_attrp->alfi_ino = old_attrp->alfi_ino; + new_attrp->alfi_op_flags = old_attrp->alfi_op_flags; + new_attrp->alfi_value_len = old_attrp->alfi_value_len; + new_attrp->alfi_name_len = old_attrp->alfi_name_len; + new_attrp->alfi_attr_flags = old_attrp->alfi_attr_flags; + + memcpy(new_attrip->attri_name, old_attrip->attri_name, + new_attrip->attri_name_len); + + if (new_attrip->attri_value_len > 0) + memcpy(new_attrip->attri_value, old_attrip->attri_value, + new_attrip->attri_value_len); + + xfs_trans_add_item(tp, &new_attrip->attri_item); + set_bit(XFS_LI_DIRTY, &new_attrip->attri_item.li_flags); + + return &new_attrip->attri_item; +} + STATIC int xlog_recover_attri_commit_pass2( struct xlog *log, @@ -402,6 +716,50 @@ xlog_recover_attri_commit_pass2( return error; } +/* + * This routine is called to allocate an "attr free done" log item. + */ +static struct xfs_attrd_log_item * +xfs_trans_get_attrd(struct xfs_trans *tp, + struct xfs_attri_log_item *attrip) +{ + struct xfs_attrd_log_item *attrdp; + + ASSERT(tp != NULL); + + attrdp = kmem_cache_alloc(xfs_attrd_cache, GFP_NOFS | __GFP_NOFAIL); + + xfs_log_item_init(tp->t_mountp, &attrdp->attrd_item, XFS_LI_ATTRD, + &xfs_attrd_item_ops); + attrdp->attrd_attrip = attrip; + attrdp->attrd_format.alfd_alf_id = attrip->attri_format.alfi_id; + + xfs_trans_add_item(tp, &attrdp->attrd_item); + return attrdp; +} + +/* Get an ATTRD so we can process all the attrs. */ +static struct xfs_log_item * +xfs_attr_create_done( + struct xfs_trans *tp, + struct xfs_log_item *intent, + unsigned int count) +{ + if (!intent) + return NULL; + + return &xfs_trans_get_attrd(tp, ATTRI_ITEM(intent))->attrd_item; +} + +const struct xfs_defer_op_type xfs_attr_defer_type = { + .max_items = 1, + .create_intent = xfs_attr_create_intent, + .abort_intent = xfs_attr_abort_intent, + .create_done = xfs_attr_create_done, + .finish_item = xfs_attr_finish_item, + .cancel_item = xfs_attr_cancel_item, +}; + /* * This routine is called when an ATTRD format structure is found in a committed * transaction in the log. Its purpose is to cancel the corresponding ATTRI if @@ -435,7 +793,9 @@ static const struct xfs_item_ops xfs_attri_item_ops = { .iop_unpin = xfs_attri_item_unpin, .iop_committed = xfs_attri_item_committed, .iop_release = xfs_attri_item_release, + .iop_recover = xfs_attri_item_recover, .iop_match = xfs_attri_item_match, + .iop_relog = xfs_attri_item_relog, }; const struct xlog_recover_item_ops xlog_attri_item_ops = { From patchwork Wed Mar 23 21:07:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12790152 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 24266C4332F for ; Wed, 23 Mar 2022 21:07:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240996AbiCWVJL (ORCPT ); Wed, 23 Mar 2022 17:09:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38306 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344860AbiCWVJD (ORCPT ); Wed, 23 Mar 2022 17:09:03 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B08AD8CD92 for ; Wed, 23 Mar 2022 14:07:28 -0700 (PDT) Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 22NKYRgZ007708 for ; Wed, 23 Mar 2022 21:07:28 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2021-07-09; bh=piXmY+S1S6x5J8G42q3OPS42p4KfHP7SjH6+nGTm5Xw=; b=Sbz1XXmJol6L8Av86wZxbQZov3ckf3vnrWk1qtvO5wnaZt7Wgl19vy9DI0gZ4Z5zG7Fz ZXbfYtxifQ9jatircXULC19Ahiz1xmYVVHshSDpB6g0DcsTLyiFetJlekDw61+CTVHjR tFuPw6qdLArFo0Tmxc7Kf4gMYwRDInP/8+LPq37iEciPocb4i1/4AbODD9Mq0oU/qPmb gdW5phYUZgjeKPoHxlLvjSi0CXPgIgXdqU9fOD9XEbczlvt+p62IHcytP3ZOLnoJCoIA 2/+balFe2WDXRE/7BsDfqU/BtMzBn3EKT42Ce2aam+NuOLNN6pbss8dF0nwygZ6lWg6f Iw== Received: from aserp3030.oracle.com ([141.146.126.71]) by mx0b-00069f02.pphosted.com with ESMTP id 3ew7qtawts-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 23 Mar 2022 21:07:27 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 22NL6LdD082870 for ; Wed, 23 Mar 2022 21:07:26 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2168.outbound.protection.outlook.com [104.47.59.168]) by aserp3030.oracle.com with ESMTP id 3ew578y1wr-7 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 23 Mar 2022 21:07:26 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fpDanooWIdSOhpVoYpcEQvM0Rjo9P5PIOwfBpHpTda45Vh/kRtBMbW14RdiBiw8F58Xjh78rBxQxg4op2iCTX8SsjUG7SiRFDI3euH4wF0b3iwxxdN3WYfS78u9Wex75q97UPi+OQ/50m05crlQ2aC+HnXYBPKunKWFExDDWedOujQKLIL3qCV9v57kAwEZLbe4pR8wSo9CrsheP/vjBD+SbRdthPlWoA/9QZ9U746Q8J03eKTvuZQtN4deg4+UhO/XvosKqS3sV/ZkaR1pkcBDwlwtR6Do87+wh6w+j2W6Y2Qwy7Fu12JfoSONe6YMBFFUQ29VLPZgQDhlasbzthA== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=piXmY+S1S6x5J8G42q3OPS42p4KfHP7SjH6+nGTm5Xw=; b=j3Jqo0eCmYZn/mzEBMEigziVRpNoepK9WuFbsm1f/YpQJ+8cYCSLT85Y0XyE02VirtI1G6iYD+Zg9/seiT6JOPau3sI0EHUTPCJ5GuDZ7x44/UjkIkuNuNMUs00iuJy37teolvx2z6bIqhbgddYO+ZUaHV8mwGyq0gqWjlPBRnPLshI+apAHCylMAhMJuHGiON6j8FYVqIgpQez5ncQAPauMVtOVFJ/rd3mm9zhcDKqjsjoZeHCIOmoDW1Mjt3ktnyKTmRoztGz5TFfTQZQ2+L0QzeMQC9bg9ajbMRA2bU5fIifBBSRxQlgaAPwP5cK1aNLxylPyqJCMKZLOXEC4dg== 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=piXmY+S1S6x5J8G42q3OPS42p4KfHP7SjH6+nGTm5Xw=; b=YTDsHmM6mzFtGao1qMiq34nyxR3qO68YFoaTMNDbOXlUlPrNVE+mFWDH8b41x30kihwdCRQMX1CqkdpQnDqMAu9ePvFxN1Mmgw6jcqny3fJl0T7vTP36O+pGkUq/MDGFAbRXbv6nucLYF+wo5lp8oG26ewgrZWfs6TdUaLDJ/TE= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by PH0PR10MB4744.namprd10.prod.outlook.com (2603:10b6:510:3c::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5102.17; Wed, 23 Mar 2022 21:07:25 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::c517:eb23:bb2f:4b23]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::c517:eb23:bb2f:4b23%6]) with mapi id 15.20.5102.017; Wed, 23 Mar 2022 21:07:24 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v29 06/15] xfs: Skip flip flags for delayed attrs Date: Wed, 23 Mar 2022 14:07:06 -0700 Message-Id: <20220323210715.201009-7-allison.henderson@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220323210715.201009-1-allison.henderson@oracle.com> References: <20220323210715.201009-1-allison.henderson@oracle.com> X-ClientProxiedBy: PH0PR07CA0084.namprd07.prod.outlook.com (2603:10b6:510:f::29) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 104b472d-9e6e-4e4d-c9cc-08da0d11211c X-MS-TrafficTypeDiagnostic: PH0PR10MB4744:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QsXcr7HCb6wlryAakHbUyU3kugRl+5jFvd6VnUPDG1T8kKUWT+FK0ia+9sqvIoy5EUHkcl71tmXS1xgraZktc5rG1X7Dw8DVVabnbfOxjZTuw0FEhZjYewjLHqJTFuQXqwQ5yUPr0yglceO/pcqV/XSzei1fkhkU47cqpCyVod4M9nAxcrxWQnYjR9PhfzdJr/TT9TIdwn0+vd+u2wjaZx7YxMrd+sFzbxm2n9TzabjnkKEIEJVQJ+Rm6R6c1nAT0pDJpgFxPSIxutNFLACD99OLpM4oPmGYCPEGLpW5Fd3SPxfoJCRUf9hAek2J4/EEirfs3rIRDH+GZHQUW6l1S/5sO3716gJCU/S2OocvzJLB5Y0GBu/PxPff0HhcsX8GjJhcrw4/oLR/dMVynUKhism+l48h08eRod6XyPY/finQtY4jKNagDU56F5aQt2mkDp1mhoyB2TLoF2YJO7zSDkEutHNyrtROi6SGxgoh8Pkvy/WjavGa2ZxWtD5w2HmVu10VPaNGlfHgYnGOoVYMN2ngD2JjEts0qU7QrCjUFan2xKn9kWV1TaoXQX3WweS1T0eG0dxjwEmkIowGsOU6z9xgaNrzlYQXGYkoxMueRRYkBtiHsmDtd5yF6Bu5mPqagRtIB2ECTtgEvUWsUpHnUAeZF6sA/qauJU8ywimwcgv3UqMa8YpbqrvyTNcUduIcE6P9lGBH2Z5VixnRliyQnw== 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:(13230001)(366004)(6666004)(44832011)(2906002)(508600001)(26005)(186003)(36756003)(38100700002)(83380400001)(6506007)(38350700002)(6486002)(52116002)(86362001)(6512007)(5660300002)(66946007)(8676002)(66476007)(66556008)(8936002)(6916009)(316002)(1076003)(2616005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ShJl6kzQFdtejFQcxxJV9f66YCCvDg/CIzOLeUANqr/mYEhSOef4vn04duWJY5Ft1spUjavmcZ8uUpZLYsMlOBCPsEuMLgpiqFOK6v+s3PUKADf3vP5F6T0b6iPCLzMD8mYV0Yjbz+Vfn9DqZAHEvsPclnLQtMED5FJ3IJJ/ys6mr6bmZNcAdi7gBUyD/ohfmEuPHPGqzJsF/HmbVfjObr79xG6/nZfFkilJzm+XbRjTYznYWrjnYFr70JoWvMIje1EBytd7XGVDrrOvaF8W5fRJEl68mpO9G8Ull8hP8l6NLXGW5kqcDnDVF3+0XXqKG5Zy35plUcoXS0QZ3HLe0iJS97pc+BgMSkoBTeAKlimhAHET9x43IoGO/6WGmSiY9RZg5fi2BJlyJ+OIYuc1ECfmp97mgDO++QIWSRYRagWoARqZwbzOycrv2xr4v7Ek4FQ5pPjbPz4071EhVQlYq4qsJqmfVAMs5JiQOVvYapdmssVplJTNn78qNNwCaTrj7tgZIMehS8a0kLTdhsk/MrhWsTq0zvrRyaGhIyJhIS4GWI1Z0T10pRO4zzgWvmQgU1Tb5LD7ACWOYv1GB34sLZGk22VhJ4Nifv3zfGs0YzGL8K+UYvgpd9ofZpTLYKG40rzVwIatwUQPBD9u35LcK1lXCvJubzfngOcow28ebWW8q1cW/lhTu8e/HhQnekzUAVTUt5Kzhxwx2PIVbC1pu3dyw7keBvdYV37R2vxNJfGGmVE8hbsJo+DivBzeMFkZKaOILXUpAmFaTYY+iDHxY7h63cA3mSeX1mOIQPdRoeiEejw5Zr7i9EbJYrmDrV7UDFC7DlhJ2oAQ7IYypGDCMiptZ7jRIsToaM+PQuQkLYwdPiHQVTJth0NhERdBsYuM2IuS2XMXbtKP91Y4UsLPpw+3crSgY0sCjYbovy0lPI/MiDvKNesj8F11C7RP0YWpY2gYteInpK2asY8Pd7bSKSapV9mJeCIiYkR9rkpE0kZo86BIQPHyJjLjs7zKKEyqAtChH5Xq32qYimvqHB3CurFSCV5UgpmtZukqNjQvaIRQr+2hZGdH+I0InAwcOzxjHEoD1rb9S990EMpLF6cczC9FyPCdc4e6dmJ1UnahUSPJqxIasSMDTrYq7EBxjJVguVA/Nm/ZRiRv46bIvlDbSn0WZ3ZnCj6LdMZpUMoQkvYUa6Dks69y4ieFw2EbW6iGctzsXomtntkXwkjBMFtVYVn4n738R+fQBBmtsnmFmxsBw+6OYlKzczsBhVT6UpvxTM4aRDnsj6gaARO1ouW9FwGN02oofH/cDNaJdXdFk46BAQ9MGJ5WvjvGbg0csKRTn6W0KoXOJmSbWDpw/fyURnDyuwNvyU73LdtdEnZTqWQ22r+3imi2F/EhRBlWn55lSupfky92Xn6bk45JlXuYyx7zL2o1wjMto3U9gym8qAyHdW9QegQWwT5TDLXgJvF6LjUQ6pmLPLY4lURbnR6OBw== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 104b472d-9e6e-4e4d-c9cc-08da0d11211c X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Mar 2022 21:07:24.9048 (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: Wj/ednIJmKM5d+I4Vyz2C97UtIZWtlvpag9A5VN562u5LnZmrYXnzbpGmus4ypBuMr6DjLgcGUXohujQG77VJEtGsOz4J1GUOEZHauk0VaY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4744 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10295 signatures=694973 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 suspectscore=0 spamscore=0 mlxlogscore=999 phishscore=0 bulkscore=0 malwarescore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2203230111 X-Proofpoint-GUID: kVB8L7gLy_5XispxAQNWsLrXZyJE8jGQ X-Proofpoint-ORIG-GUID: kVB8L7gLy_5XispxAQNWsLrXZyJE8jGQ Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org This is a clean up patch that skips the flip flag logic for delayed attr renames. Since the log replay keeps the inode locked, we do not need to worry about race windows with attr lookups. So we can skip over flipping the flag and the extra transaction roll for it Signed-off-by: Allison Henderson Reviewed-by: Darrick J. Wong Reviewed-by: Chandan Babu R --- fs/xfs/libxfs/xfs_attr.c | 54 +++++++++++++++++++++-------------- fs/xfs/libxfs/xfs_attr_leaf.c | 3 +- 2 files changed, 35 insertions(+), 22 deletions(-) diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c index 21594f814685..da257ad22f1f 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -358,6 +358,7 @@ xfs_attr_set_iter( struct xfs_inode *dp = args->dp; struct xfs_buf *bp = NULL; int forkoff, error = 0; + struct xfs_mount *mp = args->dp->i_mount; /* State machine switch */ switch (dac->dela_state) { @@ -480,16 +481,21 @@ xfs_attr_set_iter( * 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. - */ - dac->dela_state = XFS_DAS_FLIP_LFLAG; - trace_xfs_attr_set_iter_return(dac->dela_state, args->dp); - return -EAGAIN; + if (!xfs_has_larp(mp)) { + error = xfs_attr3_leaf_flipflags(args); + if (error) + return error; + /* + * Commit the flag value change and start the next trans + * in series. + */ + dac->dela_state = XFS_DAS_FLIP_LFLAG; + trace_xfs_attr_set_iter_return(dac->dela_state, + args->dp); + return -EAGAIN; + } + + fallthrough; case XFS_DAS_FLIP_LFLAG: /* * Dismantle the "old" attribute/value pair by removing a @@ -592,17 +598,21 @@ xfs_attr_set_iter( * 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 - */ - dac->dela_state = XFS_DAS_FLIP_NFLAG; - trace_xfs_attr_set_iter_return(dac->dela_state, args->dp); - return -EAGAIN; + if (!xfs_has_larp(mp)) { + 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; + trace_xfs_attr_set_iter_return(dac->dela_state, + args->dp); + return -EAGAIN; + } + fallthrough; case XFS_DAS_FLIP_NFLAG: /* * Dismantle the "old" attribute/value pair by removing a @@ -1270,6 +1280,7 @@ xfs_attr_node_addname_clear_incomplete( { struct xfs_da_args *args = dac->da_args; struct xfs_da_state *state = NULL; + struct xfs_mount *mp = args->dp->i_mount; int retval = 0; int error = 0; @@ -1277,7 +1288,8 @@ xfs_attr_node_addname_clear_incomplete( * 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. */ - args->attr_filter |= XFS_ATTR_INCOMPLETE; + if (!xfs_has_larp(mp)) + args->attr_filter |= XFS_ATTR_INCOMPLETE; state = xfs_da_state_alloc(args); state->inleaf = 0; error = xfs_da3_node_lookup_int(state, &retval); diff --git a/fs/xfs/libxfs/xfs_attr_leaf.c b/fs/xfs/libxfs/xfs_attr_leaf.c index 014daa8c542d..74b76b09509f 100644 --- a/fs/xfs/libxfs/xfs_attr_leaf.c +++ b/fs/xfs/libxfs/xfs_attr_leaf.c @@ -1487,7 +1487,8 @@ xfs_attr3_leaf_add_work( if (tmp) entry->flags |= XFS_ATTR_LOCAL; if (args->op_flags & XFS_DA_OP_RENAME) { - entry->flags |= XFS_ATTR_INCOMPLETE; + if (!xfs_has_larp(mp)) + entry->flags |= XFS_ATTR_INCOMPLETE; if ((args->blkno2 == args->blkno) && (args->index2 <= args->index)) { args->index2++; From patchwork Wed Mar 23 21:07:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12790155 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5D779C433F5 for ; Wed, 23 Mar 2022 21:07:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240993AbiCWVJM (ORCPT ); Wed, 23 Mar 2022 17:09:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38552 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344858AbiCWVJD (ORCPT ); Wed, 23 Mar 2022 17:09:03 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CC6A28CDB5 for ; Wed, 23 Mar 2022 14:07:28 -0700 (PDT) Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 22NKYRLM007704 for ; Wed, 23 Mar 2022 21:07:28 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2021-07-09; bh=jyBWlsAAoUdphRnovHJ1XpDiH45isDpg/XR9NlNv5BA=; b=uYaN9+ZoiSdKr9tv4yhP1uonlURFqJ7S39UWF+gTeUATF5TvXqvsAUPwFHvm05tLwMQa oDsZa5t69NZJC2E5xnYT+S+XsLK8Le1n2vSNDXUJVZuWEB7N6dbWMUZPGkE4xjLYehQJ 1fcxylGyMYHMfY2dtq5AGpJ/UPlRjNSJ9QY77KvtosONCqWov6/nwCuaRcwEYQ6Kimam uhVFh70ixu1kAw/OMWVPSId6pQ3EcJ7zuH0OJpq9gr2i0Hug1lr6mxn7mjujH7/UFSLe V9MMdNurVwQ5izBwnjgILwTtKO7uZhcUFPgvLSZMmh4ybjUngjxQBofJJyYhFe4iz7el rg== Received: from aserp3030.oracle.com ([141.146.126.71]) by mx0b-00069f02.pphosted.com with ESMTP id 3ew7qtawtu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 23 Mar 2022 21:07:28 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 22NL6LdE082870 for ; Wed, 23 Mar 2022 21:07:27 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2168.outbound.protection.outlook.com [104.47.59.168]) by aserp3030.oracle.com with ESMTP id 3ew578y1wr-8 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 23 Mar 2022 21:07:27 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ayhjxiUDvHUP7vkRDxaqzp7iqvertQj3tqBnjfFXBrF4hsubOR0Nv37kF+oRQuZ++MWj8FfCGFctLB9DaxVPiu1FgyW7OC/oBH91HGSllXinQlXgPiLWDfl2No/ooi+5vBA6CX4roFRmTxHIfZNPI1LTogWIy80zY45UmSdQBYWuvzLLbCLoGxXFa9lU/T2ieYL0ULa9P4p2Mh0nMw9DmWvkJHwvOEHECorumxmqkt+odhnI7tnZpI0uE+VLsdTwW0qJb84YnLXqkuN6cx7kMGepXxxoz/3AlY3ACKU4GaMQRyXx0CGr0MMfTaGns/zDE5R1QIKo3HUixMnzW323Uw== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=jyBWlsAAoUdphRnovHJ1XpDiH45isDpg/XR9NlNv5BA=; b=Mxk4faPtYS9amlQso6WsZZCny9bziUT6S6tr3Uy9EcMpCbQ01a3yIyMa5DNxyjnUKkxbV+aBBFLlugJDwpvwMyWFwdMeAMZvbwBDC0bGtPVj54e5OPVAQ8hq9lnVc8FqQQwOUURTtNrvYaE6F7yO+L6X4mqVFIMpw+jw68WylPiWvL/iD8U/IiikA4xN6eYyALaV3K6Aw1zrPMn5wvVdiGWr1+CsMZ4NuSVbUImLRH71FvDr/si6uJbhHieTOmNGLuKEwbr4egxrxLXwOzR1+0SwuFb+0Q2iUzPG7K7UZf/f3zmyaSqAFWy07XkxJnYOpQuqnjlA3L/cJJ0r++uheg== 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=jyBWlsAAoUdphRnovHJ1XpDiH45isDpg/XR9NlNv5BA=; b=jtpDbS1yiJRKKrop+sfN2TeRsAT3kHz6iEq7Mvload1J6XYKPPF1lDBiuXgPBUhobFQ51mZbJiyPojquyjPTaIzNI0s/5WSIC4ytFR+ONtQFHEx4hNgt/qP05X8ZUwI+lsISanDYCLuzXpMThcyWY+lkx6lmuBfnJpNbDAzRXeg= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by PH0PR10MB4744.namprd10.prod.outlook.com (2603:10b6:510:3c::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5102.17; Wed, 23 Mar 2022 21:07:25 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::c517:eb23:bb2f:4b23]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::c517:eb23:bb2f:4b23%6]) with mapi id 15.20.5102.017; Wed, 23 Mar 2022 21:07:25 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v29 07/15] xfs: Add xfs_attr_set_deferred and xfs_attr_remove_deferred Date: Wed, 23 Mar 2022 14:07:07 -0700 Message-Id: <20220323210715.201009-8-allison.henderson@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220323210715.201009-1-allison.henderson@oracle.com> References: <20220323210715.201009-1-allison.henderson@oracle.com> X-ClientProxiedBy: PH0PR07CA0084.namprd07.prod.outlook.com (2603:10b6:510:f::29) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6e53661e-54de-4673-c431-08da0d11215a X-MS-TrafficTypeDiagnostic: PH0PR10MB4744:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 46jkzuFnUngQGirI0GpgVk2KFMm4tVGTh54+FRQzi3YyV3q+iI374TWTF3Yk8xX+huJEexPpDzibB1eVwywrdUr4NHvd8ZyxpXac8B7CN2NlQAakbY9f4avmNJvnaAwAwf/FC9Rdx0VOxjqU/pNSeQq8VDCmIPxp7deYtfuuuHUGX2NjZs3CJGfqaa22BalY+tjM116JbC6bEXWjtHIAZYl/PKLaEMxSgJeZQ5JJY6/yp+OkTMhywVIXTUIWZ2tEYs96Euls2tsMXuIGiGNzvgfyQiDGZE+TgG+KgquX+3YVUXByU7GajauyqaICRh/E+xGSdCrwAhHStmEjub/9ubSxfuirZdpmEosEKH3DRuFBTBP1WYCZKtBwele/LJlA4w+xsLOSonlNCgReevHUFi2I7sl7kI17oXP7BnbOsV7+t4BLJF/XO24lE/2A0ll0CYi7qzzfVcR6h/naz//62OZxQOokLB+KOi5gy2G7GAKzaIKVkNmnZhOgBeO3jf1BeZU0s0HRSk6VlQEGJobB5EzpUrNf5S2Sjh8Girzh/uDWhNovhdhw14EplK2eejyrQRRI99pRlWJQMLDdifOHfqHwZ6h5jkN/nvPaz0SEnPo1aLqwmdnJTEy6yhFsW7RlZvGmRwcletVGd39JbsD/7viS2T1bvqLux6nWChMHPb6PRU9SGDXYFHiCMu+iV/qt9zLG7UflnhhWH6jZKOfcFw== 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:(13230001)(366004)(6666004)(44832011)(2906002)(508600001)(26005)(186003)(36756003)(38100700002)(83380400001)(6506007)(38350700002)(6486002)(52116002)(86362001)(6512007)(5660300002)(66946007)(8676002)(66476007)(66556008)(8936002)(6916009)(316002)(1076003)(2616005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: W2gsPustFihw1fZ2464+vS6cp/ShNgmX/ypcHVyya96CcNLLyGg3Fu2kipaWvgD2M2YdpYlo5MsoFVfm/D89eFdQ4785/ZrtBkzjepqsFJU/lgx/MZqGOssZhWyMVEX1Ga2198wQ2bAymRyyPdZSJcjnQ26U1lxdKX42f5u3szclVBtKvu58kiAuZJCcy4iFheJUWafSLTzULE9uCB6h/6mT9ZIH18FzlcKNyC1R0Ab6Knx9rwhW2u6JxhNzZmCpl5PtXgK6ykNn+9jLtK6OwoWjXNV1Rel0kGse+V/tyLgYikdlNF7+hX68usedA3GoNTk2rNV8XBs/gkEVL92BEYx3Dc0VOf1ncOPwVn8afBpbazPxHR9sYNztKVCGEjbZOvsNg3QagffZtrYSbaRMWafs1gkguJPMbX2kJ4zUgqsgzNT+Fj08yTJdrbnwpalgDTIg9lFaDOE/oTDOEJ09RUdX87j/nVsUZG0IGA/Xs9D2DNg5IhPN4MMuqB97XgrFsvdm45YFNlQ0mkofGt9P4Ua/z1+egXuaa9O9AL8RBJJOlqQqsyZDVjuaCpLXPX4Kcqj1AFQCQkCMHiqY6zI9GxWCnrukhpjUEuXnj478jICUdGpQtdmE8/oegCCk2KgcCpB5YHNnEKV9ybamyRw2uTTPwRQGHnB3gKk8m0lSl0OWLKZVuD37IMzUNrZvyNBih//VmsPVAXpFCMA/AIBDvChC6q/FRP71uabadZDk2cE/S7+WWeesZINbMC52JpLuEB+c/gtpmZPxk7AtqZZpT4RjRW3b/yuljKIK1Dbz2XsRH0NwFKQlBC4Ub5wSc0RCthxqCLS751T27n1PjzMTOknPLy9OPGYhyoCOHxG4s22yp2RETTC3Bsx5B6IqK8GDViXnTYzFrQG8ZvHGgw9Conbqiv684JMPBG1sJMAW9e7FAAsMDe/qgQxR1G2E4fyX/9Xa+pulvG7+lXyxsJ41pRhQ3BN1nlY31K6+/JKKtedbM8o4IfFuRgvXH57g7nC/7Tzdaldu5LIZph1nkhDBu+Ruw3I5yAiwyxLW7LFNtL6xoF5mj+OkuoKB3KiAnEeYkN1SdYyW0N0KRHQPDPNJjOJnZLwTxzbaAsFrQkgZrfhrFX4hoyNC7Km0HjPg1gGdFSGQVDm+vomGdBoW8cuJGQrEZkne2AODt01rpij86iJtOB14tmbBzFRfyAuLgPEaka5otfb2rdZLy5rx2hOJZtXJIfhdFYsOnULHkEmBfYQoO0Hdx59ve3umL/wJLYhDCk0QObpypWzMxgYaBfFKTOq2QwKfSXd0SxsRtO4DEnH7DmJXrekKxLOlSgFLvFfuoFWla71AL4RhddRbvBaw5eoxbiC5Y7HW7xbbY5EYhw8M5FBBNqP39vP9f1fkdfMV6po5xrtfHD8q9b3MhIjSw88XeCF3Cx0f3DTYp0ZcsIDJZlhyH48fpqcS6F3W4lpnQCEx30PN4TNWcKZENn7aiQ== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6e53661e-54de-4673-c431-08da0d11215a X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Mar 2022 21:07:25.2642 (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: GCrGN2N92LvPAFZa5/gciZ1l27gaXHeknEiYDXCpm9fLDXXFJLwnC0bgoyGOgndSy6CwMl1z7UIe8vGvTFa4QiqTI3rVcCFEsdFjxMyfgac= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4744 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10295 signatures=694973 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 suspectscore=0 spamscore=0 mlxlogscore=999 phishscore=0 bulkscore=0 malwarescore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2203230111 X-Proofpoint-GUID: y0YMle53bEDF21dBKhZEE_KlMo15qeRh X-Proofpoint-ORIG-GUID: y0YMle53bEDF21dBKhZEE_KlMo15qeRh Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org These routines set up and queue a new deferred attribute operations. These functions are meant to be called by any routine needing to initiate a deferred attribute operation as opposed to the existing inline operations. New helper function xfs_attr_item_init also added. Finally enable delayed attributes in xfs_attr_set and xfs_attr_remove. Signed-off-by: Allison Henderson Reviewed-by: Darrick J. Wong Reviewed-by: Chandan Babu R --- fs/xfs/libxfs/xfs_attr.c | 71 ++++++++++++++++++++++++++++++++++++++-- fs/xfs/libxfs/xfs_attr.h | 2 ++ fs/xfs/xfs_log.c | 41 +++++++++++++++++++++++ fs/xfs/xfs_log.h | 1 + 4 files changed, 112 insertions(+), 3 deletions(-) diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c index da257ad22f1f..848c19b34809 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -25,6 +25,8 @@ #include "xfs_trans_space.h" #include "xfs_trace.h" #include "xfs_attr_item.h" +#include "xfs_attr.h" +#include "xfs_log.h" struct kmem_cache *xfs_attri_cache; struct kmem_cache *xfs_attrd_cache; @@ -729,6 +731,7 @@ xfs_attr_set( int error, local; int rmt_blks = 0; unsigned int total; + int delayed = xfs_has_larp(mp); if (xfs_is_shutdown(dp->i_mount)) return -EIO; @@ -785,13 +788,19 @@ xfs_attr_set( rmt_blks = xfs_attr3_rmt_blocks(mp, XFS_XATTR_SIZE_MAX); } + if (delayed) { + error = xfs_attr_use_log_assist(mp); + if (error) + return error; + } + /* * Root fork attributes can use reserved data blocks for this * operation if necessary */ error = xfs_trans_alloc_inode(dp, &tres, total, 0, rsvd, &args->trans); if (error) - return error; + goto drop_incompat; if (args->value || xfs_inode_hasattr(dp)) { error = xfs_iext_count_may_overflow(dp, XFS_ATTR_FORK, @@ -809,9 +818,10 @@ xfs_attr_set( if (error != -ENOATTR && error != -EEXIST) goto out_trans_cancel; - error = xfs_attr_set_args(args); + error = xfs_attr_set_deferred(args); if (error) goto out_trans_cancel; + /* shortform attribute has already been committed */ if (!args->trans) goto out_unlock; @@ -819,7 +829,7 @@ xfs_attr_set( if (error != -EEXIST) goto out_trans_cancel; - error = xfs_attr_remove_args(args); + error = xfs_attr_remove_deferred(args); if (error) goto out_trans_cancel; } @@ -841,6 +851,9 @@ xfs_attr_set( error = xfs_trans_commit(args->trans); out_unlock: xfs_iunlock(dp, XFS_ILOCK_EXCL); +drop_incompat: + if (delayed) + xlog_drop_incompat_feat(mp->m_log); return error; out_trans_cancel: @@ -883,6 +896,58 @@ xfs_attrd_destroy_cache(void) xfs_attrd_cache = NULL; } +STATIC int +xfs_attr_item_init( + struct xfs_da_args *args, + unsigned int op_flags, /* op flag (set or remove) */ + struct xfs_attr_item **attr) /* new xfs_attr_item */ +{ + + struct xfs_attr_item *new; + + new = kmem_zalloc(sizeof(struct xfs_attr_item), KM_NOFS); + new->xattri_op_flags = op_flags; + new->xattri_dac.da_args = args; + + *attr = new; + return 0; +} + +/* Sets an attribute for an inode as a deferred operation */ +int +xfs_attr_set_deferred( + struct xfs_da_args *args) +{ + struct xfs_attr_item *new; + int error = 0; + + error = xfs_attr_item_init(args, XFS_ATTR_OP_FLAGS_SET, &new); + if (error) + return error; + + xfs_defer_add(args->trans, XFS_DEFER_OPS_TYPE_ATTR, &new->xattri_list); + + return 0; +} + +/* Removes an attribute for an inode as a deferred operation */ +int +xfs_attr_remove_deferred( + struct xfs_da_args *args) +{ + + struct xfs_attr_item *new; + int error; + + error = xfs_attr_item_init(args, XFS_ATTR_OP_FLAGS_REMOVE, &new); + if (error) + return error; + + xfs_defer_add(args->trans, XFS_DEFER_OPS_TYPE_ATTR, &new->xattri_list); + + return 0; +} + /*======================================================================== * External routines when attribute list is inside the inode *========================================================================*/ diff --git a/fs/xfs/libxfs/xfs_attr.h b/fs/xfs/libxfs/xfs_attr.h index 80b6f28b0d1a..b52156ad8e6e 100644 --- a/fs/xfs/libxfs/xfs_attr.h +++ b/fs/xfs/libxfs/xfs_attr.h @@ -525,6 +525,8 @@ 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); int xfs_attr_calc_size(struct xfs_da_args *args, int *local); +int xfs_attr_set_deferred(struct xfs_da_args *args); +int xfs_attr_remove_deferred(struct xfs_da_args *args); extern struct kmem_cache *xfs_attri_cache; extern struct kmem_cache *xfs_attrd_cache; diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c index 0b346162d851..09281f064019 100644 --- a/fs/xfs/xfs_log.c +++ b/fs/xfs/xfs_log.c @@ -3992,3 +3992,44 @@ xlog_drop_incompat_feat( { up_read(&log->l_incompat_users); } + +/* + * Get permission to use log-assisted atomic exchange of file extents. + * + * Callers must not be running any transactions or hold any inode locks, and + * they must release the permission by calling xlog_drop_incompat_feat + * when they're done. + */ +int +xfs_attr_use_log_assist( + struct xfs_mount *mp) +{ + int error = 0; + + /* + * Protect ourselves from an idle log clearing the logged xattrs log + * incompat feature bit. + */ + xlog_use_incompat_feat(mp->m_log); + + /* + * If log-assisted xattrs are already enabled, the caller can use the + * log assisted swap functions with the log-incompat reference we got. + */ + if (xfs_sb_version_haslogxattrs(&mp->m_sb)) + return 0; + + /* Enable log-assisted xattrs. */ + error = xfs_add_incompat_log_feature(mp, + XFS_SB_FEAT_INCOMPAT_LOG_XATTRS); + if (error) + goto drop_incompat; + + xfs_warn_once(mp, +"EXPERIMENTAL logged extended attributes feature added. Use at your own risk!"); + + return 0; +drop_incompat: + xlog_drop_incompat_feat(mp->m_log); + return error; +} diff --git a/fs/xfs/xfs_log.h b/fs/xfs/xfs_log.h index fd945eb66c32..053dad8d11a9 100644 --- a/fs/xfs/xfs_log.h +++ b/fs/xfs/xfs_log.h @@ -155,5 +155,6 @@ bool xlog_force_shutdown(struct xlog *log, int shutdown_flags); void xlog_use_incompat_feat(struct xlog *log); void xlog_drop_incompat_feat(struct xlog *log); +int xfs_attr_use_log_assist(struct xfs_mount *mp); #endif /* __XFS_LOG_H__ */ From patchwork Wed Mar 23 21:07:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12790158 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D2502C433EF for ; Wed, 23 Mar 2022 21:07:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240170AbiCWVJP (ORCPT ); Wed, 23 Mar 2022 17:09:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38568 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344880AbiCWVJD (ORCPT ); Wed, 23 Mar 2022 17:09:03 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 753C38EB4E for ; Wed, 23 Mar 2022 14:07:29 -0700 (PDT) Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 22NKYFfE019841 for ; Wed, 23 Mar 2022 21:07:28 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2021-07-09; bh=4lZk2qI5oRE/oOjKu+/53ym6UisnjP+x0eag4vasz2E=; b=YAB/iJAVNcETTHe05Qta1S36EBw3VeZsbUA64GizXsyi2rWYHkwwOsJFbuWXuyonXxUP NTlJv+myWV4+42KRtj1RMhqujQ9Ouwc4/bJorwTJFndgNidnde7hq5/WMmqXFBqPIYvW 2MC2zdoA2fTeGd+QOCPx+BhZ1ej3Q9YhJTocTvFSvP8VpByudkrq5tcqE/LDop9a5wvz tUGWq1WhRTcO180L3lyRM4GeL3s1/oU018KXMS+YbvVX1JRIfHUxnpK4DrAtLmFnXwlu k+nfOfCLz6AdJQroUyi1sOTReBC8iYWXXEPXa6lx6MuG9EC30Sj4J6J61oPLRKphFhnR 2w== Received: from aserp3030.oracle.com ([141.146.126.71]) by mx0b-00069f02.pphosted.com with ESMTP id 3ew5kcth7q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 23 Mar 2022 21:07:28 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 22NL6LdF082870 for ; Wed, 23 Mar 2022 21:07:27 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2168.outbound.protection.outlook.com [104.47.59.168]) by aserp3030.oracle.com with ESMTP id 3ew578y1wr-9 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 23 Mar 2022 21:07:27 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=C29cLOfLKvE3cyLzZwoJuS5W3Qc9nXYv0/oNfnpbVnGjJkDbx/MiW0pkt0HAg/Rv6YzvAb7sStPEAw07o2JFZ6s9i3vQBwXKjOfrSinPwi0PN/V2q0NKSI+cSGb89dZ8W4Xb+1ipqXfMk2tG1tzMdYxt51FO0U3hRsrFpaU+xsFGM1Yfx7RZh5m5ezcFmOL50Gr3EMe8CeqXH0mCYLIqGJpeS25dIGjP83V/+7Sz8S1LuTL9eJEaR77riWQELKtihiAKmrZMUi+YV0Ibxpsn3oEwnWNg3G2n3v9A/ePQ4dE6D7LNzw99HamN0Ip52QsBD+VjNh5hOK1lcgkYCpEHCA== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=4lZk2qI5oRE/oOjKu+/53ym6UisnjP+x0eag4vasz2E=; b=ZdHQHonwYIHm+5JL/VjePtLYUh+hA8gztGcb8iQ4cKenxsu2eltQ0CwXly6F8rQ56J6/tfLYLFtf+Dtfv9K3vkEhHFmNnIB4QHVxnDh+g0+uxl0CQrrmJMz3YenuBFQRhoWHnEj0k7+XdJ0RKDCL93qdnIc5+8HL69S7Mpxc8rEfbctTp5QBJmajCTQ5KCO1yIsrGqbGpogEUApv2CHy++LjokwuCBKpFXLbf0KlEMWRJrK+Pn0QO2IM59d5KAYAy7ZWmIgPBt6Teneu4qCx+fT0M4nnSdLsO8KvOJ4XczQsDpLy2EyhpNRV7lTdQf6VEZ2/p6QMBUpv8ymq8OusLg== 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=4lZk2qI5oRE/oOjKu+/53ym6UisnjP+x0eag4vasz2E=; b=GULevByRPYlLKQ8vAkiGm6+zK3dRfs9dSYgedgxo9XrskOXzh0IWW5cfQscOxdBBQIskJpTyJ6sUVVdcZNM+A1q0RmliJvd8HnE/an1X66qEJDTs8VeIOXsyx/4yhTr2Y/oFHri6teCpqBzZi+YNONm/zKLS2EUYDGfK2F+CH2Y= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by PH0PR10MB4744.namprd10.prod.outlook.com (2603:10b6:510:3c::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5102.17; Wed, 23 Mar 2022 21:07:25 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::c517:eb23:bb2f:4b23]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::c517:eb23:bb2f:4b23%6]) with mapi id 15.20.5102.017; Wed, 23 Mar 2022 21:07:25 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v29 08/15] xfs: Remove unused xfs_attr_*_args Date: Wed, 23 Mar 2022 14:07:08 -0700 Message-Id: <20220323210715.201009-9-allison.henderson@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220323210715.201009-1-allison.henderson@oracle.com> References: <20220323210715.201009-1-allison.henderson@oracle.com> X-ClientProxiedBy: PH0PR07CA0084.namprd07.prod.outlook.com (2603:10b6:510:f::29) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9f129718-37de-4c0f-97c9-08da0d112191 X-MS-TrafficTypeDiagnostic: PH0PR10MB4744:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: fPSWT+EHGXgxfUfBc+2cmBvTQycF7Gv+Paw/NNwxy/i1vIgPKM/GGu8NJ2Oug/h/C3k4vePKn42b+Q12RTK8XvevJRJ4iwe3HlXfgtAZobPOeexa+dxrCA9fa+FaK2IiQRNdSEcii63HqIvccRuNbU7/6ka5NUXrvPvNCP5SJZN/Xr468PMUSPKtzJ+HGzTJ1lKDskXfa2sqfda335tcAFud08jrBiDYQ7Zv+lnB8TEa8ovENc4nNJ3ehso2JnnusUE6C18kse3IGs+0pkUs3psUD+4iXjo1Z2VGkGOPN0nBBPLrb9cUmaWb//JhEVGU+cu7kYZKl6MsUUtME/ygGeMlb09q/F2RrBRFXWBJwiDiQPyY8dRfhTywCGnHMShecGEQYb/VSBYxLeFLWW787Thw+Tj9fADYs9QNzDurNyDg8jAVWpVAy7nP90VSUd1skTdGlMbPiAhChSNJUQzj/2wxro2Vs6B0qwrVHyPF9QdwMaSZHQlCkvVyzDwx+pOg4dSu6EprYGmA1+851ScqV5KVyDMA+kckaJtUo5B4hUqFbb2MCyAV0aEb2Kk/yisUHnJ7bEQA5Zn3sSOFc3ONN+TsEEm6F6DzG4O1fEnhXEa4NMoKdyZYBwPI+NjVc2ty/SLUXN4C3SyM1hMQECECFTHzLHuRLyS7BWQnroPsWkBXmOJrrCRG8Ug7qIdGRuVkpe6PLVdQj0/dapAXzhrYsg== 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:(13230001)(366004)(6666004)(44832011)(2906002)(508600001)(26005)(186003)(36756003)(38100700002)(83380400001)(6506007)(38350700002)(6486002)(52116002)(86362001)(6512007)(5660300002)(66946007)(8676002)(66476007)(66556008)(8936002)(6916009)(316002)(1076003)(2616005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: GwuaB+sL0GLIYWxMdI1whQ9Cj4tBDOD6Td5d7wm8k3xtJbehzxGJAsVFtvpmceRXxjMj/SowU17JPb1QdtEqEw9scmRhxJXWGi2IqNeNe3HMMyyv5iXGVO8ErMU4Wrytw4Yb/cd4OH5Bmh0jCVDdqhJ7b8Cf8pqRxeLBWSTdCc9YgtodfIrXfUplZwWEOzYDUdQCX0EeAxzkV21foQ0dL1/4P1LWBcPiB+MI0Sb6zBS/ufyNVcRPToGEqq56YYJv7DJv5szUScW4+f1IUqu6PXsNDqnVulVnGWC5SAGwfYLWOhhYq1WscyBsUcPi9VV+v8ppbUSEEkgup+a68r+cboZk1/tuVRkxCjKSRdqmh5OypMtzMuj+Kt1REzqqCAMYJmAngIoOEaIPUw1YXNgL1i20Xz5rWOxlBk7uKucyB13pFqZWd3VGxmOoJzm1w3W/APd7sk+CYpMp6OEVUT9I7KpoO0LtAVkt8fsGlxOqoHk8U3BKUAqDwO9UVMbi2wl21c1vtVdF1wHNny0lr3bMSxASvNi1M1zgjDsCcDKeitugkS9qQnMPWPzzMPzvVhGuL8w/+26z6mcnc3mihrNs0oBE004GUXTNYwHiEe0+pN+1p0ziUHGElpfX4zA3cZZG/Pcd05SC/ldtdbWXF00hWb0DlGO86GQ6MoRS3Vuyl/00u2i5XiINfXPyErnLR4VW64FbuMCqP/S0iY+SqXCe96z6hd+mijh4mCAIcK+EEVfYxYNLv4VpVEf1Q3U6PpB1AVY1Acta2hQmqrPO+Tjb1TSVgyICedtwRPK3yKLjYrGMFbjpwsnRtXCVNurL5h9nKZtWN0N/8/MSUm6nrgLkRM1qNStd2ZmRfTOATbey9qWBkEUJMEJcEET/kN8wEtSUf/9lUdW01QW1rAWhjIrYsVFwqJDjs5zJWmGjKNIvTXPnuKg0VdRC5bpoaZCMSzqEH4CFf4jfwy1LLSF5NcgSie51L8dDRnlf+A6Np0KdJw25A//hsZ0Al9jtyLhWONG8lZ/ZZnLqjPSN4KDCAJM0OU797CC5T+jW8ofmu+Bo6oTS5LkxJSJ67Ax8a00uhtPP/nHCj7qZoWUj7vVd4H4txO76A1s2cIVT/zSRkLKEVQnwswHgYVGNWtjapApdjuNXumITl35XHji8loTf4FyqpHBoEythZoqzwcmeftOpVf5ywGDCfIkxr6ntwpFIalOG073p21j3haIbWScmvu0jM2WHxXCaEn35t8igpCLqCfxsNt8Wz4lhi6yuxJlCORHBKs3OZhskxxke0KyDkRDnBhdPsYZdC1G/yJiFsI/5PKQx/J48imj6XwxT1y0BgnWMHjlfQgbnqz51sHbRXBZopMwPVLiiF1RCPEbCuDqxO0/dDZaj1uUbY/uZcUZlvW/kRySoMqhSB8JpH/QXdA7jzrKxDde8DBtJYM4GiWKfSo14zPUfyEbZ7bZtFv1Lr1yLZJQ6QiZiEK9ZkO99w+rPeQ== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9f129718-37de-4c0f-97c9-08da0d112191 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Mar 2022 21:07:25.6703 (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: ewA9uHW58bhNo0vTa+XtmBtP0DixTQpAqXRC/iU/AA9TFrH9WafE7U21IKiy1STkooZrV9jk9mzClRHjZP+sz6LUHMhfQKTCANn2lQcDVws= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4744 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10295 signatures=694973 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 suspectscore=0 spamscore=0 mlxlogscore=999 phishscore=0 bulkscore=0 malwarescore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2203230111 X-Proofpoint-GUID: t6PDB8y6NJYDL-hvDOp4h7biK6o0fjwP X-Proofpoint-ORIG-GUID: t6PDB8y6NJYDL-hvDOp4h7biK6o0fjwP Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org Remove xfs_attr_set_args, xfs_attr_remove_args, and xfs_attr_trans_roll. These high level loops are now driven by the delayed operations code, and can be removed. Additionally collapse in the leaf_bp parameter of xfs_attr_set_iter since we only have one caller that passes dac->leaf_bp Signed-off-by: Allison Henderson Reviewed-by: Darrick J. Wong Reviewed-by: Chandan Babu R --- fs/xfs/libxfs/xfs_attr.c | 106 +++----------------------------- fs/xfs/libxfs/xfs_attr.h | 8 +-- fs/xfs/libxfs/xfs_attr_remote.c | 1 - fs/xfs/xfs_attr_item.c | 9 +-- 4 files changed, 14 insertions(+), 110 deletions(-) diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c index 848c19b34809..3d7531817e74 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -247,64 +247,9 @@ 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. - */ -STATIC 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; -} - -/* - * 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_sf_addname( - struct xfs_delattr_context *dac, - struct xfs_buf **leaf_bp) + struct xfs_delattr_context *dac) { struct xfs_da_args *args = dac->da_args; struct xfs_inode *dp = args->dp; @@ -323,7 +268,7 @@ xfs_attr_sf_addname( * 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, &dac->leaf_bp); if (error) return error; @@ -332,7 +277,7 @@ xfs_attr_sf_addname( * push cannot grab the half-baked leaf buffer and run into problems * with the write verifier. */ - xfs_trans_bhold(args->trans, *leaf_bp); + xfs_trans_bhold(args->trans, dac->leaf_bp); /* * We're still in XFS_DAS_UNINIT state here. We've converted @@ -340,7 +285,6 @@ xfs_attr_sf_addname( * add. */ trace_xfs_attr_sf_addname_return(XFS_DAS_UNINIT, args->dp); - dac->flags |= XFS_DAC_DEFER_FINISH; return -EAGAIN; } @@ -353,8 +297,7 @@ xfs_attr_sf_addname( */ int xfs_attr_set_iter( - struct xfs_delattr_context *dac, - struct xfs_buf **leaf_bp) + struct xfs_delattr_context *dac) { struct xfs_da_args *args = dac->da_args; struct xfs_inode *dp = args->dp; @@ -373,14 +316,14 @@ xfs_attr_set_iter( * release the hold once we return with a clean transaction. */ if (xfs_attr_is_shortform(dp)) - return xfs_attr_sf_addname(dac, leaf_bp); - if (*leaf_bp != NULL) { - xfs_trans_bhold_release(args->trans, *leaf_bp); - *leaf_bp = NULL; + return xfs_attr_sf_addname(dac); + if (dac->leaf_bp != NULL) { + xfs_trans_bhold_release(args->trans, dac->leaf_bp); + dac->leaf_bp = NULL; } if (xfs_attr_is_leaf(dp)) { - error = xfs_attr_leaf_try_add(args, *leaf_bp); + error = xfs_attr_leaf_try_add(args, dac->leaf_bp); if (error == -ENOSPC) { error = xfs_attr3_leaf_to_node(args); if (error) @@ -399,7 +342,6 @@ xfs_attr_set_iter( * be a node, so we'll fall down into the node * handling code below */ - dac->flags |= XFS_DAC_DEFER_FINISH; trace_xfs_attr_set_iter_return( dac->dela_state, args->dp); return -EAGAIN; @@ -690,32 +632,6 @@ xfs_attr_lookup( return xfs_attr_node_hasname(args, NULL); } -/* - * Remove the attribute specified in @args. - */ -int -xfs_attr_remove_args( - struct xfs_da_args *args) -{ - int error; - struct xfs_delattr_context dac = { - .da_args = 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; -} - /* * Note: If args->value is NULL the attribute will be removed, just like the * Linux ->setattr API. @@ -1309,7 +1225,6 @@ xfs_attr_node_addname( * this. dela_state is still unset by this function at * this point. */ - dac->flags |= XFS_DAC_DEFER_FINISH; trace_xfs_attr_node_addname_return( dac->dela_state, args->dp); return -EAGAIN; @@ -1324,7 +1239,6 @@ xfs_attr_node_addname( error = xfs_da3_split(state); if (error) goto out; - dac->flags |= XFS_DAC_DEFER_FINISH; } else { /* * Addition succeeded, update Btree hashvals. @@ -1578,7 +1492,6 @@ xfs_attr_remove_iter( if (error) goto out; dac->dela_state = XFS_DAS_RM_NAME; - dac->flags |= XFS_DAC_DEFER_FINISH; trace_xfs_attr_remove_iter_return(dac->dela_state, args->dp); return -EAGAIN; } @@ -1606,7 +1519,6 @@ xfs_attr_remove_iter( if (error) goto out; - dac->flags |= XFS_DAC_DEFER_FINISH; dac->dela_state = XFS_DAS_RM_SHRINK; trace_xfs_attr_remove_iter_return( dac->dela_state, args->dp); diff --git a/fs/xfs/libxfs/xfs_attr.h b/fs/xfs/libxfs/xfs_attr.h index b52156ad8e6e..5331551d5939 100644 --- a/fs/xfs/libxfs/xfs_attr.h +++ b/fs/xfs/libxfs/xfs_attr.h @@ -457,8 +457,7 @@ enum xfs_delattr_state { /* * 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*/ +#define XFS_DAC_LEAF_ADDNAME_INIT 0x01 /* xfs_attr_leaf_addname init*/ /* * Context used for keeping track of delayed attribute operations @@ -516,10 +515,7 @@ bool xfs_attr_is_leaf(struct xfs_inode *ip); int xfs_attr_get_ilocked(struct xfs_da_args *args); int xfs_attr_get(struct xfs_da_args *args); int xfs_attr_set(struct xfs_da_args *args); -int xfs_attr_set_args(struct xfs_da_args *args); -int xfs_attr_set_iter(struct xfs_delattr_context *dac, - struct xfs_buf **leaf_bp); -int xfs_attr_remove_args(struct xfs_da_args *args); +int xfs_attr_set_iter(struct xfs_delattr_context *dac); int xfs_attr_remove_iter(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, diff --git a/fs/xfs/libxfs/xfs_attr_remote.c b/fs/xfs/libxfs/xfs_attr_remote.c index 83b95be9ded8..c806319134fb 100644 --- a/fs/xfs/libxfs/xfs_attr_remote.c +++ b/fs/xfs/libxfs/xfs_attr_remote.c @@ -695,7 +695,6 @@ xfs_attr_rmtval_remove( * the parent */ if (!done) { - dac->flags |= XFS_DAC_DEFER_FINISH; trace_xfs_attr_rmtval_remove_return(dac->dela_state, args->dp); return -EAGAIN; } diff --git a/fs/xfs/xfs_attr_item.c b/fs/xfs/xfs_attr_item.c index 1e2fcc9da340..e10202c4e299 100644 --- a/fs/xfs/xfs_attr_item.c +++ b/fs/xfs/xfs_attr_item.c @@ -296,7 +296,6 @@ STATIC int xfs_xattri_finish_update( struct xfs_delattr_context *dac, struct xfs_attrd_log_item *attrdp, - struct xfs_buf **leaf_bp, uint32_t op_flags) { struct xfs_da_args *args = dac->da_args; @@ -306,7 +305,7 @@ xfs_xattri_finish_update( switch (op) { case XFS_ATTR_OP_FLAGS_SET: - error = xfs_attr_set_iter(dac, leaf_bp); + error = xfs_attr_set_iter(dac); break; case XFS_ATTR_OP_FLAGS_REMOVE: ASSERT(XFS_IFORK_Q(args->dp)); @@ -425,8 +424,7 @@ xfs_attr_finish_item( */ dac->da_args->trans = tp; - error = xfs_xattri_finish_update(dac, done_item, &dac->leaf_bp, - attr->xattri_op_flags); + error = xfs_xattri_finish_update(dac, done_item, attr->xattri_op_flags); if (error != -EAGAIN) kmem_free(attr); @@ -585,8 +583,7 @@ xfs_attri_item_recover( xfs_trans_ijoin(tp, ip, 0); ret = xfs_xattri_finish_update(&attr->xattri_dac, done_item, - &attr->xattri_dac.leaf_bp, - attrp->alfi_op_flags); + attrp->alfi_op_flags); if (ret == -EAGAIN) { /* There's more work to do, so add it to this transaction */ xfs_defer_add(tp, XFS_DEFER_OPS_TYPE_ATTR, &attr->xattri_list); From patchwork Wed Mar 23 21:07:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12790153 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BA6F6C43219 for ; Wed, 23 Mar 2022 21:07:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245251AbiCWVJN (ORCPT ); Wed, 23 Mar 2022 17:09:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38344 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344877AbiCWVJD (ORCPT ); Wed, 23 Mar 2022 17:09:03 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 54A528EB4D for ; Wed, 23 Mar 2022 14:07:29 -0700 (PDT) Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 22NKYRLN007704 for ; Wed, 23 Mar 2022 21:07:29 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2021-07-09; bh=Fk5gWWpFoH1MXDV+EGU4PgQkp/9UJaE4Z6KlJD6Biek=; b=imFpgmIuHklaJRzrVGE9vl6KwsxRplxaTNUoYC49FfDEWA6+5RQYeoXhwnLtTeS+4l/u zSloP31OTWfEWxyFshfx8LsRlmgdI66Bj0pv05zlHKXcRy2wOS8mCro6AVGrGklnoXii iG7CD/JyKa8VNXkjgOuEIUGaZUPBc9MAPV8z+jCV1lrzzcov5HjNbHHUb+Z4q7ny9SDA SESrgcPR3j3N/Uv+Kj1K85tjr0UWReJNDFkywBwJnJDSbRgBbKmk9901aHF+12TReybd VzoJLsT58CsCcFBAplpTUAuj0rKxICyHNtmt8Jw7LmB3hScxp+t2RvL33xmRKkQ7CA8t GA== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by mx0b-00069f02.pphosted.com with ESMTP id 3ew7qtawtv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 23 Mar 2022 21:07:28 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 22NL6R9l154749 for ; Wed, 23 Mar 2022 21:07:27 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2174.outbound.protection.outlook.com [104.47.58.174]) by aserp3020.oracle.com with ESMTP id 3ew701q88e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 23 Mar 2022 21:07:27 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WIaXG6GuSzn00tTFSvryAx4KEPw88EwfbR6dP8N4BIhM/P5reAc064xJCuENeJRbaOxtfJAB+k2tGp504o7iGvB7Mxkmmj0lWOLNkKU0MseoG7412EG/ZNFo0BT2RlouTCwwf2+DHMfclg4LbbOpl6Qln2eXPywZdbRQ51GWVE9wrtfMOiLcIEHEpDJfk7Qfx4hzs4rRQg4Pvs2/s2TbG9xSPMTnBuJFVz1wAYai30Gp4INrwkL4RnyZlwhTRR4OJyDAMqNcd6E1o0BvmtYbBHNS0x2r4bRN5SYseYlbIG1gyPfR63Joo663ga9L929iv4FYnv0M63Jn+aBV7vAf9A== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Fk5gWWpFoH1MXDV+EGU4PgQkp/9UJaE4Z6KlJD6Biek=; b=MAyeG+wfLtcnv1FAVv6wOkyvcBPQjNmvwwi95Herg6jXvu6E9p0SruYcnFRB1TX02U3k7s5UBAjRXYeZWuxllb3jZ+U6eneiKSDEA+fWZcPwVY76S+TYur8I6N0JxQeb+dDrQotJgfSTvRnT9d7XtXkXQ5CdLHh5AmN5enFov0Cm99R070E9XbuUnwGKfzWIY1a/r6DWSakqqo1rq8O1w5hvk+DHXgG0PS8uZIpS8DFquUzQON6lPh3aS8+xVE2zx4UZQYgfOMmcB788ZHVaFD/25hnyNH5Xu2B6yHC6f/+z2snqhPVK36P/rTssbpkQfQ3XnxLSaNCCSlKb8+c6xA== 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=Fk5gWWpFoH1MXDV+EGU4PgQkp/9UJaE4Z6KlJD6Biek=; b=NCdw0FMnysXlJwhzy/7zUHtDox2/x2I8p8LMG2vOJIoajAomRX2kjTzaZfxHDKd8BqzY2TFil0ZPIIcYeH4H1YXXyms6sCR5Q1aM2jwZIp9RamFp18WsmCanHgJ1ZqNgzeEiPog7oSynzJkt4qNO7+c+/6ZMXPeICiAufGT8mEg= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by SJ0PR10MB5600.namprd10.prod.outlook.com (2603:10b6:a03:3dc::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5081.17; Wed, 23 Mar 2022 21:07:26 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::c517:eb23:bb2f:4b23]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::c517:eb23:bb2f:4b23%6]) with mapi id 15.20.5102.017; Wed, 23 Mar 2022 21:07:26 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v29 09/15] xfs: Add log attribute error tag Date: Wed, 23 Mar 2022 14:07:09 -0700 Message-Id: <20220323210715.201009-10-allison.henderson@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220323210715.201009-1-allison.henderson@oracle.com> References: <20220323210715.201009-1-allison.henderson@oracle.com> X-ClientProxiedBy: PH0PR07CA0084.namprd07.prod.outlook.com (2603:10b6:510:f::29) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a57d360c-1440-47d3-3000-08da0d1121cd X-MS-TrafficTypeDiagnostic: SJ0PR10MB5600:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Ib3Q+AtOvQPljZSkQoKrkVc+o+r3Leq07b5zriwiaXm/qGYUtbEJIQXZcf27bNAbXJ1bGWMAtplM+qIYxWllSx9CLiG9niloIOUWkrOAlAhI/yCX6ddRJLvZ81mMd+yMjTpUwGUWuZM0LCS1L5JNqrUJ5on2ZNMUXE04vyli6KoJPlFaURWHbhGvNTRX+9l4ExrFOxi0DJcvw009EcOhAM4MRMBI0HGfqTTUYHwFn02qxBGkvJUs/X+PHmiyocJzElvD5yCifKLhX0SXr5gMJ32mT9UeWdZdhDOekOZf3wphPRc2fsatX03M1j7kMuKXexxJAXOV+X2VK597h58BCivIIgCDrWSFcSZPhYngPWlM8moxzwX6mEnCoi1FS2qXbJnoacIAJgqhjvRhBt674wFTjKngCIe5ocNuf/i881bMnQlc9ObMSrh+LrwphBeOk2nR3hL8wMf41DmwNHTeQYqxkvGy5hWZcL3XMiYUDv2OJ+fH5Emil0r+Jn6NG09FFefFmhV8EX6AgTLfBoqP3Ac62f9m4N5gOr3dJb6qyWSEVhZMA3OWqWI50wYaKqDzWgLC2TmtCWhUh3Q30z+anQdTCMWMur5NWNuPhfBNOqNxbFQXIrDmZqQBkFxysQeToC31DrlN1/fQJgSRptx/NjQ4uFZmJ1SAO9Ct235J7LLejw/09dVQTNWLVFIht7Pw7OCeH4PeDSmgkeTq5+cELg== 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:(13230001)(366004)(66556008)(66476007)(66946007)(44832011)(8676002)(6512007)(83380400001)(86362001)(52116002)(6486002)(6506007)(508600001)(6666004)(2906002)(6916009)(2616005)(36756003)(316002)(5660300002)(1076003)(186003)(8936002)(26005)(38100700002)(38350700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: SrZoRsomfgI9JL+jkPtUxrFfnTZejhPZSuW0vkg3dNbbaNZeTEZGsREtPQaqM1RAGTrqjFvWQUaWu577E8UqokVe2bqsldqA+a6VM8RdhA7upmcL+QFPKX9DRdDEuS30OoQqS43/emQHCytzYQwJ0nmWJhhLgzc6LiD3eljpFl1E3jZOrJth49sIYrcKGaRfsftAZegpcGix7/soX1+NO9rTSJ56b+ugGIDx91BMvLuTcNjX3Gfgtfg5x0Lie3rVX9n4PhQDCt7GL2kEw5/OSs6iyU+Zb5nhAWmZdIsAiB5wiXdT3ITfK9jyZtuuZMhK7YwUSHTadFMIMfGRYH/0nFYiLejYMYL9ZZ9QDbGgZtpoZ1PZYW6do6Njsczogp3SgWfnh8QYXnYlKuxf71PT02z5pVMAnnsGu18ulsqgDg/85tzv5at57V25mDfDv/W+h3FLfj2i68FFQtA8Pv4NoDbevR38v2cDi+cyYTEohO4lAw+nLn9DSJC3h6v99eERkc0ZrAmYSFI495cFNUBDl2N+dn/KMi4xzNu0ISFuVs3ZVyT/u6KBIrJG66PHYZTVZRmSu3gVGnINXatMgamueA+HGR9G+3dmP2urqKZ+905CHPX3bcaJ+q8ZZqQ/griKrWuGlF+o1sJsJLtUGos6+TA4R2A2ILlb2kAZydJ5QqU5pYIkdxvocD5hmSdx11lrrOoBW/N2MnWS8A+RI/5RxiR4aB8fREhiqb3fJIU/y7XoAF9P35DwkXeXe3zb/+fUUh7sKqKN4Cn7SIg8qq51+J+eflNsEuXJ2ggUAGulv/bV/FQR1rGtalMHtoYpNxp/HnyolX6KmXBAecxMh4dkhk25Pk1iyMVXD+qY+CYRZyGCb7cuyEnN5jHilufJQiAWloZt8QEGBKZjh/GuIGSf7tebLFEID5gbw0+3T+X9Xr/vK2dKzPijWKtFreDho7rXol3SEii42QkEnNqsmKBGy0eB/kQlYYrYH8EdU9/TwI0K2XtYvs57xpb8/WbhHxftY03lbsTsD/80+ZvmP+XLaoMLDMVfpVIxsyYVXUiXufRSVmuxNYB7B958TsNTwGY3myb9Z4jY1wKJYvMMMWiqIqpTmB6B2mvD3j/SsrLRVkH9CYAgyLVwnfwcTfvkxp6676UobKI2u2bXtZXjPcfD1p9qSuWEKc+v1x+oC2hSImDIbGkfbsshDaq03GRm0wXDuOkRovTNfCFGpoSAbNKY3dYRjGtXu3PGcCIDdisvG8yxqU6YU7aKpZGfwBFpk7SkEOMM8zVGj+cjF0mzON+HdscXMEU2g0sFbHqPpN/2dj1mBmlRlhDOymek67a+VP2hhU+6AzkQXhWt7jCHTvyJ5b5Q3rY37/3+nunzOaeYMO3lC7FpojNm1vUeqgsnTaRrEool2UYj4qzZ15LReqBeIGJYhkN2i5AwjT4aTIAm+rO1pvpp4/tix/eZUgLYKT8nb8r0eQ5RXGvUIEz+TWzutQ== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: a57d360c-1440-47d3-3000-08da0d1121cd X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Mar 2022 21:07:26.0452 (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: AbfMsOOfjGFOjLkcklokS5X68AsgRCtlZ3f71pnuW9laOcbun0OGZI+vZ0u8Hu3egSiBSDyAMQ3LOKwMcZbfHBJDNG+0wMk9Y/xL3lNSRH8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB5600 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10295 signatures=694973 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 spamscore=0 malwarescore=0 suspectscore=0 mlxlogscore=999 bulkscore=0 phishscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2203230111 X-Proofpoint-GUID: Q4Pd4X3f1FYTf39LSuQ-7lKwHueDWAgZ X-Proofpoint-ORIG-GUID: Q4Pd4X3f1FYTf39LSuQ-7lKwHueDWAgZ Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org This patch adds an error tag that we can use to test log attribute recovery and replay Signed-off-by: Allison Henderson Reviewed-by: Darrick J. Wong Reviewed-by: Chandan Babu R --- fs/xfs/libxfs/xfs_errortag.h | 4 +++- fs/xfs/xfs_attr_item.c | 7 +++++++ fs/xfs/xfs_error.c | 3 +++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/fs/xfs/libxfs/xfs_errortag.h b/fs/xfs/libxfs/xfs_errortag.h index a23a52e643ad..c15d2340220c 100644 --- a/fs/xfs/libxfs/xfs_errortag.h +++ b/fs/xfs/libxfs/xfs_errortag.h @@ -59,7 +59,8 @@ #define XFS_ERRTAG_REDUCE_MAX_IEXTENTS 36 #define XFS_ERRTAG_BMAP_ALLOC_MINLEN_EXTENT 37 #define XFS_ERRTAG_AG_RESV_FAIL 38 -#define XFS_ERRTAG_MAX 39 +#define XFS_ERRTAG_LARP 39 +#define XFS_ERRTAG_MAX 40 /* * Random factors for above tags, 1 means always, 2 means 1/2 time, etc. @@ -103,5 +104,6 @@ #define XFS_RANDOM_REDUCE_MAX_IEXTENTS 1 #define XFS_RANDOM_BMAP_ALLOC_MINLEN_EXTENT 1 #define XFS_RANDOM_AG_RESV_FAIL 1 +#define XFS_RANDOM_LARP 1 #endif /* __XFS_ERRORTAG_H_ */ diff --git a/fs/xfs/xfs_attr_item.c b/fs/xfs/xfs_attr_item.c index e10202c4e299..5255d0550078 100644 --- a/fs/xfs/xfs_attr_item.c +++ b/fs/xfs/xfs_attr_item.c @@ -24,6 +24,7 @@ #include "xfs_trace.h" #include "xfs_inode.h" #include "xfs_trans_space.h" +#include "xfs_errortag.h" #include "xfs_error.h" #include "xfs_log_priv.h" #include "xfs_log_recover.h" @@ -303,6 +304,11 @@ xfs_xattri_finish_update( XFS_ATTR_OP_FLAGS_TYPE_MASK; int error; + if (XFS_TEST_ERROR(false, args->dp->i_mount, XFS_ERRTAG_LARP)) { + error = -EIO; + goto out; + } + switch (op) { case XFS_ATTR_OP_FLAGS_SET: error = xfs_attr_set_iter(dac); @@ -316,6 +322,7 @@ xfs_xattri_finish_update( break; } +out: /* * Mark the transaction dirty, even on error. This ensures the * transaction is aborted, which: diff --git a/fs/xfs/xfs_error.c b/fs/xfs/xfs_error.c index 749fd18c4f32..666f4837b1e1 100644 --- a/fs/xfs/xfs_error.c +++ b/fs/xfs/xfs_error.c @@ -57,6 +57,7 @@ static unsigned int xfs_errortag_random_default[] = { XFS_RANDOM_REDUCE_MAX_IEXTENTS, XFS_RANDOM_BMAP_ALLOC_MINLEN_EXTENT, XFS_RANDOM_AG_RESV_FAIL, + XFS_RANDOM_LARP, }; struct xfs_errortag_attr { @@ -170,6 +171,7 @@ XFS_ERRORTAG_ATTR_RW(buf_ioerror, XFS_ERRTAG_BUF_IOERROR); XFS_ERRORTAG_ATTR_RW(reduce_max_iextents, XFS_ERRTAG_REDUCE_MAX_IEXTENTS); XFS_ERRORTAG_ATTR_RW(bmap_alloc_minlen_extent, XFS_ERRTAG_BMAP_ALLOC_MINLEN_EXTENT); XFS_ERRORTAG_ATTR_RW(ag_resv_fail, XFS_ERRTAG_AG_RESV_FAIL); +XFS_ERRORTAG_ATTR_RW(larp, XFS_ERRTAG_LARP); static struct attribute *xfs_errortag_attrs[] = { XFS_ERRORTAG_ATTR_LIST(noerror), @@ -211,6 +213,7 @@ static struct attribute *xfs_errortag_attrs[] = { XFS_ERRORTAG_ATTR_LIST(reduce_max_iextents), XFS_ERRORTAG_ATTR_LIST(bmap_alloc_minlen_extent), XFS_ERRORTAG_ATTR_LIST(ag_resv_fail), + XFS_ERRORTAG_ATTR_LIST(larp), NULL, }; ATTRIBUTE_GROUPS(xfs_errortag); From patchwork Wed Mar 23 21:07:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12790154 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 310E5C433FE for ; Wed, 23 Mar 2022 21:07:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241015AbiCWVJO (ORCPT ); Wed, 23 Mar 2022 17:09:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38566 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344879AbiCWVJD (ORCPT ); Wed, 23 Mar 2022 17:09:03 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E04158D68E for ; Wed, 23 Mar 2022 14:07:29 -0700 (PDT) Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 22NKYUvv011998 for ; Wed, 23 Mar 2022 21:07:29 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2021-07-09; bh=3CKt3Kwzn19dUSRfAM8d8zKP6m2jL9pOOdLbeTl0s6g=; b=k37aPJdMBwFu8mwXwB+tCPWU96Zd/2u7JkuS6btVWXc2fgNyu4mz2Ekdd2zMYJPvsYyx U5wFxwve9UKkXKPG26Mtq9hLLKteMwebWVF2Sp+z6I+Ad13Bge7rSPcg/Rbx5IZiMZuh bgAGYBbmo+WQePC1aEdQyR6ExWLcK67lbxeGL3W1Iqme0rojMdFnc2eNlXSk7zd7GMdh bIUFhAYBBbcw0GkQ55Z/HaBTXhiTyy8n2A1dYyVOJzBKZ+FVPc+bPQxg6j9mGL4BwWpB qw/d68QAlrpQXGyo6gD8h914TBWSAp+4BH5IdwpPq4a31iJNA4vl4QVhGdMkKQHtJ6PP bA== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by mx0b-00069f02.pphosted.com with ESMTP id 3ew5s0tt85-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 23 Mar 2022 21:07:29 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 22NL6R9m154749 for ; Wed, 23 Mar 2022 21:07:28 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2174.outbound.protection.outlook.com [104.47.58.174]) by aserp3020.oracle.com with ESMTP id 3ew701q88e-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 23 Mar 2022 21:07:28 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TVOa4Z19wYxhPcriVInkcD6m1Vg0FCUwff+HslsUddAJOSjcRAx1zlXpwiy4V6UJUBuHykYeC7xuza9TzNiQkrbDugCM9ZFoXewbrzbikFhxmjHGydEZQ4TlwsCso3wHfvNPgtTez6P9VICEgvIvrigiFTkqd7QNlkDFarubw0WsbCPMM1SoRXGS+LcmODEtVGKm89bHGXpXn9l422sXdXCmAVpBEZj1HtJlvzI/ndtJh9SNFi+qUjRUsnUz+Lsw134cFZpjmbN8b6ISS3fIMpyE0ypumufjdJdTUFyVbBk6kM6PYmyt6wrDwzWPCLZUbedOPZ0q8sVIw2qNfOEz9g== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=3CKt3Kwzn19dUSRfAM8d8zKP6m2jL9pOOdLbeTl0s6g=; b=BuMekyJZd800U+ecbLn44YwSSsuFeI0zXL2Dl//Sew4SSi25+Hl3Bz59rEZASPCMcAp/cRwXq7vouqQiGUN9pplXlJOvmfDOsOuAXc7OEE0isMD1jAg7JZhGpTzUjE2XOPboY5rmL4uIyzJSO8XMybbDgn/Gd9ZObc6D8b/RHZUa8rb+nlMxfSu4ykhl9uHk7o0g+FAbDogl3d8gTqRUb8aOIziKrN5Nb/CphNspzp2W3szCpKHG50MU+kGDW65Ct4BFU7OzRo83IwBRiTg0M/gD0chYQZTfi5kvH4ag62ORY8KYT2Ed45W0pXe7bWISkT3b0+WugAGJbbIOa3AbdQ== 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=3CKt3Kwzn19dUSRfAM8d8zKP6m2jL9pOOdLbeTl0s6g=; b=IzwSahSWwYaL+/45laTLsO6lyqQo0zUfEYmnm7rm8Y0mv4R62q4F+rvK8P4ia2eKnt5L+zd7eSLlwlZoDfqx6+Nrfeikl4sK6ZiE1ojitImJ+aPGUON73x693BuyXG8mUgzu7kQruTRRJKyjIJFV5C+TAx52Wjk/ORzPn7fC+gg= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by SJ0PR10MB5600.namprd10.prod.outlook.com (2603:10b6:a03:3dc::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5081.17; Wed, 23 Mar 2022 21:07:26 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::c517:eb23:bb2f:4b23]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::c517:eb23:bb2f:4b23%6]) with mapi id 15.20.5102.017; Wed, 23 Mar 2022 21:07:26 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v29 10/15] xfs: Add larp debug option Date: Wed, 23 Mar 2022 14:07:10 -0700 Message-Id: <20220323210715.201009-11-allison.henderson@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220323210715.201009-1-allison.henderson@oracle.com> References: <20220323210715.201009-1-allison.henderson@oracle.com> X-ClientProxiedBy: PH0PR07CA0084.namprd07.prod.outlook.com (2603:10b6:510:f::29) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 30d09e35-cc16-4a70-e31b-08da0d112214 X-MS-TrafficTypeDiagnostic: SJ0PR10MB5600:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: fqkgO9eJd+75cnNxNg7ZIwMn11Pkv/4NP30H7GfVdAFEsSC6+gajeVrexHp0fZIB4JyOcizClLudZjnGRDuomb9rjbY7Xf31PZlSAGqnRy8oGwW5AhAtyQ5PuHocSzTnhIuMaForDtOzmKPOr3a/4L0V2lFF98fsLPbnbVzt51py2vpNW+qb9rJKFxo6uuLKamSEKjZE4KlounTbZ+Y7RLw8Arg15Ve/IIxf3Zz6Sl3+cYPSP5PpQJWWmOZar84y70ogK4vUNpXwnYUEKQEepgCpUMuHB2Gx7IaPH6cIXaMmqprcn/J9y94UTiGFr/QelTzRcElH+j9in2vk1vhWfk4s31t8iNIPvHsa1LrQhDVtxDybGCcHt214303/Bsada0wJYXY4MVZUOM2DBBD5nFNb4hwXIwIQf8syRNaXZ2RbwDuZEGsDNmY2+i4jlRP9B/cb6H+ehH00lhaA7LXtZW82mI+xngl7Xc4PzS16k6BLKjcXlsRFkTwT/KmXdpTYQdE5K8sd6AxO3Ou93tkj2OyQb/UOGtCp6Xjvia/uIdwoePHVVOFDnxhH0xWeAoeXBjokifgJ/LOkE2COvZ9XLfBRZvHDlGocqv+0QwoomQ11w5NglmzZ6pgmxBkHbf5Kt7XuflWhbtJ6exXbMMcvD2v2kBjDDV61haUpmqAHiaaLtZs39/Jq7xACJojGMnaIXAracFJSQZ9vp7iyYguZDw== 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:(13230001)(366004)(66556008)(66476007)(66946007)(44832011)(8676002)(6512007)(83380400001)(86362001)(52116002)(6486002)(6506007)(508600001)(6666004)(2906002)(6916009)(2616005)(36756003)(316002)(5660300002)(1076003)(186003)(8936002)(26005)(38100700002)(38350700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Jpv0CvzurFJJ/tZMw5sDoqvI7b9YyBGWCHrs/vyex6EMmUMTmMgSPAv3W7ab+GzSw+jYBw2LjF3IGOKPxRB4lwbn8X+BUgHWmJCmD7Dfx3cm0qV1ydKvdyJZAYDaNP2f/5+nMcEOEbS93RjVZPsoXz7FxYCzfRJ2/Eqx4Kqpcwf30CgzVy5lJC4e8TSsBVUWD8hG1GQ0xDh6JxZhLzRK+DoE2ROk2oFFF9r7bRprn3q3qBMlMYjkWHzuAlw1PMCqv3kvFhtJfDgD2DkzwgWBvBlaFga+isbnbRjTrqurgNWPB/+FpozEzXIk9Y4WI7Xn06+iRUqC4aGKyZ205tqknie+jJLdBQdpnbQwmhXV0Wvlb0qNBs7y99jOvfMf99TkUkQQAwAgM0AbtRrhVtl50K1OTmD2tk17IHHdGq0Ep0rFV1XkMAJb696+/ImdssGNonLTfkBRPWuqvhVGwVfas1+NmDUBntZVp8XC0yqGlvJ0kVZweY0g2GJeqiIz1hoT3/uR30DkGVLCNYXW1J4693soWpJDQ51FfzLPn7FIPK6Tkb7sTZe2NJQ7/1TMyxbgwBPTVfPfDCJd4exwsarjcs0EnrVZLdX1/52jUE5ByPG71MoDZSknKBcB26X0NvOjaRjsCzI1iblwWnn+Tx0PU/lBuXVnsgYkOMr2VbLgCD4mRHsS6wI8CE96zDsiAZ1rSfC+f1cyNwVw/HCWdsYEa8++7w7/W7r8W7C7V4RSspf1idYrTHX6W0D7H4pA7tvEfxNFG4yFfP8q2nU4Uq0YJC13XLL/0LSlFc37VWPUNfKrafoa8ckiZfSQsQJjwViYCwWf0at9ddX+p02RagvTx/f41s2BzwXk5fyqSjXlYz997MpF1pYRh6bdaosx4h+2oQqTkCFbGNbmTatsIMvPQvuGy5pgQszvB0aVp2r6Xn1nBH5MD5HMlYbU6h4U10Cipt7hZF9kXG89/BPt1a4vDqQQ96+pEfMB7wFYEbwmKVX2Ctk38qvToexKPXDizu7MxvojXOS6zf9lECxv2vCHx/yFBF1Ed3ecdC8PniJr902x5L4syCoaDA1vwPavV1i2995DSXLI06XLxtgM55Q618ZhA/KOORoPrlBdFanTRu2rS5rhFlXEbhk+6oagK9Zy0Bp/yNaGLVWP3CgFt39lIt2oNDZ3Bn6zi0WmgQqkmfxcuZ+DkDrb0yDEPfME27QI1ZXga7Zlbc8tpE4o6eYQSY/31Z2nopdC1gKy+gOjQ38aqfvh/W0Z1aNNmSHsPOXr5NhIACFkt2xiGg0MFZDptqkqf+CncaK87hEeCm2IhYtyK6DzZKghYUdOFgeh5IRXX8xzkc5pl9yCmOJuK7nXjyDyjq3ExvbfN59kMetILcegSRoEGt/hZy4tTGuz2x5t9MTaG4q4Es89f8C7GjzFNy4ufTkYXapZttic1mJO42d9ZuzI9p9Bk7dnW/pqwLg7JeFNvn4eOw9OWkfMiTFENQ== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 30d09e35-cc16-4a70-e31b-08da0d112214 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Mar 2022 21:07:26.5464 (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: 1vkqNtv4X8n6ZFMsN80JTzF0oq4jynoHLaSg9QEIk4LNsTbX7bulPLt3birxUkMBQYO3xDuYxgKbTyrL8LYwZkukEp2ixlsr0m0kMj3Mpms= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB5600 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10295 signatures=694973 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 spamscore=0 malwarescore=0 suspectscore=0 mlxlogscore=999 bulkscore=0 phishscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2203230111 X-Proofpoint-GUID: 68SI2IIPURhV336uFO9bo6ZvmwOwXi5s X-Proofpoint-ORIG-GUID: 68SI2IIPURhV336uFO9bo6ZvmwOwXi5s Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org This patch adds a debug option to enable log attribute replay. Eventually this can be removed when delayed attrs becomes permanent. Signed-off-by: Allison Henderson Reviewed-by: Chandan Babu R Reviewed-by: Darrick J. Wong --- fs/xfs/libxfs/xfs_attr.h | 4 ++++ fs/xfs/xfs_globals.c | 1 + fs/xfs/xfs_sysctl.h | 1 + fs/xfs/xfs_sysfs.c | 24 ++++++++++++++++++++++++ 4 files changed, 30 insertions(+) diff --git a/fs/xfs/libxfs/xfs_attr.h b/fs/xfs/libxfs/xfs_attr.h index 5331551d5939..78884e826ca4 100644 --- a/fs/xfs/libxfs/xfs_attr.h +++ b/fs/xfs/libxfs/xfs_attr.h @@ -30,7 +30,11 @@ struct xfs_attr_list_context; static inline bool xfs_has_larp(struct xfs_mount *mp) { +#ifdef DEBUG + return xfs_globals.larp; +#else return false; +#endif } /* diff --git a/fs/xfs/xfs_globals.c b/fs/xfs/xfs_globals.c index f62fa652c2fd..4d0a98f920ca 100644 --- a/fs/xfs/xfs_globals.c +++ b/fs/xfs/xfs_globals.c @@ -41,5 +41,6 @@ struct xfs_globals xfs_globals = { #endif #ifdef DEBUG .pwork_threads = -1, /* automatic thread detection */ + .larp = false, /* log attribute replay */ #endif }; diff --git a/fs/xfs/xfs_sysctl.h b/fs/xfs/xfs_sysctl.h index 7692e76ead33..f78ad6b10ea5 100644 --- a/fs/xfs/xfs_sysctl.h +++ b/fs/xfs/xfs_sysctl.h @@ -83,6 +83,7 @@ extern xfs_param_t xfs_params; struct xfs_globals { #ifdef DEBUG int pwork_threads; /* parallel workqueue threads */ + bool larp; /* log attribute replay */ #endif int log_recovery_delay; /* log recovery delay (secs) */ int mount_delay; /* mount setup delay (secs) */ diff --git a/fs/xfs/xfs_sysfs.c b/fs/xfs/xfs_sysfs.c index 574b80c29fe1..f7faf6e70d7f 100644 --- a/fs/xfs/xfs_sysfs.c +++ b/fs/xfs/xfs_sysfs.c @@ -228,6 +228,29 @@ pwork_threads_show( return sysfs_emit(buf, "%d\n", xfs_globals.pwork_threads); } XFS_SYSFS_ATTR_RW(pwork_threads); + +static ssize_t +larp_store( + struct kobject *kobject, + const char *buf, + size_t count) +{ + ssize_t ret; + + ret = kstrtobool(buf, &xfs_globals.larp); + if (ret < 0) + return ret; + return count; +} + +STATIC ssize_t +larp_show( + struct kobject *kobject, + char *buf) +{ + return snprintf(buf, PAGE_SIZE, "%d\n", xfs_globals.larp); +} +XFS_SYSFS_ATTR_RW(larp); #endif /* DEBUG */ static struct attribute *xfs_dbg_attrs[] = { @@ -237,6 +260,7 @@ static struct attribute *xfs_dbg_attrs[] = { ATTR_LIST(always_cow), #ifdef DEBUG ATTR_LIST(pwork_threads), + ATTR_LIST(larp), #endif NULL, }; From patchwork Wed Mar 23 21:07:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12790161 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 89EF4C433F5 for ; Wed, 23 Mar 2022 21:07:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244308AbiCWVJQ (ORCPT ); Wed, 23 Mar 2022 17:09:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38440 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344866AbiCWVJF (ORCPT ); Wed, 23 Mar 2022 17:09:05 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7779C8D69B for ; Wed, 23 Mar 2022 14:07:30 -0700 (PDT) Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 22NKYSvp007722 for ; Wed, 23 Mar 2022 21:07:30 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2021-07-09; bh=fCI0Y9BL7TSwWfi/8hdeiRdPITAYLwmcFNdKa8EM4Mw=; b=DOAMcFzYBRiEVy6pCkhuNXbgzkrlofZPaR9436pCDUJPvcCNXE9L/MJhmu+QzCCtFyAT IHfFxI7reU29MfHtPpafCqX9MzjTQDolXPliBJS15jAstaTfbAeqQBhjaWhsyNExDex2 sPOVGfjQJYPBb/8Sv+rVUn5Lq/Wz5qAkDLlkQCPddKXlvTJPTQWXoDUWBVn0gy+1gCm4 x0r6oJHXaTpqVnCHGwY+EV+9XxMcTEWxqsFdr07aYtZTX8tpSd42apxIAc0e7i+4dWs5 nGAdNIPSEgdJKk0TJVfZQFqdaYyifGaXddBRgRys6WIYyHGOrpQDwA8+qkMQ/MVALRAa mQ== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by mx0b-00069f02.pphosted.com with ESMTP id 3ew7qtawtx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 23 Mar 2022 21:07:29 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 22NL6R9n154749 for ; Wed, 23 Mar 2022 21:07:28 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2174.outbound.protection.outlook.com [104.47.58.174]) by aserp3020.oracle.com with ESMTP id 3ew701q88e-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 23 Mar 2022 21:07:28 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HPCyDln1tkgzQFgWYPNLlB+HWj3SSiuWyFWXThH7vU3KADzj/xgEf0QJ2aB2ZMAirfOZKfeyHKQKPalajRJ8lRj4iV+sg9Mq7qHUKa7ee7ZoD5EGfxrpJAUE/VNYm7t3PzHCMvj7RaQJmm+DND2gbq8lprzTsXTnKRJMheQFzgyfldgoYJGCypq/iBccMiWGnyB/uAnPv+3jrcG7cHufTLdTxJ3vCpbHixevVA7c6pGukLRNlcITbK4gqFvA1fGv1y/gKnxFrExz+1jYlSBFSV6VUPYmLwAoTV6CzoY/DzKThlXaHGOojbFihuKq9HrgUr70Fd0q91F9Adt4mc0m6A== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=fCI0Y9BL7TSwWfi/8hdeiRdPITAYLwmcFNdKa8EM4Mw=; b=LqzCwTZ21uZV7E27HqfdOwqzGo1I3UgHPeNXbGu7EEZEii4uuYcTSCnCmc+xJz78Sn9Uwml5fMtqZs680YYitsbOhhEPs3dVzhSsma8cXztmlEDm8fYfN2k9d8uA2ySXHkpuMeoGufwyXw4nX6ipJ/02may3qe1LXCEFxM8xGsnK7MST47vZxVg8tbqqxLkaQBNacbXXiXedIFbCO8x3DoJj9ImTX+Lu9kZe2hf4IeVUjhvaF1M0Au8W7BAsIb+fEpRD8qSaQq8zsggzwi1kC8EmtExlIPzyOJhYeHMqpHiBFILTSkE5lWnSKPchoWyFn7Fr3+YTuTMHUbXGDpZG5w== 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=fCI0Y9BL7TSwWfi/8hdeiRdPITAYLwmcFNdKa8EM4Mw=; b=Dk+yOiJVVnNksSwxnmQHa52zZEOPpNetwK28MYIv6y3JgndHa5zuNDXbjhOKYKHCk5r4LHnBtLnfmQ3vb6azInlpeNCOlVx9xwvHKatkN3jBFbGIdDQGodKhrj/8za1hEwtN5Rq6cRMOtEYcqrEDEjmhljulsPfitAD+e0AcXxA= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by SJ0PR10MB5600.namprd10.prod.outlook.com (2603:10b6:a03:3dc::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5081.17; Wed, 23 Mar 2022 21:07:27 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::c517:eb23:bb2f:4b23]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::c517:eb23:bb2f:4b23%6]) with mapi id 15.20.5102.017; Wed, 23 Mar 2022 21:07:27 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v29 11/15] xfs: Merge xfs_delattr_context into xfs_attr_item Date: Wed, 23 Mar 2022 14:07:11 -0700 Message-Id: <20220323210715.201009-12-allison.henderson@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220323210715.201009-1-allison.henderson@oracle.com> References: <20220323210715.201009-1-allison.henderson@oracle.com> X-ClientProxiedBy: PH0PR07CA0084.namprd07.prod.outlook.com (2603:10b6:510:f::29) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b000bacd-ce59-46cf-a201-08da0d112257 X-MS-TrafficTypeDiagnostic: SJ0PR10MB5600:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: b4cg9vUl9cyKwsEZ6TURwhU0yu9LRaa3hvRwoSNaW2tUg9xcwpWdtzSHMzYDyOlr7AarhSTJIQinlizlgv477FUTU7tCw7nf0T0AAy8jFZ4mUoEga7GFmnZ1bl8PX6Lfl6ESXwX57AUZyD3v5AOJZOzezZUcfYxsCivVyhW5DmadgL+bcx5HuAs6xJsK1nTI0lQG8b3OHJunBONzWHKTrh8IYaQzyBCV93Z1kF8Y+FZbB0RvF5AjatvNVSyf29h/9HlTNq1KTZ9heqHfFBSUsKtbpeTnd+dMqFie/O55cHg87ZSV3RMEVvcZq2qelrU98Eo8dUGvor8oEK5AVbw0Q0GN00zVOC1optQ6XNxgcSEraVflhsTK34g+Ei5/ybHB4DJDtIzIjzwl5r4Ulp5j4EmGIMXxe9KQBU6OijpmogNORa8Oro4azQ/upk6WF3AxOCW8Z7PgNBD8V8pTgmA0LH/6+KDzFsuecj0uKSaxeuCqEVoTc+Bzm6bHZ7DkvZrzITXaDKlS1zxqAfXhwQxbXNwVmAStD2CrjRhMTrpfVWLn4amFOhqyjSK5kjLvoOveceqgITVib4DTyLItxa3Xq3oBM+vNhwc5Hw1FGSzV1WnCToMOCPGa2Slv96eUrVrv8PADOcYrYE8PxTMYz+vP31bvNS7IEV3kNI+lOaQtJ5t0mdPVR+r/Fjf+Ipyd43IPf1oxoAw8A3RydVH0TCEhMA== 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:(13230001)(366004)(66556008)(66476007)(66946007)(44832011)(8676002)(6512007)(83380400001)(86362001)(52116002)(6486002)(6506007)(508600001)(6666004)(2906002)(6916009)(2616005)(36756003)(316002)(5660300002)(1076003)(186003)(8936002)(26005)(38100700002)(30864003)(38350700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: +rw3y1plfrxpCdbzZTUnU2c9XF7Lpt4NXK1ZqA4cbAujU5+9gIfcwfwtgyTLXM5d8BkiPx8LXfyM0Bv8XLV9i0jre+w7RWYsGaLeVrXi3rRZkrLSoBbRSoxeU+JGVOe1yIhlOE0FiGg8hTZ0Z0GYxX+7xUn91D5sjzCxQKA0NqKWpNNluf1ghKP8XwJh5UDZol/yZskJ3iuXSZPwM/T4GY3ge3zPZNjktvC9J4PXenHU2Jo93l7D8TANIlH/Z7WprkRhB7kOy7rITpFzwCNCb6LN0iw5oitAFqFmBhmGjeBDeJKd9xFxWUbidFxD+Y4IfTROI0mrMwtBykyMQuws+cYqQ17RkkVJf1lNBvrP8Siisuf0XoPl6NuXTyOAFXWdyKlTnG3y5T/N+RyGLC9p3TznWEhsMn8ly26gM3xV+l1BhBNiBVgKbEQiSgfFgpB9IkGk7PHTcdCEy+j4cK56m2oA7eTrEjSap7+0ZqV+DqTbXhlkxz0hcd70bm772iXuvC5AlbygbdKVvtD45QPlnD5Lxyr/6qSc54fVI8OHk2ZT+O91vjr88p0XrxNVP70Nend+8uad1x/NuFlet/iyK7PiVAh5i5v1+Ss7To3FVg0jA36khOJiFI58VCWtBWPcPJZi48WMrY8boOLk2cK6k9h4usvgo3DTjDwc8OJoh7YsYQPcmYGXKwXuVlEIOx3TrxJmzojVExXJ6lcI2M1eWqGR0J5vy2Yk7teXX6VZvmbK+BRB7N4Mi3LdehClPEZI8/ZJeJMHfUT4jRyxCDwG0m3ZRAZk6ekXr59yVb3sXos3zJruvObySbQ6CXKCZfHcrgX9cWbZWW5g387DBVF614Idk0Iq+bq/qViWcnexXxa0UmPlqvXE8jhuoOWo8cgPO2ggfDs7NJ6kI30W9dPyUhIU8DlYETQDPCnu/U1eopTdlZHifYORVbvmvB56jQLYLU6Sz6YyDVQrvjuVn4LnCK/SJR6StKSAZbu0AasgL8xA/41zI51v+m/x3sty8x7yPBkrlD3k1S9nq4IdjaSOW2N+DDmmAhr6N9hpVuc0OrG/RMyEcnd4V/LjZ+RUrGUPDyfD8rDzBJrsS5DkyNqYBF6AK+R1ExMkrjTiiCC2/TpDgNkhk1GcUGjTopsPo/u7eMcmKwcZVSZSfoKpkf24DjtHBiaJXKjtsLFVFkLH1N+nWvRvqaNfkx6kOWjw5cvJTMtK51bZ2ZXoLlTXGxGgjRRMmGh5qIsHy6RwjfyaUVvKaHjNC37ql8pVW6FaAs9ZUbEbDwp/hkr6Lzd5234Ch9mnoE1fVKk9r3V0yYjTXiokvbbcUI8tfTBc0POKQRmC808m08ra1YCq6gc9wllkjeUlilYqNSsp8CEq2cQ2cAhe6RUJ9XQERmpXiHh0d6D/8MNZYBEx/WvP2p9CuUMzOvObPttAJxlORbxacwKr9LQWqGVZC900Zd/3JdsWicPWFvIRFb2JGJwLsbc0ZAXP5A== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: b000bacd-ce59-46cf-a201-08da0d112257 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Mar 2022 21:07:26.9526 (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: X3rFY7jK0p/+2pSw6/jyQg3BcXS79sHg1T5FMoD/Y+vkvB02qd3y+xLfBaGwPWw2iJcRvWMsrYRj+stVvNFCYGFecWhpXkZDTeIN2AV6G2c= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB5600 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10295 signatures=694973 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 spamscore=0 malwarescore=0 suspectscore=0 mlxlogscore=999 bulkscore=0 phishscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2203230111 X-Proofpoint-GUID: SQfVtBcPUVw4gpB6pNvp7Tieep1ZPQY6 X-Proofpoint-ORIG-GUID: SQfVtBcPUVw4gpB6pNvp7Tieep1ZPQY6 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org This is a clean up patch that merges xfs_delattr_context into xfs_attr_item. Now that the refactoring is complete and the delayed operation infrastructure is in place, we can combine these to eliminate the extra struct Signed-off-by: Allison Henderson Reviewed-by: Darrick J. Wong Reviewed-by: Chandan Babu R --- fs/xfs/libxfs/xfs_attr.c | 162 +++++++++++++++++--------------- fs/xfs/libxfs/xfs_attr.h | 40 ++++---- fs/xfs/libxfs/xfs_attr_remote.c | 36 +++---- fs/xfs/libxfs/xfs_attr_remote.h | 6 +- fs/xfs/xfs_attr_item.c | 50 +++++----- 5 files changed, 147 insertions(+), 147 deletions(-) diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c index 3d7531817e74..1b1aa3079469 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -59,10 +59,9 @@ 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_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_addname(struct xfs_attr_item *attr); +STATIC int xfs_attr_node_addname_find_attr(struct xfs_attr_item *attr); +STATIC int xfs_attr_node_addname_clear_incomplete(struct xfs_attr_item *attr); 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); @@ -249,9 +248,9 @@ xfs_attr_is_shortform( STATIC int xfs_attr_sf_addname( - struct xfs_delattr_context *dac) + struct xfs_attr_item *attr) { - struct xfs_da_args *args = dac->da_args; + struct xfs_da_args *args = attr->xattri_da_args; struct xfs_inode *dp = args->dp; int error = 0; @@ -268,7 +267,7 @@ xfs_attr_sf_addname( * 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, &dac->leaf_bp); + error = xfs_attr_shortform_to_leaf(args, &attr->xattri_leaf_bp); if (error) return error; @@ -277,7 +276,7 @@ xfs_attr_sf_addname( * push cannot grab the half-baked leaf buffer and run into problems * with the write verifier. */ - xfs_trans_bhold(args->trans, dac->leaf_bp); + xfs_trans_bhold(args->trans, attr->xattri_leaf_bp); /* * We're still in XFS_DAS_UNINIT state here. We've converted @@ -297,16 +296,16 @@ xfs_attr_sf_addname( */ int xfs_attr_set_iter( - struct xfs_delattr_context *dac) + struct xfs_attr_item *attr) { - struct xfs_da_args *args = dac->da_args; + struct xfs_da_args *args = attr->xattri_da_args; struct xfs_inode *dp = args->dp; struct xfs_buf *bp = NULL; int forkoff, error = 0; struct xfs_mount *mp = args->dp->i_mount; /* State machine switch */ - switch (dac->dela_state) { + switch (attr->xattri_dela_state) { case XFS_DAS_UNINIT: /* * If the fork is shortform, attempt to add the attr. If there @@ -316,14 +315,16 @@ xfs_attr_set_iter( * release the hold once we return with a clean transaction. */ if (xfs_attr_is_shortform(dp)) - return xfs_attr_sf_addname(dac); - if (dac->leaf_bp != NULL) { - xfs_trans_bhold_release(args->trans, dac->leaf_bp); - dac->leaf_bp = NULL; + return xfs_attr_sf_addname(attr); + if (attr->xattri_leaf_bp != NULL) { + xfs_trans_bhold_release(args->trans, + attr->xattri_leaf_bp); + attr->xattri_leaf_bp = NULL; } if (xfs_attr_is_leaf(dp)) { - error = xfs_attr_leaf_try_add(args, dac->leaf_bp); + error = xfs_attr_leaf_try_add(args, + attr->xattri_leaf_bp); if (error == -ENOSPC) { error = xfs_attr3_leaf_to_node(args); if (error) @@ -343,19 +344,19 @@ xfs_attr_set_iter( * handling code below */ trace_xfs_attr_set_iter_return( - dac->dela_state, args->dp); + attr->xattri_dela_state, args->dp); return -EAGAIN; } else if (error) { return error; } - dac->dela_state = XFS_DAS_FOUND_LBLK; + attr->xattri_dela_state = XFS_DAS_FOUND_LBLK; } else { - error = xfs_attr_node_addname_find_attr(dac); + error = xfs_attr_node_addname_find_attr(attr); if (error) return error; - error = xfs_attr_node_addname(dac); + error = xfs_attr_node_addname(attr); if (error) return error; @@ -367,9 +368,10 @@ xfs_attr_set_iter( !(args->op_flags & XFS_DA_OP_RENAME)) return 0; - dac->dela_state = XFS_DAS_FOUND_NBLK; + attr->xattri_dela_state = XFS_DAS_FOUND_NBLK; } - trace_xfs_attr_set_iter_return(dac->dela_state, args->dp); + trace_xfs_attr_set_iter_return(attr->xattri_dela_state, + args->dp); return -EAGAIN; case XFS_DAS_FOUND_LBLK: /* @@ -380,10 +382,10 @@ xfs_attr_set_iter( */ /* 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 ((attr->xattri_flags & XFS_DAC_LEAF_ADDNAME_INIT) == 0) { + attr->xattri_flags |= XFS_DAC_LEAF_ADDNAME_INIT; if (args->rmtblkno > 0) { - error = xfs_attr_rmtval_find_space(dac); + error = xfs_attr_rmtval_find_space(attr); if (error) return error; } @@ -393,11 +395,11 @@ xfs_attr_set_iter( * Repeat allocating remote blocks for the attr value until * blkcnt drops to zero. */ - if (dac->blkcnt > 0) { - error = xfs_attr_rmtval_set_blk(dac); + if (attr->xattri_blkcnt > 0) { + error = xfs_attr_rmtval_set_blk(attr); if (error) return error; - trace_xfs_attr_set_iter_return(dac->dela_state, + trace_xfs_attr_set_iter_return(attr->xattri_dela_state, args->dp); return -EAGAIN; } @@ -433,8 +435,8 @@ xfs_attr_set_iter( * Commit the flag value change and start the next trans * in series. */ - dac->dela_state = XFS_DAS_FLIP_LFLAG; - trace_xfs_attr_set_iter_return(dac->dela_state, + attr->xattri_dela_state = XFS_DAS_FLIP_LFLAG; + trace_xfs_attr_set_iter_return(attr->xattri_dela_state, args->dp); return -EAGAIN; } @@ -453,17 +455,18 @@ xfs_attr_set_iter( fallthrough; case XFS_DAS_RM_LBLK: /* Set state in case xfs_attr_rmtval_remove returns -EAGAIN */ - dac->dela_state = XFS_DAS_RM_LBLK; + attr->xattri_dela_state = XFS_DAS_RM_LBLK; if (args->rmtblkno) { - error = xfs_attr_rmtval_remove(dac); + error = xfs_attr_rmtval_remove(attr); if (error == -EAGAIN) trace_xfs_attr_set_iter_return( - dac->dela_state, args->dp); + attr->xattri_dela_state, args->dp); if (error) return error; - dac->dela_state = XFS_DAS_RD_LEAF; - trace_xfs_attr_set_iter_return(dac->dela_state, args->dp); + attr->xattri_dela_state = XFS_DAS_RD_LEAF; + trace_xfs_attr_set_iter_return(attr->xattri_dela_state, + args->dp); return -EAGAIN; } @@ -494,7 +497,7 @@ xfs_attr_set_iter( * state. */ if (args->rmtblkno > 0) { - error = xfs_attr_rmtval_find_space(dac); + error = xfs_attr_rmtval_find_space(attr); if (error) return error; } @@ -507,14 +510,14 @@ xfs_attr_set_iter( * after we create the attribute so that we don't overflow the * maximum size of a transaction and/or hit a deadlock. */ - dac->dela_state = XFS_DAS_ALLOC_NODE; + attr->xattri_dela_state = XFS_DAS_ALLOC_NODE; if (args->rmtblkno > 0) { - if (dac->blkcnt > 0) { - error = xfs_attr_rmtval_set_blk(dac); + if (attr->xattri_blkcnt > 0) { + error = xfs_attr_rmtval_set_blk(attr); if (error) return error; trace_xfs_attr_set_iter_return( - dac->dela_state, args->dp); + attr->xattri_dela_state, args->dp); return -EAGAIN; } @@ -550,8 +553,8 @@ xfs_attr_set_iter( * Commit the flag value change and start the next trans * in series */ - dac->dela_state = XFS_DAS_FLIP_NFLAG; - trace_xfs_attr_set_iter_return(dac->dela_state, + attr->xattri_dela_state = XFS_DAS_FLIP_NFLAG; + trace_xfs_attr_set_iter_return(attr->xattri_dela_state, args->dp); return -EAGAIN; } @@ -571,18 +574,19 @@ xfs_attr_set_iter( fallthrough; case XFS_DAS_RM_NBLK: /* Set state in case xfs_attr_rmtval_remove returns -EAGAIN */ - dac->dela_state = XFS_DAS_RM_NBLK; + attr->xattri_dela_state = XFS_DAS_RM_NBLK; if (args->rmtblkno) { - error = xfs_attr_rmtval_remove(dac); + error = xfs_attr_rmtval_remove(attr); if (error == -EAGAIN) trace_xfs_attr_set_iter_return( - dac->dela_state, args->dp); + attr->xattri_dela_state, args->dp); if (error) return error; - dac->dela_state = XFS_DAS_CLR_FLAG; - trace_xfs_attr_set_iter_return(dac->dela_state, args->dp); + attr->xattri_dela_state = XFS_DAS_CLR_FLAG; + trace_xfs_attr_set_iter_return(attr->xattri_dela_state, + args->dp); return -EAGAIN; } @@ -592,7 +596,7 @@ xfs_attr_set_iter( * The last state for node format. Look up the old attr and * remove it. */ - error = xfs_attr_node_addname_clear_incomplete(dac); + error = xfs_attr_node_addname_clear_incomplete(attr); break; default: ASSERT(0); @@ -823,7 +827,7 @@ xfs_attr_item_init( new = kmem_zalloc(sizeof(struct xfs_attr_item), KM_NOFS); new->xattri_op_flags = op_flags; - new->xattri_dac.da_args = args; + new->xattri_da_args = args; *attr = new; return 0; @@ -1133,16 +1137,16 @@ xfs_attr_node_hasname( STATIC int xfs_attr_node_addname_find_attr( - struct xfs_delattr_context *dac) + struct xfs_attr_item *attr) { - struct xfs_da_args *args = dac->da_args; + struct xfs_da_args *args = attr->xattri_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, &dac->da_state); + retval = xfs_attr_node_hasname(args, &attr->xattri_da_state); if (retval != -ENOATTR && retval != -EEXIST) goto error; @@ -1170,8 +1174,8 @@ xfs_attr_node_addname_find_attr( return 0; error: - if (dac->da_state) - xfs_da_state_free(dac->da_state); + if (attr->xattri_da_state) + xfs_da_state_free(attr->xattri_da_state); return retval; } @@ -1192,10 +1196,10 @@ xfs_attr_node_addname_find_attr( */ STATIC int xfs_attr_node_addname( - struct xfs_delattr_context *dac) + struct xfs_attr_item *attr) { - struct xfs_da_args *args = dac->da_args; - struct xfs_da_state *state = dac->da_state; + struct xfs_da_args *args = attr->xattri_da_args; + struct xfs_da_state *state = attr->xattri_da_state; struct xfs_da_state_blk *blk; int error; @@ -1226,7 +1230,7 @@ xfs_attr_node_addname( * this point. */ trace_xfs_attr_node_addname_return( - dac->dela_state, args->dp); + attr->xattri_dela_state, args->dp); return -EAGAIN; } @@ -1255,9 +1259,9 @@ xfs_attr_node_addname( STATIC int xfs_attr_node_addname_clear_incomplete( - struct xfs_delattr_context *dac) + struct xfs_attr_item *attr) { - struct xfs_da_args *args = dac->da_args; + struct xfs_da_args *args = attr->xattri_da_args; struct xfs_da_state *state = NULL; struct xfs_mount *mp = args->dp->i_mount; int retval = 0; @@ -1361,10 +1365,10 @@ xfs_attr_leaf_mark_incomplete( */ STATIC int xfs_attr_node_removename_setup( - struct xfs_delattr_context *dac) + struct xfs_attr_item *attr) { - struct xfs_da_args *args = dac->da_args; - struct xfs_da_state **state = &dac->da_state; + struct xfs_da_args *args = attr->xattri_da_args; + struct xfs_da_state **state = &attr->xattri_da_state; int error; error = xfs_attr_node_hasname(args, state); @@ -1423,16 +1427,16 @@ xfs_attr_node_removename( */ int xfs_attr_remove_iter( - struct xfs_delattr_context *dac) + struct xfs_attr_item *attr) { - struct xfs_da_args *args = dac->da_args; - struct xfs_da_state *state = dac->da_state; + struct xfs_da_args *args = attr->xattri_da_args; + struct xfs_da_state *state = attr->xattri_da_state; int retval, error = 0; struct xfs_inode *dp = args->dp; trace_xfs_attr_node_removename(args); - switch (dac->dela_state) { + switch (attr->xattri_dela_state) { case XFS_DAS_UNINIT: if (!xfs_inode_hasattr(dp)) return -ENOATTR; @@ -1451,16 +1455,16 @@ xfs_attr_remove_iter( * Node format may require transaction rolls. Set up the * state context and fall into the state machine. */ - if (!dac->da_state) { - error = xfs_attr_node_removename_setup(dac); + if (!attr->xattri_da_state) { + error = xfs_attr_node_removename_setup(attr); if (error) return error; - state = dac->da_state; + state = attr->xattri_da_state; } fallthrough; case XFS_DAS_RMTBLK: - dac->dela_state = XFS_DAS_RMTBLK; + attr->xattri_dela_state = XFS_DAS_RMTBLK; /* * If there is an out-of-line value, de-allocate the blocks. @@ -1473,10 +1477,10 @@ xfs_attr_remove_iter( * May return -EAGAIN. Roll and repeat until all remote * blocks are removed. */ - error = xfs_attr_rmtval_remove(dac); + error = xfs_attr_rmtval_remove(attr); if (error == -EAGAIN) { trace_xfs_attr_remove_iter_return( - dac->dela_state, args->dp); + attr->xattri_dela_state, args->dp); return error; } else if (error) { goto out; @@ -1491,8 +1495,10 @@ xfs_attr_remove_iter( error = xfs_attr_refillstate(state); if (error) goto out; - dac->dela_state = XFS_DAS_RM_NAME; - trace_xfs_attr_remove_iter_return(dac->dela_state, args->dp); + + attr->xattri_dela_state = XFS_DAS_RM_NAME; + trace_xfs_attr_remove_iter_return( + attr->xattri_dela_state, args->dp); return -EAGAIN; } @@ -1502,7 +1508,7 @@ xfs_attr_remove_iter( * If we came here fresh from a transaction roll, reattach all * the buffers to the current transaction. */ - if (dac->dela_state == XFS_DAS_RM_NAME) { + if (attr->xattri_dela_state == XFS_DAS_RM_NAME) { error = xfs_attr_refillstate(state); if (error) goto out; @@ -1519,9 +1525,9 @@ xfs_attr_remove_iter( if (error) goto out; - dac->dela_state = XFS_DAS_RM_SHRINK; + attr->xattri_dela_state = XFS_DAS_RM_SHRINK; trace_xfs_attr_remove_iter_return( - dac->dela_state, args->dp); + attr->xattri_dela_state, args->dp); return -EAGAIN; } diff --git a/fs/xfs/libxfs/xfs_attr.h b/fs/xfs/libxfs/xfs_attr.h index 78884e826ca4..1ef58d34eb59 100644 --- a/fs/xfs/libxfs/xfs_attr.h +++ b/fs/xfs/libxfs/xfs_attr.h @@ -434,7 +434,7 @@ struct xfs_attr_list_context { */ /* - * Enum values for xfs_delattr_context.da_state + * Enum values for xfs_attr_item.xattri_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 @@ -459,39 +459,32 @@ enum xfs_delattr_state { }; /* - * Defines for xfs_delattr_context.flags + * Defines for xfs_attr_item.xattri_flags */ #define XFS_DAC_LEAF_ADDNAME_INIT 0x01 /* xfs_attr_leaf_addname init*/ /* * Context used for keeping track of delayed attribute operations */ -struct xfs_delattr_context { - struct xfs_da_args *da_args; +struct xfs_attr_item { + struct xfs_da_args *xattri_da_args; /* * Used by xfs_attr_set to hold a leaf buffer across a transaction roll */ - struct xfs_buf *leaf_bp; + struct xfs_buf *xattri_leaf_bp; /* Used in xfs_attr_rmtval_set_blk to roll through allocating blocks */ - struct xfs_bmbt_irec map; - xfs_dablk_t lblkno; - int blkcnt; + struct xfs_bmbt_irec xattri_map; + xfs_dablk_t xattri_lblkno; + int xattri_blkcnt; /* Used in xfs_attr_node_removename to roll through removing blocks */ - struct xfs_da_state *da_state; + struct xfs_da_state *xattri_da_state; /* Used to keep track of current state of delayed operation */ - unsigned int flags; - enum xfs_delattr_state dela_state; -}; - -/* - * List of attrs to commit later. - */ -struct xfs_attr_item { - struct xfs_delattr_context xattri_dac; + unsigned int xattri_flags; + enum xfs_delattr_state xattri_dela_state; /* * Indicates if the attr operation is a set or a remove @@ -499,7 +492,10 @@ struct xfs_attr_item { */ unsigned int xattri_op_flags; - /* used to log this item to an intent */ + /* + * used to log this item to an intent containing a list of attrs to + * commit later + */ struct list_head xattri_list; }; @@ -519,11 +515,9 @@ bool xfs_attr_is_leaf(struct xfs_inode *ip); int xfs_attr_get_ilocked(struct xfs_da_args *args); int xfs_attr_get(struct xfs_da_args *args); int xfs_attr_set(struct xfs_da_args *args); -int xfs_attr_set_iter(struct xfs_delattr_context *dac); -int xfs_attr_remove_iter(struct xfs_delattr_context *dac); +int xfs_attr_set_iter(struct xfs_attr_item *attr); +int xfs_attr_remove_iter(struct xfs_attr_item *attr); 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); int xfs_attr_calc_size(struct xfs_da_args *args, int *local); int xfs_attr_set_deferred(struct xfs_da_args *args); int xfs_attr_remove_deferred(struct xfs_da_args *args); diff --git a/fs/xfs/libxfs/xfs_attr_remote.c b/fs/xfs/libxfs/xfs_attr_remote.c index c806319134fb..4250159ecced 100644 --- a/fs/xfs/libxfs/xfs_attr_remote.c +++ b/fs/xfs/libxfs/xfs_attr_remote.c @@ -568,14 +568,14 @@ xfs_attr_rmtval_stale( */ int xfs_attr_rmtval_find_space( - struct xfs_delattr_context *dac) + struct xfs_attr_item *attr) { - struct xfs_da_args *args = dac->da_args; - struct xfs_bmbt_irec *map = &dac->map; + struct xfs_da_args *args = attr->xattri_da_args; + struct xfs_bmbt_irec *map = &attr->xattri_map; int error; - dac->lblkno = 0; - dac->blkcnt = 0; + attr->xattri_lblkno = 0; + attr->xattri_blkcnt = 0; args->rmtblkcnt = 0; args->rmtblkno = 0; memset(map, 0, sizeof(struct xfs_bmbt_irec)); @@ -584,8 +584,8 @@ xfs_attr_rmtval_find_space( if (error) return error; - dac->blkcnt = args->rmtblkcnt; - dac->lblkno = args->rmtblkno; + attr->xattri_blkcnt = args->rmtblkcnt; + attr->xattri_lblkno = args->rmtblkno; return 0; } @@ -598,17 +598,18 @@ xfs_attr_rmtval_find_space( */ int xfs_attr_rmtval_set_blk( - struct xfs_delattr_context *dac) + struct xfs_attr_item *attr) { - struct xfs_da_args *args = dac->da_args; + struct xfs_da_args *args = attr->xattri_da_args; struct xfs_inode *dp = args->dp; - struct xfs_bmbt_irec *map = &dac->map; + struct xfs_bmbt_irec *map = &attr->xattri_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, + error = xfs_bmapi_write(args->trans, dp, + (xfs_fileoff_t)attr->xattri_lblkno, + attr->xattri_blkcnt, XFS_BMAPI_ATTRFORK, args->total, map, &nmap); if (error) return error; @@ -618,8 +619,8 @@ xfs_attr_rmtval_set_blk( (map->br_startblock != HOLESTARTBLOCK)); /* roll attribute extent map forwards */ - dac->lblkno += map->br_blockcount; - dac->blkcnt -= map->br_blockcount; + attr->xattri_lblkno += map->br_blockcount; + attr->xattri_blkcnt -= map->br_blockcount; return 0; } @@ -673,9 +674,9 @@ xfs_attr_rmtval_invalidate( */ int xfs_attr_rmtval_remove( - struct xfs_delattr_context *dac) + struct xfs_attr_item *attr) { - struct xfs_da_args *args = dac->da_args; + struct xfs_da_args *args = attr->xattri_da_args; int error, done; /* @@ -695,7 +696,8 @@ xfs_attr_rmtval_remove( * the parent */ if (!done) { - trace_xfs_attr_rmtval_remove_return(dac->dela_state, args->dp); + trace_xfs_attr_rmtval_remove_return(attr->xattri_dela_state, + args->dp); return -EAGAIN; } diff --git a/fs/xfs/libxfs/xfs_attr_remote.h b/fs/xfs/libxfs/xfs_attr_remote.h index d72eff30ca18..62b398edec3f 100644 --- a/fs/xfs/libxfs/xfs_attr_remote.h +++ b/fs/xfs/libxfs/xfs_attr_remote.h @@ -12,9 +12,9 @@ int xfs_attr_rmtval_get(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_rmtval_remove(struct xfs_attr_item *attr); 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); +int xfs_attr_rmtval_set_blk(struct xfs_attr_item *attr); +int xfs_attr_rmtval_find_space(struct xfs_attr_item *attr); #endif /* __XFS_ATTR_REMOTE_H__ */ diff --git a/fs/xfs/xfs_attr_item.c b/fs/xfs/xfs_attr_item.c index 5255d0550078..c80ea443d380 100644 --- a/fs/xfs/xfs_attr_item.c +++ b/fs/xfs/xfs_attr_item.c @@ -295,11 +295,11 @@ xfs_attrd_item_release( */ STATIC int xfs_xattri_finish_update( - struct xfs_delattr_context *dac, + struct xfs_attr_item *attr, struct xfs_attrd_log_item *attrdp, uint32_t op_flags) { - struct xfs_da_args *args = dac->da_args; + struct xfs_da_args *args = attr->xattri_da_args; unsigned int op = op_flags & XFS_ATTR_OP_FLAGS_TYPE_MASK; int error; @@ -311,11 +311,11 @@ xfs_xattri_finish_update( switch (op) { case XFS_ATTR_OP_FLAGS_SET: - error = xfs_attr_set_iter(dac); + error = xfs_attr_set_iter(attr); break; case XFS_ATTR_OP_FLAGS_REMOVE: ASSERT(XFS_IFORK_Q(args->dp)); - error = xfs_attr_remove_iter(dac); + error = xfs_attr_remove_iter(attr); break; default: error = -EFSCORRUPTED; @@ -359,18 +359,18 @@ xfs_attr_log_item( * structure with fields from this xfs_attr_item */ attrp = &attrip->attri_format; - attrp->alfi_ino = attr->xattri_dac.da_args->dp->i_ino; + attrp->alfi_ino = attr->xattri_da_args->dp->i_ino; attrp->alfi_op_flags = attr->xattri_op_flags; - attrp->alfi_value_len = attr->xattri_dac.da_args->valuelen; - attrp->alfi_name_len = attr->xattri_dac.da_args->namelen; - attrp->alfi_attr_flags = attr->xattri_dac.da_args->attr_filter; - - memcpy(attrip->attri_name, attr->xattri_dac.da_args->name, - attr->xattri_dac.da_args->namelen); - memcpy(attrip->attri_value, attr->xattri_dac.da_args->value, - attr->xattri_dac.da_args->valuelen); - attrip->attri_name_len = attr->xattri_dac.da_args->namelen; - attrip->attri_value_len = attr->xattri_dac.da_args->valuelen; + attrp->alfi_value_len = attr->xattri_da_args->valuelen; + attrp->alfi_name_len = attr->xattri_da_args->namelen; + attrp->alfi_attr_flags = attr->xattri_da_args->attr_filter; + + memcpy(attrip->attri_name, attr->xattri_da_args->name, + attr->xattri_da_args->namelen); + memcpy(attrip->attri_value, attr->xattri_da_args->value, + attr->xattri_da_args->valuelen); + attrip->attri_name_len = attr->xattri_da_args->namelen; + attrip->attri_value_len = attr->xattri_da_args->valuelen; } /* Get an ATTRI. */ @@ -395,8 +395,8 @@ xfs_attr_create_intent( * this is a list of one */ list_for_each_entry(attr, items, xattri_list) { - attrip = xfs_attri_init(mp, attr->xattri_dac.da_args->namelen, - attr->xattri_dac.da_args->valuelen); + attrip = xfs_attri_init(mp, attr->xattri_da_args->namelen, + attr->xattri_da_args->valuelen); if (attrip == NULL) return NULL; @@ -418,10 +418,8 @@ xfs_attr_finish_item( struct xfs_attr_item *attr; struct xfs_attrd_log_item *done_item = NULL; int error; - struct xfs_delattr_context *dac; attr = container_of(item, struct xfs_attr_item, xattri_list); - dac = &attr->xattri_dac; if (done) done_item = ATTRD_ITEM(done); @@ -429,9 +427,10 @@ xfs_attr_finish_item( * Always reset trans after EAGAIN cycle * since the transaction is new */ - dac->da_args->trans = tp; + attr->xattri_da_args->trans = tp; - error = xfs_xattri_finish_update(dac, done_item, attr->xattri_op_flags); + error = xfs_xattri_finish_update(attr, done_item, + attr->xattri_op_flags); if (error != -EAGAIN) kmem_free(attr); @@ -553,7 +552,7 @@ xfs_attri_item_recover( sizeof(struct xfs_da_args), KM_NOFS); args = (struct xfs_da_args *)(attr + 1); - attr->xattri_dac.da_args = args; + attr->xattri_da_args = args; attr->xattri_op_flags = attrp->alfi_op_flags; args->dp = ip; @@ -589,8 +588,7 @@ xfs_attri_item_recover( xfs_ilock(ip, XFS_ILOCK_EXCL); xfs_trans_ijoin(tp, ip, 0); - ret = xfs_xattri_finish_update(&attr->xattri_dac, done_item, - attrp->alfi_op_flags); + ret = xfs_xattri_finish_update(attr, done_item, attrp->alfi_op_flags); if (ret == -EAGAIN) { /* There's more work to do, so add it to this transaction */ xfs_defer_add(tp, XFS_DEFER_OPS_TYPE_ATTR, &attr->xattri_list); @@ -605,8 +603,8 @@ xfs_attri_item_recover( error = xfs_defer_ops_capture_and_commit(tp, capture_list); out_unlock: - if (attr->xattri_dac.leaf_bp) - xfs_buf_relse(attr->xattri_dac.leaf_bp); + if (attr->xattri_leaf_bp) + xfs_buf_relse(attr->xattri_leaf_bp); xfs_iunlock(ip, XFS_ILOCK_EXCL); xfs_irele(ip); From patchwork Wed Mar 23 21:07:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12790162 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E0222C43217 for ; Wed, 23 Mar 2022 21:07:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240930AbiCWVJS (ORCPT ); Wed, 23 Mar 2022 17:09:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38570 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344861AbiCWVJE (ORCPT ); Wed, 23 Mar 2022 17:09:04 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BFB1E8EB50 for ; Wed, 23 Mar 2022 14:07:30 -0700 (PDT) Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 22NKYRLO007704 for ; Wed, 23 Mar 2022 21:07:30 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2021-07-09; bh=zqBAj51JLZvrXZKxM0mMKB3s9alfhgk07k0IC6r8FfQ=; b=uKYt8wS2BgdCGq6CDHFwIag1dLGrNXch4OBmkvCTjl1nwG+8UPyArhHA1zHkdOmAdD68 U2qElkJwbAPFXP7FWEkASuvMsKGVU/FuAuZbyxAdJY4etD+dkCPN4xl1LDQ/TO6YmUmL fMYqNVVxYl/tNuALs1JqHA501Z6RF0kGddUkH7ytlcodkOczBeyAwkTWbxT4eQBfvJEu KAzPgEsXYP9woOPLAxJ4LeqmcsA6s7gYwhP0irn1x8GnlyC6pdz9RyaB3JEfaB5nByGR +2LbYZ5JPND+oKOhkxNP8JqokkwH4p4jQ1X5OfQFsn95H3ncXRK7EahL7Ft5spzJVDz4 sg== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by mx0b-00069f02.pphosted.com with ESMTP id 3ew7qtawty-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 23 Mar 2022 21:07:30 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 22NL6R9o154749 for ; Wed, 23 Mar 2022 21:07:29 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2174.outbound.protection.outlook.com [104.47.58.174]) by aserp3020.oracle.com with ESMTP id 3ew701q88e-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 23 Mar 2022 21:07:29 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=F/TdZJ9tpYRM7otYVHMJK5m7ZZLOGMFotxDfAo8KwqYwI77DMnLsHLG+0OhSaUFQZ/dYLfTY0FQsuLe4xhZk5bqEfD7PCnN0Vw+CUfcCFtRbWn1xOChmdUoWQYTf21vv7NkXleaDqXBaQh8H1l86SFy/XwF6GS76PrI+fbKGXNux0d9S1Hc77OwrjzkOycxehgrd6e5jcvwG3+bVJA1+v4iyo046S602CofTU+sJSC7ue9sx9fAhDAiRu+/PtyxSLwR/r3nGQFlrpgd4OhZUxNXBBCRNZVoLZLtoCjK7fXUApm/+awjrCAXquYMrwNJelpVPZ+oeaPnSLBlkJjQ7sQ== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=zqBAj51JLZvrXZKxM0mMKB3s9alfhgk07k0IC6r8FfQ=; b=JEs+4IPm/baiQpgwPIb/5KargMTXV4gG6F0LMmrZqGDDaEBlJkmKHOWeqpduM1LGMM9voKJ53i2gSUb0vT76n/I0fbCkc3EeMpIVOL8gaRAG9pN3t9D7BlhvewWZYx6xa+mDjz1cw0kuuMn1ZinNHy2U/AnFGm0TYKZPo/Eu+p91iu7d6gefiQg6gYpNYC0rb8OdH2FcztprHMMF8ghaFhc81M5iyL9lguWVBvEGnSpRlRUDkDZquAYxW7qya9TDLiPu5C2bS9Ap880ixH9b7ckWO1CsGTHRhmbjxpm67d2nWeDrJOJnQP1Dnp7PRLhdIolMroXd2dq91ysI8LXYEg== 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=zqBAj51JLZvrXZKxM0mMKB3s9alfhgk07k0IC6r8FfQ=; b=obyr9rEaZZdYFzQknQLuWq+6oY8fw5iLlaAey4gTD5yoWjNOSGjpKv9e+n+SbWaHqPJRTzFKP6nBGMLubeCXAn9Yhz4n7AaQ/d32sSsHXihvls3FLfHhq8Jj8InTIPcC8x+ZIClMQKl8H8U5aJij1xqkw7ECcOWxryMzRnRKnaY= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by SJ0PR10MB5600.namprd10.prod.outlook.com (2603:10b6:a03:3dc::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5081.17; Wed, 23 Mar 2022 21:07:27 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::c517:eb23:bb2f:4b23]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::c517:eb23:bb2f:4b23%6]) with mapi id 15.20.5102.017; Wed, 23 Mar 2022 21:07:27 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v29 12/15] xfs: Add helper function xfs_attr_leaf_addname Date: Wed, 23 Mar 2022 14:07:12 -0700 Message-Id: <20220323210715.201009-13-allison.henderson@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220323210715.201009-1-allison.henderson@oracle.com> References: <20220323210715.201009-1-allison.henderson@oracle.com> X-ClientProxiedBy: PH0PR07CA0084.namprd07.prod.outlook.com (2603:10b6:510:f::29) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c0e9cea3-0575-4105-3a0f-08da0d112293 X-MS-TrafficTypeDiagnostic: SJ0PR10MB5600:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ZSs+Rgb/EE1Pd9FPAX0Sv4TTf8LXzkEC/hBvwnjQmragL6nOM8SD+1Gavg/ZNAHH+rnYc1sRTelTooddojWSzRtQi5NKLBYwBPoegdTbyROVzq1SOT5+e3Od49rCCJa/AN52+LMDWbFjj/WAPJ3kfDYB5DmOjf1xMdCJY1O4EvuY2Q1+QMquCtOrjkS24lTb5nVUs7FyqTqDUF83BiXMl27jE2bbLO0XtDB8Z2BDfNOqnj+vALdiJGkUPAS+N10mKZEKdGXiSxxdFXg3rJvhOuokWjnEJJHwkNAZ13Twn8eiBabXdu8tl0hF0jSFHSav7P/VLGE/dW/zKrcqUju96Fkv764QBtGiZIAA54fZZkIOBV4C77pDIe+U5cW4dkUsGyNlH5wQ+t7dtlKO+rn8H2oL5XVezc02gqX/jT4kJY2OEkA8nDsghnFnvwuhcRmUmU1LmMecv/O9641wx3UafnDbWuEac3OxF9NhW3IdXpkr3V8KYWaOFkozBUMzP9IR84prnmrw5G2V8AV4eIoKnUg1jK+F3CoNVNYdptf2etggtNjBJmDhB92pHmrVFiCN3/dUH7cnpm5B+G3zPbuPzk80AEIPm/JdAIn+/T01zg7G8KbiU11I0OEmqVfWG0WUGx/zjUPO659FFCejS45KuXODSp0o5QZ4H83XgDZOjbnVRXqa+TCtRidAtJqoOYpuTGLGFgfkyOmablNwymHO8Q== 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:(13230001)(366004)(66556008)(66476007)(66946007)(44832011)(8676002)(6512007)(83380400001)(86362001)(52116002)(6486002)(6506007)(508600001)(6666004)(2906002)(6916009)(2616005)(36756003)(316002)(5660300002)(1076003)(186003)(8936002)(26005)(38100700002)(38350700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: XS40bDZPoZS6F/xm5JkTQzgFGLLj1TX5AvVIdYbnjTvoVdalXsxE1U3/jG991UCwcIODKIPsATF44DtLS3XUDWi6TpwyRvLZWWp+qfTfU0s7MR2VXQZ/pris7yUSkft7qFj8zbKVM4bPeFeZqLIqhEe91xNcfet0CxkZ5WYh61jmh9QSVDYrO4hf7T/JJNYYdhUC1r9ehI7f4xOGYOhX+dGw0SyptnJKlAnPa5WMWTWPw+giURtAzLeR+ALp0Jax9S+YHUy/rReZ+kGhLfSMHfshYBv5QO4jelMcLkg8Lo6rbRsNnJeGw+g45RcoZxYT8MIoYhQLpW1SKU0ygnS+NnmdLIm/uXkTplGhQca+uQl6FpM3j8uEIlUZpHd3MW8LwGIX9ixp3MdqjXHMBZCx/Dwq4F1wHF+bLSugFJHBqEyOafLdcfDo7JTZJeB+KGVa/SZJfXG3WN0QeqMjGe73OPPMWuNwhkRupN/F4ArYdxSJwmOzUBuAepb0ljxtVS3hFH4zvUbohzsAN0drX1WetfmA5ZG5F+3V3kF882uFYOs8hHGCr0jHio7FWyM1QBFhuuyZP2tVlbhRQn6n44O6JZSXW9+DqS4Jjds5AxH87LmBs83z/sZagI+hUn+mApgCwvn6K8HknCc19bdxOCE51toAQJzoOhKaTFCj0Pf8cAylXtNjeDaSWI1GECZsbWtBUy1JVWV9nOhQAJvRqjtg0WE9sRn+hDmQGPJfOpNuw6VKSUFOiXcW0w/yGKLNpblc2AGjnw34uotyk08EOW2gKuOQH0cvI8LM4fEzQVC0e5fI9TRw9d2gkdWupYcQj7NeiHKx3PzQMbKDCSNzVt40mKbL3Va+nFTwN2Wiz0RJ50zwbCtQXhBjJ4uYbwlAJJ364CA/8G7Q9wMhFghDwR36EG5GZo2M0ja3JRCOgKDEGjM5zqX/OCo5dqz5K/KSH9TXgnhDNfUR6a9HHtDrXakwzTtxh/NeVr5187z1dsbXG9gmiPma1zOFWG/OXV+IqeSW7B809dyV/2Y1mJ+RO+TIUFTgT8Sk05KeSgW0e6Q0g7y+Qq07SQbLvOAVOtBi+Jr8tHywM5J8ujJZ0AFFo8JDjsAvoFCb+xqclfwOkyqjR9uoh7JherhQjsZwMhP2AIQuyaTBHf7b3N/uUuLZ95+TbSd27m12zR0SOcL5G71nrQM1vcY1QSf9YKZt+gANsykT8Az7fMGjr9maP/nVDHbVIhpGhy7Jr3aRT5PNYEwQtAoprDhYUXAXYWr8eFDkXb4NHG/yxT7RKSAkhf57v3xULZKDgL0LSBmDHyBTOcCHq7aliPDRMbu1sTfCTgr3/yrgeHvaSY3ob/4yX6RHaiKIv1EAdtULNVUjk6Wg+LuIDYoMlBN5vKIkuwRHl1hFy9mmOJLLhuTDyZS9avIE7s7lCf6JzIOZOJ9AjR9rV+CBoBt9LOYxFyQ4aU29mF9gXbwry6ER9Pvjpg15cnqJW4lPyw== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: c0e9cea3-0575-4105-3a0f-08da0d112293 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Mar 2022 21:07:27.3119 (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: 2/T1J2QSoVsXQe1f2/dGiyMflYldju8qnIpZDrotXc9hOtkGF36w3x7eSe4Ypxw0JjHjkTYxY69tpB7hfBGziN0VlmqWCoFBwEnW3UL4hKg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB5600 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10295 signatures=694973 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 spamscore=0 malwarescore=0 suspectscore=0 mlxlogscore=999 bulkscore=0 phishscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2203230111 X-Proofpoint-GUID: pf_JHi1iYWCZbCNMS8O9GFNciBcZFV1j X-Proofpoint-ORIG-GUID: pf_JHi1iYWCZbCNMS8O9GFNciBcZFV1j Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org This patch adds a helper function xfs_attr_leaf_addname. While this does help to break down xfs_attr_set_iter, it does also hoist out some of the state management. This patch has been moved to the end of the clean up series for further discussion. Suggested-by: Darrick J. Wong Signed-off-by: Allison Henderson Reviewed-by: Darrick J. Wong Reviewed-by: Chandan Babu R --- fs/xfs/libxfs/xfs_attr.c | 110 +++++++++++++++++++++------------------ fs/xfs/xfs_trace.h | 1 + 2 files changed, 61 insertions(+), 50 deletions(-) diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c index 1b1aa3079469..7d6ad1d0e10b 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -287,6 +287,65 @@ xfs_attr_sf_addname( return -EAGAIN; } +STATIC int +xfs_attr_leaf_addname( + struct xfs_attr_item *attr) +{ + struct xfs_da_args *args = attr->xattri_da_args; + struct xfs_inode *dp = args->dp; + int error; + + if (xfs_attr_is_leaf(dp)) { + error = xfs_attr_leaf_try_add(args, attr->xattri_leaf_bp); + if (error == -ENOSPC) { + error = xfs_attr3_leaf_to_node(args); + if (error) + return error; + + /* + * Finish any deferred work items and roll the + * transaction once more. The goal here is to call + * node_addname with the inode and transaction in the + * same state (inode locked and joined, transaction + * clean) no matter how we got to this step. + * + * At this point, we are still in XFS_DAS_UNINIT, but + * when we come back, we'll be a node, so we'll fall + * down into the node handling code below + */ + trace_xfs_attr_set_iter_return( + attr->xattri_dela_state, args->dp); + return -EAGAIN; + } + + if (error) + return error; + + attr->xattri_dela_state = XFS_DAS_FOUND_LBLK; + } else { + error = xfs_attr_node_addname_find_attr(attr); + if (error) + return error; + + error = xfs_attr_node_addname(attr); + if (error) + return error; + + /* + * If addname was successful, and we dont need to alloc or + * remove anymore blks, we're done. + */ + if (!args->rmtblkno && + !(args->op_flags & XFS_DA_OP_RENAME)) + return 0; + + attr->xattri_dela_state = XFS_DAS_FOUND_NBLK; + } + + trace_xfs_attr_leaf_addname_return(attr->xattri_dela_state, args->dp); + return -EAGAIN; +} + /* * Set the attribute specified in @args. * This routine is meant to function as a delayed operation, and may return @@ -322,57 +381,8 @@ xfs_attr_set_iter( attr->xattri_leaf_bp = NULL; } - if (xfs_attr_is_leaf(dp)) { - error = xfs_attr_leaf_try_add(args, - attr->xattri_leaf_bp); - if (error == -ENOSPC) { - error = xfs_attr3_leaf_to_node(args); - if (error) - return error; - - /* - * Finish any deferred work items and roll the - * transaction once more. The goal here is to - * call node_addname with the inode and - * transaction in the same state (inode locked - * and joined, transaction clean) no matter how - * we got to this step. - * - * At this point, we are still in - * XFS_DAS_UNINIT, but when we come back, we'll - * be a node, so we'll fall down into the node - * handling code below - */ - trace_xfs_attr_set_iter_return( - attr->xattri_dela_state, args->dp); - return -EAGAIN; - } else if (error) { - return error; - } - - attr->xattri_dela_state = XFS_DAS_FOUND_LBLK; - } else { - error = xfs_attr_node_addname_find_attr(attr); - if (error) - return error; + return xfs_attr_leaf_addname(attr); - error = xfs_attr_node_addname(attr); - if (error) - return error; - - /* - * If addname was successful, and we dont need to alloc - * or remove anymore blks, we're done. - */ - if (!args->rmtblkno && - !(args->op_flags & XFS_DA_OP_RENAME)) - return 0; - - attr->xattri_dela_state = XFS_DAS_FOUND_NBLK; - } - trace_xfs_attr_set_iter_return(attr->xattri_dela_state, - args->dp); - return -EAGAIN; case XFS_DAS_FOUND_LBLK: /* * If there was an out-of-line value, allocate the blocks we diff --git a/fs/xfs/xfs_trace.h b/fs/xfs/xfs_trace.h index b141ef78c755..40f72db2449f 100644 --- a/fs/xfs/xfs_trace.h +++ b/fs/xfs/xfs_trace.h @@ -4132,6 +4132,7 @@ DEFINE_EVENT(xfs_das_state_class, name, \ TP_ARGS(das, ip)) DEFINE_DAS_STATE_EVENT(xfs_attr_sf_addname_return); DEFINE_DAS_STATE_EVENT(xfs_attr_set_iter_return); +DEFINE_DAS_STATE_EVENT(xfs_attr_leaf_addname_return); DEFINE_DAS_STATE_EVENT(xfs_attr_node_addname_return); DEFINE_DAS_STATE_EVENT(xfs_attr_remove_iter_return); DEFINE_DAS_STATE_EVENT(xfs_attr_rmtval_remove_return); From patchwork Wed Mar 23 21:07:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12790157 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 75A89C4332F for ; Wed, 23 Mar 2022 21:07:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343724AbiCWVJO (ORCPT ); Wed, 23 Mar 2022 17:09:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344885AbiCWVJE (ORCPT ); Wed, 23 Mar 2022 17:09:04 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 052EA8EB51 for ; Wed, 23 Mar 2022 14:07:31 -0700 (PDT) Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 22NKYUam011994 for ; Wed, 23 Mar 2022 21:07:31 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2021-07-09; bh=79c6zpZdeboofoM9tiGBGDOO5n4VwpSabJbfqGUT/Ac=; b=A+nNXdUyUiA4gi9lKK+Cz2fom2ZvpRMjSpYwha8lHKXv/sgNPsm1ojV/ErC6rCjEjwAr SDIQ5FcJLOq5r+8Z++7VTegSIgShTanfEdn8MPMbahqlI+U88RRX0vkNk17gWNx/TYJ5 sXNJ5Pcmy5zhQMPAQhLjF9zgED6qs3Xa5Lcw6XIGgfR/kcJ6CSnDGgpuaQDAMxwTgh4H 3oSboG/zOPSbNKvU+nOPmDWxf1xASSO9w8TmQd92NeyL7QJkREJ8Mm6WpG2+b2zNuKH4 VfDrzSopnIqSbrK7cGRt+mJIh4gA044yklxkVbDp+cpD8ZqEAHvv4W4g/D9WICGL24PQ DQ== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by mx0b-00069f02.pphosted.com with ESMTP id 3ew5s0tt89-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 23 Mar 2022 21:07:31 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 22NL6R9p154749 for ; Wed, 23 Mar 2022 21:07:29 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2174.outbound.protection.outlook.com [104.47.58.174]) by aserp3020.oracle.com with ESMTP id 3ew701q88e-5 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 23 Mar 2022 21:07:29 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GNiM4Jor1SeZGuWXCWbOMlLZ1DChcraHhVkJiJNFg6hHTLTc1R061YsZDG3tPuWuW6Ya1S3h5MN3P9Xg4n0mw/uH9Hz/Ndbgtlg3GcjAgAI5ESx8jbyHBH1u+pgRjUlsB8wquS8z1jhcsUHG73d5pzpz4LlSi3omU+ok5tFutbT1DC1utNgfbW8bRTq+6hhzcqPEPOgS9yJsuTYwsR50eWMmXArUIZblCvSsFudxfCER7tl+5xSLKUfIr0XrXMMemVRA8uk7l4wQyPR3sLY8m9cmR824/H8pa+wW/LgEOKbpMXllNci5LtYNZJLYDv2227SdApC+RzCTmTY4qqL51g== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=79c6zpZdeboofoM9tiGBGDOO5n4VwpSabJbfqGUT/Ac=; b=YMQ8LjpKd+LBf5sX61GikbgasVyBMhxCNz3nqI91vhgmpen1yY/DxkoDHM5NJDiN5Iv/EYAzgsJNTtiyFVPidKtkO//g4v4xJwmwPjSjQbQWqbuS0m66/g2g7PbTlU8deA1Ju8LKUHMoxVyVzchzG3WRSSir8OikCGItUpPYUq4SYi/1J3SqJfltkYEDIIOyJgxvtFvUi3jszWlFrYnIAawXMu68ycRcol7ZI3109B2/0qYKKNCkdAW2pW3XNjmgpKQs1+yHfzbHHZPfBALTQGxt/fmqL3MhG0hZS39WOOEE5RX1nhOoELJD16mNvQdB/9MOZMUn6bAcoUfXoBc66Q== 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=79c6zpZdeboofoM9tiGBGDOO5n4VwpSabJbfqGUT/Ac=; b=jTD116zXNXREhVXcZBCAsUJa/l7+0IHB122pAtrbkEzQWmtNtBtBYkNtUuTB//puvrzbN7ChDL/5Z0X33bw5M1EA0YJHNJivmnomoUhC4ym8u6FudsXF5o3TRf0c/IpfJWoeCMNrXT75LR+A6p0GeUYqvATgk/DXhvKJNwWS5ME= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by SJ0PR10MB5600.namprd10.prod.outlook.com (2603:10b6:a03:3dc::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5081.17; Wed, 23 Mar 2022 21:07:27 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::c517:eb23:bb2f:4b23]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::c517:eb23:bb2f:4b23%6]) with mapi id 15.20.5102.017; Wed, 23 Mar 2022 21:07:27 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v29 13/15] xfs: Add helper function xfs_init_attr_trans Date: Wed, 23 Mar 2022 14:07:13 -0700 Message-Id: <20220323210715.201009-14-allison.henderson@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220323210715.201009-1-allison.henderson@oracle.com> References: <20220323210715.201009-1-allison.henderson@oracle.com> X-ClientProxiedBy: PH0PR07CA0084.namprd07.prod.outlook.com (2603:10b6:510:f::29) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1670771a-dc3b-4ba5-c481-08da0d1122c9 X-MS-TrafficTypeDiagnostic: SJ0PR10MB5600:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: hx9uvAHbAlcbE3es8529bc7WHDN/5ZYG0ePnjFBvqz1TxBbK1Cs7Ssv31eAqnk/zVE6sAuvPOOpzfbQ7y/I6e6iipxqmRd+QZtdDnfsspfmnWYJBgdYef7ipMh+ozd990qHhZYvVL8i6VJU++cmABrYkVEn1o5zN8Bi8HH4nRoYNfWnALhdkfRofOFcBBS2FZOdkruATIiZOpgOmWHBJdFYRBNCCJKA8o27f27teR5kKjsharlKNNsowljnyA7Yqo2Mj4lWTnyFIeFY44bpMqSd6rm/ul0bgVlPxBSEFvenpt/FhfUEPk9MALo3YujLB9LzAUmfO6nsO6sFCB1fsPs0JkqjpsIjvbrnKTUrwng4/dipRN2VHwfqqBQq1RCwMR9wMAVedZ6+/h7CXqHRV6VcPKQzPwJLFMkHVzOt/8cwe+JiaSac301N3OfCGeAVWXOO9ngUHbFSeAb42bMJ0dALHkybq+Rktmj5E7lGyqm0pYAq54/jsZYPufIh3YhzGrngtrx9sSvkpTDGJft7qvL5AoVjr7IZ2i4a/X3om+bJCUAlqSH/L3skh1nKk18ZO9hZ9/OT55fP1Wg4SSKrGnpf6RQm9wxiL2u4A9AtvyOUtVQ3yb/c6wI8AI+CvedShYnpk2hd4Cmiib3L0iYESCNzLqmcnWED0BjaCUNA1yrSjjg26z2onuuFOEKvkV5X+3avwMNXf0pm4yhtOUkGZfg== 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:(13230001)(366004)(66556008)(66476007)(66946007)(44832011)(8676002)(6512007)(83380400001)(86362001)(52116002)(6486002)(6506007)(508600001)(6666004)(2906002)(6916009)(2616005)(36756003)(316002)(5660300002)(1076003)(186003)(8936002)(26005)(38100700002)(38350700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: LD3IssTOIIEGyucQiH1vOtFTq8c3f6S0TNimz7hiIu3wRvwkke649th96Kvg/Y5C7jpTOnVuK8UMnkqWjTHIp21XFi7+JbboMcj6CtXCA0x5M1wuOqL8n5fgKdG5G71DwE7/UOY5DT5FnmB5ZcSxB8HKgzQDrYcPqiEXPRJHgsXBPKZirqpzdHF6uRTOuofueNcyjtxfu6iGkNfCmHN0KZd/4ayed6ndevOX3wdeLYKLzYXH9U1GjU8X/KAZ609nVd/FsyOi8SdFBx4hqL3sb1m8dYX5bwFE9Jh5Gd/rl+VVL0FBuGlJ2ejr0zeG1y3C2sDYdBCODnpEXgap+bRHzt3x3P+jIM4BJH/tk0iFAnXSCgmnJgZCeXE+QaUndcxlubpAVULjQZyOGMCEd3LlI6Ro93AR4Y3FfqIlCEHUMdDTVOiLqHtd3DKOKIRgUHz3zskTSEYJU9RrlUTxc19yObcp+wmmrWbxFjPe+i9FEctp6HB2aG9vF4olZivNobVqbUN8eP8Kkh5oY/4PYdb875ZqMGLxltEev2iO7k9YHmO8uihOqD/C355fapzhpK9QtAlmVCIGllrHgRJBPZ56LDOOKxIIccfhpPBhOBDqhmXT0wyzbpZL2qkEGkR9t26dz6bjUoxvS0GTfzOYNqhGGEm368B1+X6m1NDwOVn/DT+egPdcytIR20CusYzOngZcyTqR3PzApk9dHye2W9eWLQMkO+0SXqmBkxRys3QL68U9VEJtb1XzOnXotS2yR7aFpQ6ppSB+doJrxgVaN2Q2e2xw6dY0QlQza2AFF36Pm4xniwkbygvmwD1BboBHKcQned+O7hJQXieUW1hU2VEC4Nqn/sQeZkvYXLm10Q/lyaTfkAOMK2b7X2B56WO5Cegm6nsLRF2Ziuo9MZCvUJW8lSneDS8oWc9KI3PtJ8dYFYzytvC4A1XuKwi/5/JhHmxu+gl8JXVUaQW0mRfPj2d6qJtFFayqwItoagq62/UImb/GsMToe1oHmIeEWt/ldJ/nBIsTyhvbiQzUjYOaZ2AizelzhGlrCsmdt2ZQXS9NXU+vhj5IdMxJa7CtAc2cWezXFNLy+KqPNHNe8aVhe4WTDliNnPk1K+M+kPkxzfD6OkzCs2OpE07NNJ4jBet0yRNISn/lUtm6ZLVk/uwBHiZjdM0t/W7tsVARVkdDbl0nkmOKGMxGPkSiOzrYEmvm1NwCM4waW4sF73ytULWqoVKr3sHEPPKCY2cdOguCtyJhm1FxEgLY9sK4LWi8AoDr3qbicL/KA3FMdUwPZk/Sgyu2pgEEQMZZ+x5oOke00jA3+R18bjgGjEo0ogUyZ0f5TGiI/XPWUP4Xwm1IJja5Rsxe6Ul9EM/qjEKdnMGfz+Sdq9opQEsTgEvEmBk/SjwAXBp418cxF85DeRjE+lB1oELLBeSvDd55t/GxBB9X16e788KgloV7BAzkmQR/26yz2afXOPFhQnh5bkXXeHQW0SXdng== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1670771a-dc3b-4ba5-c481-08da0d1122c9 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Mar 2022 21:07:27.7162 (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: OdquI3x6jxHzJTrfpDQiyHLPylhN4x+JiblL2LdzpzAx7ucCVjbhY3rQqb1Lo3ORtzcR74WV2XQTg0YXiwN+DRC9+muC5xFhpYnzqLIr1mE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB5600 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10295 signatures=694973 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 spamscore=0 malwarescore=0 suspectscore=0 mlxlogscore=999 bulkscore=0 phishscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2203230111 X-Proofpoint-GUID: diGDGyklDIDxSncYPQEPU0807SBkJU7V X-Proofpoint-ORIG-GUID: diGDGyklDIDxSncYPQEPU0807SBkJU7V Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org Quick helper function to collapse duplicate code to initialize transactions for attributes Signed-off-by: Allison Henderson Suggested-by: Darrick J. Wong Reviewed-by: Darrick J. Wong Reviewed-by: Chandan Babu R --- fs/xfs/libxfs/xfs_attr.c | 33 +++++++++++++++++++++++---------- fs/xfs/libxfs/xfs_attr.h | 2 ++ fs/xfs/xfs_attr_item.c | 12 ++---------- 3 files changed, 27 insertions(+), 20 deletions(-) diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c index 7d6ad1d0e10b..41404d35c76c 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -202,6 +202,28 @@ xfs_attr_calc_size( return nblks; } +/* Initialize transaction reservation for attr operations */ +void +xfs_init_attr_trans( + struct xfs_da_args *args, + struct xfs_trans_res *tres, + unsigned int *total) +{ + struct xfs_mount *mp = args->dp->i_mount; + + if (args->value) { + tres->tr_logres = M_RES(mp)->tr_attrsetm.tr_logres + + M_RES(mp)->tr_attrsetrt.tr_logres * + args->total; + tres->tr_logcount = XFS_ATTRSET_LOG_COUNT; + tres->tr_logflags = XFS_TRANS_PERM_LOG_RES; + *total = args->total; + } else { + *tres = M_RES(mp)->tr_attrrm; + *total = XFS_ATTRRM_SPACE_RES(mp); + } +} + STATIC int xfs_attr_try_sf_addname( struct xfs_inode *dp, @@ -701,20 +723,10 @@ xfs_attr_set( return error; } - tres.tr_logres = M_RES(mp)->tr_attrsetm.tr_logres + - M_RES(mp)->tr_attrsetrt.tr_logres * - args->total; - tres.tr_logcount = XFS_ATTRSET_LOG_COUNT; - tres.tr_logflags = XFS_TRANS_PERM_LOG_RES; - total = args->total; - if (!local) rmt_blks = xfs_attr3_rmt_blocks(mp, args->valuelen); } else { XFS_STATS_INC(mp, xs_attr_remove); - - tres = M_RES(mp)->tr_attrrm; - total = XFS_ATTRRM_SPACE_RES(mp); rmt_blks = xfs_attr3_rmt_blocks(mp, XFS_XATTR_SIZE_MAX); } @@ -728,6 +740,7 @@ xfs_attr_set( * Root fork attributes can use reserved data blocks for this * operation if necessary */ + xfs_init_attr_trans(args, &tres, &total); error = xfs_trans_alloc_inode(dp, &tres, total, 0, rsvd, &args->trans); if (error) goto drop_incompat; diff --git a/fs/xfs/libxfs/xfs_attr.h b/fs/xfs/libxfs/xfs_attr.h index 1ef58d34eb59..f6c13d2bfbcd 100644 --- a/fs/xfs/libxfs/xfs_attr.h +++ b/fs/xfs/libxfs/xfs_attr.h @@ -519,6 +519,8 @@ int xfs_attr_set_iter(struct xfs_attr_item *attr); int xfs_attr_remove_iter(struct xfs_attr_item *attr); bool xfs_attr_namecheck(const void *name, size_t length); int xfs_attr_calc_size(struct xfs_da_args *args, int *local); +void xfs_init_attr_trans(struct xfs_da_args *args, struct xfs_trans_res *tres, + unsigned int *total); int xfs_attr_set_deferred(struct xfs_da_args *args); int xfs_attr_remove_deferred(struct xfs_da_args *args); diff --git a/fs/xfs/xfs_attr_item.c b/fs/xfs/xfs_attr_item.c index c80ea443d380..f2d8d6998bfe 100644 --- a/fs/xfs/xfs_attr_item.c +++ b/fs/xfs/xfs_attr_item.c @@ -567,17 +567,9 @@ xfs_attri_item_recover( args->value = attrip->attri_value; args->valuelen = attrp->alfi_value_len; args->total = xfs_attr_calc_size(args, &local); - - tres.tr_logres = M_RES(mp)->tr_attrsetm.tr_logres + - M_RES(mp)->tr_attrsetrt.tr_logres * - args->total; - tres.tr_logcount = XFS_ATTRSET_LOG_COUNT; - tres.tr_logflags = XFS_TRANS_PERM_LOG_RES; - total = args->total; - } else { - tres = M_RES(mp)->tr_attrrm; - total = XFS_ATTRRM_SPACE_RES(mp); } + + xfs_init_attr_trans(args, &tres, &total); error = xfs_trans_alloc(mp, &tres, total, 0, XFS_TRANS_RESERVE, &tp); if (error) goto out; From patchwork Wed Mar 23 21:07:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12790160 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 58BF5C4332F for ; Wed, 23 Mar 2022 21:07:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344854AbiCWVJS (ORCPT ); Wed, 23 Mar 2022 17:09:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38590 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344888AbiCWVJE (ORCPT ); Wed, 23 Mar 2022 17:09:04 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 51C8B8CD8A for ; Wed, 23 Mar 2022 14:07:32 -0700 (PDT) Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 22NKYMjb031979 for ; Wed, 23 Mar 2022 21:07:32 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-transfer-encoding : content-type : mime-version; s=corp-2021-07-09; bh=h5DhRca4zryPXrcoZOXKCc0lz+98mokyw5DgOaFMES8=; b=xy8XqZOaMBmVzCzTfEVG5pJzNGEU7UW0DT2O7LXjvq1G5KcILwCMsTw9Zx1LdhFIsHdA /vNQMWiKcPPPptRC9hfaEMn6MCmy3whPBlYH6vmuJk/7eOQdTdp0fsZhOoTQEfdpO5pf BQ/WQWYtXa7/56o93FbF3cujFkNRHjCy8jE4S7AIPwAG69eOzs5IuYEsyuLcKAl6lsvb kTVbs8KYXF/peaqIJhJe9trz7LRTD57GBJftl8v7TH/6xUe8a9dQyqwKB13Uq5dxvJTn piIXAyk7iHKjpdTuIs1jznpm7pgaW7a13VwiOeMyx5BAHJaTg7II/Hx8J/18KvKGdOsr Xw== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by mx0b-00069f02.pphosted.com with ESMTP id 3ew72ajf38-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 23 Mar 2022 21:07:31 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 22NL6R9q154749 for ; Wed, 23 Mar 2022 21:07:30 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2174.outbound.protection.outlook.com [104.47.58.174]) by aserp3020.oracle.com with ESMTP id 3ew701q88e-6 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 23 Mar 2022 21:07:30 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bBM238ntxKVGtbrJeQTbbkeOjZiWLkzIFFSDPPIAlhhIkNR2KGftWLuhR4eo01qrPwcmLwbaEg3rZ8IujDmhG3WXT1feUSrZvo73QEWAAmsVuWolbBBhfMUMdEfiE0f4QSxrG2H1qFbz6hN5DxE/dLt1xJ2pxon6uICrYKcwmYrAFLVHRfhitt591c/07xCIa2viX5rHJsuvmYn71aVFTj+Q/OzpTjM7MhUETvamPJ8eo0kDQBZs6L3/4ZwZRK7m2GMwj5CaEyWHu4vPfyS7FRGBnDy1HlfgNdzVE8zXlOBn9Mm6r8OKCmYqUg0Ivt7g1v4DbMXgv5Mwd6Usd6oHbg== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=h5DhRca4zryPXrcoZOXKCc0lz+98mokyw5DgOaFMES8=; b=AXinGgd+mNK38OSkBg47nTTVAbgMLftGRkQOEGDhiNiKIdHbq8+zPK+1KBCg42gzNUIqNVdfqeE/e4JCIuGKyisdmvaOpIkbFCdU5DsBzDCFQhNdCNCNeFhFyeoYQw3rXBQVKqquHJXVn3HP4wAdU+CEOqfoj3htFlpgZv3Dql/nNa1HXVoc3RBMPxInn8TJyfpoPbkroz8/6IifGi4IU6otiXqSSDu6b7rbGiJesrqYpY8HGwx+DIFnu0RJw+LzLzuoaTxrNmvv+ja3QloKzmWDY2RJoDwDIUGpbhsMVG56w42TEOREUxOX4NZptWohfxAFqIOXs6VqvLJzgIwekQ== 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=h5DhRca4zryPXrcoZOXKCc0lz+98mokyw5DgOaFMES8=; b=oS8fcwYs0HYnBYCMlpmY4bfO+vVlET9Efsrvh0AG0PQHE08Sm7zOv0q06FgB1OKqpyySCLxY1l7Mtc/aOmZGQhbZXZje51ovNH/uhW6pdw27HwiSEtiMJzaw6Lwg6R4k/oRE/eG9YISmJkNaLAefmSTnm+b8Su63Ba5XA4vgGK8= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by SJ0PR10MB5600.namprd10.prod.outlook.com (2603:10b6:a03:3dc::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5081.17; Wed, 23 Mar 2022 21:07:28 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::c517:eb23:bb2f:4b23]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::c517:eb23:bb2f:4b23%6]) with mapi id 15.20.5102.017; Wed, 23 Mar 2022 21:07:28 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v29 14/15] xfs: add leaf split error tag Date: Wed, 23 Mar 2022 14:07:14 -0700 Message-Id: <20220323210715.201009-15-allison.henderson@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220323210715.201009-1-allison.henderson@oracle.com> References: <20220323210715.201009-1-allison.henderson@oracle.com> X-ClientProxiedBy: PH0PR07CA0084.namprd07.prod.outlook.com (2603:10b6:510:f::29) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 08b8d182-aba2-4b6a-ef4b-08da0d112307 X-MS-TrafficTypeDiagnostic: SJ0PR10MB5600:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: nf+Usf+Ju3m2bE3jfm1Ws5wMOvGcxu69Y5SIVOOqc9ew7g2YIky4EYxxT0luvCvrw+10j1SpyUoOAMFYIgY0dtheGJdYRSCY0DZV2RLMjG/rSFrVl8NT0cbHn16LyJ+Dq+lNjZKPPsTFPQH4CZxtN2bDd9PuGtEvJJISwLXOLXZGM+/eR3B7sFysJtld0k0bT3MKfpHGanFeqk9G81FASR6GUMPU6Rrj7yi34V3VdZTP6SSafCRn7lRvD+/XrXeGsFLXSNUebPfxOEibsyTjAnj1MwiAcM7Fgwkimrl6EKysN7pJTNo30BOmi3fpkln1SqKuxq4/fcx7GPdgKuwbkFNwX5qmqHSqiS60dBeXPT7bohYyXxoHeq7lLMXaVPhEm3yZT5wzGPR9B7AmqLgJQavHbPSSha5skNvY0CH/657Xl6N+YM183JO+TqgI5lRUpmAD+55neFC4kXt/up/1I3Z1+xeZ5xXam5/FXoKGA6fwoLYZq7SnusUF4tyS/+Z5JUyZmVW6Wgwp68ttP/iTbErwu8nwJfp5LFsLPv0UUoCXQWFS6bS+kxs6MyRUleKNS2FP2ys2hfnp+w1B7Mk4/xllsHjjeeuXCwSYNrC7A72UpM9QmG0+hRsje1yS8L+L8lvvQt4l8haJ1OBeBoWpiD0RS51ttYxLKYE6XFq8LymrYFUyYwUXEHtXF7WSW15MPfaH4gxiBgKVFFZmLcWOjw== 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:(13230001)(366004)(66556008)(66476007)(66946007)(44832011)(8676002)(6512007)(83380400001)(86362001)(52116002)(6486002)(6506007)(508600001)(6666004)(2906002)(6916009)(2616005)(36756003)(316002)(5660300002)(1076003)(186003)(8936002)(26005)(38100700002)(38350700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: +R1tHXWaTgqnWRGR1qP/GTkI38jTZoVin4mXhimflRKH8vCqPTc7h0DPb92C9nSFEMEKOWz6+VMC23NENl4IzjzRFxugjAQ47YW74+N1GsOd64h/ZX1bvmuLpRNa/FHq/ou4zWc95a1Rg87A/vLsUKa/gtmyH9zGmg9O9k9Y4/1x0+gl2xdLvR9MM8AE5CZKVt9fSi6FxOray+/Hx9BSb/3h8afJ++pIAfRc3e30oj26CNBWIRqhydV2iD0w+Eiyt2QBi2lyOrmZG6mWbeA2EQAjPZ/Nh2RwVo/Suge3evHMdDmPjM323hqcxmRXO868o89FS/26hzDB3TuutFefM2R2itOzMWX23TQeh2RHfVAA09gIZWD+G4JShyqEpARaYymKDr9yPn8Fe65Le06r5EaYZ2a6WYkxziIsLoCw1ZzOYa7vMdlps51JgbiHETQHehgHv8vdURZC+On0ZuhUZ0N+SCp0I2r4/02Q/2vUeBp6KiAb5mam3nuum0zJqOZgwIcCdDG0qiFk+EqwjQsLcAd5NSVNGa2CilYsZeFyj3UOPr5cwKooiYg4M6691lrdp9wECZgCnH8jnJTf8ZadwldsFekd1dWHcG8LwYO8sJ0yiOJcfZjHqMHs2zKtfdK8sIV5SR1dgglTQDJUVyjEqetUQj9c7yqoJxe9nQ6xEZKb4rIujJZHBOgkPPnuhrtCqzHVxyqfYiBW4BjQqfQ0u00aF/ODvPmBELEYyDhSwiwbrU9S5L5quoly9U3v2S+duo0cOKOCT0iqIGjY0WjK01sjTnMTSS4vihN0yOtnziIOt0CRMjvZfDszlYMMNVo68X6TMkF1/XgKKtDdQa2hcDzZBSQGoTU4RPKUeenkuELWSWrzue4r2I7WL1IuoiikNV/n6IeRWNXLRkQmzIIFeY8ufZuyJ2dUMMUhCRrOZVN0J1rf7pDHxky688kx5tUodkKegwuDb6S923uhJcHxgMKSfkrGecIFNBwkdkaSoPlJKjYuDn/SBxrhwwiSrEdhx2AkiPfBk4WH8FXu52beXjW+XXrFO4dMdKqma5K9VnIaxVhEw+iKTtf1txly1m7//9RP/p/uMpb2LHQtUZkNiVouSguJKAkeSGVIDfflmjE0C+c4H6bzvAQwOPkT0zDdWMBADYMQwBda3jKo/di/vhWlrsZkgKW1drbzV6EDH3SgPpOYxg9sjudfoUBD2FMfn42+50lvJ8uaHC73sgpTB2R9QPWJAa//Ksb+UHgKPtYlg72y+rl0Iq/1Z7GbwHaYFDz7zLxNpiYoBok8L7MtSJmSvFqOWyO2rJ7ln6QLyVCj/sa6yzPudolB8hLwsYRX894MkZNmG3D7ESukVQEK3mIITIp7BtX1z6zl7gLdfdgM+YBWRdApIwbnkEGJT45SlAsVON1Qwhy4TMU7b6XSowlJ8U6gbpCXBv0WHY/rdbNCpNeP1nKvfTNhUhpKCWLYK4xoZFWpqHCOLz/fj3WQYw== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 08b8d182-aba2-4b6a-ef4b-08da0d112307 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Mar 2022 21:07:28.1237 (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: 3xHxU9gwpd0KnvXdvet7olTiYW5KJRa6dWMAio211TdxXZPZDYJWjQqAsMFbGGBh+vdZLhcYMgBuH7lMVVSkMyrMJCk7tgyspu+CsMSkqH8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB5600 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10295 signatures=694973 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 spamscore=0 malwarescore=0 suspectscore=0 mlxlogscore=999 bulkscore=0 phishscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2203230111 X-Proofpoint-GUID: wvnbrS7FkWB2QbOqGfCB8anod1_38ata X-Proofpoint-ORIG-GUID: wvnbrS7FkWB2QbOqGfCB8anod1_38ata Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org Add an error tag on xfs_da3_split to test log attribute recovery and replay. Signed-off-by: Catherine Hoang Reviewed-by: Allison Henderson Reviewed-by: Darrick J. Wong Reviewed-by: Chandan Babu R Signed-off-by: Allison Henderson --- fs/xfs/libxfs/xfs_da_btree.c | 4 ++++ fs/xfs/libxfs/xfs_errortag.h | 4 +++- fs/xfs/xfs_error.c | 3 +++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/fs/xfs/libxfs/xfs_da_btree.c b/fs/xfs/libxfs/xfs_da_btree.c index 9dc1ecb9713d..aa74f3fdb571 100644 --- a/fs/xfs/libxfs/xfs_da_btree.c +++ b/fs/xfs/libxfs/xfs_da_btree.c @@ -22,6 +22,7 @@ #include "xfs_trace.h" #include "xfs_buf_item.h" #include "xfs_log.h" +#include "xfs_errortag.h" /* * xfs_da_btree.c @@ -482,6 +483,9 @@ xfs_da3_split( trace_xfs_da_split(state->args); + if (XFS_TEST_ERROR(false, state->mp, XFS_ERRTAG_DA_LEAF_SPLIT)) + return -EIO; + /* * Walk back up the tree splitting/inserting/adjusting as necessary. * If we need to insert and there isn't room, split the node, then diff --git a/fs/xfs/libxfs/xfs_errortag.h b/fs/xfs/libxfs/xfs_errortag.h index c15d2340220c..6d06a502bbdf 100644 --- a/fs/xfs/libxfs/xfs_errortag.h +++ b/fs/xfs/libxfs/xfs_errortag.h @@ -60,7 +60,8 @@ #define XFS_ERRTAG_BMAP_ALLOC_MINLEN_EXTENT 37 #define XFS_ERRTAG_AG_RESV_FAIL 38 #define XFS_ERRTAG_LARP 39 -#define XFS_ERRTAG_MAX 40 +#define XFS_ERRTAG_DA_LEAF_SPLIT 40 +#define XFS_ERRTAG_MAX 41 /* * Random factors for above tags, 1 means always, 2 means 1/2 time, etc. @@ -105,5 +106,6 @@ #define XFS_RANDOM_BMAP_ALLOC_MINLEN_EXTENT 1 #define XFS_RANDOM_AG_RESV_FAIL 1 #define XFS_RANDOM_LARP 1 +#define XFS_RANDOM_DA_LEAF_SPLIT 1 #endif /* __XFS_ERRORTAG_H_ */ diff --git a/fs/xfs/xfs_error.c b/fs/xfs/xfs_error.c index 666f4837b1e1..2aa5d4d2b30a 100644 --- a/fs/xfs/xfs_error.c +++ b/fs/xfs/xfs_error.c @@ -58,6 +58,7 @@ static unsigned int xfs_errortag_random_default[] = { XFS_RANDOM_BMAP_ALLOC_MINLEN_EXTENT, XFS_RANDOM_AG_RESV_FAIL, XFS_RANDOM_LARP, + XFS_RANDOM_DA_LEAF_SPLIT, }; struct xfs_errortag_attr { @@ -172,6 +173,7 @@ XFS_ERRORTAG_ATTR_RW(reduce_max_iextents, XFS_ERRTAG_REDUCE_MAX_IEXTENTS); XFS_ERRORTAG_ATTR_RW(bmap_alloc_minlen_extent, XFS_ERRTAG_BMAP_ALLOC_MINLEN_EXTENT); XFS_ERRORTAG_ATTR_RW(ag_resv_fail, XFS_ERRTAG_AG_RESV_FAIL); XFS_ERRORTAG_ATTR_RW(larp, XFS_ERRTAG_LARP); +XFS_ERRORTAG_ATTR_RW(da_leaf_split, XFS_ERRTAG_DA_LEAF_SPLIT); static struct attribute *xfs_errortag_attrs[] = { XFS_ERRORTAG_ATTR_LIST(noerror), @@ -214,6 +216,7 @@ static struct attribute *xfs_errortag_attrs[] = { XFS_ERRORTAG_ATTR_LIST(bmap_alloc_minlen_extent), XFS_ERRORTAG_ATTR_LIST(ag_resv_fail), XFS_ERRORTAG_ATTR_LIST(larp), + XFS_ERRORTAG_ATTR_LIST(da_leaf_split), NULL, }; ATTRIBUTE_GROUPS(xfs_errortag); From patchwork Wed Mar 23 21:07:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12790159 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0080DC433FE for ; Wed, 23 Mar 2022 21:07:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344503AbiCWVJQ (ORCPT ); Wed, 23 Mar 2022 17:09:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38592 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240930AbiCWVJE (ORCPT ); Wed, 23 Mar 2022 17:09:04 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 600958EB53 for ; Wed, 23 Mar 2022 14:07:32 -0700 (PDT) Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 22NKYUvw011998 for ; Wed, 23 Mar 2022 21:07:32 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-transfer-encoding : content-type : mime-version; s=corp-2021-07-09; bh=Af03T31u2y2ZuaGoP2kTHccW+Eg4gGdVpOz4egX7exA=; b=qkefzN9y+9QmwY+QikZP2PvapswsT9jFa3o/1qqvUbIn0Xgvrtx7R7Ufs4KdRx3b+KJS XHY91hCV1VMyXsoYdnaWgBndIrfMQ0mLL5enBemwrfHqyAqJLp+hLtWykhTedmT9/XJT L1Bv5rHmHYN4sIi2O66DCGajIDHDyWJxhUtr1jPgsMr4R3yfkXcy45QK9KLbLcz+JkHe Qmve2yr88Z0+OgU9rHTGdEl0LN/gqWaolrAgLNGBxpHUoripmKJg3BJ6kcGsfunlt3c+ TABqCCIarA2axskSwrNs007vX3qnLCvRX3J0XqCaLGFYKS5NawKDSpnG8lxZHYHdNxKy bQ== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by mx0b-00069f02.pphosted.com with ESMTP id 3ew5s0tt8a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 23 Mar 2022 21:07:31 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 22NL6R9r154749 for ; Wed, 23 Mar 2022 21:07:30 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2174.outbound.protection.outlook.com [104.47.58.174]) by aserp3020.oracle.com with ESMTP id 3ew701q88e-7 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 23 Mar 2022 21:07:30 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=V/9DZvArN9eExc0hJVUn2rptRsQS3ypOBHoCgYb+EvTGCx5QXmwVaqjb7KipUq448SyupaxdLiVgZgxCDm/n0l6UuMDF/w6Rx3tz7l9xf9EHuH1Rm7jFrVUdD54gRHGI5Drw4l4qdRXy0zLUsIdcxbaiJ/ExXNp1VbwZyAu2eNipO2s4O3fCAUHSzjx+blrvgnQUaGrmBhnPwWd9E370+2EdYD2VzKwmuDsCZCEZCju81yqFeAY4Jo1yCGm76t1/P8vZnVeU529NS5tGarJ7NpkCqJalFui9DTyKAVxEhNBw9Qm8AvdWCkHB/17K3+uCTeEu4RjPwf0FTKH/W/AfYg== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Af03T31u2y2ZuaGoP2kTHccW+Eg4gGdVpOz4egX7exA=; b=P41efDo2zyT/BPFZ4dCSe+RitTDkflyoo2igvaYCJyYHDrdVf9DQIegfw1XehE1JMlnAoQqmzk3dr4fPFqWzuC+PjIOtkiEKs+XKJ39ea8vtEWCG4VKB85E5AS8neu+iOLhS/7s0yb7MMsdKNQLly+TSzshW4PO3YMkrZl0VtU20FRs1NHSBzrlzGBfdTGZLqZiv4/R3uxx5xCtTzby5LF9xXyoKl9IBuP4ENyxMjO45q+KxgjWfbyL7iNnucOdK2v/l5tQeksU7AWuFevt89Tw6jtCQoLvuXr64Yy2I0vmJOanp+Tz4G6RwKq1tTOZxvzSPaRHHURqPeokCEkQbIg== 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=Af03T31u2y2ZuaGoP2kTHccW+Eg4gGdVpOz4egX7exA=; b=ZKT2TwzZbt9bryjBbY4ljJf4Fb7qawBJWswkPHjY8V3RGNDk2Rkd3SeerXAKMfAjtLIFw0VqM3oNonRfIrgRLj7xwrY7RkNXa6EtSkd3ouBfUw8ZnNMVMlQ0i6T6nvksKO5do1yXGgf5F5LNWWIJ4qDJPr22DKxcuSFXSGfeXIc= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by SJ0PR10MB5600.namprd10.prod.outlook.com (2603:10b6:a03:3dc::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5081.17; Wed, 23 Mar 2022 21:07:28 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::c517:eb23:bb2f:4b23]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::c517:eb23:bb2f:4b23%6]) with mapi id 15.20.5102.017; Wed, 23 Mar 2022 21:07:28 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v29 15/15] xfs: add leaf to node error tag Date: Wed, 23 Mar 2022 14:07:15 -0700 Message-Id: <20220323210715.201009-16-allison.henderson@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220323210715.201009-1-allison.henderson@oracle.com> References: <20220323210715.201009-1-allison.henderson@oracle.com> X-ClientProxiedBy: PH0PR07CA0084.namprd07.prod.outlook.com (2603:10b6:510:f::29) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5d6fd293-ba56-4caa-1d70-08da0d112346 X-MS-TrafficTypeDiagnostic: SJ0PR10MB5600:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: HC0B6GyiNZp3fZkMWIGXEJ7Y97WMv/fVANknMqBo+rCUiKSCPvOpOWz4+9LAeccf9JdtM+939lU6F/AoCYOd8C/dgK8dobhGhKJZqeZKMfJJvqJeipKW/9a09ozOgo1kw97EdgY+EghgxG9W+ntmAZQlCHM3TeGjssO/CYR7Pcn3FybEyLdWWw65SqF5TcmEFFjrs5XQ2fIYhW7l+vGqIX/tHVqwIYUhoRhSMoWdnkGVWlVTQ4CCd6iBSRKoFIGKZgbXqEi0L63+snGLy9VwFryi7Thd7vpdMimIhxEtmJUxvfk38CvCyEwkyt0nyOQrV5lJUOxPdGu/tCPZLuzK3GMjJVNsvL1gnrgKbYNqaaVeI4XjqBwzSPAXG1MNuiOV+ThjqMwQ2XmhXQT0ZLpDAGMo4sLn9i0chFgKQ/0YiUTraHSBuHTdjEamaOzCIKXVXVrgEdI8TbzS+bFcLxxekVe/ooaVPdH7mLwYDvQFf+wULuuUbMjQG9qyLRD1XURqJGUKDh37s6tqSQ4FemNrbir2NhBSO6yMHPozxpaczkUoPjbcBmw9cAkyoqmDQ6R+ONiPS7Ek7JOcgRTZxKamM8xtuTxWdcFXlYOpM7xgFUUQl3SzlS+o++A4zinpXsYlU1qToZ+CRQvhct4TndsUAVEvppvDNi9RNxdYY/JMHiZhzmYP2g0brVp+3SMyJJfRpJzk+iXLfLtYLR5JgfAdaA== 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:(13230001)(366004)(66556008)(66476007)(66946007)(44832011)(8676002)(6512007)(83380400001)(86362001)(52116002)(6486002)(6506007)(508600001)(6666004)(2906002)(6916009)(2616005)(36756003)(316002)(5660300002)(1076003)(186003)(8936002)(26005)(38100700002)(38350700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: qKvsj0eVj+KdKJVlj+30ucJQpWisg7Nx0BYGWQqY8q/MV0242jmPCyHb+TfNnEK6kgiDtk0S1XdN7KLe/GPBNoNDvH5IPKntiOnnZHaqTUpsakId8bzruIuR9mEMYAqbtaVCMTAVRXsTzL64xqlsQDxv7GXwKFjX9bjZqGOxlDTnSQXfheJ6y3TQP31wCEn91UL/VL50LLSOhmVpPP+Kr5bTSpNlERJsmtZPX50byMrNwmiVHCSbYXsGlBaAbrAu74HTMQrd0qUJemS7fnOmXC9pjZSSsk+CRpAVgU70tgs/2gf50OXB661IWrZGvrU1oUzu+wntxgi9BWofnCd6QcUH8ACFSkeZjmqUEyYBUnCSVOv0a19dCIjAWQf4nkO4zBdo16tao9zCVryKd/Un5aNQg1VwYaNT6PHVW3AJpmPLHmPIot4uJDq5o70lfdf9jtP4hEb43spiSO69qpJDUUYH/sk58HnD4twYHLBV6thDSRdZE/fpSN88UK4A4utAiaC3MgpQKXrGy4za4HoYpLTdeVnYR2FE5UkE5dY8GhubQqaH95YlkTjWfhXfY8uxwYpVs6DArbbq0DYLHD4kk9yS6d5kK0gBOUiVy3jRjb6GwihaZXfYdD5lbP2vPoj1Q/2OGYNqkJ6PGCF3gKgUZMx74MGpPUnW/WJhMbDuEG1rZntA7E7CRoVabbe1MD2tkQ7nt1ey+ZM2MrjdKjY08SnmRSwResN98esyGFwCAisVicaY376G+ahvm+3yu3Gmj26Bjhr4PNOhLYdHrPWwqpKhc5HHfrpEVbX1iJvL3rld3wPnvHs5TrITkclSaGp1hrV64mD6ds+kDh4UR2EcfuW+2RFEy1+MOHi6J6z4Dj08pMq4vhp+q26psLBOrkKgkATStOdclSGnYeMEHQDJuKs8/rndTo/ZLi5n2Ek6Fp1vR2oSC4UX9cghh8PjlWcaa99W0qit7gPbLvRZIznHI6OB5apcfJWT8B+Pj7itflbIFR/O3xNuqzro8N8M6peMVKqHtFb9i2VqNZ0XLLDh8AEgXgjWodXuyBPFk1mrXr0mU+ME7wOmMJcoklkukLKZZ2h+B0Wb8GBteVoaEJjsUuhfn4ZNjyw7MpPh1KhBGllY94RohR7wPPqlTMfRybxss9ltAqIni2CjXuIV8kxnlov6eUQniKzFgFnLIVPX5GT6WYXq4mmp6V4XdOKg0QXEfCjet/c97+FdGVA3qNkUXw/CfuXG6nhySTss6z/BP53YxZ7uH5iC9OFG41bM6t5QBE2p3l8eiBx/cK284YuNj0AaTHsqi+2uiSOkCxjBbGvLvf/MBuQflVoAFvU+Eup+c+3bwVVpa6LZizN2XeYR0AU3kAgJIT92e0ZeYBBCgLsxr7dcl0TGtcRtLvfCKUptyPMnkHCuW2PGEw9L54on7ToGArhxZU8aHbP0ZM4vDt6P+wtxAsH2cIbi/r/sffOzE/BwT48LtJ9Z/aPNVdHj8A== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5d6fd293-ba56-4caa-1d70-08da0d112346 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Mar 2022 21:07:28.5311 (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: HyeLFsSj0VGBlysUmNH+/JHaILSmjSqcf2TzQKQWGVVJRaar30RXNhOUO5oQoMxFgVIafPLaMFFhG1R3gdtza7c+fwyUp6Z52+f6r5PeZfk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB5600 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10295 signatures=694973 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 spamscore=0 malwarescore=0 suspectscore=0 mlxlogscore=999 bulkscore=0 phishscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2203230111 X-Proofpoint-GUID: B3FDnb96RsTBx_k1h2aovCYZGxBsd6nO X-Proofpoint-ORIG-GUID: B3FDnb96RsTBx_k1h2aovCYZGxBsd6nO Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org Add an error tag on xfs_attr3_leaf_to_node to test log attribute recovery and replay. Signed-off-by: Catherine Hoang Reviewed-by: Allison Henderson Reviewed-by: Darrick J. Wong Reviewed-by: Chandan Babu R Signed-off-by: Allison Henderson --- fs/xfs/libxfs/xfs_attr_leaf.c | 6 ++++++ fs/xfs/libxfs/xfs_errortag.h | 4 +++- fs/xfs/xfs_error.c | 3 +++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/fs/xfs/libxfs/xfs_attr_leaf.c b/fs/xfs/libxfs/xfs_attr_leaf.c index 74b76b09509f..e90bfd9d7551 100644 --- a/fs/xfs/libxfs/xfs_attr_leaf.c +++ b/fs/xfs/libxfs/xfs_attr_leaf.c @@ -28,6 +28,7 @@ #include "xfs_dir2.h" #include "xfs_log.h" #include "xfs_ag.h" +#include "xfs_errortag.h" /* @@ -1189,6 +1190,11 @@ xfs_attr3_leaf_to_node( trace_xfs_attr_leaf_to_node(args); + if (XFS_TEST_ERROR(false, mp, XFS_ERRTAG_ATTR_LEAF_TO_NODE)) { + error = -EIO; + goto out; + } + error = xfs_da_grow_inode(args, &blkno); if (error) goto out; diff --git a/fs/xfs/libxfs/xfs_errortag.h b/fs/xfs/libxfs/xfs_errortag.h index 6d06a502bbdf..5362908164b0 100644 --- a/fs/xfs/libxfs/xfs_errortag.h +++ b/fs/xfs/libxfs/xfs_errortag.h @@ -61,7 +61,8 @@ #define XFS_ERRTAG_AG_RESV_FAIL 38 #define XFS_ERRTAG_LARP 39 #define XFS_ERRTAG_DA_LEAF_SPLIT 40 -#define XFS_ERRTAG_MAX 41 +#define XFS_ERRTAG_ATTR_LEAF_TO_NODE 41 +#define XFS_ERRTAG_MAX 42 /* * Random factors for above tags, 1 means always, 2 means 1/2 time, etc. @@ -107,5 +108,6 @@ #define XFS_RANDOM_AG_RESV_FAIL 1 #define XFS_RANDOM_LARP 1 #define XFS_RANDOM_DA_LEAF_SPLIT 1 +#define XFS_RANDOM_ATTR_LEAF_TO_NODE 1 #endif /* __XFS_ERRORTAG_H_ */ diff --git a/fs/xfs/xfs_error.c b/fs/xfs/xfs_error.c index 2aa5d4d2b30a..296faa41d81d 100644 --- a/fs/xfs/xfs_error.c +++ b/fs/xfs/xfs_error.c @@ -59,6 +59,7 @@ static unsigned int xfs_errortag_random_default[] = { XFS_RANDOM_AG_RESV_FAIL, XFS_RANDOM_LARP, XFS_RANDOM_DA_LEAF_SPLIT, + XFS_RANDOM_ATTR_LEAF_TO_NODE, }; struct xfs_errortag_attr { @@ -174,6 +175,7 @@ XFS_ERRORTAG_ATTR_RW(bmap_alloc_minlen_extent, XFS_ERRTAG_BMAP_ALLOC_MINLEN_EXTE XFS_ERRORTAG_ATTR_RW(ag_resv_fail, XFS_ERRTAG_AG_RESV_FAIL); XFS_ERRORTAG_ATTR_RW(larp, XFS_ERRTAG_LARP); XFS_ERRORTAG_ATTR_RW(da_leaf_split, XFS_ERRTAG_DA_LEAF_SPLIT); +XFS_ERRORTAG_ATTR_RW(attr_leaf_to_node, XFS_ERRTAG_ATTR_LEAF_TO_NODE); static struct attribute *xfs_errortag_attrs[] = { XFS_ERRORTAG_ATTR_LIST(noerror), @@ -217,6 +219,7 @@ static struct attribute *xfs_errortag_attrs[] = { XFS_ERRORTAG_ATTR_LIST(ag_resv_fail), XFS_ERRORTAG_ATTR_LIST(larp), XFS_ERRORTAG_ATTR_LIST(da_leaf_split), + XFS_ERRORTAG_ATTR_LIST(attr_leaf_to_node), NULL, }; ATTRIBUTE_GROUPS(xfs_errortag);