From patchwork Tue Aug 24 22:44:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12456017 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 96651C4320A for ; Tue, 24 Aug 2021 22:44:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 710A761371 for ; Tue, 24 Aug 2021 22:44:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230216AbhHXWpb (ORCPT ); Tue, 24 Aug 2021 18:45:31 -0400 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:24870 "EHLO mx0a-00069f02.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229840AbhHXWpb (ORCPT ); Tue, 24 Aug 2021 18:45:31 -0400 Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.0.43) with SMTP id 17OLrRMk015014 for ; Tue, 24 Aug 2021 22:44:46 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2021-07-09; bh=ncy9fIfoR8J9ug74+k59S/EA8Vjw7S1DvrQfkF0MIug=; b=Dc/rnDoIkz0F8pg7ZKNirLtxsvpygNVPsUAOg8zcrBjVkpE7we4n7SKJB+Vc+BrrEMqz eGHPJJGAChMxV6D2KQl840Rn1eNuLcmtNDU/9Q/m+vHLKY9LTX16FczimdWUxSejGeaA wUDdJXJTGX9ShAXagaCJp5/jk+dZlerOgaqGmt69fH8N5VHHkqrw2pyI/0SM89tRuVXP 41EECO4lzfsuQd//IPkHiccd6t11bH0PJwSxu1JYu+WTEPNg7bXkNpDYXAyqrP0Taz3s F31et+p0xUK3uVrl5waAo8UHwVr89K7DyRGSscPljUYiGiEAxtmj/mRj+ZxfDmNETAy/ uQ== 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-2020-01-29; bh=ncy9fIfoR8J9ug74+k59S/EA8Vjw7S1DvrQfkF0MIug=; b=plFJq18lkJ01QdZA1RgaXXPSIx8Of9/YRQHj8L+KxLcXPOZqQJBeo2ZTTT1K01Mhl+Mx 2vOLYsW46+qU7r1S7Q5hWvowIfKCdmc5VYjNUTbPBqTrpoecTJF3W+0xDzAZIg9TQRKN wlL5VQg6S9IoF5HPKdTJhxDNDBigi8p9CFEdnRTvVtf181QBiw1Jbod+R1F6maOmhNY1 /DWrXdlb+QiMqOVzDQvXEh4m3FGvbYFLrYAuKym0luCUBmFhoRcPOxgfx4xd/v5nIDAz sB7cGAQ7FB7m9OqE3a4o10OL/bfoANIfGaXnByt17Ry+Y2BWkmrMAy/kkSAoV76NCKYH Tw== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by mx0b-00069f02.pphosted.com with ESMTP id 3amwh6hxxa-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 24 Aug 2021 22:44:46 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 17OMfLTE138047 for ; Tue, 24 Aug 2021 22:44:45 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2177.outbound.protection.outlook.com [104.47.55.177]) by aserp3030.oracle.com with ESMTP id 3ajqhfehfv-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 24 Aug 2021 22:44:45 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EOXChtl5FIqMkYIR0PJ0OEw3cQwXsO6JdUw1b+9AxdHKFhY99j3vBtzqZ6FLKHIyGEFThLW3t80mBI+6GfLu9H/f4CKlfxPU3W34G6y7sPLna6Sxfd+mVkPcC/0R/5ffl3jdLRlBjNm/aBVoL09ZlQO6E3Us7GsaLNFPW+5ibdlhxv8W3EYxG3GZWDy+GiZKf3DnMSZcVQJjMHXa9fFzuDpuR2pTOTGbnX8/tlJQqjjii8kYKZVktDEU/OYsseHNZQjQAnCX/rJ0zmdZAdnmHKdQ+7rIRYE9zRvnul9eVp21jWMhkVXBuXenkuHYLasxmyGsothqk3Uxm/ZJRSzsZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ncy9fIfoR8J9ug74+k59S/EA8Vjw7S1DvrQfkF0MIug=; b=gS2i+AqD2eGPn7BJ2MUV7Hik4QPyG4b/9uSlsCnBF8p/duH9k8NtJvXajdqKeYShvk9nwcSrk61b8PVUWyqhgVOTqgwAVAglM12Rrq+hobhU9tLb0/iNUo+USdGI3WY2hBPjIfZU6/srHnWMCW1nA6LZ0+Ofyw9h5FsmBI7zvMNNzpj/pauWgW9o3+qTN1BednPkTBr4W06DhAy53CzmOsfuw1frrLVffQinbS/vDF48e42OkBp2UtIDeVUw7PdVKsXzdVZJ24CvLvnJaCSl3FiEYDj8GJAQBTiXz/08UJHzBTk7GrR8sA+G+Zpk2X4Vh3PRfzLwpqG4kknEGUzBcQ== 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=ncy9fIfoR8J9ug74+k59S/EA8Vjw7S1DvrQfkF0MIug=; b=r72qD976W+/92C09qvjWlu3vU+fNdSKTzRNd1lDitM3VkO+5aiQJxiP8bgXqLn5LuHQHRzSkoK3NThsWaKUN4TrQK8DA4OoaHWm1HXaeXv/VweMWZoHp5i8gXHaawo5pGb0L0SrRzbBVtfSt0rb6Z2in4NMYnRpm6ZhlHQI7wSk= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=oracle.com; Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by SJ0PR10MB4653.namprd10.prod.outlook.com (2603:10b6:a03:2d7::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4436.19; Tue, 24 Aug 2021 22:44:41 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::7878:545b:f037:e6f]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::7878:545b:f037:e6f%9]) with mapi id 15.20.4436.024; Tue, 24 Aug 2021 22:44:41 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v24 01/11] xfs: Return from xfs_attr_set_iter if there are no more rmtblks to process Date: Tue, 24 Aug 2021 15:44:24 -0700 Message-Id: <20210824224434.968720-2-allison.henderson@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210824224434.968720-1-allison.henderson@oracle.com> References: <20210824224434.968720-1-allison.henderson@oracle.com> X-ClientProxiedBy: BY5PR17CA0012.namprd17.prod.outlook.com (2603:10b6:a03:1b8::25) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (67.1.112.125) by BY5PR17CA0012.namprd17.prod.outlook.com (2603:10b6:a03:1b8::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4457.17 via Frontend Transport; Tue, 24 Aug 2021 22:44:41 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c08c400c-7fe2-49f1-8779-08d96750c2e5 X-MS-TrafficTypeDiagnostic: SJ0PR10MB4653: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: G0KMsIRRMrYFdAH3FkTkcCbE1oVxBcbcSpnZ6JmMyRu6wnDAu+KQgZyhCfuobkPGq/ew9LpL4PqACMe/dUcm2zaQegrMGK/6q7DdUnS++aYdTIRrjNcLntcue73dk25a5iBtBhlXKO2vuvOudu/6RvQSJ5dVOamIyF4fjbGHUPH2f79uzgDp1xGrQqFLffzN5pf8B2sSmHKmP4jdqii15IaCLekEC8g+fr+TTRbGWi+b87WlmeuT0kEbfz2/2Vvoegpj9NDn4hrQPgfBbtCqwCgH6NvXajBDROY9PyR90lkuqrEd+ZmPp9+InxoSzrJWmQn9RQ5um7fX6y5yo22OGVZeA+cBDh2GIHn5nF3diT77LbVsbDKvRSwk/NCgAq9zDkmhp68YWNjNOHR7GYadOm8DvNfqgQ04eIS69ejZkpEE2Qzx9H5JZWJDugPi/4rnpVI+E1mE+xtM7NpIs1NIw+JsZf7vN/m8O82uCRktqM7LYuqFzBOF3iW580DXMhc/6ADsVEJDac4NaPYqAgHNRPYTFYTQPs2GEgj1RV/K2eur/uYIrxEexaR6iInrwGKOaZP9OJD5hEvKEn5IGQ5e3PfSFceJayBgVom20PTFUjXkecvrqgzUuKLbO3/w3vK/2ydtvJUVn0dnBwNquv+ZdCtX5HQ2d3XAljoS6IK/j7nivd+K3FkUK3pVLmIpptK3lwzCs8bu567xpQZBkuj8aj3svkv6i3zacyZdjpcHcYWIn/NzKczqE/V0Hce4dPo/cfDSa1br3qeyXV5S7J+eXw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(6666004)(66476007)(86362001)(66946007)(83380400001)(6486002)(6512007)(2906002)(52116002)(186003)(6506007)(66556008)(508600001)(8676002)(316002)(956004)(8936002)(36756003)(26005)(44832011)(5660300002)(2616005)(38100700002)(38350700002)(6916009)(1076003)(29513003)(40753002)(133343001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Yo0rws+9HYb4qSuzBTdUG0yG8TOTN/z9vF0HuAvuAXou5swuzqQti/izRbm4aJj0QhuLsB9R9J1gSYw9wfG/41DT/q/5JVJ37Zue8bI2oMgtNwajM7KZL7ghSmOa+vLcdwN8UbG3lMIBKrKzhRMAJqnhIi6DT03hWcy11EHMGKHfgIQuXd2VPf7Txx8EueBuuEBYCD7Kfb3YszJBZ6AD6Ci1lo8z8rf2OrmgIqwuspgdrpA+ueyE2GOcvdA/anJdR64o59ulgJlCxlT09aJFpR/oWa4/H93XE6zlGkU60Zxu8Q0CP2fUoiyWAQFmOrn8NdEsX1OFsdS2iYlOVG5Bk1xwwLRvN/0qmNidUHDMHaC0qQ1ooTCF7YYmMyAonNtR14hSnO58SjpV8TT5d3/4kByn9/2sB+tYoXZrTMZ7ORRFhi6KgjSLoge70rLVWXKugagS4qKm1bsdBTGNhMJO2uQcJqVSnxmPkosEB9YUSGAthIaINdTSO7r1NH2WHtq278qqBNe0JNPUEotrnF1TH4xUH9b/vIVEmrrTHezWOHMQZhIlQktxb8WBIy+qINwWcLuEsGezBqpxk37F3pbSO7Dm9sRSm5MINgOb6hTARMz/dhtMevTs/Rc8pYMVPHFkNIACF6PfBf4fntGGkKacVUIUkSqIRJwXC0Er0H4nG0d7845H1kCB6GrbB2O8RU1ngUHcKU9DQUqCs4yP2eK/A2jnwgoNQgAxcrKgOJi2W6A7u2uWb0n6Cy9pMkWu5sbOueqQppStJbtvd1UNs1vkn0wEMPiupekSOvh+JnmW9exW3m8Rg5+aWlMW6gmi4z0S74Xc2qNhJhz9v3H4vIcWOS+zkYp/Teyr3P0gOet2UNGaVgLkssVmuZTHn63iFfdvZCiieiBK8MXpSXcX89+/6JOyJx5RWaC8iaLjKvjplBg1dlphIzlbyeSEnjd0YJcT22NrmCC8F8lvkjuxxC28NRvZhdSzlhkH1faDNroVPFGK7jEy5K8Poic0xtI8tTNmihJcvtXWm3S8dajq0a3loBULfVqAOylZHAIZDxdXFJkUkK/8CIfBe0rqZIGq2XTVsg2iAlPdiXqGHFqYb6RLaN0mxzcIVsxeSngjSzkwu+7J2MzRF9tFmthZoRzfII/bUf6LLavGEC4yog9zO1NTfWB59GSc1IH4Y136lSiuJFWhVOr+WpuKYY+6Zbojs4ozsCma0dvh7qXKFwCzxA7sY2gbdWT5GydkJZjEVygZ5wlb5ybizFUfAp9VsgBZJ1sXECStZ3Ryx9voJ3E83TRpZ7BUKjbyS7B5o9ziigW0EnhmSRsuJM55mPndlt9KEbit X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: c08c400c-7fe2-49f1-8779-08d96750c2e5 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Aug 2021 22:44:41.6185 (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: Cw6L0MkPhkgGrBOzzI66QrAyefzy7v3yuw23niyOzx8suTTOCP/oAYvuQrvOQcF27SXSHXwwYol23IBrufo+muof13bHCpwF5FMXj51daGw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB4653 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10086 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 bulkscore=0 malwarescore=0 spamscore=0 adultscore=0 mlxlogscore=999 suspectscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2107140000 definitions=main-2108240141 X-Proofpoint-ORIG-GUID: wKpTDRZoocqd3eR2AgZbowIaJNFR13Q5 X-Proofpoint-GUID: wKpTDRZoocqd3eR2AgZbowIaJNFR13Q5 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 fbc9d816882c..50b91b4461e7 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 Tue Aug 24 22:44:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12456021 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 32761C432BE for ; Tue, 24 Aug 2021 22:44:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 11A3561371 for ; Tue, 24 Aug 2021 22:44:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229840AbhHXWpd (ORCPT ); Tue, 24 Aug 2021 18:45:33 -0400 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:25276 "EHLO mx0a-00069f02.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229521AbhHXWpb (ORCPT ); Tue, 24 Aug 2021 18:45:31 -0400 Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.0.43) with SMTP id 17OJGjVW025058 for ; Tue, 24 Aug 2021 22:44:47 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=36oRWiIKZ7x2f4yT2eh46gx0opTIue39d6UEZcudQLE=; b=bVM5IqSCt+sFCrg+479WNEYlx69c9QBiZmqT1l21qJq1Wi5ra0jm4NcO2UjuIiIgZXj8 KDUh2qPj7WXHfupY4TVG+0kQ+Ewo0BNohN+VxeisOYYkz0RT+DxeoGlgtbL62DD6jNDb zNdDCoBmQgJlTCnLs9jiTenumlIc1gJ8K1l8HzSZacLVv2xHZVOHueOHDIFywSwxSudj +pRIA0I1lxl5KXhAblybFfR7pIqCYm6HYBgDA1E4Xap2uhw7ImFec50bgdoc0TfWjJLO zuaPpFasgs7VAKrzmeVQTt/8LhjRSeznpVq7EthbuPVBaODm+g6U1M/dHu3qj65YnWzo 5g== 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-2020-01-29; bh=36oRWiIKZ7x2f4yT2eh46gx0opTIue39d6UEZcudQLE=; b=x22woJBYReN5vD8Ouyo0ezp8KBq6YDrHqjisJtRTsfhkHPCGCTSrr5c0lQd8Dxl9Vv8A e8peTkyFRMcQsVvhiz5W9jUo5NJZJSdD/zPP/yDqZVj8jS+wbhOSsVnaPPNDakDuX3ad IY51wi3QFk+aSyVrZbrTPezFb8KEDsK3Vin4d6ANMLFPjGeV1Xg1gAHxnizVCNhz8J0e BtlFDo4P1t/voivmAt2iSKsyrUttt8X58oPPgIdJLp6Ve+Gxmj8AhkNU8zx/uVvTil8X tzM9yQOBK+7is4ssz5YnLgjDMDUV2X2Dyhyq5JhU4LU+avylVE/NfkCaf5/y7UJprtzP Gw== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by mx0b-00069f02.pphosted.com with ESMTP id 3amu7vtdx5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 24 Aug 2021 22:44:46 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 17OMfLTF138047 for ; Tue, 24 Aug 2021 22:44:45 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2177.outbound.protection.outlook.com [104.47.55.177]) by aserp3030.oracle.com with ESMTP id 3ajqhfehfv-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 24 Aug 2021 22:44:45 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dTIiCA/6PMx3D02mzKg1Bj/07PrTyQ425YzIa4OdbhQAUCMoBXJkRRklec5hFXr2hbkowtnB+VPMhokfZrm1YYx4W2lvB9czE6QvT6PV+nMlnRrVqRMm26/T75YS1ZWgM9V226Uj2npcqctWdnmHJ4SBn+qcm8HdrP8xhJ70eK6ROm94/xD54uTvL7IEINSZZff8lDme/vGuybma5yQ4tHOmDuHQMFEJKC78xeJ69kM1hoI7lNsAiq7KfbKZoWoE3LF0UTMEiDnWJv2D5UWfL7uOGvUyBFvlty1tQM5u8/p38rGkWeFeVpouo3H4odZ2CJ0xMVp29dkn99aHD3tTEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=36oRWiIKZ7x2f4yT2eh46gx0opTIue39d6UEZcudQLE=; b=fpu00OJbmBUCBiA7mHD2BH59xkKX8aYLl/TvlsT9csDcs4M1XOeJNvPWYR40U+/h52mThjkSFNVDzjT/lkz6e6xdkbyYg4QHA24xB6JRtnHAv6q2xzmKvmbwGe3LVuPg6d16bVTREGPEMa9At/xxMTHzrzOyeSN7k4Eibm+2xrFXyo7kRTkHf4S7aAvQ4312AGp0tcltQCI1l2+QWjk0khSKCJhWMb2mFt6/ImBRxoCSVJt1dJr3EPRXHa0mV3te9G1dCC/7tj0EbhgN1L8LNsPtSs0KIOO6n5kBd4cwTiEa62Lou8ROOCsShB+HpNNrjVWSw3knNxTqpFkwh24GUA== 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=36oRWiIKZ7x2f4yT2eh46gx0opTIue39d6UEZcudQLE=; b=f7a4AcfRiE6CPb6ejbNRX3Q4vACPMNWmpTQDPlhVKyOIDda/cdxFNHUziivIdIBf9xLtAcIHvup4UUEfwH2ZOX+LhA1CuESP1ZJx4hGWIk/9bthBzCnMZZjitwPXu34FS5pUmhi7r2hrP4YPoZvXmKFPtaiNFNOosjbQFjg3Eic= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=oracle.com; Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by SJ0PR10MB4653.namprd10.prod.outlook.com (2603:10b6:a03:2d7::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4436.19; Tue, 24 Aug 2021 22:44:42 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::7878:545b:f037:e6f]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::7878:545b:f037:e6f%9]) with mapi id 15.20.4436.024; Tue, 24 Aug 2021 22:44:42 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v24 02/11] xfs: Capture buffers for delayed ops Date: Tue, 24 Aug 2021 15:44:25 -0700 Message-Id: <20210824224434.968720-3-allison.henderson@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210824224434.968720-1-allison.henderson@oracle.com> References: <20210824224434.968720-1-allison.henderson@oracle.com> X-ClientProxiedBy: BY5PR17CA0012.namprd17.prod.outlook.com (2603:10b6:a03:1b8::25) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (67.1.112.125) by BY5PR17CA0012.namprd17.prod.outlook.com (2603:10b6:a03:1b8::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4457.17 via Frontend Transport; Tue, 24 Aug 2021 22:44:41 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b4cd42a7-eb44-4628-38ff-08d96750c328 X-MS-TrafficTypeDiagnostic: SJ0PR10MB4653: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:428; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ZPGtqG98KgE8JcHGDLxq/p4XNqQneO9kLSH3hkLILpS/Lh28AkrFMIp/wC6Rt/OnXPI8PtGfEnHzVM7bQ6cnUEOKeIrddqwkVnB0iuCAdJJsjHYcqPIIZzu+lXTJ0CC5EZSvQzMNa9KPcSUL/kbkHahiflRf/Y3it2DjBckx0gpoF4YYev+I02rjDrN+dc9hPDDeTJI9sFfJcLTbjNH7pLR41h2PIS8VTOc7MwCjVNCdXMkq1JrLDR3xq03KR1MpbFZY5vPPdBU1LuxcHHqEdrlpz3d8v4krBKSsnxQghtgyOCtl4gCgBddVvngm9dGWt2T9PfE78eYnHQRQ1MgfeY/nV0+OnRavmDUhrNzn+m2OtsmZXnzgU1s5aIN9LoBycdxl/qmIvP7FbqBpFvtpqYBPDJN7H/qxye+l+nzJUDnpinB8JpzuOH41ellZbceQihD4YmwqLs9j4YU1D2ddq5Tu+NIJ3ZExBkVPE/kd4wrw0Dz/o/8Xm6u8w4ANGSFmE8SjxBd+vmyOFoFPBz0RNJBvLQgZdVX9ZLnNdY7w39h1WnfAUkuLtWVILkdvyugxlmJ/JOA4tZMHLzuPd7+w4cng3tTRg8RxbaTOVhozdadK8lDQi/NQWEwYg6HJ6OhKXveFoWXCHTboNlY+/TEjxQTxMG7mcZfd+u0FqBML9AeLIe8C4bT3YZXkKdiRc+iYSIZWpEzVCcLoJCg6tmnOnA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(6666004)(66476007)(86362001)(66946007)(83380400001)(6486002)(6512007)(2906002)(52116002)(186003)(6506007)(66556008)(508600001)(8676002)(316002)(956004)(8936002)(36756003)(26005)(44832011)(5660300002)(2616005)(38100700002)(38350700002)(6916009)(1076003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: kTpYvv+h/gyyUk7+/tILhTiWhs5et3kO8T56JLjsfZbF+RYEH/394vpD2Cpy3nI0hYYz656DdDdFtiT7kXI0VBt+iZAq7lvIthyLdTIALQ8Moy3IcCuEtt3+l3aoLKWBwiHEt7dUgLmhW1PYZgDFBz71lqKLJKUcAg5wAIz/C0s8WDNKS9ylR58cugJ4fNDZ/4WLGc7+Mvcl2ZwURpKsVEdQ0U3wIUqyHzUo9VI1lV6pwsX1hKBaOj/w/3741rU0lncD+Xnes+aKhxL8H/TwNQYMKEjLgniH+yJW9xz4IBmGZAFwntdFqTN5P2VWQU86zTMJH+FKgT8H60Jx0M6XSBKq/UsuU6iMk/xvM50nuSRNciydZtiZdOBTSzEC2bg8xUiHe4LY6BSWuIOpN8aXzILvfO8G80OWq8SA9vY91jvg1vNyXjAoXPgUwiTuxpF+N8KQVoCBUG4xSDnqCWIIZFkzgXOKrAQzrNkEQQBAjgyTiDSDi4FEaADp1/BYWgUKeqhPQlaxkxOM4FBO2lofI912WmKUwzJp8nidOsY5O6X9EKWSNrFXn4CzUqqffRtyLprdDVWMts/NXq73yi8Z5QPmWTHIQmqcMK/sNGQ+56ctIMz8FC/03capGBUNJXFhbrGAm5yCfsmrlcb4pokWZQEzK+5XuPTutHcQ/xvrIpDZ56fJSaufeyfTQer/YJLgukWlM0sTiDm2XwIk700HeX60+eSm2ZQ5qEIFNW38BUVNrpUY/Vh5cZ8CaLgX1BLGrnt6ug7SWQU6LdT7mEHcJBfmgCf9DEBV5Mya1Uo/6qyqqysyBxDQ3gCESh9I6XZ5ZXSMpZoHU/Sv8/G+7S6Nhx4NY5ARyf5VMcboIsF/fuu45Yl/l95iRuZu9RA8apvL2WAsHTMXiDoeFO9Qjvlj9KZ/w9npnczJdYhbpKQ8G/80daqTuDki0TMkoMT0Mi+5bNdU6XAKHPXdp1JGeTQy97UBI/5zPxKP9helEnEqzTrZ5aBhY2llcs+vOX4qFAPNc076OwDlqJvKLAH4uYv4iFE86mE0leFP5Ucnj8MSsG30/QCaDvd8+ZGmP6Dq8YWRO3m05rVRnRMtjaNyQCRvEZ6gNcYl5SIkZyPd95XIgMmjOKD+aixs3I+EsXZBoiNW0DZQpzqSWuPcfDKqTc896wJhWcDVZFTJkALbuX6ZckqF36v92P5Kdd4YzI7z77Oo62obJGDCK91hN/j7VuihItRYHTsxtvPozhJMf2/Pu2q1RaInvwCn53tMVnCclI6GFXhchluxkGXXzlP1F8FK+THDueMX6swFor1qiInaGNNDayTqw3Tvz1ng1HW0fjtd X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: b4cd42a7-eb44-4628-38ff-08d96750c328 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Aug 2021 22:44:42.0884 (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: fxsazdlL8azqCpoIvrKDzeZFyN4l2JezGtpU9gWaGzK9HJ+qHil5kYd9m+mwraN6mQ4OQSf0SAWLhFgj661oTlKUMjRpNI0KUgZlkfPUFxE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB4653 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10086 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 bulkscore=0 malwarescore=0 spamscore=0 adultscore=0 mlxlogscore=999 suspectscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2107140000 definitions=main-2108240141 X-Proofpoint-GUID: sG4zjPIfWjFXPP-3b6gFtv2v5vSvaY_U X-Proofpoint-ORIG-GUID: sG4zjPIfWjFXPP-3b6gFtv2v5vSvaY_U Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org This patch enables delayed operations to capture held buffers with in the xfs_defer_capture. Buffers are then rejoined to the new transaction in xlog_finish_defer_ops Signed-off-by: Allison Henderson Reviewed-by: Chandan Babu R --- fs/xfs/libxfs/xfs_defer.c | 7 ++++++- fs/xfs/libxfs/xfs_defer.h | 4 +++- fs/xfs/xfs_bmap_item.c | 2 +- fs/xfs/xfs_buf.c | 1 + fs/xfs/xfs_buf.h | 1 + fs/xfs/xfs_extfree_item.c | 2 +- fs/xfs/xfs_log_recover.c | 7 +++++++ fs/xfs/xfs_refcount_item.c | 2 +- fs/xfs/xfs_rmap_item.c | 2 +- 9 files changed, 22 insertions(+), 6 deletions(-) diff --git a/fs/xfs/libxfs/xfs_defer.c b/fs/xfs/libxfs/xfs_defer.c index eff4a127188e..d1d09b6aca55 100644 --- a/fs/xfs/libxfs/xfs_defer.c +++ b/fs/xfs/libxfs/xfs_defer.c @@ -639,6 +639,7 @@ xfs_defer_ops_capture( dfc = kmem_zalloc(sizeof(*dfc), KM_NOFS); INIT_LIST_HEAD(&dfc->dfc_list); INIT_LIST_HEAD(&dfc->dfc_dfops); + INIT_LIST_HEAD(&dfc->dfc_buffers); xfs_defer_create_intents(tp); @@ -690,7 +691,8 @@ int xfs_defer_ops_capture_and_commit( struct xfs_trans *tp, struct xfs_inode *capture_ip, - struct list_head *capture_list) + struct list_head *capture_list, + struct xfs_buf *bp) { struct xfs_mount *mp = tp->t_mountp; struct xfs_defer_capture *dfc; @@ -703,6 +705,9 @@ xfs_defer_ops_capture_and_commit( if (!dfc) return xfs_trans_commit(tp); + if (bp && bp->b_transp == tp) + list_add_tail(&bp->b_delay, &dfc->dfc_buffers); + /* Commit the transaction and add the capture structure to the list. */ error = xfs_trans_commit(tp); if (error) { diff --git a/fs/xfs/libxfs/xfs_defer.h b/fs/xfs/libxfs/xfs_defer.h index 05472f71fffe..739f70d72fd5 100644 --- a/fs/xfs/libxfs/xfs_defer.h +++ b/fs/xfs/libxfs/xfs_defer.h @@ -74,6 +74,7 @@ struct xfs_defer_capture { /* Deferred ops state saved from the transaction. */ struct list_head dfc_dfops; + struct list_head dfc_buffers; unsigned int dfc_tpflags; /* Block reservations for the data and rt devices. */ @@ -95,7 +96,8 @@ struct xfs_defer_capture { * This doesn't normally happen except log recovery. */ int xfs_defer_ops_capture_and_commit(struct xfs_trans *tp, - struct xfs_inode *capture_ip, struct list_head *capture_list); + struct xfs_inode *capture_ip, struct list_head *capture_list, + struct xfs_buf *bp); void xfs_defer_ops_continue(struct xfs_defer_capture *d, struct xfs_trans *tp, struct xfs_inode **captured_ipp); void xfs_defer_ops_release(struct xfs_mount *mp, struct xfs_defer_capture *d); diff --git a/fs/xfs/xfs_bmap_item.c b/fs/xfs/xfs_bmap_item.c index 03159970133f..51ba8ee368ca 100644 --- a/fs/xfs/xfs_bmap_item.c +++ b/fs/xfs/xfs_bmap_item.c @@ -532,7 +532,7 @@ xfs_bui_item_recover( * Commit transaction, which frees the transaction and saves the inode * for later replay activities. */ - error = xfs_defer_ops_capture_and_commit(tp, ip, capture_list); + error = xfs_defer_ops_capture_and_commit(tp, ip, capture_list, NULL); if (error) goto err_unlock; diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c index 047bd6e3f389..29b4655a0a65 100644 --- a/fs/xfs/xfs_buf.c +++ b/fs/xfs/xfs_buf.c @@ -233,6 +233,7 @@ _xfs_buf_alloc( init_completion(&bp->b_iowait); INIT_LIST_HEAD(&bp->b_lru); INIT_LIST_HEAD(&bp->b_list); + INIT_LIST_HEAD(&bp->b_delay); INIT_LIST_HEAD(&bp->b_li_list); sema_init(&bp->b_sema, 0); /* held, no waiters */ spin_lock_init(&bp->b_lock); diff --git a/fs/xfs/xfs_buf.h b/fs/xfs/xfs_buf.h index 6b0200b8007d..c51445705dc6 100644 --- a/fs/xfs/xfs_buf.h +++ b/fs/xfs/xfs_buf.h @@ -151,6 +151,7 @@ struct xfs_buf { int b_io_error; /* internal IO error state */ wait_queue_head_t b_waiters; /* unpin waiters */ struct list_head b_list; + struct list_head b_delay; /* delayed operations list */ struct xfs_perag *b_pag; /* contains rbtree root */ struct xfs_mount *b_mount; struct xfs_buftarg *b_target; /* buffer target (device) */ diff --git a/fs/xfs/xfs_extfree_item.c b/fs/xfs/xfs_extfree_item.c index 3f8a0713573a..046f21338c48 100644 --- a/fs/xfs/xfs_extfree_item.c +++ b/fs/xfs/xfs_extfree_item.c @@ -637,7 +637,7 @@ xfs_efi_item_recover( } - return xfs_defer_ops_capture_and_commit(tp, NULL, capture_list); + return xfs_defer_ops_capture_and_commit(tp, NULL, capture_list, NULL); abort_error: xfs_trans_cancel(tp); diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c index 10562ecbd9ea..6a3c0bb16b69 100644 --- a/fs/xfs/xfs_log_recover.c +++ b/fs/xfs/xfs_log_recover.c @@ -2465,6 +2465,7 @@ xlog_finish_defer_ops( struct list_head *capture_list) { struct xfs_defer_capture *dfc, *next; + struct xfs_buf *bp, *bnext; struct xfs_trans *tp; struct xfs_inode *ip; int error = 0; @@ -2489,6 +2490,12 @@ xlog_finish_defer_ops( return error; } + list_for_each_entry_safe(bp, bnext, &dfc->dfc_buffers, b_delay) { + xfs_trans_bjoin(tp, bp); + xfs_trans_bhold(tp, bp); + list_del_init(&bp->b_delay); + } + /* * Transfer to this new transaction all the dfops we captured * from recovering a single intent item. diff --git a/fs/xfs/xfs_refcount_item.c b/fs/xfs/xfs_refcount_item.c index 46904b793bd4..a6e7351ca4f9 100644 --- a/fs/xfs/xfs_refcount_item.c +++ b/fs/xfs/xfs_refcount_item.c @@ -557,7 +557,7 @@ xfs_cui_item_recover( } xfs_refcount_finish_one_cleanup(tp, rcur, error); - return xfs_defer_ops_capture_and_commit(tp, NULL, capture_list); + return xfs_defer_ops_capture_and_commit(tp, NULL, capture_list, NULL); abort_error: xfs_refcount_finish_one_cleanup(tp, rcur, error); diff --git a/fs/xfs/xfs_rmap_item.c b/fs/xfs/xfs_rmap_item.c index 5f0695980467..8c70a4af80a9 100644 --- a/fs/xfs/xfs_rmap_item.c +++ b/fs/xfs/xfs_rmap_item.c @@ -587,7 +587,7 @@ xfs_rui_item_recover( } xfs_rmap_finish_one_cleanup(tp, rcur, error); - return xfs_defer_ops_capture_and_commit(tp, NULL, capture_list); + return xfs_defer_ops_capture_and_commit(tp, NULL, capture_list, NULL); abort_error: xfs_rmap_finish_one_cleanup(tp, rcur, error); From patchwork Tue Aug 24 22:44:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12456025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9D9E4C43214 for ; Tue, 24 Aug 2021 22:44:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 77D1461368 for ; Tue, 24 Aug 2021 22:44:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229521AbhHXWpe (ORCPT ); Tue, 24 Aug 2021 18:45:34 -0400 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:25936 "EHLO mx0a-00069f02.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230292AbhHXWpc (ORCPT ); Tue, 24 Aug 2021 18:45:32 -0400 Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.0.43) with SMTP id 17OJtIwl001072 for ; Tue, 24 Aug 2021 22:44:47 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=LbIV1lThQHlNsR5ZoHe22gwVN3UPS5rCBSLJlJyf0XY=; b=JJ5FH99ctzxSK9z7feKOaT5FL1QFoDyAy8Zl8y77IJlk3NCfW0XHDAYQsl7xYq+SCbyq vvWU+6O8jq9jsoKlB7pkCHfdVQ7ZeApotB9UOJ9wqjFQlKPl9/XZBn4Z9sgUHFg6gejz gRny7urG27UVfNtcDck/DmPsLAQuzFS2Tt1gZSp39D+K+OVX3YP3pwK2o8p+qJkOqNdQ 15R8IokvtZXtGHyMmXNUkuXXif9pd0AxmqKvGq+xEZjRJH3Z/AuENndAZv7AFmuGhBJ7 Z/FFVEVMX1S+UHQBwd97FlzypXIEixXXn9ZsG3f1FTxOjqpudt0PqWHSLTMm+tHeb+gb Jw== 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-2020-01-29; bh=LbIV1lThQHlNsR5ZoHe22gwVN3UPS5rCBSLJlJyf0XY=; b=Babs69t+T9z36UbtdOpYlcC08yi4wGSNUP/vQ8GUjPtHsW9XbMAQKEeZ6EyumVsp3JkY rjy3yJQf8jZxDzbwZU2yidxWBr3bEjcRBN8Xp7kjPCfMRwqLjZI9mHjIuO/CX8L2gSbB oAcez9GBM896JRg/LWvh39+J6I/n+YdqBFixY0MEgKLqpEcex1ozd3YUlKN93M4YMp8l ZzmIkDO/2TvRsjBI/8fqXQbCan1Iu+T4WN8QEzuQiMz3+Ab+RoLMzYbw4DGxL/T+bnEd V9+Q2Ai3ciSD4d2AMwcpp4bfoexB7iJJWxIm2C5sU1+pNtffeibL1R4C61AxsE4CUcG1 pQ== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by mx0b-00069f02.pphosted.com with ESMTP id 3amvtvt4uf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 24 Aug 2021 22:44:47 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 17OMfLTG138047 for ; Tue, 24 Aug 2021 22:44:46 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2177.outbound.protection.outlook.com [104.47.55.177]) by aserp3030.oracle.com with ESMTP id 3ajqhfehfv-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 24 Aug 2021 22:44:46 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=g7aWOekPzTNh0/MLAIHgBqCUVP+VJLtFFN6IQmqkjuGZMlF3M+tWxpOtMUfZ2CAaDYtaI8u12pQoaoKtP96uGP1h84rMaU8FLK3zjUdC4O0sRb7jisyjWXu1OoT+TCkyGNjfBW9ZU09RwSgymehWz1NDmcw9jWtY0eswj7KkLBHXBEUETb5xyU/beryNPYGRdeU0Lf6Y+X0UnIy+rxdenFn/tG+GMPKAbHkh8Kr9eX2e80p6r0FDZoPJ47mzMCpzW2sGufxACHpmCjJisdNDfgjdJKeubiPBNKfv2lyzas1YAAYLehi4gqHb/UGHsgCV96uKCoeHaCLoEnQXCAUJqQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=LbIV1lThQHlNsR5ZoHe22gwVN3UPS5rCBSLJlJyf0XY=; b=E0v9YaLtne+YNX/x46sON3eDvMGDoxfYxqJz2a4fb5WANy6Ai7xXHxQE4bTL3yTH25Q0WsUlG6iMkXvGRPxpmwbKt3nVJrFL3D1AdDuK6keQzCCLO4sYrU0kuNUAe0Pz3D9takBC4/W5dt4kfo32p0cicEZ+hk+R/ju90NNaIhaOiyICeASDDYrzQ/IGVQSr1zKpXXpl2K8wT92nH8Qz1BWvPGF7arhAytybJPi7sNSeUy3hZvX9KLFr+wkC5EHVPNT9LV1j3NKD5Ga15DIW5Nb5EeIg+B3ZdCYeqzptLqozTIm61BBfk223+hcyxpN3C4G4uPxMPKRR9XxYkcaFgA== 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=LbIV1lThQHlNsR5ZoHe22gwVN3UPS5rCBSLJlJyf0XY=; b=DlqueNYqGD+Fuv/KPpjJa6Tz5HHg7/uYt/DjF8SK7D325bNafCtNIBbFK7NiFr6Y/P2aqcGJ1D9sM9atLas0hhEa4BtHuussmAHVNZupG8tytaaqWyViG0sCVuvJM+e/csCDD2da6vxRbDBMR0MXVZTcqaZuRVmvdOFAJz35UYI= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=oracle.com; Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by SJ0PR10MB4653.namprd10.prod.outlook.com (2603:10b6:a03:2d7::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4436.19; Tue, 24 Aug 2021 22:44:44 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::7878:545b:f037:e6f]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::7878:545b:f037:e6f%9]) with mapi id 15.20.4436.024; Tue, 24 Aug 2021 22:44:42 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v24 03/11] xfs: Set up infrastructure for log atrribute replay Date: Tue, 24 Aug 2021 15:44:26 -0700 Message-Id: <20210824224434.968720-4-allison.henderson@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210824224434.968720-1-allison.henderson@oracle.com> References: <20210824224434.968720-1-allison.henderson@oracle.com> X-ClientProxiedBy: BY5PR17CA0012.namprd17.prod.outlook.com (2603:10b6:a03:1b8::25) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (67.1.112.125) by BY5PR17CA0012.namprd17.prod.outlook.com (2603:10b6:a03:1b8::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4457.17 via Frontend Transport; Tue, 24 Aug 2021 22:44:42 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 28367d11-3bc6-4c5f-6c41-08d96750c367 X-MS-TrafficTypeDiagnostic: SJ0PR10MB4653: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: EMhOq8jyVQex8RlIu2yikRa5c1aOEEn9hQ9ewkSIHYFoH+ILuuaBPuJ0YnFBMwBPmaRKWuK3T59Tux7EL6JfUlBkrRrHyf2FMQ8qS0M3bMYPnQVp9wOwe46HYsJ8t+g+LNorWiqkxpmZdFS5Tl28o/dreE49uVG3u8HfpB9ogij8iuhxT8UCuctSDeWDuHIygb1oZy/1SqGTOge+xWocpALQknR4j1/WA38bsHhzPRB2w+iRKQ3J02lmcK/jf9TxIYuiwzMTWvE1DWDeCY4nhxCpDBD5e5VA0a6is69RMUCCLKKLWmawkj+473Y11P9vNvtpn0sBTmtudtNK8OJZYt+PVM7jsnJHja7IVRXedi+UJ0BZZHTjZYhJgHc5UQNKlYGM2vqfXfC470CShbay31BnSB4dLWjZVO9OoD6BHTsVOvipSnMM4sm/gs/77bX/hH6UjGCwatUBUgcaPdSyTYjbxFxwW0zNqFirCwJLQQqyuvslZ1F6kATqrUtCQd1wn/qgwvlH/0BQo5AzkogmV5Ny2/eaOSQMP7LQQmUI/kGMGKIfu3dCTrsAdWFI6hhSJCHBMHAidlVB4k1lBfnXJGB6MTh4t7n1jGprBN7HN5L2Inhsm+z0VB2qb+w7t2h+kSZEUrtSql6RLIuG8KMXIdL/9gqSxpeZqSCZK9k3KN06H0eGV68hraA/qklQvld7MecuPkf/WGaaTy8Comm3ng== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(6666004)(66476007)(86362001)(66946007)(83380400001)(6486002)(6512007)(2906002)(52116002)(186003)(6506007)(66556008)(508600001)(8676002)(316002)(956004)(30864003)(8936002)(36756003)(26005)(44832011)(5660300002)(2616005)(38100700002)(38350700002)(6916009)(1076003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: KLC74rOhFGkKAbVw1BZ2e05f+tcJGhUbV/e5YwLXQLAtyH19zRT2iZvydvvQd+ezD4XyvECQTi0tdVhLurj3Kt2DD/0gKWbUgJSf8sJaMxJe2HsRSELbjNGxHOcgE0ouglTzmbul+o07HnHLvnznEww52lFnVGBxUSEEi8iHAgTQpxe7UqWe8KC9sAoG7z3BbSLrCmi1kAILcwnUTjpKuA4AwgSIwpf5LebLoWLkQDAqG0m9+e53fU6yZROhK/O8em2XSHVcNW6cmZlxTvy1Qe3tHMmjs4FuBf0VlVinpXjOnchqRSDjrXz8w1G1MSC98Itf3memzDUCiaGUXtshuC2Td82xc0C3/EpYqAjY53RJJazqOJwjVKzrTmrJu9LpiZjfEkocons01AN3bZb+es67i10dvxr53OHaz4I+nXehDfPnYluXVxYuY/fYuOZxJtYp0nBWthvfcN4sU4C3N0OJxVszv83VYXAqbnBuYm+/rEM41nej5QaVRcq6RvtImrcN9H9uzIrUYrntX0r/BqV0V2zsW+a3PdcLX3/ZZjdWZbS2GnQYb8TaaD1fnjNpUjoiyV+EMFXfycQg+CdtLXYkBM6rH4dyPMlHDfPMyQNRmg5Gqcotx4svjnl4t0xWyxoWEy01LrP/XDfeM9p8MMYzpwBIDsFKvSkuSi3jtzhMeO3G2HTvuM58zmYKWU/oevJqMkNSnsIyHQJo4qwFZiBeglYXEUCr164Pu537J1daUbfbl2b/ScT8TEBBprnbdUrZXz1kO9i+P25zgWvijqJQJfzlfqWPFZRv+XzZpBkNMPt54i4Uiu5Rx7mVwWz3pKnyNFfe+Xn5pn+s0E8wjbzo6geUlcCpVSpijR5ukKlSsmAw72z+G0hl9FG9IPhqwsk5EWzHKz7cv8xFir+18GlYbIxcorJnUDJlSUgMU/zXPRT67BJrLE68iffkrfg+ZrPYw2+ztoQtIcP2rIF0k7gDv21j6Px16Q/WLEpY+LEomcsxg0RgxXUCWSugcJzwHcZ2aFyYSFmjputS4UMj5Un6XZTU3kuA43vQQk886OhtKw0QFJbFalZ1hG83gDNjJQ1QRXrnNL3SFc9DG4HXiSYrhflTQCZrxPFOElu6oHkI72t7hBVpF+aYdhNsgaG9m9Y7WaOJjFmK4Ct05eNaPxBeV+iSlSCjLj+7ohkiARknUvyma8dx1bBoEMmFnqk6lC4OQvLeSQ4o7Z96JZKFouTXGjB2oub5qJKzr9NU7vS8W1LcYveiWc02izxQxo/KyV3jbR3AH7QQ/RD2/dIb6ZQqa3wspacF38pJxrv2otl5ctKjlt5IewcXxxtlp54q X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 28367d11-3bc6-4c5f-6c41-08d96750c367 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Aug 2021 22:44:42.5494 (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: DReWzfweGdKhg63SGC435nrrKb2BaoUWRFKuOfd3b15Fo51lhi4vu9VA3BN43fOH66RlGtS6kNcIx0bkQDYCWujCvH/ahoH+rOICOKPDQZw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB4653 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10086 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 bulkscore=0 malwarescore=0 spamscore=0 adultscore=0 mlxlogscore=999 suspectscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2107140000 definitions=main-2108240141 X-Proofpoint-ORIG-GUID: fwEKPIvscfPhncNBKYSYoCHLy_vFAw3K X-Proofpoint-GUID: fwEKPIvscfPhncNBKYSYoCHLy_vFAw3K 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 --- fs/xfs/Makefile | 1 + fs/xfs/libxfs/xfs_attr.c | 5 +- fs/xfs/libxfs/xfs_attr.h | 31 +++ 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 | 453 ++++++++++++++++++++++++++++++++ fs/xfs/xfs_attr_item.h | 52 ++++ 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_recover.c | 2 + fs/xfs/xfs_ondisk.h | 2 + 15 files changed, 600 insertions(+), 5 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 50b91b4461e7..dfff81024e46 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -24,6 +24,7 @@ #include "xfs_quota.h" #include "xfs_trans_space.h" #include "xfs_trace.h" +#include "xfs_attr_item.h" /* * xfs_attr.c @@ -61,8 +62,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 +165,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) diff --git a/fs/xfs/libxfs/xfs_attr.h b/fs/xfs/libxfs/xfs_attr.h index 5e71f719bdd5..aa33cdcf26b8 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. */ @@ -454,6 +459,7 @@ enum xfs_delattr_state { */ #define XFS_DAC_DEFER_FINISH 0x01 /* finish the transaction */ #define XFS_DAC_LEAF_ADDNAME_INIT 0x02 /* xfs_attr_leaf_addname init*/ +#define XFS_DAC_DELAYED_OP_INIT 0x04 /* delayed operations init*/ /* * Context used for keeping track of delayed attribute operations @@ -461,6 +467,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 +485,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 +518,13 @@ 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); #endif /* __XFS_ATTR_H__ */ diff --git a/fs/xfs/libxfs/xfs_defer.h b/fs/xfs/libxfs/xfs_defer.h index 739f70d72fd5..89719146c5eb 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; + /* * This structure enables a dfops user to detach the chain of deferred 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..879a39ec58a6 --- /dev/null +++ b/fs/xfs/xfs_attr_item.c @@ -0,0 +1,453 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (C) 2021 Oracle. All Rights Reserved. + * Author: Allison Collins + */ + +#include "xfs.h" +#include "xfs_fs.h" +#include "xfs_format.h" +#include "xfs_trans_resv.h" +#include "xfs_bit.h" +#include "xfs_shared.h" +#include "xfs_mount.h" +#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_buf_item.h" +#include "xfs_log.h" +#include "xfs_btree.h" +#include "xfs_rmap.h" +#include "xfs_inode.h" +#include "xfs_icache.h" +#include "xfs_da_format.h" +#include "xfs_da_btree.h" +#include "xfs_attr.h" +#include "xfs_shared.h" +#include "xfs_attr_item.h" +#include "xfs_alloc.h" +#include "xfs_bmap.h" +#include "xfs_trace.h" +#include "libxfs/xfs_da_format.h" +#include "xfs_inode.h" +#include "xfs_quota.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; + +/* iovec length must be 32-bit aligned */ +static inline size_t ATTR_NVEC_SIZE(size_t size) +{ + return size == sizeof(int32_t) ? size : + sizeof(int32_t) + round_up(size, sizeof(int32_t)); +} + +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 += 1; + *nbytes += sizeof(struct xfs_attri_log_format); + + /* Attr set and remove operations require a name */ + ASSERT(attrip->attri_name_len > 0); + + *nvecs += 1; + *nbytes += ATTR_NVEC_SIZE(attrip->attri_name_len); + + if (attrip->attri_value_len > 0) { + *nvecs += 1; + *nbytes += ATTR_NVEC_SIZE(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, + ATTR_NVEC_SIZE(attrip->attri_name_len)); + if (attrip->attri_value_len > 0) + xlog_copy_iovec(lv, &vecp, XLOG_REG_TYPE_ATTR_VALUE, + attrip->attri_value, + ATTR_NVEC_SIZE(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 of the specified size + */ +STATIC struct xfs_attri_log_item * +xfs_attri_init( + struct xfs_mount *mp, + int buffer_size) + +{ + struct xfs_attri_log_item *attrip; + uint size; + + size = sizeof(struct xfs_attri_log_item) + buffer_size; + attrip = kvmalloc(size, KM_ZERO); + if (attrip == NULL) + return 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; + uint 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; +} + +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, +}; + +/* Is this recovered ATTRI ok? */ +static inline bool +xfs_attri_validate( + struct xfs_mount *mp, + struct xfs_attri_log_item *attrip) +{ + struct xfs_attri_log_format *attrp = &attrip->attri_format; + unsigned int op = attrp->alfi_op_flags & + XFS_ATTR_OP_FLAGS_TYPE_MASK; + + /* 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 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, +}; + + + +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; + char *name = NULL; + char *value = NULL; + int region = 0; + int buffer_size; + + attri_formatp = item->ri_buf[region].i_addr; + + /* Validate xfs_attri_log_format */ + if (attri_formatp->__pad != 0 || attri_formatp->alfi_name_len == 0 || + (attri_formatp->alfi_op_flags == XFS_ATTR_OP_FLAGS_REMOVE && + attri_formatp->alfi_value_len != 0)) { + XFS_ERROR_REPORT(__func__, XFS_ERRLEVEL_LOW, mp); + return -EFSCORRUPTED; + } + + buffer_size = attri_formatp->alfi_name_len + + attri_formatp->alfi_value_len; + + attrip = xfs_attri_init(mp, buffer_size); + if (attrip == NULL) + return -ENOMEM; + + error = xfs_attri_copy_format(&item->ri_buf[region], + &attrip->attri_format); + if (error) { + xfs_attri_item_free(attrip); + return error; + } + + attrip->attri_name_len = attri_formatp->alfi_name_len; + attrip->attri_value_len = attri_formatp->alfi_value_len; + region++; + name = ((char *)attrip) + sizeof(struct xfs_attri_log_item); + memcpy(name, item->ri_buf[region].i_addr, attrip->attri_name_len); + attrip->attri_name = name; + + if (attrip->attri_value_len > 0) { + region++; + value = ((char *)attrip) + sizeof(struct xfs_attri_log_item) + + attrip->attri_name_len; + memcpy(value, item->ri_buf[region].i_addr, + attrip->attri_value_len); + attrip->attri_value = value; + } + + /* + * 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; +} + +const struct xlog_recover_item_ops xlog_attri_item_ops = { + .item_type = XFS_LI_ATTRI, + .commit_pass2 = xlog_recover_attri_commit_pass2, +}; + +/* + * 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; +} + +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..ce33e9b5a9d3 --- /dev/null +++ b/fs/xfs/xfs_attr_item.h @@ -0,0 +1,52 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later + * + * Copyright (C) 2021 Oracle. All Rights Reserved. + * Author: Allison Collins + */ +#ifndef __XFS_ATTR_ITEM_H__ +#define __XFS_ATTR_ITEM_H__ + +/* kernel only ATTRI/ATTRD definitions */ + +struct xfs_mount; +struct kmem_zone; + +/* + * Define ATTR flag bits. Manipulated by set/clear/test_bit operators. + */ +#define XFS_ATTRI_RECOVERED 1 + + +/* + * This is the "attr intention" log item. It is used to log the fact that some + * 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 calling functions xfs_da_args. 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_attri_log_item *attrd_attrip; + struct xfs_log_item attrd_item; + 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 8783af203cfc..ab543c5b1371 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 0ff0cca94092..f81e5d55341b 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 f6cd2d4aa770..4402c5d09269 100644 --- a/fs/xfs/xfs_log.c +++ b/fs/xfs/xfs_log.c @@ -2157,6 +2157,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_recover.c b/fs/xfs/xfs_log_recover.c index 6a3c0bb16b69..c248fd5cf9ea 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 Tue Aug 24 22:44:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12456023 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id ADDC4C43216 for ; Tue, 24 Aug 2021 22:44:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 943A161368 for ; Tue, 24 Aug 2021 22:44:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230293AbhHXWpf (ORCPT ); Tue, 24 Aug 2021 18:45:35 -0400 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:28566 "EHLO mx0a-00069f02.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230292AbhHXWpf (ORCPT ); Tue, 24 Aug 2021 18:45:35 -0400 Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.0.43) with SMTP id 17OJtEOs001055 for ; Tue, 24 Aug 2021 22:44:50 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=DVh7eBi/ZV4ynP5Wciy32Lz9Ep6dkrzfquYLT7uBew4=; b=oh3Y4r+6h53Za/mx3zFWZljgx4QHwrYUaTAVrPmxORW07/o5POUPtODN/hXQjWNXbgOS G4pC6nc0WwKHFGKVdXMKXpWiE+aFBtN2jIHl8Ggwb1qodfOs5uuuaReITwqx9kj+UfdZ /IB9D1/E8wGPyJsh6BjBIi+nGPr08hcgFavoV16rKL4G6SM9pg/9Z9m9Vx6ZBE3ieMoH jYyO95LQ9DT0raMaFDtWYEjh8RiRAG22uBQrdoq9IS9JWp/LghudQJaeIZ4S0ZM4P+Cz UpfLHCsD17bKyfyp+DhzsjfTa3rOa0u5knCYjS+5uI4AYEIln+sjE58xcpXwbxoKiTjn EA== 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-2020-01-29; bh=DVh7eBi/ZV4ynP5Wciy32Lz9Ep6dkrzfquYLT7uBew4=; b=yTLXupQ10/HggsXM9/kNVwjFivVYX5u3sbkM3Zec0zasTsn/R1dJ1ZSvC0SwtEVE/W+4 YPefdkVhj0jMkz7/9E8k0zdHsvuygp4kFIbdnW6HJD+4LHQl2mqBHmrqHEKl08tPgSsp 9SHB8IBMxvi396EXuubevxMBCqBbN4VgLeGYcjDztxxiUuWHRDnR35u7HduuAxq652lx vuih2BtZmEh5tmnnyfplJWv7/R9v56pn8AJ4J7Sd3ierH9It1zP/MoAo5El+pPEOSj42 rqcfVTHbm8zNp5K9goNjw7zmHAkSEwqecyIwrxa0ENoaI6TbCuPaOPpmD22VRTcbpScE CQ== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by mx0b-00069f02.pphosted.com with ESMTP id 3amvtvt4uh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 24 Aug 2021 22:44:50 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 17OMfYQ0025324 for ; Tue, 24 Aug 2021 22:44:48 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2177.outbound.protection.outlook.com [104.47.55.177]) by userp3030.oracle.com with ESMTP id 3ajpky4yms-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 24 Aug 2021 22:44:48 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KROI1RJEPfVtS2hGt0ndP9SCRE+xHo4vbXAgDqM1UErGNhAYGBV57S6QQ/IJnBUKAhNywDZFxA/YNXmW0YGfF3R3lPcMurisPcmPHmnbcrl/86OsoScN36DpY7JR9auhAkWKQorg6be9ld6WOO1C6rPcjhJsbpgeyX/CT/1+1JLpv0KIvoFNkQVxpbXO8Ze2UJc6PHECRLqg77rVdv96zJvnmVGl0s1UzQcEFK8eBxU3EAARXiJwsSFJq2mcYJj8ng3TYfgwzwfV1rQYiV3ZEbdgYXCr4vOa8iSpmeclrrXp7e41AdcWvg4SQT+c1JzJpjaRRhRt4OuIk1Fkv/nXxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=DVh7eBi/ZV4ynP5Wciy32Lz9Ep6dkrzfquYLT7uBew4=; b=XC3pmRtEdnxxNTiQrBftbgwzpKRJ1n2c0QUZWyJXT4TTn73Y6GAYh2ChWZL0jbIbcdu0DL+sjz14x7nPp/MMtNAjdbAh+Bf2JdovsWf797vzO08nTY4HhuAsk1yWAPAbzwb0dR+r6ub5aySZBMVlwv5Eren51RKGdxdd0JV4mLs85Vp0PiOWEx/wSHiQ+NH7oJ93Dd1P5sQuk8V+XA/SndCPrTp8wFCEuniY62L7u5UFesZwvpHL0Kmgufxbev0PVKvd8AZAAfHFUBp9pPhyKQzkq8vQpmAfJVZhx2+Lly8on3V57SPHSsbW+ywxCH6el+GONQ1ZxLY2FqRIx3rNEw== 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=DVh7eBi/ZV4ynP5Wciy32Lz9Ep6dkrzfquYLT7uBew4=; b=0JsWd/rrcPvF+VM4DMUdQomNWGAVEfWqIGZJdzCQ9/xtSCCNxMQo4eLdYwPdc93L3dYtBOikK3+UeJw/ksvCNbdUEY9EgNuy21x8WVPTcsCHImPkAmR3tHzOXFSx7MvATtjU/CvBKb9LAHsKdDM9WS1u5K9Jp5aG9WwmSPDsxMI= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=oracle.com; Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by SJ0PR10MB4653.namprd10.prod.outlook.com (2603:10b6:a03:2d7::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4436.19; Tue, 24 Aug 2021 22:44:44 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::7878:545b:f037:e6f]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::7878:545b:f037:e6f%9]) with mapi id 15.20.4436.024; Tue, 24 Aug 2021 22:44:44 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v24 04/11] xfs: Implement attr logging and replay Date: Tue, 24 Aug 2021 15:44:27 -0700 Message-Id: <20210824224434.968720-5-allison.henderson@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210824224434.968720-1-allison.henderson@oracle.com> References: <20210824224434.968720-1-allison.henderson@oracle.com> X-ClientProxiedBy: BY5PR17CA0012.namprd17.prod.outlook.com (2603:10b6:a03:1b8::25) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (67.1.112.125) by BY5PR17CA0012.namprd17.prod.outlook.com (2603:10b6:a03:1b8::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4457.17 via Frontend Transport; Tue, 24 Aug 2021 22:44:42 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 240f73f6-3d36-4012-686f-08d96750c3b1 X-MS-TrafficTypeDiagnostic: SJ0PR10MB4653: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:207; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: kGPs4buA02nEAji5M+8pc4sJpmFB/m32HR5Gg3ESYoLNIUcL4XgI8msSAqPYKbri2NSDA2MdGRZ8VzEmEeGzH/YwFu15gG+Ln/lKXHmK6na2vATtJ9R+2mtINQGge3Xolhp5hCMhw0h9W5tdIjdhjITwPbfDVtEqm0e5pgrVq4+Krlm1gd6XYDRFXmjJruMFf8/XcxnCmw7mE/3t4sz5+OUHFKfNzuLDDCJeYMcRiQESwAa5YBLY27f7LiEMN0TAC0mEZwswMHZJjg9AlSJAtA/H3wd21mue7D1Fv0RVyHcIW3S0VISoBbr5SW6Sd024Y/WHZOGqqbSa/MrbqPGgwzFjB7FAISuwAKT3hwywwhLuFbI7mE+zH1DAirU8cp4je4FnkJOSAxnbi2iOkQGAQJTUd2iSYgZ/+Q7rzTKIHluKa2jfHeG+YyxPFPwG51Nw3zg2DC6PvYVrro9V0vPzz11tZbEVt3uApHRQQaOt67XSXSG2MO3RLyagFcNW6RawvaowE63JP+V/Qea4OhNVNnLbdIPHNgr3RxlegZ45Ym8HwN+NYniPS7b2Oocx7pU2us6KDFWUEf6HxQe/cLZ0YqS/5fMoafjCsCh2JcJ4lsjNpC+/ZZ+Tl1TnylZ4fAiqLYdSHAjjwCleQBX06QwU1Lq/vGI1czQTPexq49S/jKHKwCr++7cFLuA5CDPJ6zXkjRSZ6WlTfirfs2LwhsmbWw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(6666004)(66476007)(86362001)(66946007)(83380400001)(6486002)(6512007)(2906002)(52116002)(186003)(6506007)(66556008)(508600001)(8676002)(316002)(956004)(30864003)(8936002)(36756003)(26005)(44832011)(5660300002)(2616005)(38100700002)(38350700002)(6916009)(1076003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: fEo5ob5x0kFxg3EMDlcLOW4QSxazXf9zuMKSmvlydJ/KY1xF6zvbWe+S8fXLdXXlx5gzRVs0BO941SfGT0UiMiwd7Dl7GlEIruI1TEimgOhAnAUcTjWNbStfGA4uMuMfcsv0k+8EWfM1HRFXD7owtrNY5Ye9lmvqWdUpS5zE8JoQT2BEjz/DzxhDiPr+Jk3SGbMK8hGKN6C4TrI54f89FSCwg8HOrX2DiXvlULPQhyUUb3jtmiaK6c580fIrnM/rmNHMj1cRfIgK9H6ZAjr8k0lobtAfQAF5yhVJ58voJ54XYuYbXon4OLAI4lC/UWCWLvCNhJWk7THEs0d5Of+dzGGu1wdrVH373yvbgrlzxjKAdhzUtwCdxQPrOsXGXmSVgaG0CFIcj2ZMqspQYVFmuJEfHbTa7G/Ay/OKzy/C8EOynuCAXnkMN0PTgOrI7HMaOugaXLB/UNMrI/n03B/i6HL+fKZRWaYwTuvknYiDIiapFPvE4BPtQaOObcN2rBnKIAm1dxk4VD7FlwCVMfQUU55gOfvkhxTs34W5iP/hUj6tJ4Q+QgVIHg+jz4fXUC3nLo8bDi0N7au8cL1j84FRB3P0OGOmxKHbvnWmdqxyUSJYFYebk1aK3eOXpc+QqdX8CoKOulfyYdDHNaIvQIQX3Wnb1W/JQBcnonYMArsW3yHhz0DQKPZMEnLMDHTu1YDeyDYjgqd5zIR+RaTa0viaR45UsDf+EXZ3rA38wgX8Ph1BUFPdrEkxvOpp+KfG6khrKWqw6x+PJ+LpCOqYJRT0Si0s24RM4PySp3+53EHNd7bId4rKfZ2cBXBBDVVeM9afEseyuKYwvNuVzcRDEehR6VZ/+C/HuZU4IZUzij+tnJlpAIrEm0guD4IpBqgn32B5bCmZQmVartOGpP01xZsv2GMhSqIsMzyGCkK4ZiVEVLsKUttF/ED0lcjTPknuFmtZdX5JVocq2LSHiVJePXU+Jwe64kuIAHyWVm4o8rKarm5cnSq/Wm1DBWbOMv5pbMgCSwntIb2HJk2OGv45mAu6iX8LBIAtQgjuWgptG4hrwrm3eK0QuSm6Z/Kwtq2cZaRRWdBxSu2PHY7Hu5UWtOM+GzRxQEpX6AGjrq2v2xsPM5WvsqMj65HiqGnousPG231KKQJdhMl3k6C2ycqiPUW1DoYzo8493Mhv4bvzvvtag6Ir8sth74XJcYRmA0Lv6QjuGsjKuaGQ/SGBRFR2DGFE4iC0pAq3jJ71SQ/6L1505soH3TDDfMFnq7whbPWc8u8sr3ELXHF8UR6bI3FkgRfF9734A786XCutP9KGeeWLe8qLeSmrdrt025gbH5dFVKoT X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 240f73f6-3d36-4012-686f-08d96750c3b1 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Aug 2021 22:44:42.9268 (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: NQsMjBHdnDE7ic/Krx+7u8Ny3AJNAXqCLolwGXhlpguapVL5/3IiCORtS2flmbKq8+6TYBe7vwxx4IHVSV16Sk9hLMhRzVKPE2JGDqTAItM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB4653 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10086 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 phishscore=0 malwarescore=0 mlxscore=0 bulkscore=0 mlxlogscore=999 suspectscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2107140000 definitions=main-2108240141 X-Proofpoint-ORIG-GUID: 357oV0BzIncG-vpjNH9811oBjyPMxCUZ X-Proofpoint-GUID: 357oV0BzIncG-vpjNH9811oBjyPMxCUZ 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 --- fs/xfs/libxfs/xfs_defer.c | 1 + fs/xfs/libxfs/xfs_defer.h | 1 + fs/xfs/libxfs/xfs_format.h | 10 +- fs/xfs/xfs_attr_item.c | 358 +++++++++++++++++++++++++++++++++++++ 4 files changed, 369 insertions(+), 1 deletion(-) diff --git a/fs/xfs/libxfs/xfs_defer.c b/fs/xfs/libxfs/xfs_defer.c index d1d09b6aca55..01fcf5e93be5 100644 --- a/fs/xfs/libxfs/xfs_defer.c +++ b/fs/xfs/libxfs/xfs_defer.c @@ -178,6 +178,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 89719146c5eb..d70525c57b5c 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 2d7057b7984b..2e0937bbff6d 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,12 @@ xfs_sb_add_incompat_log_features( sbp->sb_features_log_incompat |= features; } +static inline bool sb_version_haslogxattrs(struct xfs_sb *sbp) +{ + return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5 && + (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 879a39ec58a6..c6d5ed34b424 100644 --- a/fs/xfs/xfs_attr_item.c +++ b/fs/xfs/xfs_attr_item.c @@ -275,6 +275,163 @@ 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_trans_attr_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 delayed 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; + + attrip->attri_name = (void *)attr->xattri_dac.da_args->name; + attrip->attri_value = attr->xattri_dac.da_args->value; + 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 (!sb_version_haslogxattrs(&mp->m_sb)) + return NULL; + + attrip = xfs_attri_init(mp, 0); + if (attrip == NULL) + return NULL; + + xfs_trans_add_item(tp, &attrip->attri_item); + list_for_each_entry(attr, items, xattri_list) + 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_trans_attr_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, @@ -306,6 +463,30 @@ xfs_attri_item_match( return ATTRI_ITEM(lip)->attri_format.alfi_id == intent_id; } +/* + * 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; + uint size; + + ASSERT(tp != NULL); + + size = sizeof(struct xfs_attrd_log_item); + attrdp = kmem_zalloc(size, 0); + + 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; +} + static const struct xfs_item_ops xfs_attrd_item_ops = { .flags = XFS_ITEM_RELEASE_WHEN_COMMITTED, .iop_size = xfs_attrd_item_size, @@ -313,6 +494,29 @@ static const struct xfs_item_ops xfs_attrd_item_ops = { .iop_release = xfs_attrd_item_release, }; + +/* 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, +}; + /* Is this recovered ATTRI ok? */ static inline bool xfs_attri_validate( @@ -337,13 +541,167 @@ 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_mountp; + 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, attrip)) + 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->op_flags = attrp->alfi_op_flags; + 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_trans_attr_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, ip, capture_list, + attr->xattri_dac.leaf_bp); + +out_unlock: + 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; + int buffer_size; + + old_attrip = ATTRI_ITEM(intent); + old_attrp = &old_attrip->attri_format; + buffer_size = old_attrp->alfi_value_len + old_attrp->alfi_name_len; + + 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, buffer_size); + 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; + + new_attrip->attri_name_len = old_attrip->attri_name_len; + new_attrip->attri_name = ((char *)new_attrip) + + sizeof(struct xfs_attri_log_item); + memcpy(new_attrip->attri_name, old_attrip->attri_name, + new_attrip->attri_name_len); + + new_attrip->attri_value_len = old_attrip->attri_value_len; + if (new_attrip->attri_value_len > 0) { + new_attrip->attri_value = new_attrip->attri_name + + new_attrip->attri_name_len; + + 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 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_recover = xfs_attri_item_recover, .iop_match = xfs_attri_item_match, + .iop_relog = xfs_attri_item_relog, }; From patchwork Tue Aug 24 22:44:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12456027 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B579CC4338F for ; Tue, 24 Aug 2021 22:44:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 96C8961357 for ; Tue, 24 Aug 2021 22:44:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230292AbhHXWpg (ORCPT ); Tue, 24 Aug 2021 18:45:36 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:47624 "EHLO mx0b-00069f02.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230388AbhHXWpf (ORCPT ); Tue, 24 Aug 2021 18:45:35 -0400 Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.0.43) with SMTP id 17OLngIf000895 for ; Tue, 24 Aug 2021 22:44:50 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=Fr8oDlcw9bUSh+DcCl4JR7UZiAUvVmGrJpqhT2uXtO4=; b=POBb6QZEuqeil/CCvMZD1/XyUq1QQWmQRrU47Sy2wd3N3pbwr/B9IAG0S8z8kTt06Cad FTFY5kywlZd0G17x4xu5uPo9MyIC8jMODvyxpLmnFqyG7Hv8S0Lcp40wbKKB+D521OzW idirWeVcCovnlm02WIdcz4clqSJoG9LRJyQnK9gZmYVhidh0FLpA2XPhlWNTggY0UTr1 ynoLhHswO31YcF8z9wPeLQ3iEH+u+nw1D4FxosP/7BewsEbzChB3xKl0LTlRj5nXO5jh wmwl+EyPmkEUNAvonJUnwlg3UM7PRhsPjb7A0M1EWBHEN76p01+P3Q/BK43Twpi1xkij 7g== 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-2020-01-29; bh=Fr8oDlcw9bUSh+DcCl4JR7UZiAUvVmGrJpqhT2uXtO4=; b=c5AD5PrRpnlGoRjs5HUYZmKRWGw8WOIOvmDaWYsWuW/7o5u5R4dr00xWAmZ/vGVuKBUZ r8+yofyDIPzhO63+iUCUm/EKuuXkP+Gy13Ff+k8PerzqlrMn9GAhbaAqvEzFh/S+rumy YvI1fNBghYmdkP1Kq1Ixu7e2Pp+h0ONXD0h6fdCsmiDHqMyD5FhlnipMwZ4xsBGNlrji 6QOFCLMmwMwQ1BNgOKYiyQARDeIdmhl4+NVR4eIbuJVRXQnRRTOKxgMKx8mZ7Z4CWq5t ws5JLLC3GeXFCUYXFQdozV673cT5n+vnGAtpJ0Y3d9N3U6ZZZ0CGyIEPNm2sPY6/4X9m +Q== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by mx0b-00069f02.pphosted.com with ESMTP id 3amwpd9wfc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 24 Aug 2021 22:44:50 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 17OMfYQ2025324 for ; Tue, 24 Aug 2021 22:44:49 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2177.outbound.protection.outlook.com [104.47.55.177]) by userp3030.oracle.com with ESMTP id 3ajpky4yms-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 24 Aug 2021 22:44:49 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gaCmI2rQ4m71gqBaFThKfzYqW4HMnIW2wn6RFYPq8BRV0q3eW4pp5vEfR3LEOQ9lrmNiQZxtfUbA6HjhDF4jKFGWhlzp6CJwuIQYwZ+Ap+z18w10mamS+TS1Q0BnvyENwNM6gC+7wtEVe+NPhMOI3ZKmc3pKiGQJ3LlbDBedlL9BltiSVYRczo4Z/mWpmvtZ3jrdhttku7y+he3Xq/cDfrwrovgL76yZmOx2GEOuCXVN1H/xQ2OwQYnohdpK9bdQ+y5Yl7Zjiv0d2NkmhPNmZPF4tYSiDsADG4FJr/IZC+bz8bXyDvr1WD8B+Ydpb0jMSBDEWT3ONUicLV913sk7RA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Fr8oDlcw9bUSh+DcCl4JR7UZiAUvVmGrJpqhT2uXtO4=; b=M/yoX0OTR7wFbzxQUm8GiLBGSMTjhWRqm3Dm+lCblKymGqEIjuIivVGWijwgiY1Ly1LFu65mspJAHKk4oucCrcHC4FVCQYdE6X7gODVecXJy9TnNRJmq1EXQcDg4hVF9JspWFsIMOZClUKwDdzA2ynx/kVSKwslq+HhPMegfNBiaJ+mL/5qCmV/QlEWprklbM8BV3PGT18jpZyaMKDPyuGAp8aEhUoqgg012QoHvPl43mVsqcJTlKeqfcw2UKv3iCeF7HkTdoBolTjAzivLHNnhVwUHwxD7N4nQDbHMQUS0sgcwTIIgxSANfktw09Wa2qsX/M6AnXgqn6WuNdananw== 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=Fr8oDlcw9bUSh+DcCl4JR7UZiAUvVmGrJpqhT2uXtO4=; b=YhwjQoaRZ6JjoCSD+8JwHTgL5uIGXvIP1/Vr4jA0yrpbxrbn3QrvhVUXzkMQ5WpvHgAByOw8yMSerAE8AqHEw12mKCKnCrB8ibasg8R8gHT/BFACmDH4A/f32XFWwQQZvhNbNsK7FG9wnblvbnd6zdKAGAArH4rP38dm487d7dw= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=oracle.com; Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by SJ0PR10MB4653.namprd10.prod.outlook.com (2603:10b6:a03:2d7::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4436.19; Tue, 24 Aug 2021 22:44:46 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::7878:545b:f037:e6f]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::7878:545b:f037:e6f%9]) with mapi id 15.20.4436.024; Tue, 24 Aug 2021 22:44:46 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v24 05/11] RFC xfs: Skip flip flags for delayed attrs Date: Tue, 24 Aug 2021 15:44:28 -0700 Message-Id: <20210824224434.968720-6-allison.henderson@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210824224434.968720-1-allison.henderson@oracle.com> References: <20210824224434.968720-1-allison.henderson@oracle.com> X-ClientProxiedBy: BY5PR17CA0012.namprd17.prod.outlook.com (2603:10b6:a03:1b8::25) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (67.1.112.125) by BY5PR17CA0012.namprd17.prod.outlook.com (2603:10b6:a03:1b8::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4457.17 via Frontend Transport; Tue, 24 Aug 2021 22:44:43 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e8154c4e-dd85-4324-8168-08d96750c3ec X-MS-TrafficTypeDiagnostic: SJ0PR10MB4653: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: mtxb4Cs28wF+rhlChNXoxui6Pn0hbh+rGD3L5SR/gSS0ZfYdHvB0db8xdeqzGblE9fJ0mYNzYCZBrloT88DxjB9nLb84v689OxXVVbgwDdtvFl3kTV1xrFWIP3zM2hRk7h3v10hioDE4VGqNfoekiYgcZIv80cqURrvmgJ+4HR0sFbkdI8bVkn2tYpTwFWUVtw0FTxYkHwfhbCP+MGlpjvszhDCWq4WjaYWBjp2ia5DoAFAdqO7xdLn1Fn3ggQdsCXLBTX9f6qTE5/8SzXmiowJGAWCScvAqEYtm/ajtC2Z/cjBVoDN7KhbQE2Ygw0Wu/riRRdYWyDSBnME5plZlLCX3LAhs7zAm3yT/VcGjVfhrMm9XeLvVYu59ZPeDPmc9hqevIjE5UI5ISj1hYyne0Hk5/WMUkEzqD2dJA74xe10IG9ZBHAf1LZ3AuNhh4kUJ7LP4ZBKq6ip2GYutFWDexXPVAkloqtouHZwrHhB7qMCWuDiZbte4OwhzFkAO0ORNLlqUm+UPgh0iJ7j/X6pgB9fbJfgNSjyyarKBvGkIT37GNaCS7knnF486Qtsp+E+yLxyiVZwwz1rfgn0wV6DY0F0gM1ojWctAbB6k2r5x8PynbYWNoYl4sWFlbrKakVkNnPoJOcOU3Ms5ufYyhihZxrICaLDtBZCPlVkFbxLYjYL5bGdFFVKqdrtHcFHdr1aW X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(6666004)(66476007)(86362001)(66946007)(83380400001)(6486002)(6512007)(2906002)(52116002)(186003)(6506007)(66556008)(508600001)(8676002)(316002)(956004)(8936002)(36756003)(26005)(44832011)(5660300002)(2616005)(38100700002)(38350700002)(6916009)(1076003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: lIaaISZkIQUwLxvaLJWHBpc5lMc6O4TWkp67JniJvx4Wgd+PlGOLTJbzj301faZo1FEgBoZqEQ1Qb2kFGQBtCNsJQMC6my0jO3SjcxWyUFrjHTD8fdnI6Si4QUz5F1DcJ2YpDSNOtXUraCZMxOTi+6O2UpEL4zmPAdJ/1ey4/QkoSoFJ4OKS5N+DhdHSxDNs6H1BepfWN0+gZz+C4iUv9Um7xzJ9VyEke/RpReZHxXFE59CNRzz7OeCUN8AYidA4R8d6iWbORhvwtwDPMWv7hQ0i+5FSUrZr552KHHl1W8RnlhVj/yyQy8m363qNOZtV0hZURaNgCsWaH8qFu1cvTiiu2vmt5zgLdC4raSnzD8IpLH5mPTs+S+3GMehpC6YdcqZ9iH1RIxrUVSs/3SEzAFSnpSwq0zEWcHPE4QkAYi9aS8GDBgFjwAIpPWclWEjGwsIQBaOA65qzP/NrSeyCVhvLqLuZM8EkI4lAn0ifgvoyIb9fGfLa2/3W+AlLJcZX11KxndzwxabonKHn+f/UpRseDF5hr/HtVfeGob8GYeA4eCCOnZFpQ0+gyqSA2yYOmof7EiMz9sxASSBevFRjTXJ/E5nlm5hSmK+9R3iI9V5SC6hasUTc7+KXivrHdAQgrmZQuK3GECPH6Maxbz1BrAYUIXNWPi7t0efyNx9Wvb8MffxxRX5KSw4Si0RlRDUg0ffxFITwpiV7niy8mzeUChQGP78fqcJSwmj2TanC/cQg69xp+I7GymNwDrkD4RTojEwVL1jgR2dhpsl60LjlQPv6iFfC7wIDvqAwooHLqkApB1LaOfefh4UGGySwWn355+09V7esDvxp4AbSLotIudU/z9IA622UBcqcV7yEBthYjFwouQVsnuuUvFcWnYHFFkNy2Ce6nnuhIRDgYvse1W+bJkh8gb/VYArqllym02DDFSZlZWGuL9Yl1XxhJS5pWBC5baLIgdnfrXa0ig4lWR5gsRZbdZSNswo34chjxtQPMJfO0kiMxdF0oBAzSV3oJzko/gQLnFx+5QvFqI7xykGbThL+xuFBIVPtyLlFe2JIAXT9Xl0t03MEvxv7NCk4pHdOu2CS9r1uiuBiqyG3JmuIYzxbONClyi1uh36lFR6j98eC8/uUv2vkY+KKuXNyGTJV47chNl1vKVUX78FzJ1zb4iu9ta4Qjzq+OQaTuxY8DLU9tkQAofPVe1GdWliniT6LSS3cWbCdwHkuQ8QGdQxCCFXdPQ2JXQ+KWddMKfZA+A/LKk/tvPgY7Q3M7sNBAAPFwqgwM6QOPfwY4rVrGSLUi5a/sqTEwwZGUXS1T79eYmPYJ481JHvccAHB7rtS X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: e8154c4e-dd85-4324-8168-08d96750c3ec X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Aug 2021 22:44:43.3370 (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: Idwdzk1sQgONOXAWokzwGdM56fH9JLWSsHrhyk4EZ0dfTZJa5pjpeciT/bJE+k0HnmOFs6S5J0az8OMsQfiWxJV52VJ0Z640jgJcglKclKw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB4653 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10086 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 phishscore=0 malwarescore=0 mlxscore=0 bulkscore=0 mlxlogscore=999 suspectscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2107140000 definitions=main-2108240141 X-Proofpoint-ORIG-GUID: qr_lxR9vI-9qMfZn56_MlmBQU5fzanwo X-Proofpoint-GUID: qr_lxR9vI-9qMfZn56_MlmBQU5fzanwo 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 RFC: In the last review, folks asked for some performance analysis, so I did a few perf captures with and with out this patch. What I found was that there wasnt very much difference at all between having the patch or not having it. Of the time we do spend in the affected code, the percentage is small. Most of the time we spend about %0.03 of the time in this function, with or with out the patch. Occasionally we get a 0.02%, though not often. So I think this starts to challenge needing this patch at all. This patch was requested some number of reviews ago, be perhaps in light of the findings, it may no longer be of interest. 0.03% 0.00% fsstress [xfs] [k] xfs_attr_set_iter Keep it or drop 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 dfff81024e46..fce67c717be2 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -355,6 +355,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) { @@ -477,16 +478,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 @@ -589,17 +595,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 @@ -1236,6 +1246,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; @@ -1243,7 +1254,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 e1d11e314228..a0a352bdea59 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 Tue Aug 24 22:44:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12456029 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 64287C4320E for ; Tue, 24 Aug 2021 22:44:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4926F61265 for ; Tue, 24 Aug 2021 22:44:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230388AbhHXWph (ORCPT ); Tue, 24 Aug 2021 18:45:37 -0400 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:30868 "EHLO mx0a-00069f02.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229618AbhHXWpg (ORCPT ); Tue, 24 Aug 2021 18:45:36 -0400 Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.0.43) with SMTP id 17OJtEOt001055 for ; Tue, 24 Aug 2021 22:44:52 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=lL6Vhj0wXx7fEncQZyaT7f1MkTmtmyaMVQ7xLHxPaM8=; b=tIpWOOsttadUb/de2I3Y8J46CihvHAkX1KdHrTJ78Po8H02JGhlCuzRFTnIJQJN+6Tjw HWbsT0OvUCBJSZxroaNBreAYgLwtr8wpGGDNDIjZ8oiBWpVy/G4KTJOP1sqRU4FahPGp 9H6Q5GOhZGb3TGCghgvpGs6Aj67BSaVT40RQR5M+BIVPpBqZYkZJR8guPxR7ezzTzFxG aANyK4zJQfVj9fgvTuHNfV1nUDBEiMS5r5UJhme4U2RadePIzpPIfKibLBT8g7VGVT0w 3RMU69kODs1T16Vo/KFMAEIiKkRb4jDFctxDIM71hHh52vdL8fqDQJzYQQ+TUNfPn236 7Q== 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-2020-01-29; bh=lL6Vhj0wXx7fEncQZyaT7f1MkTmtmyaMVQ7xLHxPaM8=; b=GNp4o+FxV9IedlPH2/Psx7/MRDdAOlEstK9xkuIChIOKTOsobdqFQA6lx1BCiSNJDNzN aXx83FNkRfcSoB0/9kY/FqrSPGpnOhgAKnb0N8zoGUpkRMn5v7U2WPE6eF5kTICWqxQr eSImlBYJSYHKtVBo4xYwKlRzfqKg1x1kk8R3HnaDO49cyRpmTqUqiXoXHioBRar0+1w0 8m9lLCaYB49SRDO5/moYkkMrbWOt0hmmMRp88jaEWTiaDnL/61BKMd+CxETt5d/P73qV UFvK86YydCgl9AkFeyJ+8bbuLzjmQejkazZNkuHOew7laCTCLi4Z7MWyx8t5QgVfhdpq Vg== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by mx0b-00069f02.pphosted.com with ESMTP id 3amvtvt4uk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 24 Aug 2021 22:44:51 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 17OMfYQ5025324 for ; Tue, 24 Aug 2021 22:44:50 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2177.outbound.protection.outlook.com [104.47.55.177]) by userp3030.oracle.com with ESMTP id 3ajpky4yms-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 24 Aug 2021 22:44:50 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kAfcNv9hYBEDWioS5YhgLIAM9ESZ8KWRGdh5kkdfX4aJsLunLKWVjjc7g+93dxmwoGvZx1fy3O+D5MrrKKZ9ND5ECugtX2NAeUZf10Rn4y0C2A5NhTE4qaEc6zLYCgfEOOJFElJJN0H7yzcg5EB1mq0YbR50ISXoM9qS1PGikI13Wqs7FvCv7K14ogEH2Kl1ZqeD1y00mXPkobkXe5Hzc6eSq4geTWqARZWkbi2prsncvLdxDeP67EvWEgLJWRLz+GzveM4Mx/cALVt0hOJjjcuzd5irHJMh791lsf874F4rkHahlnwIGDXrNznpXSw6PFlWZfJXhExLTdH1CZ6A1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=lL6Vhj0wXx7fEncQZyaT7f1MkTmtmyaMVQ7xLHxPaM8=; b=gK+3BJu/r8nufmThN7l1kROK6iEHMlJe+fJM3/EJQkjYjNnF6pEM0dy0niAmWxINzHrR9LoRytIFFCjamjHYnrGuErQIsG4VgDWaojgjrsL8koNA92apgEFJs4IJ9jjsxI9FsbcsWgeuBzXBT3rPp0xcW+grCd90QMp8drLuPF14rkTAoK0/kdKs2DhHaulVZjR7HSMddl9PN/qKKmfUqJagZsIca3cKQXsT3KuZmA/IoNQAZa7uDL1Gdldy3URVIJGGru4utWDLu2nS9D+uqUSHegI0rN026WXq2aoNbo1RHpnSj9chamIqCotLC9NGyFtmrUDfAUDOsjTKlwN8vA== 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=lL6Vhj0wXx7fEncQZyaT7f1MkTmtmyaMVQ7xLHxPaM8=; b=asRTrwXC8qMCd9xiVTPN//pMGFOuEcQ16V/5oIYH9O4rxUS3C0sGll5Jn21CFN6KjiY+NlL7W6eWCG//c/NL0fPsY8SZ7V9GVfbuU2Whh+ECQShpJFmTArHkgZDgCa2KoMj2AF69NA++AkXYGaoXk3bgnQtKakTh4s00OEn12Lo= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=oracle.com; Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by SJ0PR10MB4653.namprd10.prod.outlook.com (2603:10b6:a03:2d7::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4436.19; Tue, 24 Aug 2021 22:44:47 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::7878:545b:f037:e6f]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::7878:545b:f037:e6f%9]) with mapi id 15.20.4436.024; Tue, 24 Aug 2021 22:44:47 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v24 06/11] xfs: Add xfs_attr_set_deferred and xfs_attr_remove_deferred Date: Tue, 24 Aug 2021 15:44:29 -0700 Message-Id: <20210824224434.968720-7-allison.henderson@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210824224434.968720-1-allison.henderson@oracle.com> References: <20210824224434.968720-1-allison.henderson@oracle.com> X-ClientProxiedBy: BY5PR17CA0012.namprd17.prod.outlook.com (2603:10b6:a03:1b8::25) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (67.1.112.125) by BY5PR17CA0012.namprd17.prod.outlook.com (2603:10b6:a03:1b8::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4457.17 via Frontend Transport; Tue, 24 Aug 2021 22:44:43 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a7f2de91-0f3f-4d45-0f1a-08d96750c428 X-MS-TrafficTypeDiagnostic: SJ0PR10MB4653: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:494; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: gcJKnqVTg6LclYRtoflkGov0RM91Re6gs/5CLXlI/WS+cxl2JcKOjzxlTFjIDMfyRaA7KQZHqiVOEUjq0cosZFsIAG3g5EPkp150wx/21g0kfGJYidDsm8U/MjI9aZYb0aIyfzs6EYdkUOq4+fh1lYPPjF1xo+XdEYZ7hf6VF6fgd8Epy6+Isoev5zEJcZJ6zCCVonWQPsKLfK8adcaM6FoyugX18MAezl9jihVmMrW0vG38GCQFryulWWWE0Pp8R8BA+D+Wk3lUqgI7HF9Gh/i7KqIyLRhStgX6kvq6KCnac4MOm/hlYACZTGSzua6hmr328J4dFoHytaB0j/h+QhJeO9yXFabWrngUcGnyOB/ouH8XEZ6pcqPIEeGWSN5oyi4zHzvod5tIzUInN7qLCUgWAjZRrr7p3ZbJiK8jalthxs77Wj/4N9xeQpQcGoLb01uL33PnGrGXJxIUNTES7A60BqwnIYc7DVQK/DpD01/j74fs9NwX3id01vGoqx1weFntYMMCSEiv5m6821r/4ree+UHEUrojIjwvct7ukzWO2qPbnbKl6RafRISEk9PApwSKwe0/wv+ADlUGq17pGCaE1u0i6gdLrpCc55MphT7PRoJEwUBMRnr+reOeOBXIbERl+r2Vcd80I1cHN0bLKqQb5BPN6awnTHl3YkpuPtoZy4x6BIOzzeqIyUnrhlS9Es0wX7lGHAYaDbPpJcmLlg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(6666004)(66476007)(86362001)(66946007)(83380400001)(6486002)(6512007)(2906002)(52116002)(186003)(6506007)(66556008)(508600001)(8676002)(316002)(956004)(8936002)(36756003)(26005)(44832011)(5660300002)(2616005)(38100700002)(38350700002)(6916009)(1076003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: YJMbXOczc6fQ5CFLaseWL13UMO0TTP7OmTB81LN+ZJaBUAwjpuVzKD3gxngSQArEkzomyBnMV6SAev3kM+qpcVKBH7amCMAJt2OHPi8KLb67aW2bfNuHmJnmgl90oNsfzIRk5QKjOayN9BIXaoKo5RwIvwyDo+DjoBzqTL9V+k4y5jJv33Ta4y3JQb9a1ENSpmm9T0OlIBFgC8JjDe0nHzz1NTyJk8UZuClP9EW2kYXSqntIkZcpGxdPjhsA9/MJ5OlnrHZzUzyFlkN+eyob+B+LNhBZoODg+TNKtGQFPUa3eJRSQMFXy6E6Hl7n/4JD6ZXuf5N9Y2IN0c7HB9AEjKo95E+fGqGYKnnzvcaalTxVgTiq8CKoZ1/Cv+csGGk1dM93+3qkr4rbMeKBbA1Db5v3Uc8QIizzMPGM/uDKwpwR37EpE/vG+2kQj1UFikGgiF7+2LQ7/Xp/ItVYeJfv2ZNMtZnKz1QpZ+SxWBReWb3H6f93W+GtGaRSPITi3eSw7WzQdb3uOWxNzvNlQ/HpbiMIiRKrP04jAFC80LRgh3Ay94JrR1IU8HBEPIuhp5qtd+ls6jWlAjpYBWqTU7DOo9IkXp7E4KiMwzVHImr9CC9VZB6o4Imd6AWcI0S9iZZh4PTmYfltzSnSdNMhxsP++rQHL3eD4xmJsyLVtcNCNK3LelK0dWjySfc76jWZHvQgT39CWDi6bn7KGdcwZzEe9fe7UyH8GrM8WJcuMNvacn0/UpkTk7X+FXCKodMBq6+wMPGAVFqa+Ja3D35/T4MF146osv+qwvCmML91jpTBDOjbBLeXx38qy6rkVEsgIU+nhGYibuh/IQVweorAMoNckiumvCIy8vxYjpqvMN/QgA5h7IWBMxUE5eO9jdMM4HxuRom/dLqsywmnSVXxQxJXVZwyXm0tWGPpd0qj4Oa9EeG1hluW3DOXg3HKkilkehtoQ1gI0XwVVbehjU9ySVgG9nzHrI7d9YAG6HtNLGKawmdYN7QtYMRaJ8kC/oBROCllXEkpUpjXmstNYdd34oSa63w7jtBjNiOPK5kJZ5Y19FHUoJ+L/9PFQSFnsShg5K6czGue9YAXb1rnvLpk7cYdl1E0rWnf7z2nTINVPaLT3a4PT/E4YNFSsMq5caMavIhN2QUUxqBrnOGSneFUvcBaJ0zb8VAxyGbJyTVJLYymUoEGgqoDtnRapqw2R/k9/HJUd+aQQX+q7gwwCkNngrlJO8t6z0g6mqTCF2cDRKoaX6Zac3dgZ3Tya1b6QnDf6pa5+aYmFntThDOR4NJtbQRXSpoaYL1VV5UZE4DPCU2+SKbavS0//RdAyN+En4XOkxuP X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: a7f2de91-0f3f-4d45-0f1a-08d96750c428 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Aug 2021 22:44:43.6974 (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: 8F67rqqzJuZ3Kkzl58uc7hDQJbuhkFPzlTAmF85JhoOPMjrjmGsxyHDWblrhsz+vW78YXMCWBbetHnqKVnWvFp8x5X1jXtHt2CDbcu3knMg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB4653 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10086 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 phishscore=0 malwarescore=0 mlxscore=0 bulkscore=0 mlxlogscore=999 suspectscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2107140000 definitions=main-2108240141 X-Proofpoint-ORIG-GUID: vSnyGtU9yQlnNSgESVZry2pobA2jkwQW X-Proofpoint-GUID: vSnyGtU9yQlnNSgESVZry2pobA2jkwQW Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Allison Collins 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 fce67c717be2..6877683e2e35 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" /* * xfs_attr.c @@ -726,6 +728,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; @@ -782,13 +785,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, @@ -806,9 +815,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; @@ -816,7 +826,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; } @@ -838,6 +848,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: @@ -846,6 +859,58 @@ xfs_attr_set( goto out_unlock; } +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 aa33cdcf26b8..0f326c28ab7c 100644 --- a/fs/xfs/libxfs/xfs_attr.h +++ b/fs/xfs/libxfs/xfs_attr.h @@ -526,5 +526,7 @@ 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); #endif /* __XFS_ATTR_H__ */ diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c index 4402c5d09269..0d0afa1aae59 100644 --- a/fs/xfs/xfs_log.c +++ b/fs/xfs/xfs_log.c @@ -3993,3 +3993,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 (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 dc1b77b92fc1..4504ab60ac85 100644 --- a/fs/xfs/xfs_log.h +++ b/fs/xfs/xfs_log.h @@ -144,5 +144,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 Tue Aug 24 22:44:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12456033 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EA254C432BE for ; Tue, 24 Aug 2021 22:44:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BFD046128A for ; Tue, 24 Aug 2021 22:44:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230475AbhHXWpi (ORCPT ); Tue, 24 Aug 2021 18:45:38 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:50140 "EHLO mx0b-00069f02.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230396AbhHXWph (ORCPT ); Tue, 24 Aug 2021 18:45:37 -0400 Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.0.43) with SMTP id 17OJMfk5030398 for ; Tue, 24 Aug 2021 22:44:52 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=OePTOhm3QQIxzhLWAS2JnKE9a9ppYu8Dg7JhuAi4l+E=; b=WC6hWDHT0sWVYEia35XArr8y036hJvWihGkj6AdpRllyCigVvXpwDq01yd9kYOvgcVpX ME/Sou4bhJhi7eD5FRAUy8e5jI6LX+rOE8102SFRcLbg0ct0UGzftN4PPKe/GtOjqrbu CS+tOxZowDHSXyd1Frc3Y85fv7ssJPzg4fK+o0/cSBdPWfxZv7AQy+TuIq0IcyTPRbmK Y2RSKJrwYpb++ZPCE8ODEpb0LRlf+eFScp1tBijWW+BlPPfpx/lXAh39uyXQrh0IDEdB qnaTlGPowAqk+f8Y+80KoQKkfaqed7NMqpYsOFxKaeUIhsZ6RLwyBXrl02dqgKMC59ZZ Dg== 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-2020-01-29; bh=OePTOhm3QQIxzhLWAS2JnKE9a9ppYu8Dg7JhuAi4l+E=; b=sTM2lrRMWjNpvc/G5E4JOi8bkYjYSjdMfXU14juHEdd6Pt+DOc1es4oAQpZK9K8rM1Ev LHPve4h3b6r6mjJPQdjHs/smbodGI25BrMeyPFryyRbUCXJHJ0HKxTK3Zt0FCJZCPXRu HhtRQJvcvht8rnXUCAgyKCVIUneIegUoIwx+DTxnIycuIBphZuoCBT++itpGaitzzPub COrgglWp2xHZiNDJJ/bLDGhYN8ASRzNnKP0ELJR8Scfe/kb6zZKnBMm3NL0QIfpiWE0o y2R3N8sielTYQk22i277NcN9vBU9+EkcW0ggrCYCHnDnTvxOKJPRs55UZ0McjZH1brfG +Q== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by mx0b-00069f02.pphosted.com with ESMTP id 3amv67a7xc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 24 Aug 2021 22:44:52 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 17OMfYQ7025324 for ; Tue, 24 Aug 2021 22:44:51 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2177.outbound.protection.outlook.com [104.47.55.177]) by userp3030.oracle.com with ESMTP id 3ajpky4yms-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 24 Aug 2021 22:44:51 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XBmYU+IjhrDTj0yYrbfRfCprR4xKBUNgT36S7PvX9Iz9ViVUIDTdayHdc63QBmKelDYMsiGKZgGd7TUxA87+mvibrIZjfP4eZfzdUkq/LEx+pWDbTloEU/uMnWDQS9PpizHHpufhNlXNB1shLW1gCjtsZzKtxkjURvYNg/ifewK6wIw66nSpyMwesNwOhKVe/6SZC38kicYdwgh4occwnyVXmLufXZ/JZQX/8cpcudfyGIgI3IrMl3vsqgJ98ucayiQGF++WRhtgiACTE8QbgxiAEZpaAPuEiMxE6VbdACWmW5wB6wIqTVjr0KZADxz9KFNGND84bZWSxUxM7xFG9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=OePTOhm3QQIxzhLWAS2JnKE9a9ppYu8Dg7JhuAi4l+E=; b=OXTf4sekmsg2xHbf4fgWUvddXSAcw1EX5DzGDT5Wuj3NLU9pIBIiZAlbFnlGYp9ksjN+s+rP1Nge/vs9udoKEKds9kL7A98f9V2L2n1WhWLlRe6DH/C82TPRbDdwtbQ9BIjHSVmlGOoq9DHapXvvn0NWB6gaLXn4O5Io+VB2l4E6WpnxyNRCCDrICK24t+Q4q4VO5cZ95HKzHZrGR4He/QohjKVAO0rBYPf07CoIWABwld2MxkQj57c2kSERu0/q+gsBPvXA7q28NSPnLQNRn38gwyGKC0SbWfgBwtNECXBhgWPUMTt7vtv4TauOK+d2BPlaMq3j7e8zFAIBIAYczA== 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=OePTOhm3QQIxzhLWAS2JnKE9a9ppYu8Dg7JhuAi4l+E=; b=b/Hi/Tkj3eCZbuU1hzvOzkl/PpCnD6YqZEVBXDDS3ZAwjNFos2tpHBMJ5FpxOv+Uv7gypE4SWAIJte5Yz4xXh+417XvcdESgPJL5ZLIRqNeLNv6EY2ptZPwHAePDBKplOLjAg/FcABStJKTuonQWY1OyZnLOQDtctnunHWMS7GY= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=oracle.com; Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by SJ0PR10MB4653.namprd10.prod.outlook.com (2603:10b6:a03:2d7::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4436.19; Tue, 24 Aug 2021 22:44:47 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::7878:545b:f037:e6f]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::7878:545b:f037:e6f%9]) with mapi id 15.20.4436.024; Tue, 24 Aug 2021 22:44:47 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v24 07/11] xfs: Remove unused xfs_attr_*_args Date: Tue, 24 Aug 2021 15:44:30 -0700 Message-Id: <20210824224434.968720-8-allison.henderson@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210824224434.968720-1-allison.henderson@oracle.com> References: <20210824224434.968720-1-allison.henderson@oracle.com> X-ClientProxiedBy: BY5PR17CA0012.namprd17.prod.outlook.com (2603:10b6:a03:1b8::25) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (67.1.112.125) by BY5PR17CA0012.namprd17.prod.outlook.com (2603:10b6:a03:1b8::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4457.17 via Frontend Transport; Tue, 24 Aug 2021 22:44:43 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 06449859-cf0c-4546-d064-08d96750c45f X-MS-TrafficTypeDiagnostic: SJ0PR10MB4653: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7219; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: nFeBu+2io9/vQHKvKN3Oa/Jcop3dvkZsczTlZ6RW6U63HOcTt5F3g/G56W9DrIMETUhxbXECFokNGrZK7xl1xmT9hK4GHqE3PZd+ZPrIUTlVTxmE7Rjzk22v+6eJ9dZS4YRQnrtCjGJe38Sjgn8EJwp7nNV/TyhB2Wq3Rk/BTXHJOTK8TqWXS3jG7s5M/Hqw5/yY/bdacRo7YihS46PVoY9lmGfBRfUF7UY3JK4rCq6SwEkrHZH/S8QgY/ejH0kGsBmELQ5d25m1EgEw5aAdaTVIfKVwqzjazVVPv0AFN/25IREHqmUrXW+dMyDhGqne6P9dXLglKpIIsojmzWJm+MBzuj/vu6trqATCP9i3RQsp1jKzEcq1Exjdlq+7S+P1w5Z8+3dWu/CTjLZyZqO573FpqItvhBh1RteSb1n28C9aHYMk220HqIMlGwZL3cI4ajSxEGJGWgLk/BfQISUb8DMNfA/M5ZmYw9gPOGH/XarSg7NTTOf4wm95j7N4tn4lhmZoa2Ygk3trUaIIzYvWF/b/HLmDGxW6k94nUaAHR3ox06V0kWFAGQOc2n7jEWSCEYCAyvNFnzwtfI+opt6lvWCu+MdADyb7/kzXWUY8PYwvqdA3roVVRj9jdMDFFYRspcX+WPgkoSDR2L5inpnZYY/AqnrnnbUaXjpQDwSb7CKaspXX/xBJzKtEtT7esyVU6o6cC+Pp9x+rEKnyAaUasg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(6666004)(66476007)(86362001)(66946007)(83380400001)(6486002)(6512007)(2906002)(52116002)(186003)(6506007)(66556008)(508600001)(8676002)(316002)(956004)(8936002)(36756003)(26005)(44832011)(5660300002)(2616005)(38100700002)(38350700002)(6916009)(1076003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: wsBXVUtSeYsK1LOpBWhFHUWzcDFb4538Y+pZEGliir/KQuSlruTO+RQ+qGt+09E8wqu2wNumeV3GNxMwGiHM9KP1ocupbaluOGUzVgc29eA6iNzviGQn6szQqhGn3vCzR8HjFFL+/P9kVF/qbCz6tgRmKW5B7FIR6ayPp6yBOyS4nFgrFCJdKNx/zfAKG1qHnh1eZaTYMW4LRrm4sMlWoMkAjONrOCgVdB3Dom6pnEuf69Qz69rENY9QTgQdoEhaLDX2N2qKDyDWj7/aXK9WWZvKqfzurtBvHcVC8JtDxhWq3/7AI5ikM6OrqLUwZ3WMkujH5+4H4ykbJd8o7keiW1inAGZTgNs/gOBuuFkd8MHEMJ1IxSEaVYDdGYqDT0MgvO5BNAvx2t3/UKHawIzjMP5Ud7cRoz9cSfMry93CfHCGW7W+1BreiIpIIx2Pzw1Qi8NGdLJi5sU0lkJ4/zNDv/v2FwVLtYYuzSxnjdHAj3chcQE7sRjfNCrnpWPfGhDZeYm2WsC7FaGhfMFRxBlcSfS9Pq+3rpnWGhx8mhBYPDK4j7QSfImaHVwTDFdw8KWYEz7sEtqXdDubh//bQBfK8dx+3/lPpWjyfTyWM7cjCRrlB/cemAE63f2Dtmju3ATEojYncAe9UayMYhJG3wf3OR83yaXxLH2aOSbiNJQtYpLzvBY8UQTRREB3j64qHawNaaRCR19uM8PnoOTp/JrVDscdn4hukvcksO+XP2cGZ7+VgBy+PO1Jt9BCEzCkJeWG8PexgRJMjHaUdu/2cJxi2o6DtdaXagRxg5B3ydh2oXgCFe3sj5JMsNFwTpyzqA/Hr/Z6N+NwBpe3dImroZakR/scOHFg7CpbAZLG3UF1o7kaNvZ9yZ4TvouldvKHzcbdF9S0x0es67dwNTt76vfZ1kooZXi5x8Xrmp9lgCW46MNTQIifoN4v0ufcbz2t4REZWuLgRHb4jQvbc0WVEpoe0lQkfxGpqU0OOhY0EGbyyG/nHSr/7CTr74M+jc8mzClKxkAJwZ4J8agSkZnZpFOWsSENbJUbXXbFYWGnHesC8XBTFhZ1gEgwTt6RD+BKZ6tS06LqRBpHddWGW938lKvvaqc2CnNm3qA3rJWqDCNpYQ+dvuZv1SNHnu8xcEVkgBGjrtimhdVh5jQQ5CWCR5VeTfH3UqFQj+4/jxia9gytwPGYskuW7IrJAvWHeIj0KHjqGLRf9Txkt2gV/9x+iqFiIsKg0s44f0d3aZwKjxVFgv5DCAzyAfxTWSIZA8ba/YmvQrr/D5ucodoklQS2jsQ8cNilrpx+k88jrHISrNTqQdLnDfnh5HYRBuphTfWg6dZJ X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 06449859-cf0c-4546-d064-08d96750c45f X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Aug 2021 22:44:44.0837 (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: qZOomViSR6jXpaBOz6D2iRE/1gCxPd/wBK56SMT6OJ3u+eHNbUVmnHMqvJFGil7b7lAdUVh1c2z6+0UifDVI82eE6M+4MbMHWNhX3ScxAxY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB4653 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10086 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 phishscore=0 malwarescore=0 mlxscore=0 bulkscore=0 mlxlogscore=999 suspectscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2107140000 definitions=main-2108240141 X-Proofpoint-ORIG-GUID: tfcAXloi33UK7pcdLZf_9EH4Uz4ukxEu X-Proofpoint-GUID: tfcAXloi33UK7pcdLZf_9EH4Uz4ukxEu 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 | 10 +-- fs/xfs/libxfs/xfs_attr_remote.c | 1 - fs/xfs/xfs_attr_item.c | 6 +- 4 files changed, 14 insertions(+), 109 deletions(-) diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c index 6877683e2e35..d62ab53c3b07 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -244,64 +244,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; @@ -320,7 +265,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; @@ -329,7 +274,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 @@ -337,7 +282,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; } @@ -350,8 +294,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; @@ -370,14 +313,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) @@ -396,7 +339,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; @@ -687,32 +629,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. @@ -1275,7 +1191,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; @@ -1290,7 +1205,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. @@ -1544,7 +1458,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; } @@ -1572,7 +1485,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 0f326c28ab7c..efb7ac4fc41c 100644 --- a/fs/xfs/libxfs/xfs_attr.h +++ b/fs/xfs/libxfs/xfs_attr.h @@ -457,9 +457,8 @@ 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_DELAYED_OP_INIT 0x04 /* delayed operations init*/ +#define XFS_DAC_LEAF_ADDNAME_INIT 0x01 /* xfs_attr_leaf_addname init*/ +#define XFS_DAC_DELAYED_OP_INIT 0x02 /* delayed operations init*/ /* * Context used for keeping track of delayed attribute operations @@ -517,10 +516,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 c6d5ed34b424..928c0076a2fd 100644 --- a/fs/xfs/xfs_attr_item.c +++ b/fs/xfs/xfs_attr_item.c @@ -285,7 +285,6 @@ STATIC int xfs_trans_attr_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; @@ -295,7 +294,7 @@ xfs_trans_attr_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)); @@ -405,7 +404,7 @@ xfs_attr_finish_item( */ dac->da_args->trans = tp; - error = xfs_trans_attr_finish_update(dac, done_item, &dac->leaf_bp, + error = xfs_trans_attr_finish_update(dac, done_item, attr->xattri_op_flags); if (error != -EAGAIN) kmem_free(attr); @@ -617,7 +616,6 @@ xfs_attri_item_recover( xfs_trans_ijoin(tp, ip, 0); ret = xfs_trans_attr_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 */ From patchwork Tue Aug 24 22:44:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12456031 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3BCE2C4320A for ; Tue, 24 Aug 2021 22:44:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1C5566128A for ; Tue, 24 Aug 2021 22:44:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230396AbhHXWpi (ORCPT ); Tue, 24 Aug 2021 18:45:38 -0400 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:32980 "EHLO mx0a-00069f02.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230465AbhHXWpi (ORCPT ); Tue, 24 Aug 2021 18:45:38 -0400 Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.0.43) with SMTP id 17OJA2Fi025080 for ; Tue, 24 Aug 2021 22:44:53 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=ngfNUC6hmrtrQ8bw+5q0Om5im+vQgjwxgLh8LBPmwrE=; b=jLOTnhpPagkJQmfuf6xdezU1+6e2krEOpAITxdequzc6RPKOy+1bJIcpQAnOjpSvea0b eQRNyDMcboY9UkY34jqCxfk4ghxiIEnm809+0N+ZU9QoRLIgOe062LXIIp7KQZKTQlo0 cxS+ShXrkLB9puw2yPTW3RHqyJxQAr2A62w94DGKqEjq6gy5/RBrlc5/DhGLks6pVe/F hGHFMZ8uip6pQKHErjLXXMmF1XUBn8JS5Jr403ZjwaB10pKlsHwrIJ8jw4R3bMoM8Nnq rAL/pwI3Dxp7um5xx1vcBrUeSdfWcfNJuRzmFfirf0K9p4Osta+wpxwK1uifI+pzBguy vw== 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-2020-01-29; bh=ngfNUC6hmrtrQ8bw+5q0Om5im+vQgjwxgLh8LBPmwrE=; b=xJhP2JPM1+zSlfzOCrqt2JisBH/t1kJUNdvDVULo6l5cFULBNRJEdnrOaftgQHSRx/R2 nCfK6Tcu5hgTOqK4Qam4YdNxVlUjcFNUG/oJqUZzb6jp7YtDGhDY01Luk3R2Svxq5ABL mxQphRP8WksHFg2Ep2qCeBmhlH4x3D30I8IO9S5gWxGshDASbqwTy9MGb1sJNUnOcK3e EOgkhwkCkaG5lvWRY/QlwxF8kAeZqsVS8zLrt4JVkKa5CqHTDwWcSuXZjWiYUTMcK5Jy y8bmrgWn0bHKpiyFex1GD69/k4h/f5bkk/ZJ57KJxx3A/H+0nxQgnPk7N6LzKhUl57dZ rw== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by mx0b-00069f02.pphosted.com with ESMTP id 3amu7vtdxe-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 24 Aug 2021 22:44:53 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 17OMfYQ9025324 for ; Tue, 24 Aug 2021 22:44:52 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2177.outbound.protection.outlook.com [104.47.55.177]) by userp3030.oracle.com with ESMTP id 3ajpky4yms-5 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 24 Aug 2021 22:44:51 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Y+PaLN4tm1BzA7YeD9vc+aNu2UMQrxYgaW3pfLG5B2Tu5s680vKm9Y4tpoNboUVyhqQ6kFgQ0QoqSt3ZUEtojVHgtfpcCaT/QVPlyAZIkHqKXyRJ7V3booqgwU8EP2fb9Pk7TwBw1MH3DnwoULwWXUZGMe/v1+QD4KxuI/X7eQsKWnUuf2z9ZRAnR5dOJRljW6gaDqnneoo9DmKIyxQAuW46KFSre5bGWQrn/EZSADKQVNhCzkOMr1zxRVkaknQ2H8zbDUS6LtZ9DvDKYI6INxA7Y9BVfrnQnAfC1bHpb9nckaOBca4mQJ+n3BgW8t7ecmOmzLkcw5My5nLn+eDLPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ngfNUC6hmrtrQ8bw+5q0Om5im+vQgjwxgLh8LBPmwrE=; b=ezjGcDiMs1PGVJ9IBug/XNFF0h90lqa02qw1GEIqqoX7Z9Rqdgplf1aj477VPgcaYhofwyTZnXzmTBiYovbcR/NXZ6U2/BI8mF5gqeL2OuXz7U65S3EShTH8hLj6ie7HhhOGjDS0OqtUHhm/gkVPnFy6QtZbVORZ0Z582W9nyKvG4BqzWw2afEvZ6AiVYzZ0hE4DQixEiLp3ZsAJNDWcGCzJTt7/X3I8Wj0QzeOQoW2PQc2BVz6EHrxqV12AjL0iMG78VUzj1oYccbDJzLMWdOkkjoqNKgxSo5ngnRgudT8v04hYehe0TRCa0gHULf3pRkfMijpDTQhCKesN9kW2Tg== 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=ngfNUC6hmrtrQ8bw+5q0Om5im+vQgjwxgLh8LBPmwrE=; b=Fy3RhLtd/lMEh0ZnDWe9yfjTjuyFD747yo310VC0SXKSE5jIvwCc7P7lbf9Y0NtgPCMqgkQjFJ8THTZu5h8+NarWgwVez27ebUCDHp9ydP5lWGfjtHzVCgNW8eKkMJuKyEUDtBlLtYwvoSiTDwyWyQZ8vnpFflQQOlYFwy1VvI0= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=oracle.com; Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by SJ0PR10MB4653.namprd10.prod.outlook.com (2603:10b6:a03:2d7::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4436.19; Tue, 24 Aug 2021 22:44:49 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::7878:545b:f037:e6f]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::7878:545b:f037:e6f%9]) with mapi id 15.20.4436.024; Tue, 24 Aug 2021 22:44:49 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v24 08/11] xfs: Add log attribute error tag Date: Tue, 24 Aug 2021 15:44:31 -0700 Message-Id: <20210824224434.968720-9-allison.henderson@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210824224434.968720-1-allison.henderson@oracle.com> References: <20210824224434.968720-1-allison.henderson@oracle.com> X-ClientProxiedBy: BY5PR17CA0012.namprd17.prod.outlook.com (2603:10b6:a03:1b8::25) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (67.1.112.125) by BY5PR17CA0012.namprd17.prod.outlook.com (2603:10b6:a03:1b8::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4457.17 via Frontend Transport; Tue, 24 Aug 2021 22:44:44 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ae7371aa-8136-4a71-c270-08d96750c49a X-MS-TrafficTypeDiagnostic: SJ0PR10MB4653: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2150; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Smjz34EFB/mPnOy9alfTk58HdxJCxX0X6VWBgQDt1EyiIsmqxRrGfZbW4RSH3lm/gUupfs7iUFa9FvbQF/gVGiUOae/6dFxGrVf8ZPrSTm7flgEQfaUVBWoZelK9rdSNZkBSgHHypYxFwarsfP0+6IOzVIC2myp5ua/bY6USyGu3IUdf/gUyQHIlkbD+d1ai+C2SFl3O+xpITN3fjjeRkdY86Zj6YZn7QQ0c7gBJuhwq1a6ZMODd9uC/Ou+urnU2i8cwbbsFkyGSHCIoC//9k41UKgQxSQ+q1Uny8HR4GGETmomAX2tIw6UQQMMOUj+RWCI1CAgGkf8MgcBBoKH2OMjAGC0ZWGrXogXwyRJnw29nKta6oe5Ym9GTPEf7/R9hV0c0BtE3hQKr2TkdRQ37Njdn/OUrLeFoR0V4TmxyiuYF1WziClAhTPAa1UacWnY+3H7ndrbU7T2Iy/nNQLyocj7NFniFeu99wedr982oSNd+8UMlxZ/aFadoV/MxzDNtSaCYJsyIwkpqnPY5TnKZT3k0etW+DMKRcP5sYTwKpwhCtkVAVCWUPWLsqkJHhxp20pKW20Yu65tgbapVfHVLEqW5G48xKJ3wvPemaUxvfAMuKp3V94yWXmxmdQh9A9o0eWdGIAhnt4EhIlewy/ge5fT52zG6E0Lmkj5mI81UnULOEywruLIG23v0ipDB1pP1Ww5KRb0kC8qLKpmV0Jeifg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(6666004)(66476007)(86362001)(66946007)(83380400001)(6486002)(6512007)(2906002)(52116002)(186003)(6506007)(66556008)(508600001)(8676002)(316002)(956004)(8936002)(36756003)(26005)(44832011)(5660300002)(2616005)(38100700002)(38350700002)(6916009)(1076003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: jKg2Vn0TAAunGN2Gpk4Cdi84qIe2D/rFGAPElUab//JeNsvSwB//wSN6gqJo6aC5qVpduWnvYn1hGBOLJqmNVxmbyvY99XWQEOfpZCLovI+GOzsHPT43x7RnGEmclQ7QBVaa7huFGrY39ObiznrDtVzPMGQSyFSVd3QWHYI3+W8jHlWHVtcJAfUaEfGInfP0fKLg3tIJkT45ntJjf/XKNo+X6hUsf0uq/oLr5mD4pkP8EqR8r06jrcJx0Pi4szL5MqZ/VAoWpLm8QwoakwM7gMmJ8g1IDs5p0VeFH3BcP3hiklmf1ZuKjyNCw2lb1Uq/uW77pSxK6WY1Va2B5tTr3cnNTE/l0wwKl4cns34oPYc3bD34stBJUGdGcx4Hg3nrWpPsTZWPdVpPYPx+kJjlyAbXxTtQEh4KU4kjBJLtkK8F7RzEM7nADUkPFpc8KfktB0e+uRJ/F7l0147DVlaZ3Bt5Vz08aLdZCvsdGKX4jfNKFKQW2EigLKXXHcMx7MtA1MN7HZRxqIAvNkg2aViKEoUTibhXAYd8WM/jZderUFigszLNwi4cflrLCW9g8FftgWUAyda23LdbW1b0nTSd/NOQ9KoqeKecogLptXY2r4JdaJgejgDTWJELV0yTlVVXGVFrQlyADGNCOkAsvb6WBAildVkfIwYuNOQ/lRgeK/iRzVz0cgLMXF7SbkWQ0WMKA7xueu2VvBp46IesSSr6DecqR1NoAmwC5zNY9hZ5QmQu8gc+M6u3v1ui+ThowyXwJFVRU4Q+n0ZbTnNE7L1OSINshox6rRcAzlSQlaTkegrLFewbfA7BG3wAipccCQpEW5da8hYOK8+lJHSUS8bQE9dfuX2kGEnTtUOOEQFKkJfzpdYsS8JfY8TQnIXoQo5FMz7Aa27YB9oTABdzWaIhIL/Do+lJ3jTs2gIwWRgeMeyhSqPh26WZ58y4WkIVmcvWFIKdZZzFw7m9CaaQu6nzKAnEAgEAPNvDeL7MQmvGGoQDTnG+Y4A4dRTvY7sdaRlzNjuqBM7sEkwTpewn2b3TGIYWIMApmzsX+uwzXwECVW4HB4SX7m3RZXTVwRbXPunxB0CbdklkZbCU+DoUGsSLbzlN5Y5wN35t32i9RdNUEup18QzBA+pxE49rrpMzVZ1OcKSETDytpSixdS34eTDHzdtY+vmFjkI7M8xT0aDriaLSkIbpkvAc7RoEPSzmbOllRHFbpQpqWw9riDL6j22382TurH1cIzcvS2w5z8M5T0xF8zPx3KDkMHU5boQJdPeh1RBYgLmrA2Qm2X/s0Sp49wM6YNH++GhUHy0/oBuG9GTGhal+IfEZlH2jZHTtLKD4 X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: ae7371aa-8136-4a71-c270-08d96750c49a X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Aug 2021 22:44:44.4740 (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: nVhfX2GuM812mQnRdFpbWNPRikh4cxFZr89Oj2cS9qlOhcgNENz8E4CoKduAfpO90nmgti4+3NnnWsX9oxCR7a/kOm7LM7nMP2Qw1j8JjNA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB4653 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10086 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 phishscore=0 malwarescore=0 mlxscore=0 bulkscore=0 mlxlogscore=999 suspectscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2107140000 definitions=main-2108240141 X-Proofpoint-GUID: rYuYbRovr7b2wI_yQ5aiYZwdgJqKbUi2 X-Proofpoint-ORIG-GUID: rYuYbRovr7b2wI_yQ5aiYZwdgJqKbUi2 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 928c0076a2fd..69646a8b6e09 100644 --- a/fs/xfs/xfs_attr_item.c +++ b/fs/xfs/xfs_attr_item.c @@ -34,6 +34,7 @@ #include "xfs_inode.h" #include "xfs_quota.h" #include "xfs_trans_space.h" +#include "xfs_errortag.h" #include "xfs_error.h" #include "xfs_log_priv.h" #include "xfs_log_recover.h" @@ -292,6 +293,11 @@ xfs_trans_attr_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); @@ -305,6 +311,7 @@ xfs_trans_attr_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 81c445e9489b..d4b2256ba00b 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, }; From patchwork Tue Aug 24 22:44:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12456035 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 08A0CC4338F for ; Tue, 24 Aug 2021 22:44:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CBBD561265 for ; Tue, 24 Aug 2021 22:44:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229618AbhHXWpk (ORCPT ); Tue, 24 Aug 2021 18:45:40 -0400 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:33656 "EHLO mx0a-00069f02.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230488AbhHXWpi (ORCPT ); Tue, 24 Aug 2021 18:45:38 -0400 Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.0.43) with SMTP id 17OJtIwn001072 for ; Tue, 24 Aug 2021 22:44:54 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2021-07-09; bh=/0dXR9byPBxXJGdH0D70AkdSpS2zdUPV7HM9V/ZdeUk=; b=YzeqQK+W0NMIKaRI2f8ffaavTEHQl4a+Nsne06t1hf1xUKKtady54WE/lN0snjKVYdw1 T22dZn+ohfGUZ2eSBOmNAXXzr1ORJmF0/HOzEUHIzRShdHAR/ynZXhWQi58G4rImDyuA Nxgvr6nIL51rB6iESbaafi0I8ipZ0XeOkIycJDZCl3oSOs3tvwGmvBG1M1Gn9vpEUwhc pzh/PUAqyQqfrvRxILv23Vv6iE2dgsWFaIagI5eO1ZoG/nH3UenG/isZgamf7uLYP2UV 8JW6wFaNxYjxO/WYZqXxXHZgul4kBk1rUDqoIamatluB2wU5znexnH7qKtVZVRAVI2Hr pg== 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-2020-01-29; bh=/0dXR9byPBxXJGdH0D70AkdSpS2zdUPV7HM9V/ZdeUk=; b=VOboEcvXE1H7xsFkEZyY8un4ID2l6p5rix8S8zx18axvzlYZw/FIPEqvhuLWlpwnf9Lo ybmkN7dIlqdkQTMCyqx+Y4fAr/bXwXtc5foM31mlPPv9SX//SOLS8D4sqIj/0nBjVDQp oit7zuK+WekTtjLirLPcvozZvyqKZXQzB5/RIj8wCLeLN3sv3S4+rDo0fWXgMgxB/PWg wmOfmvrneA08GHs2k7RKDmfUU9NJZgrPzs04yVzLxVWtFeQ5EZfa0VJ9mfWMdlQx/z8f EAmwmv66epA0+kF6gaSwwZj/XPk+ASUbqDvujGWqPys53beQLq8+pWKml4Aq3HjccJzM 7g== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by mx0b-00069f02.pphosted.com with ESMTP id 3amvtvt4uq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 24 Aug 2021 22:44:53 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 17OMfYQA025324 for ; Tue, 24 Aug 2021 22:44:52 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2177.outbound.protection.outlook.com [104.47.55.177]) by userp3030.oracle.com with ESMTP id 3ajpky4yms-6 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 24 Aug 2021 22:44:52 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=H7Uqz2gNjb5GMyW9PCHivDvXoyAeizS8Z5vBmyoZdxwfqHaX3QLHSXwLWaCVJH4aJGJK9FSoHTf2VpjkCGXrrnBi6YKrcbiRH86PQXD+B0ezsaMm+XAwbLFzCYVeZL7v8aVYks18jRvz+X6ef0g3KAbY78wH4u7qWaAApoCKPG7gvUu25ffFCgUSuCVS7WapUnqGlYmXYMrxwboKNeP0HxTxErA6dSQnjaweSH3qOkBx7/twNKJbJybvfWyng0J9TWzbDmlJIeD6Sd2TKt6qZKwrtL4NINdy70n8IAoeep37WOwlsbhLnFlnFC73KXC3rsJ+jZ5oY7LsUlM3lI4JZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=/0dXR9byPBxXJGdH0D70AkdSpS2zdUPV7HM9V/ZdeUk=; b=XoC2QzaDf/zNr9qO0alpg4blCy/NdEswBXZYlM04ZWPunTni3yBnLEpXr8gTChF/yBIYx+vaqH+L7hH8ORTYY1InYdB+NXpS9oPpi1jXvzcnveV3kTd8u9p5wmGRHHF+m/lx18GekP9gmmHp7dRUIq08wuflUTVZR1KBhjINMxB1tkd13vySReNqnQsPtEgkWlm2x1rcocZxRJzmBMLVog8NpbSoVcubK+qjluI6hUCAM47mSyRyh4ESQutlMGi1eh8wrztTXImJkx54tu+5DtQjxFG4D1roAuYapTgSuMei47fy27SpT/9w4vc45fMQruVC9KmincN2RRHJFIA7VQ== 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=/0dXR9byPBxXJGdH0D70AkdSpS2zdUPV7HM9V/ZdeUk=; b=J0wSnAexfYX7H0ahRfHM5Q+SJVjwHuVSF+nilgiTFfSRi9hw9pdDaiLeRUg4gPq6+98/7YleY0BYg4u+T1n07pHDZdke4JFW+NzQdrjVpx41avEcRZw81InSGWrK4qmyvQwgD2sFvLX2n9sr8oaioEknr8qFEJKJgM8+EtjYUQM= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=oracle.com; Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by SJ0PR10MB4653.namprd10.prod.outlook.com (2603:10b6:a03:2d7::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4436.19; Tue, 24 Aug 2021 22:44:50 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::7878:545b:f037:e6f]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::7878:545b:f037:e6f%9]) with mapi id 15.20.4436.024; Tue, 24 Aug 2021 22:44:50 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v24 09/11] xfs: Add larp debug option Date: Tue, 24 Aug 2021 15:44:32 -0700 Message-Id: <20210824224434.968720-10-allison.henderson@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210824224434.968720-1-allison.henderson@oracle.com> References: <20210824224434.968720-1-allison.henderson@oracle.com> X-ClientProxiedBy: BY5PR17CA0012.namprd17.prod.outlook.com (2603:10b6:a03:1b8::25) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (67.1.112.125) by BY5PR17CA0012.namprd17.prod.outlook.com (2603:10b6:a03:1b8::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4457.17 via Frontend Transport; Tue, 24 Aug 2021 22:44:45 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e4fa82d7-53da-43a6-89fd-08d96750c51f X-MS-TrafficTypeDiagnostic: SJ0PR10MB4653: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:644; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: InOQkKxnNfCE6pINNiDmzsZC8RYay5VCzH4uyjC/X8wcVhkzpxSdmwKYlRxY57rrCULG9JWM/QChf/QvNAAqHpyJ3Mt6gYy3dQBzsyvdkr2fJQm1xRYgJIDzxTc+5fIVeCRrQ1MT1llfaRhEbF1DZyJyXPUsDb1I+Ej8Scrddq3wXDaDhJJ2xYToEERhkR6wvxODsoNrfmCll7ySjnfhm5rXtsUeUTidSfCjKElnKl6r4fF6jgVc1v8bjpHoWbX2wVqPkk2QsF/Y9sDG0Iq5BOpH8NQpcFljAkbcRmOf1jJPntWGn9ZwmH0CJQLf0s17BwMWB4AXf+ZTUBV71pYeXgj/1MnGJVtCq7Uf5zhQecax7elDIMA3fcpt3TXZ+X3J1n/XJrzEnXgNyQrDbYTU5YCQ0cs8R6ZWQsaIZLdOywoZm5fxUlvm7YpLl/EEsaGU7/fjOAzQQKqfrpP9HQ65gkOJtqtNr19smZ4GDjEkxd523Y47Q/TF6YvmtcWXL8c7PWnMK5d7U712sSV8tt+v5QSL+b2V4kRmucIdeT7iObS9rBWnnLnHXlrNfho3CtD0IX6KdyHM2Te6hjOn9o6XSW3YfovHjUnEJdbj8NkgSpdrQ+xY4aZIHmy+Bd6408zoJ2tYb+TZEF8UYh92T8f6Uw8XxeibgCDIcBgZcggmMj2ekeCIAY1i6YxWdJ9SY7VlPVz0K8XV0e+P4SKEM9I20w== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(6666004)(66476007)(86362001)(66946007)(83380400001)(6486002)(6512007)(2906002)(52116002)(186003)(6506007)(66556008)(508600001)(8676002)(316002)(956004)(8936002)(36756003)(26005)(44832011)(5660300002)(2616005)(38100700002)(38350700002)(6916009)(1076003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: CglD6wG9BWqs9UQmEMKCa/kbcL/QGrB1U7fSxptQEPa3P1yF6QjFcwwOi87S28mKdaTfrgDmRTW/hZO7N3HBjQzWpy///62mOHZKwr0K5Uih229Lx+3mM1mALk7WeIodt/8QlBdZLDoom5RtPYivi66b8VLQNqi5QqnYDFQtX9dw1jYbgj7Kie8WikRhk19BXZCw+WIJAreS6Vdre6NQ+NlZOjSH521F7pHrLaNPkcc/VbHF7ni/1OJxwgowYuZtaFDzS7XD3zyck1LrmGrjvb355iSeWhsGp59N1/H94gDxjexSm7lfkqnx8MSA1DQAuXYpWov4A074HHKE33GuO4bL+8LRofwZvnGzbhqaVfOyP6ya3H2mrNukHrkxX8M7uekDUzzP1BC67xif/2n6Iq7g65bsxb2+lH7ITOle7YOiIyDoTR6Rk3oAC4gWCCZTfCme+UWLIAFGJZT9krVPkfgeYw7f6FwQhd93GH/QbS1boKNzEePbiJ4D3qxzUcVpX5+A/UhGWU2IRdvX2wnmRj30aAznkn273Kg/ODKD5pZi87lBvnh6vJcZInbOQ8Tg7iNKAf+3RkGhyoM31wclcqAASLW9IcbDkOIgHfyKLmdQ2t7XxYo+FHc1FxIdaDOtC+hX9SwA6LydGghSfA7Hdx4C2vyWIHij/UMu+t9auaJoRE1bpqWXsP82ac6a4kaWGyEk2tZhAsArBaP4+X3a4wirlKj1v/VumBUUUlBOiT86phIX6PA+bD6iWwcFUQILeQ6xi8bWH3e6bSp/lGSrqMsNvXq16pu4NBCJV1dWfXyYQMAXxon+hhzT/g8IEXxbGiBqZmu6qVqRtxOYN2QNTPr+XdneHlHfXkJCFbQOVcy1ti51bGXzMNLCQmM69vttm9DJsZf0nf4/tlPusBsOmxrmfcPZCPv2KkUoRqUl30zpUzoWGGpelyk+pcrGmDarYFL7Rq1FwTmWhDC0a2gg8TT1zP5S4V1LstwDrNEXjzRCxKtntaY+TLQqS/xiwBgcxnglwACfLKl0k8unN7QvFUj20z0k66a21u0OY/gj6L4espTCZ7IurZOxCYAOjScV4alfwuQ4DRFssBxkWdqu0vseuMF2bbjRvwY2p3qpmLlGy0xWYyYDosLfYJsRgxlonC95S/xfLmPpzNglmedqlr+DTgUcI1fn+FRcTR3jQErwuNR8A7CVlFTF5LCIqbuBQdlaP+Aouk1IQehAZqm6HyM4DsRNpN7XZtVyqv87j0ea5j/cqdOSggMBHTnf0+OBXena6P5Wrr+7Nmnb3ACJB46lRVVINgbC9/UkkkLxu8+WOklcSuPDYBbUbATYGQwr X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: e4fa82d7-53da-43a6-89fd-08d96750c51f X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Aug 2021 22:44:45.3173 (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: 4RuegMSIK0JUwftF9bLoLoiIiIufX/jtgKTqEPeY+2hsHEkktvL7HP73SG+peBcsuODEMnpWFmCBb8UEoSl0eBgPXA0Z8Yo3FvpqcEiFMvY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB4653 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10086 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 phishscore=0 malwarescore=0 mlxscore=0 bulkscore=0 mlxlogscore=999 suspectscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2107140000 definitions=main-2108240141 X-Proofpoint-ORIG-GUID: sEUqAcOhl4vEoJU6Ci1PEnqWGUfZ2nki X-Proofpoint-GUID: sEUqAcOhl4vEoJU6Ci1PEnqWGUfZ2nki Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org This patch adds a mount 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 --- fs/xfs/libxfs/xfs_attr.h | 2 +- fs/xfs/xfs_globals.c | 1 + fs/xfs/xfs_sysctl.h | 1 + fs/xfs/xfs_sysfs.c | 24 ++++++++++++++++++++++++ 4 files changed, 27 insertions(+), 1 deletion(-) diff --git a/fs/xfs/libxfs/xfs_attr.h b/fs/xfs/libxfs/xfs_attr.h index efb7ac4fc41c..492762541174 100644 --- a/fs/xfs/libxfs/xfs_attr.h +++ b/fs/xfs/libxfs/xfs_attr.h @@ -30,7 +30,7 @@ struct xfs_attr_list_context; static inline bool xfs_has_larp(struct xfs_mount *mp) { - return false; + return xfs_globals.larp; } /* 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 18dc5eca6c04..74180e05e8ed 100644 --- a/fs/xfs/xfs_sysfs.c +++ b/fs/xfs/xfs_sysfs.c @@ -227,6 +227,29 @@ pwork_threads_show( return snprintf(buf, PAGE_SIZE, "%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[] = { @@ -236,6 +259,7 @@ static struct attribute *xfs_dbg_attrs[] = { ATTR_LIST(always_cow), #ifdef DEBUG ATTR_LIST(pwork_threads), + ATTR_LIST(larp), #endif NULL, }; From patchwork Tue Aug 24 22:44:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12456039 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8FA62C43214 for ; Tue, 24 Aug 2021 22:44:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 72A5B61357 for ; Tue, 24 Aug 2021 22:44:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231143AbhHXWpl (ORCPT ); Tue, 24 Aug 2021 18:45:41 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:52836 "EHLO mx0b-00069f02.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231135AbhHXWpk (ORCPT ); Tue, 24 Aug 2021 18:45:40 -0400 Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.0.43) with SMTP id 17OM4Elo000915 for ; Tue, 24 Aug 2021 22:44:55 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=n75Fp+Ql+pwe7T3W6dNDENsXFlViZYe1Rcs0MpVmbKY=; b=n2Y9UD2BL4DsEbtJsBdnDwyeQNFArCM4CoS8tfH/kLXNoaU4XAHhivrfNrJ2vhKerId+ LZtDtWR+9Cr1r4vUBDNnUoxLm+Rgxw/WUUV5w8J5xogocr90GJi1HPnreNT1QFkl2pfz s1TpoOtJ2Rp1PqIVQH0rjOgCjayIcz6oh1CjlY+k6apkHM6CFnqHadGkByT9WTmHQwrb /2oY2lYq+jBZ2y+GeKpXAhumAWxbrsfW3+xiIrfy8aYycySSwEEhFk427qgmlKsASjsT cuwd16+/lpLd7/PtmUV64pU4QJnL3ymJAU0ko3YzWO+/0abvytrCMS2rL+00hazMyw2e 7Q== 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-2020-01-29; bh=n75Fp+Ql+pwe7T3W6dNDENsXFlViZYe1Rcs0MpVmbKY=; b=jDU15hQ2md1T6j3BAN7L6165Gmn5JSxSDT1xKHnMFWMgEo0pgsqjxoJLCVNWZoIUn3un +qs/ErpiGjLozCE/HxEB1iO5gO/FPb7gK62nfUYt0xxJiBqQhB+Bif65w35aUdgg3Mub UPz5D85xDCluWOuN0apmpVOjKtyaXr69C56AVvbfJ38gDySGz09T3j23v8119hUhvXa6 mL/2+cyayWnd742hjkExJ6JeAEiANSpuFMl6QjW399DG0C57vl6R/zwxJwaYx3kwvWPX hpwwy7OlwnGJTRskAnDskMsTPKDdDRIs2yWsjD18I2IkcSqSR5bX180QyeB8pOXq2DH9 Gg== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by mx0b-00069f02.pphosted.com with ESMTP id 3amwpd9wfm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 24 Aug 2021 22:44:54 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 17OMfYQE025324 for ; Tue, 24 Aug 2021 22:44:53 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2177.outbound.protection.outlook.com [104.47.55.177]) by userp3030.oracle.com with ESMTP id 3ajpky4yms-8 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 24 Aug 2021 22:44:53 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=F4dYEiHkDhHuj5BmUfWrnh1Pi0e46IfqoPwEUuZRKmA9obKxzaot5UGHMHCTrv0UyTUHJnvJpHvQTmvd7s+c18ZqaYG/QLp0KpLQNjsY/Z2P0xFilzl+dE4HQ4rg9kAeVmRlmSay7wb4CFV6maKc0oxk1ltQDnfs8Oh3YLhIjZ247v9SXxl/L0UBgBPEugYu8F2dWgThGrsQQl4T7f7g7RURJ2HdHh5AWzc9w6OXxe77tJav54CLxlw+HpbGssnZ85YGEqEMVMoNZqnVhwXKWfLnBlPi1Baq8kGAUT3Txw5XpZnUzjM6w+vrvzPDx9rCAgNvagwg6dDJ01hbBpV3gw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=n75Fp+Ql+pwe7T3W6dNDENsXFlViZYe1Rcs0MpVmbKY=; b=NrXagDTfN3NjfTeZD6t9r0TDBuZVD+59kQ/HfefTJldlkbnulc8i37JYo6R8P5MbNab6DjP48rJPvGgDsJdJMFC9Lx1lsDtsu1flCdaYn6c4ZJImzM4UxF1kAvQfK3FgSLFQ3knNFrENSiOvEje8SW2+Aho94VJzymkA8+d2v5FF23owU3FZQd7EyZ2hRDY1Jj7DN2WJMCA2zY5mv9kF29AUPdDJOtpRllKfcmHZ/hGO0g+HWaZthMblRSOzad3I3fL+PGr+myzI/kL6/HJrfQOIaQ22xMT6rW/RDG+A8rz819FOBDU5Yhe9OsmxTZ90vyHQBR8kdj8tUXc+wx4IVA== 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=n75Fp+Ql+pwe7T3W6dNDENsXFlViZYe1Rcs0MpVmbKY=; b=YpoirJ990vdE21/ah1YYQ3fP8puHX5Wm2aPp5f2MX5VA/p5sFIdIwE20+GcRwHO+KDznUzTPUdyDiWJpkjUPPWnuJZAPqOwDOtKYcI4FhekLfqUgvDl1C0ACFzzgUXagsRNyRdEMihKOiStCEn4sxTrwo7HM0T4w7cuJTwdyfSQ= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=oracle.com; Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by SJ0PR10MB4653.namprd10.prod.outlook.com (2603:10b6:a03:2d7::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4436.19; Tue, 24 Aug 2021 22:44:50 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::7878:545b:f037:e6f]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::7878:545b:f037:e6f%9]) with mapi id 15.20.4436.024; Tue, 24 Aug 2021 22:44:50 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v24 10/11] xfs: Merge xfs_delattr_context into xfs_attr_item Date: Tue, 24 Aug 2021 15:44:33 -0700 Message-Id: <20210824224434.968720-11-allison.henderson@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210824224434.968720-1-allison.henderson@oracle.com> References: <20210824224434.968720-1-allison.henderson@oracle.com> X-ClientProxiedBy: BY5PR17CA0012.namprd17.prod.outlook.com (2603:10b6:a03:1b8::25) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (67.1.112.125) by BY5PR17CA0012.namprd17.prod.outlook.com (2603:10b6:a03:1b8::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4457.17 via Frontend Transport; Tue, 24 Aug 2021 22:44:45 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ac5f6bf5-db78-403e-1e0b-08d96750c559 X-MS-TrafficTypeDiagnostic: SJ0PR10MB4653: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:250; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: DfmM7tBkoG0iVyifNvTkk3BMmSEK860jwfUV+d2ZxMcidbu54EJI/ys0LBYRdxd7jgurQI4NggTCwA0MdRSn2uGwV/OGjc/nEBeq4aBOzcGuY6121PoY+vU1mj6UX33M35NUaxF+jkDNfVxLGsqTnEbJLu8oLqSmfEG21rEV4EasUZjJHlGgO/489w5X6gzniNJs4AY3KwfGxGgJBYQZBECpWjfH4MZFdOHFUW0PgbdiDw5EiXIEUcpfQ8WOZpzzZTquYx/yYCMA20net49bSlx4miDGH+SWmgoIlzF6FuPgLjciwLlqXntlm7bul8QUHTpJD6n+IwHQZT/yDe2/QM7CiNBca8iZE2Swjp65J+Im2V83NlBFwflpQO94bOWwl2NHjrDjQnIwGV1uVA3ODks5YizM2SYJrxBhCGb2mTdV5RzF/7FgtbcqNjUlYJWT+6CamXmrMyDnEpJAyEseQdX0pspWfCeXYObzLjVSyLQ5IOv5CR8KyPR8sKvBkD+PdMGBTu6imnRVmGZAJTJXY4NKKuIj9CRzNqiEBg1JD6ibphxAKdiZxGHl0Ou2NJo5HGM1GK8l9rkIWtFgc8pa6dMiNOAMzXfQfnZyZUkal5GPo8ClNwWpy+yTb4ZWf3g7EDKnkQacEd3Jsnyd500aY44nkbsQYGq5VFBTSFsD+H4u5PHe2lbZQqsVoFdtbo0pmdOXA9KkRQI3Zy6urAeibg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(6666004)(66476007)(86362001)(66946007)(83380400001)(6486002)(6512007)(2906002)(52116002)(186003)(6506007)(66556008)(508600001)(8676002)(316002)(956004)(30864003)(8936002)(36756003)(26005)(44832011)(5660300002)(2616005)(38100700002)(38350700002)(6916009)(1076003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: hRRDbKKwhoh+MxA2cfpJffTSBSTbNju8uV5OB3VWM25LZ6X8pQsG1qpi1AhC+0bCNRjR9sIlVqT91l0bZVL2YFfW/2Ymx2XfrmweVeVLHpbHxEBG5WkW1eJeXshHwHSSQ0bLGQJzGB1xUCgDgnZIomEFUFVUkpbhPp7apIGL1RqVTdLu+8cPFJRZqL76z8qSuuuDKXDFrOUdL1KTUDjk1jGaE3+Nb+5Iy2i6sPoLKRWGTdk9OgXKKtJ1rxc0XdT7TE2t68XPTg4LURHbZyUJ2vCmb/VIM28XnVepjkjy6ymyYwmc2YPQ1s4EDrS1iz1I1BFeUr25rmB5gM+gj/mFAsmTEMRUyUbEtE/tj7fioZ8+q0bVWM4ahZPd74z+4iaOET6mw44u8uAn7Vdpn5sPHTN6qwfQS+BGX16kAJ318qm9MChSnHsSRbzOBso75odaTTN9UeEXVVmm0jrQtJmuU0tkA8bOiL159BEEZcXfv+OvDaImO9f3JM87ZWpVo+NQXBXW297w08R2mPJT9KrSWeDKGm6oPsZJKvElP4IIka34FVcnAUa8d0qCiAgsdDrI8gF9AVwMG75kEgaEQeHqaxe5wLBM8TxM/1TBQbOqMRQ+Bc+mSl+feE0sqw2IsT4tiY0v1MEFpQ6qRRHCCIo8jSvBDvYGi+4QWO0Rpoz2HuvrAD/4aMT90SGANZh3sOQQZ8RkjJh3w9xClXwHHiPmZQjwEcu3g98BUnLxpBwJwmM1UvjEVvTsxdLnLaon9d+wHbOHQTOmJ+bgizXzBgIqyqL+3DSW4B20jG/0a3Lwbt1wNNxS8JVHD0Z39Ogcls8oKMXPCY19bgYLVNvKdSmBcX1tVjuMn6lVF9+un7/CpggsVv1oDW8/2OWqoDVVpr+mVFB/EsWIcRCupEtKHNKk/HYu9uVBXC5EZ/TJZlQq6I2fMGaec+mq4KWgpefLTX9Ktgp8/3gRTzfdU8N+s07ut+ls+axPysh0m29qNMLZq2IvsJGdKqA53ilLYo0w0VjKb/AK6Z6gG60tk88ow9scH4Q61awXt5wlqbT+bcAYHtAJbii5s9kHmaW+DIXFpwcSRog5ApREGcbBHWNVMTyQIo0f9ZRP6DFdDtMXhbdvpTc8QrfIhZlJYcc9At4lC/14+KyKzjn1MBSgdeRA4XkyX7pc/7KCmOioiqSWbRvtJk5d0otajjdBmhghzV8EShGbLXi5pa/fra853E88KrdLgk263EEQqxvmn3cgsySiqoJNx9VShFBkSbsdf1uX/YUH1VDKJdaX/GOgEtTjfJmjeiA9G3c1nQjZ58GacHgGB4LRQXxL1IcziRH4AzgZgp2p X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: ac5f6bf5-db78-403e-1e0b-08d96750c559 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Aug 2021 22:44:45.7135 (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: ReesrVAb3C454W4D/1xZWu1jzQzGkAPLiG2GZ5j0yDup6agH8RHn7Jp8M98nRrX+hcfPoezPf7Epd4JZQL9rCRJ4k5Yqv8l4ZiGs0dd37+M= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB4653 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10086 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 phishscore=0 malwarescore=0 mlxscore=0 bulkscore=0 mlxlogscore=999 suspectscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2107140000 definitions=main-2108240141 X-Proofpoint-ORIG-GUID: RoIpmQxHZdqdjqOizAAY97JJ7P_2ZAhK X-Proofpoint-GUID: RoIpmQxHZdqdjqOizAAY97JJ7P_2ZAhK 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 | 38 ++++---- 5 files changed, 141 insertions(+), 141 deletions(-) diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c index d62ab53c3b07..c3fdf232cd51 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -56,10 +56,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); @@ -246,9 +245,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; @@ -265,7 +264,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; @@ -274,7 +273,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 @@ -294,16 +293,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 @@ -313,14 +312,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) @@ -340,19 +341,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; @@ -364,9 +365,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: /* @@ -377,10 +379,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; } @@ -390,11 +392,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; } @@ -430,8 +432,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; } @@ -450,17 +452,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; } @@ -491,7 +494,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; } @@ -504,14 +507,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; } @@ -547,8 +550,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; } @@ -568,18 +571,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; } @@ -589,7 +593,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); @@ -786,7 +790,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; @@ -1099,16 +1103,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) return retval; @@ -1136,8 +1140,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; } @@ -1158,10 +1162,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; @@ -1192,7 +1196,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; } @@ -1221,9 +1225,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; @@ -1327,10 +1331,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); @@ -1389,16 +1393,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; @@ -1417,16 +1421,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. @@ -1439,10 +1443,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; @@ -1457,8 +1461,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; } @@ -1468,7 +1474,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; @@ -1485,9 +1491,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 492762541174..ceb2c18b9cca 100644 --- a/fs/xfs/libxfs/xfs_attr.h +++ b/fs/xfs/libxfs/xfs_attr.h @@ -430,7 +430,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 @@ -455,7 +455,7 @@ 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*/ #define XFS_DAC_DELAYED_OP_INIT 0x02 /* delayed operations init*/ @@ -463,32 +463,25 @@ enum xfs_delattr_state { /* * 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 @@ -496,7 +489,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; }; @@ -516,11 +512,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 69646a8b6e09..2f48e84754ae 100644 --- a/fs/xfs/xfs_attr_item.c +++ b/fs/xfs/xfs_attr_item.c @@ -284,11 +284,11 @@ xfs_attrd_item_release( */ STATIC int xfs_trans_attr_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; @@ -300,11 +300,11 @@ xfs_trans_attr_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; @@ -348,16 +348,16 @@ 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; - - attrip->attri_name = (void *)attr->xattri_dac.da_args->name; - attrip->attri_value = attr->xattri_dac.da_args->value; - 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; + + attrip->attri_name = (void *)attr->xattri_da_args->name; + attrip->attri_value = attr->xattri_da_args->value; + attrip->attri_name_len = attr->xattri_da_args->namelen; + attrip->attri_value_len = attr->xattri_da_args->valuelen; } /* Get an ATTRI. */ @@ -398,10 +398,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); @@ -409,9 +407,9 @@ 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_trans_attr_finish_update(dac, done_item, + error = xfs_trans_attr_finish_update(attr, done_item, attr->xattri_op_flags); if (error != -EAGAIN) kmem_free(attr); @@ -585,7 +583,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; @@ -622,7 +620,7 @@ xfs_attri_item_recover( xfs_ilock(ip, XFS_ILOCK_EXCL); xfs_trans_ijoin(tp, ip, 0); - ret = xfs_trans_attr_finish_update(&attr->xattri_dac, done_item, + ret = xfs_trans_attr_finish_update(attr, done_item, attrp->alfi_op_flags); if (ret == -EAGAIN) { /* There's more work to do, so add it to this transaction */ @@ -636,7 +634,7 @@ xfs_attri_item_recover( } error = xfs_defer_ops_capture_and_commit(tp, ip, capture_list, - attr->xattri_dac.leaf_bp); + attr->xattri_leaf_bp); out_unlock: xfs_iunlock(ip, XFS_ILOCK_EXCL); From patchwork Tue Aug 24 22:44:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12456037 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3B2F4C4320A for ; Tue, 24 Aug 2021 22:44:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 215C86128A for ; Tue, 24 Aug 2021 22:44:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230465AbhHXWpl (ORCPT ); Tue, 24 Aug 2021 18:45:41 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:51930 "EHLO mx0b-00069f02.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230506AbhHXWpk (ORCPT ); Tue, 24 Aug 2021 18:45:40 -0400 Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.0.43) with SMTP id 17OLKH1k021196 for ; Tue, 24 Aug 2021 22:44:54 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2021-07-09; bh=HBfdz4ihB0iDtd2wOQAcDOXCt6f5arWP6TdO132htxM=; b=Pbk/URS2QddDhqueXAxW0evC+Qy7+hkb1czsgp4lzcBMjNH+EPBRxLkUlJkGSSgduuOa DwE8wdaTPAeb3iAhib/xVjLZmw02mJLEuE6UZn0dCf3b+LuwLASWW8sfuA3UuNjgh1Kl B7bJFF1igegbmkoXdg1WyEs9xTZzRytYQH0DQfHLEbgb9MQDxqKX0UbXv+V6/iV+uHEo who6ly2YzHJ+IGEWHrB3w9o8bc2n1Ks2dUohHxKulVz5Z+TN0AFM1EvOA+n+ESspCkCs T2ibA1xwzxbxWI++ELgDoT8FvxMz09No+zvKBsAdQBUBp8r8/w99mPfMjb7187rt6Zen VQ== 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-2020-01-29; bh=HBfdz4ihB0iDtd2wOQAcDOXCt6f5arWP6TdO132htxM=; b=TlZgrCtiOnkziJgnhJJSMLKeY/95v2ubD1VmSAE0RpXBc+UvG6gYKNnNfI3bxz1OsR9h /whzWY20H9xbasAOJnNixFmi4DYHg0XqX3hl+ct+q5U/UJ1dArgKGVwd1dc6iCI6B62U uXmOPF43+zBFWUbkN7hPvtWvAQdn06Gg9fpKMIdec76+//CPPKKHzKu6ab3nM1LRsT// VXn4nUoNa5UZlN3I+JZoiKg1kpfENQUt9ymiyCipBfxyac1fruWeAnv1wKybAOvgVXU6 Wk+p7zF1G7ey+QAxqySVI3SBBbEF4QgKx2ekB3KOlmoNEuSOpBcB/344ctrBWPFDXyYe 4w== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by mx0b-00069f02.pphosted.com with ESMTP id 3amwmva069-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 24 Aug 2021 22:44:54 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 17OMfYQC025324 for ; Tue, 24 Aug 2021 22:44:53 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2177.outbound.protection.outlook.com [104.47.55.177]) by userp3030.oracle.com with ESMTP id 3ajpky4yms-7 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 24 Aug 2021 22:44:52 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mIC0oEFmOp587qR3GIZ6BRxegXjGQNDH6RChNKIzAsgWVPx529sEICoqOQOYPejH6C41cSxIt86hONDluz2lKzQrbHCbXRGV/hOJ7UPxen4Jyr31HvmGZdY+kCGqhztT/IUZID4bKaox9KUNPjrHjnFay3NQmeJq0Vj39cUUZ3yT41TT3/FRfQ9IlRPSwf5fRNlqPbd1miA9+vgIT8GEeM5KUsdIgGL2cBA8ai+V1m6J2kFDhgpKUWyRElak/yGzxlS8RtOzdi5dRGol5mu67lBA202xelE/bRhM68gvjl0TfciEE9KbfBMeKFxdrRB0SRAjGVjVwdhLQjlqAtVX+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=HBfdz4ihB0iDtd2wOQAcDOXCt6f5arWP6TdO132htxM=; b=OsGDbJ/EicibHE/c8nj2R4/9tZ5+QjtBdyLkWz1oxBR3tpt7Riv8kL5In5y9ofHQW8vbmci3xtEEU7IVOjPOnnqToFxjd8m72TT7G4Lb6NzX75DgAz8zfxAo04iOXocAU14CdqtCnJzufLGBx8pfNWOoENy1rweRvh2qGd5YoNFgzL2XBloLVeP3iy9xWeAUkbVvrAjYhbPFjfN/6IDRD+pDXDNoqW/nqiZ0ZOjy0tihgXhTLSafmQbk59j28DIBQWUmNdoTJE0+50P7x4hejNOrj2aXoBirtXskqp9tk+qsum98xbEuiKj3t/BH2boPk8xpV++FRNHmFkkDQL5f2Q== 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=HBfdz4ihB0iDtd2wOQAcDOXCt6f5arWP6TdO132htxM=; b=mVwwkIVfB3jxRWXbDsMv3KxvtsPFXDfkNdiY60T5kURUPfeblNJGfo40vaodrK7WSVpzzsHP5uTsTfpg1tDdYVJ0yfoXm6aHLz/GwIexklXVExGvH3qbdjfiXNz87D/gVNURtlElbLoEBcct9jnMskhZdIGKPJeYtMLuspbxPTI= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=oracle.com; Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by SJ0PR10MB4653.namprd10.prod.outlook.com (2603:10b6:a03:2d7::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4436.19; Tue, 24 Aug 2021 22:44:50 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::7878:545b:f037:e6f]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::7878:545b:f037:e6f%9]) with mapi id 15.20.4436.024; Tue, 24 Aug 2021 22:44:50 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v24 11/11] xfs: Add helper function xfs_attr_leaf_addname Date: Tue, 24 Aug 2021 15:44:34 -0700 Message-Id: <20210824224434.968720-12-allison.henderson@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210824224434.968720-1-allison.henderson@oracle.com> References: <20210824224434.968720-1-allison.henderson@oracle.com> X-ClientProxiedBy: BY5PR17CA0012.namprd17.prod.outlook.com (2603:10b6:a03:1b8::25) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (67.1.112.125) by BY5PR17CA0012.namprd17.prod.outlook.com (2603:10b6:a03:1b8::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4457.17 via Frontend Transport; Tue, 24 Aug 2021 22:44:45 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d5e5c250-ddbc-4974-16f9-08d96750c59e X-MS-TrafficTypeDiagnostic: SJ0PR10MB4653: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:10000; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bIEvpEbmjaAcAtewczrqsUtpw5GEYGzNIUfFw/xvJFsob2BIyciVBSaiB9yrXw7O3X2ESvqA9jEwJYc9xnvYvATM57yZaZDYIHf1Ph2+BUD5KEt5aZkr/afPFP/2Jy5fSHNZX/7f8KqdpJ3OH9X8xDx6kHa/WeA1TCd96K4C3grH3BLRn3ET2DMdf9wzDJjDRdQ/JIZ8uSjSAWWsPalCaQiMN0Xme7yGu8xc4M14nq1Un8RC3wh7dA155sFAFP6t+mOr+Ak2aCw5FCYAiF+wZZkr9uc4c8ECQMdD3698ZZnuMSVsaQQHTtBiPoSMqiu306eVZ80JGXecr2BN9kOjp7efGoaJ1CH/IW2u+Hnb7oAcLmnuni+TdarKTi0v0C1R4+b1B8GGLREetFTrjH5OWp1PSQ5Tud0qtPdBFXcAXAOaG6EZzON2kDcMAtjpG+vcfKwh+pWsJKioa7SE62pBFv4fsOm17Cta6dADeVFldeIUNhUTJiYzZVvw5/yR83vBkz3mADmFZCuBpBM4yDau3MRwP64omejjzGsMmFo1ssGLQv2IAveXgc+FlkyF0HagoPNLMcsko7Bn28qI4E6pqks8WQ9bI6gkz+c6pos+ABeiFpxb5p+eoylSBHAlJXk/v2PIn/K7R0bn/NoB0FJqbYV0jP3tJTS1RzKjknKl+OxH9oHAYX1QqzSRC9UwtYrC X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(6666004)(66476007)(86362001)(66946007)(83380400001)(6486002)(6512007)(2906002)(52116002)(186003)(6506007)(66556008)(508600001)(8676002)(316002)(956004)(8936002)(36756003)(26005)(44832011)(5660300002)(2616005)(38100700002)(38350700002)(6916009)(1076003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: KKAwkqodEc8wIChdYXmvtmMg2ZLxF/mhdVMVdajvvg27bYL1yINQAWwi7dIHlXti+TDIEXf+9GFYxEBGw85QOVIRBEM4GuBfajAkmSuMGSYMhdbKgGIguII2cXk2L2hfwcUKtHGhu8DH4BhPIYZj4V/w7/jMja4Yaq2WCND2nYDlpRyKa1/0NRdGA8L7ujcpCgJHkK+w1KaDz2O2bXUj7EbG8U0NW3s2neJ+vjLwgpxgTf7LEwLn9NZYtU4VGqg7bMiAaLPkm0LG8XSOu7gNGTLjzo1tdRfmsIy+5EP6aD+gfxotuEh5xuCDrY4EbhwHCXEszU7SCXL3DVab+I62e9Dg2RE8iuV2VYkrwm5ERV7/bF0tgSb7FE79wkBZvx4J2Y1RikDmunLXqpbs3S8u8Y3NSY/HejNeSFNXdDcNgUR0aSsinJ2Rela0FGAU6ypcrCNbC6D8Fb4gec5P7HZr5+g0ssX6N3b0nvacs5X7icJIi85QvCPUj2p2d7kB3MTmsAdq93N90F+CDTw8LoDfxQf54P5PGbckB4Es/TS9M398Q4CaTIazCKTlzIy71du8gTJ6mDzmG7jMKlyCywdVRKC6YGnQtxKD0ZvEh9+XILrb1sEBqQMY8hDay0cAAd2AwhwGaZJAYF9qwLzewJREDXqFYA8LzOTv4SVdRNN7cTxbbdJCHCDuYS7NvlvGd48lkbxWblWmQ+yLwdepZo8if80G6Ot5ZG5o4wjLheyrdDzAgLgqhtQ5hnFiGmWQHDbe+KPbRPWUjzeu80gxqk/KkHcv1uhYjlOLwDgK0yM5vFzNMKEJq03l1JDXWjLnjgAgyTKuj+Ct8f9OsH7Nn526jbDCk9OeGnqYa1yJOxQYsrbI56UWV6M+bkj5UHRdtbVD4lnzKQayeHF+jk5yj7d/m5E9y3hAr28+gAGXyWRM9NGnGziEKwPcKk4Re3PcgEyuynMwGKMvNwNaju8iD3+vYY+M5XHADSIZGqIXhkCJVfT7f0VXITG2e/O1Q8EPj6iI8aO8Y1a6lyarzgiOfSlC/ZeYsudg367Oud18Zz9mwoy6UXu4/YCuEHD2/JYLtFL0Lncvtr2yaw28K+xk3zH0ASSlmNYiADzvq+/RhxhbBAO/LJnqfngW3NC/u2L0xyvN7CLazO+cfst0Gq2FEHAHo54DBu+19aF91dFzoi3VICMV8vHFNapRCxkxckjFis/1k1gnTWCHuInkjZwKY1AEfJm4YrEFh1UaueXuCNj7Cu7m9CxhTtqhdZ99Sp9FylKPU7cMEoBZxSSwxKfBmydVMUuQrddDYXjiSjhSlHOM4ECdouQOVjY/uWn7l6wiNR69 X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: d5e5c250-ddbc-4974-16f9-08d96750c59e X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Aug 2021 22:44:46.1974 (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: FQg9opeKo0M/wmfhOU4jC/D0ptMKlAFQDNRhWiIAvxdS7/HbfbOWUYtf7ADT3/me/tjqAyTshcGG6gYFjHS/G4Wvszk5fCt8bXLeqvgpy0Q= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB4653 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10086 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 phishscore=0 malwarescore=0 mlxscore=0 bulkscore=0 mlxlogscore=999 suspectscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2107140000 definitions=main-2108240141 X-Proofpoint-GUID: 7M8kRxsiwyDFqa_lnVmXIHG76h7mpOqY X-Proofpoint-ORIG-GUID: 7M8kRxsiwyDFqa_lnVmXIHG76h7mpOqY 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 c3fdf232cd51..7150f0e051a0 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -284,6 +284,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 @@ -319,57 +378,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 1033a95fbf8e..77a78b5b1a29 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);