From patchwork Mon Feb 28 19:51:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12763731 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1D86EC4332F for ; Mon, 28 Feb 2022 19:52:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229660AbiB1Tws (ORCPT ); Mon, 28 Feb 2022 14:52:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43540 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229797AbiB1Twm (ORCPT ); Mon, 28 Feb 2022 14:52:42 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 18CDBCA0E3 for ; Mon, 28 Feb 2022 11:51:58 -0800 (PST) Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 21SIJIAs010136 for ; Mon, 28 Feb 2022 19:51:58 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2021-07-09; bh=a4n5szR4ar5CW6cUfu8a6RCOic85ieRG4y4Jem+qoro=; b=VecvcJeRPty4Mv4Tefsk27VUdDESlThyhZKnz8iGvKLMnq+yU/VDvKyUvCTqNROREMxu VIy618bsErQq399XJzUJUWqUtXXkzsvCnrR0G9QXdEHO0RrUKviNPx86Q/q5UIyZcLax fd2fyKbUZg7k1/m9flZnUWQzKPLrW1djvcC5Xd5+DjXv1JYIaiCdeb+ljG+Vu9G1xvoD PvUN3AYDxMTJyAK3invLrgSRlZ3c5nD0QwHw7aErXtljJtSkpiJfdJmsHPPSi0q44vVg 9Ms4wWXlI6t/bdYOBYt2sSHxbUgk4QzkjpjPOpN7lyXhZ8LAznCpBuB52hktqDISbnuf jA== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by mx0b-00069f02.pphosted.com with ESMTP id 3eh1k40pq0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 28 Feb 2022 19:51:57 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 21SJklth076550 for ; Mon, 28 Feb 2022 19:51:55 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2170.outbound.protection.outlook.com [104.47.59.170]) by aserp3020.oracle.com with ESMTP id 3efc13e3fr-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 28 Feb 2022 19:51:55 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dqrxm56YpSCw7KhpvmlSrJyRyime/IyraO+GawB4tiVRU5f6JMqeVEE792jj2s5DyXRJtLuwsfG+UVNCB+SoN0zkEPJlatekqgNgTNVZ+9xys6pRBmjhByFdKvzC/rARzp1ugO3tm9S94nhX5D5N6FVqVqNQpf+QKCNGPSIStkIhu0BGs8lI9/WAI6znQ2sCL72B/F21nr4V2/FUlejGPsBBs7h5nUEpXXMW79DZmZO15oXAfWV6n67OTAG2JcZvI3zCt7u7TNmc25PL7p/jo/QJiWLZGm2FP71LwV0fE5a8QJpv2IfMLxFYbJAupBZp/l7b5ZsBXWBYAXGzs3gmjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=a4n5szR4ar5CW6cUfu8a6RCOic85ieRG4y4Jem+qoro=; b=bJIAgPEILYG5WR3p/uX0YmHSR3Fmywv/UkJaPyJFExIwGyKXEJEn2Q+kIXrihF00vwxysB049yczVpVjZvq53bJWk7TAHw5OKD3KuLPTKIN/JI+Cs4Zdjg11MmZc6IaDJn94bdITEgDqkI6mMKsGtFiJ9Yq5Kv4Fr6MQRJy1l1wzPxhZpdPmetb7NGF+qwVnvZtvPvoKhorEjOG8Bq/y22kn41ty7Bis9/FVQxRbBw6u+gM2TR+ymvYutsYEPTkqQ1ZTldbdPgvjXta1OEDrI0US1k8pWSZO5UeMwfvcpsQmrMf5w4p+W/sXtiPrHnISG09T7hzmsodE/2hgEwyieA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=a4n5szR4ar5CW6cUfu8a6RCOic85ieRG4y4Jem+qoro=; b=XfR3ldcTh021ejp4ZuhJAvucnX+YTQjHhFJ9BIA1K/lxR4qv718sFhjOzQoLbQZ+ovu2cH/malxQsevIRCn4GTxNTuPgGJ39U7iqLJ+aP1LOcHS6wuBP+2PDS5feUHImXi902IN3Y4F9pSH8kvcK8skOwSeTioSpHLlCr/2l9O0= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by PH0PR10MB5612.namprd10.prod.outlook.com (2603:10b6:510:fa::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5017.26; Mon, 28 Feb 2022 19:51:54 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::a91b:c130:5e3f:119]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::a91b:c130:5e3f:119%7]) with mapi id 15.20.5017.027; Mon, 28 Feb 2022 19:51:54 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v28 01/15] xfs: Fix double unlock in defer capture code Date: Mon, 28 Feb 2022 12:51:33 -0700 Message-Id: <20220228195147.1913281-2-allison.henderson@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220228195147.1913281-1-allison.henderson@oracle.com> References: <20220228195147.1913281-1-allison.henderson@oracle.com> X-ClientProxiedBy: BY5PR03CA0023.namprd03.prod.outlook.com (2603:10b6:a03:1e0::33) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0f799dcb-aa8a-4693-4db6-08d9faf3c4ed X-MS-TrafficTypeDiagnostic: PH0PR10MB5612:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: zXJVqubbD/T0EbIrvh+8R7XuLBVsgI8bhFoSChKOCOs1k4A/oOH2iaUlwQveQ0SpBScVOghOWOGL+ojW1R3anBoBzRgWM1GT8MSdyXqLd0Ly7YuPDQZvD2XL/XcO4r//VXsSoFzutyahB60grCKtZkNeT1cF12zdfhdKpges4hXuyxc5CCZvbKv7lnwNzcjN4V3yQ/yKvArejA8SYtRgOPzTyHxdWx/7kpcDwsyE+oPKqCJDmyXZuXzXTlS7VH0SglaEmIWU6eqiBlvIKUcM5mwgwBVhNTWGX5APSj/Tb9SoKqGphapHhgS4ATqi6GL2FrG+sDhdhf3jVoUa8opj/ED5BdYPF4Yd0FvBLHhukjwWBl7CPXHditTc3rZLpXoIj39YtzAVrQxPIwhZTgO/m0tcy8tJnJnHttzb5rxhLFoGDWFH6cDlp//DScHtyA9W72KuVbiFH6ryt7fMMKZY47xSp4Qa99/mtL7f5A4+MFNlY2JHtFLci5EM6inwafK8NzE8uPrEgRLSAN2O8d0P93kJRROqtu54I0KkdQJ0Rdrd9S+VP1IwmazYPptD7bD1HpKKIgz1da2swbzm3fQtfz2xWq9+9osWWsNNjaa89tlsr6JQbZPGlmvYbTYOCa+jMYR/xBT2w3OqVqDnhenPWwEddu2cEXq2bnvI2pfyKfuePFfA2GHF8tIkiJnQ1rhkke3OJ2SDrq28eNvLH47Lbg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(366004)(26005)(86362001)(186003)(8676002)(6916009)(1076003)(316002)(66946007)(66476007)(66556008)(2906002)(2616005)(6486002)(6666004)(6512007)(52116002)(8936002)(508600001)(5660300002)(38350700002)(44832011)(83380400001)(38100700002)(6506007)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: MsCpR+vC8fXgYJJCi0oz+NT4aXmV3irI4dPxqnyJ2VhoCCFr/gfGHbdVE6QH4TkyprTsAVjAMMLTj8IlWi8vu7awQpihpWPgWMrADccsbJ6Wx1nqb3epkKso6kyJWrdShwGqLZ3r0Yxwy1s6iTVJKZd+pbRrkvZkeSWyKHrAqWYsRHgMY5olcXHTtnt+1X1wj382XuV/MzA0GxhdUyepaJszpE7IfrGoSmhiIBH8htAgDc5R5WurfuVavd1av4hWgNhjPctXrksDr9eCRkDJdgnATKnZ+8yzVDFKF72yhg7FmkeBjDpGiHyZHUFCheJ7af/sC7TxpJCZnPL2xEmptkB3YYnRLUj4KZHkq620ozDGHbq65MpL8ZQk8Wq6ACCI7V2QAqDX7GsmHdUVQjlY5LJfSjvabot0zJ6elPryOM0DfkQq9EoosTwDOL95IKmg7LwmuQTCKuh66FmQMsmwnni+VnLHnfoprLsdgsXx2AFpwTfdXl+ZSt2xextpk9HaDr3orREChkMYsqzMoLf11HC2o4V29Zu1nqDHkbF8mJfPUxXsfpl8OVFwwGu5pAQhl4B6sdepl0Ze4OSBzMpBpxDu55ldrj/JdJsaqwpuuQ2tNsR9vp6G4Lvrk9oOZApInAh79vZIe3zl8Hho/lZAJhEr/XqelcA3VxGvH1CbPhKh7JFVFLCw2Colj0HtJR9qJA5LYXeX+X+EsknNM9+zijQqqPJHmbowCfq0Rd5LNbtBkU7g6C71e7slAnFMFMmhFD4sos2VL+68TlcCGeEWvkw/5J7/AwGaV0QF+L/RBb/3wSqhq2es1KbUekzozYmlRf/hAn9P3vHZMs5qffG0qSXSjAJGdsFND0nIEFJ0Zswx4LIi6lyni2hMY6xY5MNTNApSIDD0PkfMWzxPipezj7zqnaqAzTYEMRIR60d97Fn1cs07kRhPS41G8ifG6aswMy3xV2HzhM2SmywFqj3iQcXajrw5PTN4Lee0rHpFY4bGLeHj2scMAhtwTUYjdZAJ/6JV3S0ZyaIXV7WflDCjLZ7gP2+Of3F/dBYK5o5bSXcrlmgu5DIK2L+ji2ltmRXNc6T458jL/+m3Wp7hYgaHRWtOflu1Sx2jA5yiQfeSEOYpnzjT9u4QCDQMJJVglHlxRvzModk14M5TREFgbyLqaNMY7a+E4Kt6y06STdIZAkOtpFRK9XHDoaUU/Z0eoU4DJoijyQSq9UCORinNU5pUSr2Z+7qYQnBP7lSU4lcZYOWQ6qF9srahtNV6dphmQPOgfSb+R5nVfUHRqCFkkXsN3bE362D4BqoW8qrWPpVFQEXcTFxFyYJTorgGjdgV+8Ir7sFm0wVO5qVvyRw+OiFMtxxpiVo26tU4BqrbyfMu6ZhqFwdygEfcXYXLiOnx0WD3SvZB+w3g3odrCWsEz/kzlW+9XwGcrPtxg/WPsc0Pa2RjORQb20xSquqVL5xx0cY7xzljrU1dvhboxgnEqqTg6V+LDt1CTaM+nSYVoN9U+qrWBB5md8F2g4v9THSFqbPAPAv+iPlUWenLF6MJZioii8l+DX8niHlvPLrRxNsfVLLRwr+omdqzHqgGkzDdMoZxqhDI1T6cY0/Z4VDFN4bwaYOlZF0J2KjuFenxwiv4spsoM01aE4QGa76oY79/5v9MVjRvqDSk+ot6DWo4NJPknw== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0f799dcb-aa8a-4693-4db6-08d9faf3c4ed X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Feb 2022 19:51:53.9393 (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: o1gvDD2i8/3/cahtene6rLJzOfILcnT9XF3j0s88WoIvHMUsg+VOVMlIUTXvIMIlcUikZsvv8/H9UiB89Xu9L/+/g4IgM7pKlE1DI5va9wc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB5612 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10272 signatures=684655 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxscore=0 phishscore=0 bulkscore=0 adultscore=0 spamscore=0 suspectscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2202280097 X-Proofpoint-ORIG-GUID: nbrzWTG-X6iGE2VwEEAkEXLWAiRxNBME X-Proofpoint-GUID: nbrzWTG-X6iGE2VwEEAkEXLWAiRxNBME Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org The new deferred attr patch set uncovered a double unlock in the recent port of the defer ops capture and continue code. During log recovery, we're allowed to hold buffers to a transaction that's being used to replay an intent item. When we capture the resources as part of scheduling a continuation of an intent chain, we call xfs_buf_hold to retain our reference to the buffer beyond the transaction commit, but we do /not/ call xfs_trans_bhold to maintain the buffer lock. This means that xfs_defer_ops_continue needs to relock the buffers before xfs_defer_restore_resources joins then tothe new transaction. Additionally, the buffers should not be passed back via the dres structure since they need to remain locked unlike the inodes. So simply set dr_bufs to zero after populating the dres structure. Signed-off-by: Darrick J. Wong Signed-off-by: Allison Henderson Reviewed-by: Chandan Babu R --- fs/xfs/libxfs/xfs_defer.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/fs/xfs/libxfs/xfs_defer.c b/fs/xfs/libxfs/xfs_defer.c index 0805ade2d300..6dac8d6b8c21 100644 --- a/fs/xfs/libxfs/xfs_defer.c +++ b/fs/xfs/libxfs/xfs_defer.c @@ -22,6 +22,7 @@ #include "xfs_refcount.h" #include "xfs_bmap.h" #include "xfs_alloc.h" +#include "xfs_buf.h" static struct kmem_cache *xfs_defer_pending_cache; @@ -774,17 +775,25 @@ xfs_defer_ops_continue( struct xfs_trans *tp, struct xfs_defer_resources *dres) { + unsigned int i; + ASSERT(tp->t_flags & XFS_TRANS_PERM_LOG_RES); ASSERT(!(tp->t_flags & XFS_TRANS_DIRTY)); - /* Lock and join the captured inode to the new transaction. */ + /* Lock the captured resources to the new transaction. */ if (dfc->dfc_held.dr_inos == 2) xfs_lock_two_inodes(dfc->dfc_held.dr_ip[0], XFS_ILOCK_EXCL, dfc->dfc_held.dr_ip[1], XFS_ILOCK_EXCL); else if (dfc->dfc_held.dr_inos == 1) xfs_ilock(dfc->dfc_held.dr_ip[0], XFS_ILOCK_EXCL); + + for (i = 0; i < dfc->dfc_held.dr_bufs; i++) + xfs_buf_lock(dfc->dfc_held.dr_bp[i]); + + /* Join the captured resources to the new transaction. */ xfs_defer_restore_resources(tp, &dfc->dfc_held); memcpy(dres, &dfc->dfc_held, sizeof(struct xfs_defer_resources)); + dres->dr_bufs = 0; /* Move captured dfops chain and state to the transaction. */ list_splice_init(&dfc->dfc_dfops, &tp->t_dfops); From patchwork Mon Feb 28 19:51:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12763730 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C6511C433FE for ; Mon, 28 Feb 2022 19:52:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229663AbiB1Twr (ORCPT ); Mon, 28 Feb 2022 14:52:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45416 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229801AbiB1Twm (ORCPT ); Mon, 28 Feb 2022 14:52:42 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1821E5F61 for ; Mon, 28 Feb 2022 11:51:57 -0800 (PST) Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 21SIJKSY018833 for ; Mon, 28 Feb 2022 19:51:57 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2021-07-09; bh=nPI9yaH4OGc+g9W0ZCpRY8Yi/inmc7wmPYCxIYPPVAg=; b=EsYhWU1dfglZvkoiXD5PpvQbwCsth+ZB+5QLAXN9rb6pv40SzpzHXLGxKvGG6AcgvBs9 A+OkCoyDpkHjYsUCMyvZd1ht4m8Fqd157JsnB4FRtYL61WV5ekXCh9lA5wDCJaAPWq6G fpLFLZicE1aNc4gPCBD/0Kk6eLEOA5B1xZaJukj8UT/s4zsYCDtsr33WWxE9zc5nUFqA fJex4mQXhpMBvpfmF/sVlOuHMX0UPCwcvh5sZJ5TfS9SVnP8cC5ldkUVqj1BWL/DKBht 3B0hGOFZ6RrX5YWhkBl9aQXTc7mkJsJGzWdkaUqlHe+GHyLizLKsicQ6BFd4v1WGPhl3 cA== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by mx0b-00069f02.pphosted.com with ESMTP id 3eh15agqsj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 28 Feb 2022 19:51:57 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 21SJklti076550 for ; Mon, 28 Feb 2022 19:51:56 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2170.outbound.protection.outlook.com [104.47.59.170]) by aserp3020.oracle.com with ESMTP id 3efc13e3fr-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 28 Feb 2022 19:51:56 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fHrl7ilnUDwLwXHHub7FlJGlTzXbGOq6GtPoJ2U8gdFORcPS07CjYKicTtQszgN9f2PVs0t7x7s9Yt/DmsoHb9SFuniL7BlXoarrQh3QXDMIx3mGxppnlC+GHNLwdLV8CM6J/YUdPcjAKLHqi/tj9WJzBgWIw806XOZg9OUcYTeOS8jPVbkdiKPeA8tmbRd2k1qHjxgKArEbIazHuaUS9EflLA82FGlbvjWjpE/47TM6vxkV3kgkQ17sRKpwyTv/6Vxkpm2IlYfHtLdkxSP1uctdUUpjEpAax1PoavN2j0OpOggp6zfFGPhI0KFJ6ItT19PaAz1pymYkp9EDKep38w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=nPI9yaH4OGc+g9W0ZCpRY8Yi/inmc7wmPYCxIYPPVAg=; b=fL+JmCeRaCPuEg7TNdKy94Z47teT6OYHChkYQZ/Y+MnXci75MfBByt6nWq2zfa/DVERUmywl1G9F0Y3qaSPJPd+usshvugKsg/AL4LCRn1TlrlQrLfymNWMK8fQ1aN8Am/aptbBdufqOfsiN28J/kcwpKF+rc0G9aq9nktYo1QlGtoFJ9tyy2riFHxXynngJqmbeMzBFYmjciJbpU5EiFNIwjIf5KLzQ2aH3cIDrJIcBiQoBP2AWE3IsuVDg32K845ivp71kQ5MCAr5MHN8ijK/Ojh+pxsuj+DpWyFojdbROUxIldccMMGjxn0Z1LfOGo2X75OcqAUUpMeXIDoAwiA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=nPI9yaH4OGc+g9W0ZCpRY8Yi/inmc7wmPYCxIYPPVAg=; b=ig1130jK3DiYyTJdJh3vVqRzX++k8Prj3541B7Mp+zxSrW15mK6OAEFIlcOe1tXJDxOmDiGHWm+NLYtEziy+DU+GS68NAmpkdaKQHv0QyYTurABuUP23aqW1kLUA8AWbstKumPagvGuuDy5hQvGfXxtIGVWvY6BJe9a0bcb4MBM= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by PH0PR10MB5612.namprd10.prod.outlook.com (2603:10b6:510:fa::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5017.26; Mon, 28 Feb 2022 19:51:54 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::a91b:c130:5e3f:119]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::a91b:c130:5e3f:119%7]) with mapi id 15.20.5017.027; Mon, 28 Feb 2022 19:51:54 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v28 02/15] xfs: don't commit the first deferred transaction without intents Date: Mon, 28 Feb 2022 12:51:34 -0700 Message-Id: <20220228195147.1913281-3-allison.henderson@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220228195147.1913281-1-allison.henderson@oracle.com> References: <20220228195147.1913281-1-allison.henderson@oracle.com> X-ClientProxiedBy: BY5PR03CA0023.namprd03.prod.outlook.com (2603:10b6:a03:1e0::33) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d64d69e6-779a-4134-aa4a-08d9faf3c52d X-MS-TrafficTypeDiagnostic: PH0PR10MB5612:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Mye5c3ItTf//veo2yJgbLkxZFm1o4EIMrkqz9t4SjFNTO2IXWJga0bFSxvVp6Tx8+VgEmdOCK0cZd6m1vU18fphSW/7Q+xt6zi58bZCI9PcgapuF1v3F+i65Ix2WlG+NQpKIAoL5qgu9UDIgmRSX0BXj40vh6+ACMC62IHhoxbDoBqrIHAnMTdn1tff8W+e+4IklpqyzqRxRVA4d7Ih+wRVn+Ygy+2kf0MqDLlDTXmGtFbgn8zCihA55yQ/LXcRjgtULlyn1UVX7+eLgAv9PkqBAGyqneiOby62lfqvzZHsL7VvIrXI2zDA+6giM/dC4Dxv2tYs2cqaRBrhJ7iEJvxvUiz570/WbXJokNdgGfjSbPzm+IKAKLBJhebjs9Vpt7CDKN2YZZ1jUrpNGKTRC+rk1NiN1h/Ezuvkrg0h7iU93qDXO9Ozgdn5Y9aGFxBf2vGIjnk82A8C9kPsgl8pgblN9/IlzE7nzcjOsyLeep6/oJ42MzehN92aXBVvY5bprqAhli+eQPzvVF884QpffpAFjo2jCn5MNJtvN+zEn93ebr5fVZHrowtSz2WH1zU36hTzcgiyM9ZxO03I20tAalHIsoy0ZHbqhmZ3Tt1XNpYDB4qOG4AY7/FbxOoCrbna6bCu8NNKttIwPcY1ib0eGyF91WnOD+o1i6v7y54u8drgifZP51TUIEIFsk7SA13edLKANlS8UhCATd3052LKL8g== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(366004)(26005)(86362001)(186003)(8676002)(6916009)(1076003)(316002)(66946007)(66476007)(66556008)(2906002)(2616005)(6486002)(6666004)(6512007)(52116002)(8936002)(508600001)(5660300002)(38350700002)(44832011)(83380400001)(38100700002)(6506007)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: tAjisPLnKMKzgWc0i0bbdu3POXf5gNg0OBP/DFy9fiXsJhV3df8lAhN6xWwrIdzk/GD7hawxTjGtlGNLrq/fNBw3fwS7QXsHZnzXbYGfQVlsM7w7/GD4ZYXqEegzBfr+ILHAkC3mukFsy8Jq+8nDhWT0BPuWZFhBaokCKpUoAWJKQtG9NXLjqMg5bpvjthvDI8ThG4bNGf0IC7men+8MmlRODwPNpRix0joWMeOos98Cz5hutYrT08BCkOMwqy6mYBNnx9fF06mIlqQsSaWvjwIN58jV6g6dqe4AidGrNuK915kHFB16GFGbsCUFR1moRTw/TmEt/WVUHY4xlaSl19LLyaavD2Fr/n58g4IJjG+XIGb7oPP/yfT9E+RSPBYl9bkEl4C2iPu6Guij6csUCdYaRHK79G2mj1VmJTAG4U8lyqrtoQvwM+DNQ+C2P3gNcM15BWAALElUVw/Xv7/W2yx+UXiZ1JGq5wosAiFuvbTdSh7VQgRdqPzNqVoSwJZ9lGyJ8c1QJfv5RqE8LKVhLt+PaNffj3/ut+0UO/hFJy5u2LO2RMo685Z6sQaXD2kDmRJMGoc7pAiIM8ohF/GysaRYfueTMCuWb7oyRrCmTie321EPYu/AIpxaBvUIg+X9OIPP/WoG3EJOrOKOvAwOwlKdsUkrK0nu69P5WOySSKfXVBjdcRFjhAOSCLg/GVN8ikFKhNdLLrI//40IF5OXRYA7N68yAN2mYn7PAkplNaI7xSt/RnpM9+em4cLMNEDK2PnpaEqK5x/ufgsD/32ah4RiYw7MDhs/m7xy6ORZ5iPyNjBW8YqoeSUntY8aHYRPH084IRK+mcnKu7CF2taHwLPL//jtQcXDcWYai3ZTxR1R4PP5/pyywSE2gPNuReVSnEhh2xy4biJOyV/nyDU9Ef4JD78lKm7yqyJRz09+HzC7Csf9hPv8Cuak8xHjncNPL5RGxERvmdUNuwUFTepzXgZfyqHLZdyOtQ7ePq/1SMxtty051RLLuptpwx/BgcxSD2LAyVEC9UgTG33lmtxREmrGlE076iMWJseA9USspzqYchsR3wtRZuVvGuivoxQhA0blqlZH/ySIiQvIjhwCXDdklNIn3CqMCCC9L/WhfwMi21DU3eFm+FEtq2U2CeKp0A0MqcLkR8p0qoVp7g2AE/ROjbwkgPRKx2dIeb3qcqM9VrpXA4pEn318V2Psg7XUE0aCdKrpNiOaiubAutR+HpQce6+CbvPQw7kZMhmr6lrWfUC7QS8IPaI07lZNkYm4TF8/vufWYMiAE/E5wk5HtE0yTNnSBJ6oJL2Z263R7Wu9WZVVqkXuU/3irjXmWzLHTMLOeo9hL9SPFzctlpbwVd3bi1pJHj+DSSQ3dgS2NmYrPA3Zq6YF0KiJgc5a0CUxVLd2CtCC6Cx/7lzY6J/mncO47Niq5dnuQ/GwXvLpPRO/3cKwcZ2xnn6eIoLgP0yG+yIxS3AcBNfsw1qFeFmTOFKFOFK/kBkVLzytuduRBJQdfT8/MlSFhdOjIc6EjwWDrmEQFnwUu+K4RiGTe6V9bGraN2aCM4MUvUKOeLOzV2veyW4GH72Pc/xlhL2MINt+oi572dcC33JShwRfMFcK/hNxabKHKnF0hd6fvYJSvTX1KzYXpkELXYnrtjb+p7/qhqPyIGAlNoIn94ImyFntkg== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: d64d69e6-779a-4134-aa4a-08d9faf3c52d X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Feb 2022 19:51:54.3767 (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: zxFKfH0AmNRTVRJC2PHOROGCPVRfJhK/3uE8fdQjx21WG9iupFpnpbNAlre7pEESe4F6Rwm7+yJ31+S9lQ/QVSa1utvPMjwcvzxLkWX9UFw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB5612 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10272 signatures=684655 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxscore=0 phishscore=0 bulkscore=0 adultscore=0 spamscore=0 suspectscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2202280097 X-Proofpoint-ORIG-GUID: BsP767czTOh9Rk-TEI6CG5ihr8cvA001 X-Proofpoint-GUID: BsP767czTOh9Rk-TEI6CG5ihr8cvA001 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org If the first operation in a string of defer ops has no intents, then there is no reason to commit it before running the first call to xfs_defer_finish_one(). This allows the defer ops to be used effectively for non-intent based operations without requiring an unnecessary extra transaction commit when first called. This fixes a regression in per-attribute modification transaction count when delayed attributes are not being used. Signed-off-by: Dave Chinner Signed-off-by: Allison Henderson Reviewed-by: Darrick J. Wong Reviewed-by: Chandan Babu R --- fs/xfs/libxfs/xfs_defer.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/fs/xfs/libxfs/xfs_defer.c b/fs/xfs/libxfs/xfs_defer.c index 6dac8d6b8c21..5b3f3a7f1f65 100644 --- a/fs/xfs/libxfs/xfs_defer.c +++ b/fs/xfs/libxfs/xfs_defer.c @@ -510,9 +510,16 @@ xfs_defer_finish_noroll( xfs_defer_create_intents(*tp); list_splice_init(&(*tp)->t_dfops, &dop_pending); - error = xfs_defer_trans_roll(tp); - if (error) - goto out_shutdown; + /* + * We must ensure the transaction is clean before we try to + * finish the next deferred item by committing logged intent + * items and anything else that dirtied the transaction. + */ + if ((*tp)->t_flags & XFS_TRANS_DIRTY) { + error = xfs_defer_trans_roll(tp); + if (error) + goto out_shutdown; + } /* Possibly relog intent items to keep the log moving. */ error = xfs_defer_relog(tp, &dop_pending); From patchwork Mon Feb 28 19:51:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12763732 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F347CC433EF for ; Mon, 28 Feb 2022 19:52:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229669AbiB1Tws (ORCPT ); Mon, 28 Feb 2022 14:52:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42284 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229883AbiB1Twm (ORCPT ); Mon, 28 Feb 2022 14:52:42 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 19129D109B for ; Mon, 28 Feb 2022 11:51:58 -0800 (PST) Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 21SIJJnf018824 for ; Mon, 28 Feb 2022 19:51:58 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2021-07-09; bh=hLTFl3bdtlWGt6UMCQpgcnbNsiEqYCv7cGYKd50yvM4=; b=sdsv84fszZbvYH752V/kCibSrOIAmenkMEl2tV3WFFmpZiSGJ/dc4YsndbAlGLMz25js xoh4X9R1Hcr90RLdIgV3abJmdxaXReF4BK2cqH8oBTkih0po5bkXWiuEiZ9vTgLjbLvK LptVGROHnK3OlodFy3EWuyD4CmLelWAWp4qwJArQbX9zyk8+b2fObHJOea7QwIvl6piP Xh2jM80YJv+h02Lw/uiWGn95WyFLrbVVHQSuvHN4Naez+F1EffT6CThMMGXDFA+Wyik0 hyouoI9jhFQ3PiN8xZCSyS+K45UPQWSi61aZmadRXDHOd8A+K9N/jkpYpWu1xeIVZBZj /w== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by mx0b-00069f02.pphosted.com with ESMTP id 3eh15agqsm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 28 Feb 2022 19:51:58 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 21SJkltj076550 for ; Mon, 28 Feb 2022 19:51:56 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2170.outbound.protection.outlook.com [104.47.59.170]) by aserp3020.oracle.com with ESMTP id 3efc13e3fr-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 28 Feb 2022 19:51:56 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ltIeiiizUEs243qrCvia9rqywkeav2F9qJncveOyIXir+yNpJfFQNMRGfyM1m+96PQt5Kpql6fj+j/TMSu3WsUslyZvsq5vPGGHrr29bdEUoQDW7WEcyN1bqWuEqVUcKuqi2GQwGAPu+QOMNk2/nrGUaEyofhP/yu3+AGpN6UJBiv5M7rRBojaL2fDlPFAZAmLshK+g12doB5rT3n0iqvo++8LnC+MctCbVD1i4Ul3nZmD7k7WRVY1wzVyKpcCyUrgA13ww6yRn+amOSmD7r4Y0UT0x6HIBWF60zxcsOA5VBSEFyyNmKZMFdQ6QrayDg3ujEb9NRXFqQpONZ4gFhNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=hLTFl3bdtlWGt6UMCQpgcnbNsiEqYCv7cGYKd50yvM4=; b=jJ+b78u87BAH4lAYO0UHHnFHGKVO8bYPJiSv9bkIN/xF/8/VZDew20jGRYlcskbXq3qvlFWiYMjBvAppu4sQX9Ss3Dp3LmX0VcL8XBCOQ89LtgHfB7KlfwP3nxR4W9GmggzhueDnqLVgZ91/+W00vUiEdmUDY63uUN36FZ4Co8FkcTfFFSeiarLrt+eSB/vDFE/XsLHv4hwvvXzPRoDslKz2sebrV04udyOhQIyH4MnsLVz9msjnyvhDXKrWphva3rm+UiIIobX6MeFpYacKM+67lOuY2iqeZuvAyflRROGmKt+SAy0IRpkkaXSN0av5SQn9rwTLLiBJQNi7a/Xkcg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=hLTFl3bdtlWGt6UMCQpgcnbNsiEqYCv7cGYKd50yvM4=; b=lO0pd4kXHuewDazXYtj4HHn4PHnYR9/OwFuM92BG/sAf6qwGjVuOyROVtgyMahSPy3PAWolwOd++OI75M0CaZ8CgyEwkXS7roPTQy6h/YYWbuUMSpM8ERFezxf7b84oZ2F4XgryrfjwsS6kz9wmn0N/NturMzh2mQyQEXyiv/n4= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by PH0PR10MB5612.namprd10.prod.outlook.com (2603:10b6:510:fa::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5017.26; Mon, 28 Feb 2022 19:51:54 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::a91b:c130:5e3f:119]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::a91b:c130:5e3f:119%7]) with mapi id 15.20.5017.027; Mon, 28 Feb 2022 19:51:54 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v28 03/15] xfs: Return from xfs_attr_set_iter if there are no more rmtblks to process Date: Mon, 28 Feb 2022 12:51:35 -0700 Message-Id: <20220228195147.1913281-4-allison.henderson@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220228195147.1913281-1-allison.henderson@oracle.com> References: <20220228195147.1913281-1-allison.henderson@oracle.com> X-ClientProxiedBy: BY5PR03CA0023.namprd03.prod.outlook.com (2603:10b6:a03:1e0::33) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d4f905fc-623a-49aa-1fef-08d9faf3c56b X-MS-TrafficTypeDiagnostic: PH0PR10MB5612:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: IpzV49mecFHhP113pJsCEfB5Rk6seltoCqHAhZJt9s2vPL4fLn7gOGhSG7ZJ3KHCKfDLHBczah7VMfJeTevoUqRvBSeXHLrzTIHV/khAmijeNTWJzLiEDL40puoWKLJNaXAAb0nTSSowZWQOVH8fhho27CW+HwLdCAMUPGvtxy5TLBtKPOZncSTMBoGMOxdfccHkYBJngpRHDuWPFXy2wG0mNTsITSWvXyGXeLOrmS3yYqZ7p23KXIs3ueL8rxhqvXLSaGRXA+cB3RTgx/RDdj37CSKBjrIy16qKEVEmsdQ7rha0WI/obb0kWle/X+JAT91R8JGiBoiJkMVhpEq5GzO9Ib59uqcG10+wL5gz69bf6n+JAU1lrF2pqHml9XIZw6vvUIpXx7OGUZnSD5Yh4CLpXO0N6gUtHJeIIdnCeGRXH/DgGwg76HEurU1sO3EUKos53Cnd34sgM56w9BA2EuRYbpc1er7SDHRi/qR2rZNvdPiNgLgzcKb76NQs4c9at3zcQc4kDaY7l7Gn0iv1ugkBFM6nWb7akrRdHenTxDbmaMppcX2lpnW9ilmpt+Y2C3k3mJ/RtrtzxLqARA833YZ9nHjuQEY0Rz+vfn1EAONRZ+ndSODCKatXFFWgATox00JBGnNRuv3j9m8w8Bx2dXZ5N5A4HIY4W5HuiY7OURqtUwTie28Vg62OxLM64GZWOohyRSFGWvEOUWy0vvddj5ZKRJmQInz3ybXEwSZzT0exeyjw68SDEhe45skOluHU+/4+WKQGRnSgaKZJ1lCSZA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(366004)(26005)(86362001)(186003)(8676002)(6916009)(1076003)(316002)(66946007)(66476007)(66556008)(2906002)(2616005)(6486002)(6666004)(6512007)(52116002)(8936002)(508600001)(5660300002)(38350700002)(44832011)(83380400001)(38100700002)(6506007)(36756003)(29513003)(40753002)(133343001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: +X73keytSBW+dZNnHhFugJwPrWOWlIGq+hnmvQbA17K/4BplQjQaMEg5wFxuINnFE0h/lDaWiJB9BPNIPOYdAsJAc80wahDZwCldf4aG2riZ/M/uG2kswNCV2LCbBWcNbaIR/E8+NxjrwxLXznfdpgvATU8xbkCmKnqSh62gCT3GkuW7vD4PszBjAPGfHjvzV886rrAkZbw182Nwh/mgONT7KbfuKwaLxOEQ8D+3UWUQyY1ey1WMkm6e5IhBugvokG0sslexKPzOyq8wMhzMuRIY4teSHcRF2FuH6j8m6Qb6hRW4uY6AyXVGt2eCV1hgwRoOEKt2Kvb1vuFH+8XPEuY+yN1/wDS6gkc+whUSgZil1R+NqqhNu8OsmdKhapYOSAd5YixxceF0h9oDnILcIrPmjpmcoc4llHn8K5zAXXRg5FVlXtgnv93JD8nCRhRrf7OHIuQ4EOeBAsEwoqFca4wCvFeLpgWshDVU0Wphwc4+wuDkazfolK4b2gTokLMh/cnYDuMPb79p4MtUq5DBuVuUaOyBLl16Af24if+21zoA+zH4bt3s7m4io0dNLVSY2kKEEhxCxooAuWsQ1UNuFru/OceAqeV6aFyDN7zA7mN1wekoItGMi5A4j3e+YAdzInfKtkrPZrFcywLLcHNY4geimGxfhYYdwLIXhrjYeLns8J61l0x2PUBZ9dp/zfmVk+n74rsaXGDiKOqUYkNyXyS0jsBwwWAv3WUZ+XzwEDkTxpIVy5s2rVmGADx9iZxrMir4wsmtoAuS5Fp7Mc/GlZYnPyiB6q1m/6sAjCFmug+oNr5Cj1ZryUWeUFMKaIHph3Eo4fHOV3hKrPCZpJjma5hDz9qvj51pvV8ELw+aeevPUm7mQEAqEXnPxd2K/6y7PVmKzk4tybYonHcQsyYNIV9oJ5oB7oOXfQDAvHGUyxyUbJjOsjYmazE+PDclxLvFRcQXCNdTGjtQOBQItFxKcm/dNafkezwqXb1xbhF5vTTarPpwJb011xKWCzpo9BMFF3lCqdTqCdArdnG+hnXUSQb/7Wy0AFF15DoKIpPxsAHnp0xvvPoDp37zvMGCtmwCXbDoyM8PdT2QOvUo9RvBdrSa/1YCRwA2ZKY17LjAxaFjfOEn4n3iGpgI3I9goZreVNHqO7I9mQXrwBXgnuwrhZkDMeark5sV12kZ1T+7edEfXXl+lzmUjNQup/FBn3DZX2nzV5uoVS1gbGAjRqnAWkJA+OgKK8TjnSsBvSd/VEmvVG9WjDJHZkpWHtTGWjs9mJpjxCeuZqTXxUGjhh/91SFBZKSXqcXxto/rPAkuLIQHQ+svg3fO9VviLmjuflmHCMAZz3fRD5HL9DIeNEjqltIpBqMfuyQj3yLX+QlunVPJEadwsyNhrk8JaKIQ0ubuh86fbv9NYO2IE+dhySH6we/gfOYXjsXHC1sK0ZKaAYEzPfPvFiJ6NNQxN3Bfn7ATGOE0jH/Vw6jnc6HcQA5cYlg6YwQiEhJjzJRGv7wSoaL2i3GB/qQmf3ZJ8i/4xZjmvZz/iSQWz14K1GTs1g5UoK57oLXFRZ0y9gEUDvPTXmh2J7vcl8c6yZT1ywf7COpstAyhRCeNvZqfa256Nv06Gw9R3xhcMXOLQIHdEjERJci7y/21HFw8OqXSFQFXP+UAAGkEqUOOEA5rCu6VWVx66w== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: d4f905fc-623a-49aa-1fef-08d9faf3c56b X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Feb 2022 19:51:54.7327 (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: I9yp6R/UHxXgZkGNW7L6eNXj+8Q9kd/cRJZWdQ4Oki1stbhtvlOe3zfowlbrScdwxp/EbIWXhOPhTNFh19yzCKmh9em2yVIHPd7NpchgfD0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB5612 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10272 signatures=684655 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxscore=0 phishscore=0 bulkscore=0 adultscore=0 spamscore=0 suspectscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2202280097 X-Proofpoint-ORIG-GUID: jQzag1zlh34UJ-TDrRaKYtdbdayKb2mh X-Proofpoint-GUID: jQzag1zlh34UJ-TDrRaKYtdbdayKb2mh Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org During an attr rename operation, blocks are saved for later removal as rmtblkno2. The rmtblkno is used in the case of needing to alloc more blocks if not enough were available. However, in the case that no further blocks need to be added or removed, we can return as soon as xfs_attr_node_addname completes, rather than rolling the transaction with an -EAGAIN return. This extra loop does not hurt anything right now, but it will be a problem later when we get into log items because we end up with an empty log transaction. So, add a simple check to cut out the unneeded iteration. Signed-off-by: Allison Henderson Reviewed-by: Chandan Babu R Reviewed-by: Darrick J. Wong --- fs/xfs/libxfs/xfs_attr.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c index 23523b802539..23502a24ce41 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -412,6 +412,14 @@ xfs_attr_set_iter( if (error) return error; + /* + * If addname was successful, and we dont need to alloc + * or remove anymore blks, we're done. + */ + if (!args->rmtblkno && + !(args->op_flags & XFS_DA_OP_RENAME)) + return 0; + dac->dela_state = XFS_DAS_FOUND_NBLK; } trace_xfs_attr_set_iter_return(dac->dela_state, args->dp); From patchwork Mon Feb 28 19:51:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12763745 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 79D8AC4332F for ; Mon, 28 Feb 2022 19:52:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229810AbiB1TxO (ORCPT ); Mon, 28 Feb 2022 14:53:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59774 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229886AbiB1Twm (ORCPT ); Mon, 28 Feb 2022 14:52:42 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 34555D109E for ; Mon, 28 Feb 2022 11:51:59 -0800 (PST) Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 21SIJqOs009912 for ; Mon, 28 Feb 2022 19:51:58 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=Tqc6KUAnoZFibEJhryccn0Nl8kg3AJLGfSGVUjcqVVg=; b=CHVx/KK3cC81bPHBKFe6frDPS6AyowiBr4scXazV/te8ORe5pT5A+GG2KWPwiCe5dNg/ uGb6q6krvef+hk4ky8jskk6+RXv2VQcXH/HG3ycSnO3SnMBhKJY1bp6FF7iIiN8IvU4O HTKJKnCHQLFgX1gkMrOHoLk9bc1SKdq9nBEZq/UazmQzSNTqfcd37w97OWfzM1VFdZAi AwNj9sLKEGBPlXabBe7XGpzXYElTAsPMDoUyCQixHxr2FuNbHj7K3bxck/cxvz1jRIco plXxP24JkdGgAj11PriDDSUDz4DO9dOfXPLHz8VAYI+vcEn1MBvaNEWGh8uFJlhTLm2a 3w== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by mx0b-00069f02.pphosted.com with ESMTP id 3eh14brshn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 28 Feb 2022 19:51:58 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 21SJkltk076550 for ; Mon, 28 Feb 2022 19:51:57 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2170.outbound.protection.outlook.com [104.47.59.170]) by aserp3020.oracle.com with ESMTP id 3efc13e3fr-5 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 28 Feb 2022 19:51:56 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=J3czWdfI7I5w72Ic6OmrWzM7Q3JcEpVvQPsUyzIHqQ6wIb5kyk7Qry2erGJJ1z3h/H6OJOBm9j4ETbmyNVGKofdS0dIrRkl+PB2quE62PfhL/JkWRfsu3hj7bkI+Ctt8IqX2jSng6gMk89f5+h3VJvTIcwgf38bHIhB3YyTieeJQ9LwYvjxGg9Y4IsaY2Mf89y75Z9ca5S7AFiLHYrGnQLeH2awCSdIwFd4kcMx5dgwV4EhPPrCRN92QJ0tvbMb9cTZ1FVq9Pob0IXrottsABKxZ5IzCZoLnFBBorGNyVhd7QK9j4Gg8FzsEPVUgi6wIe9QnTWohiT8Cu8d/zSvWSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Tqc6KUAnoZFibEJhryccn0Nl8kg3AJLGfSGVUjcqVVg=; b=b3ZbY9Tke6ePi9/zhLULuc67bf3pP0FvMSVabd7C8quFkv5I1XAF25jxH4tRZz7I2f/thpcNMVgP52P2xRxyEvcqYajXms3ffR5tOEvdQAUY3xctEdMXs+c/gjEt5sQk5IRK/9rFM8YACTopkwBegArNlVL5OtPWX1aRmyFBt/vrnT3cDeNOGV6i2psZLazjW3dCWPLNCbzilF5nA348/7DeyNjtgHQEqzmlLckiE+PalRIYc3GSaWjcULZ6CRIDgSpsSFVez4AQaP4C5y/xjw2NDkYIiOxuh66OOnBKF4u54RfWT47WbwoBCqH/B/plQ76WoTP55GXEI0KXzJklUg== 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=Tqc6KUAnoZFibEJhryccn0Nl8kg3AJLGfSGVUjcqVVg=; b=lZ0kptCQ0+lv14PCbtlbQF3sgmD2rBLyzu6CpjOnm5in4SqhdtfsdGP6YZq+T2/oReS3ZCkHP8y2ph8YL2abHiYvq37QF+cRlAf2RD20cFeuYrbtJTw56yixKq3PCFP5cfUWydWaTls4RfB8vVwShbDRlB83jmF9f0USBXW+1j4= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by PH0PR10MB5612.namprd10.prod.outlook.com (2603:10b6:510:fa::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5017.26; Mon, 28 Feb 2022 19:51:55 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::a91b:c130:5e3f:119]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::a91b:c130:5e3f:119%7]) with mapi id 15.20.5017.027; Mon, 28 Feb 2022 19:51:55 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v28 04/15] xfs: Set up infrastructure for log attribute replay Date: Mon, 28 Feb 2022 12:51:36 -0700 Message-Id: <20220228195147.1913281-5-allison.henderson@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220228195147.1913281-1-allison.henderson@oracle.com> References: <20220228195147.1913281-1-allison.henderson@oracle.com> X-ClientProxiedBy: BY5PR03CA0023.namprd03.prod.outlook.com (2603:10b6:a03:1e0::33) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 30f141e2-e4c8-475d-f382-08d9faf3c5a1 X-MS-TrafficTypeDiagnostic: PH0PR10MB5612:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: tMhUG7dHON2cjQhN7thCuTgi9P1u3uefgxCjOQTsxeoz4v7g2dMnGlknBlFwDwC6zOXTXlq8jpt7bZ7AEcg+pcrEgIbCMhqcmSlvYw+Ei4AHvuRR4OGMcQBmF1KkAe22nBGSSC8AUQ6fzxVDLzyO4NgG2569a7Vzr40X4sVQ/cd33OsYmOcbE7Hhg217c7bkD1s2GIdqVzfCflU0R100bcgXKnmWyxKPeXQi/AgX/gbFgAQawr35GZuLmt8z2Klcf9uvPEId2jBEMijjUCfxqcn3R5NaCXxv/J0Sa04rASSwll8sdl8KcSzDYrBLanYHDTHP3pS5f6ZsZWX4cs9CFD5l9srqyYW+iDGcOnk/rTJ1QgSmA0DJ7HWLZ7241aO7zqEOmZxo6stZ36/Gdj2qk8uZ0AkSXGX4PFse+ghge8071QikoConemGDfwc+o4cUdzfgvEBlkjGmA/eKRR1wsRy18474mJHTSSWBtlJmPzCUF3b9W+mawe9k8TmZeY1dprKWO9K24lHQdLejnW6pBzuCQTVZAx+DrUS0y5fyywVUf/h1e2jOpCCRxQke9EzweVtLvupF/52ZaapONGQJb8pgLC8XBrqdhwYdt04WrCEqAoyOBrQPpkaW4hJVOOyFppKtLaTRXFZoAW6HhHPJy4/1/ue1QH8wKsTEqRLmOEQdZ0VnQ7q/t8r6cEKjRU8zXnTpgc0JH6GR1+IGyc9mTQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(366004)(26005)(86362001)(186003)(8676002)(6916009)(1076003)(316002)(66946007)(66476007)(66556008)(2906002)(2616005)(6486002)(6666004)(6512007)(52116002)(30864003)(8936002)(508600001)(5660300002)(38350700002)(44832011)(83380400001)(38100700002)(6506007)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 3Xu1m4nnvAqDsz+GPeWfM/bhzrVuftM4YC1+w7tfD4eXhBprF/SgOh6AwgGabZltjeVkQW8LgHF2Lpp2FnhOyqsinaVdZi2uLBQJJmgZgzxQb5uBX6ZkpzwCQCpyIIKA6Q6YedxQXYQ4Z9My6TS+Njmrp1C/+T0hV/tLJvtz3eHnn330/3qLRDzBDuqupSDjK4FYM8UntmqlDX0/0l9I+1GqwpJHsr2jaz805/3h74mtgHLe2/EDl/D67II/6L/FPC9cMH0p5xGz1J6JqYtoAUdj5TOPOdv+taA5FYKbo4Aj9+zhjJ+rzQYbhi8NSWNK8ZgIf+NRzHlsQD+QTT9zDfMNT/en99ysbfGvwVGdO1g1j4Bqum6oeNLuQ43vOw1WtHMmNjZkShMI+JZ+LEhOKNQUVdEPAv65kt0Baj2j6G5vUUl8hzmD+RT85JnbFirbchXNizRZNi9htf67O4AI5vNpJQedo7VelVM+r5dLy97fkqhqhZ8O4/xrPOppdSwxYNANOp0gR2QkzP6JbQ3ZDJW90c0wCCMCm7kxv4S1edz2fdWqf0zotPG87i/DGA+LTwIlFlok2OW4n8BYELuEo29DXpfdzp8RqCUE4/z1JoN4Yb/1qHLJrQI9RNa8p/4CxOuc905iUqxI77UPVNBxI31ONAcs8oYADvh13nUhcFQizho5yVPmToTLK83ZbmDCBgsDVwEJspwcsTgpYHYeyE5zWEMQkW64fj/HiehD1dHdmt8utcE3bBxj5G8pf8ABV1EZZbEWWEJMIk3DUKqk0soCY1ZHIidayNZj7f9Iug8ozNXhWI2dN1VztBlRh1yU/RPNl6TBBZV4jt+4AW1GncHEuP01+ZmHRwVgd2WVsp2xr2iQbn8zFskkTR8+7sB6vrHDutuqBVsLH7awdXpa7HnR5TxugK3Lwymq26qsVviE8ERjHQbVRRmUKX7tRCuirZ8CPugsGt5XXBYu4ZW7nOyj0fvaf9LfvV3u9AGL0O2L4f76wxzV7zJQr8DB28ql5Yx45OHNFMT4vHiuSSfvv344wUNsVinjfnDaF/wn/AxCowUYl5Z2FKFd+K2KfDdZ/IrMVowfNZa8IYmcryktCmiiOa68ipbNSlD4aMQxRuZjQ8/lZU2anRQZoFz73GNdL3+7s0Y8qLojNn8gS1s5/DoztQNuPIXVkv5C7BgWm4ifH+L8H3Q30pNQQcHCZGitm6EnB9DCUqSXqTCS4cSOyi7w+7/GzE2mO69AvksW0ehH9B+GJ8r9SK7w0gbBCGuVtBCF1lZs/HYJ9ESfwNeiPpjR9KmfhJ7448pGONqqrBv8luBzkZ15LO5MzspTj2kXOcv6SOZlYkeBZ3o5NYMqTDzeRl3K1sAuHG84IRjJXOdPJ2289gOnvemk26yvYZrmmebHSXCFbmwYxtcYCtA5I63iKbBGNpelDS5qpR4Y+cfNJwggI/XEeBnJsVUQw+Vp9XXoqLCdFyS/1oBYG1MhriCygAmQTdNFX3uniEoBDUvHJ0TuDsJaI2pxoDDlhcc0fJx35lzVYkxldacac9BeHFnjqHOMxi3Lu5Vf4Jjj5IJZD/oK/2G8YEPEt63v2llHth3SZal0z3VoChumXhcSWbReTQDBRPIFRhOvXJQgXsBB+g2EYClvs0+vufa+LwvQvSfAqjVRiyERVTr7C8oU+A== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 30f141e2-e4c8-475d-f382-08d9faf3c5a1 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Feb 2022 19:51:55.2638 (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: TBQcTSfNOmSdTUMbyJwIB+Gf09U1Fpjaa1JJuALdRKhsU69j1ipOG1SAr21g2nTQ88H+RMpgj29fWxrJF9GRfuaeVuqvlC+yQXjPvB9rO6I= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB5612 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10272 signatures=684655 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxscore=0 phishscore=0 bulkscore=0 adultscore=0 spamscore=0 suspectscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2202280097 X-Proofpoint-GUID: N_P_txkHhpe9IBIcYRR6Ws3js0K31tHo X-Proofpoint-ORIG-GUID: N_P_txkHhpe9IBIcYRR6Ws3js0K31tHo Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org Currently attributes are modified directly across one or more transactions. But they are not logged or replayed in the event of an error. The goal of log attr replay is to enable logging and replaying of attribute operations using the existing delayed operations infrastructure. This will later enable the attributes to become part of larger multi part operations that also must first be recorded to the log. This is mostly of interest in the scheme of parent pointers which would need to maintain an attribute containing parent inode information any time an inode is moved, created, or removed. Parent pointers would then be of interest to any feature that would need to quickly derive an inode path from the mount point. Online scrub, nfs lookups and fs grow or shrink operations are all features that could take advantage of this. This patch adds two new log item types for setting or removing attributes as deferred operations. The xfs_attri_log_item will log an intent to set or remove an attribute. The corresponding xfs_attrd_log_item holds a reference to the xfs_attri_log_item and is freed once the transaction is done. Both log items use a generic xfs_attr_log_format structure that contains the attribute name, value, flags, inode, and an op_flag that indicates if the operations is a set or remove. Signed-off-by: Allison Henderson Reviewed-by: Chandan Babu R Reviewed-by: Darrick J. Wong --- fs/xfs/Makefile | 1 + fs/xfs/libxfs/xfs_attr.c | 42 ++- fs/xfs/libxfs/xfs_attr.h | 38 +++ fs/xfs/libxfs/xfs_defer.c | 10 +- fs/xfs/libxfs/xfs_defer.h | 2 + fs/xfs/libxfs/xfs_log_format.h | 44 +++- fs/xfs/libxfs/xfs_log_recover.h | 2 + fs/xfs/scrub/common.c | 2 + fs/xfs/xfs_attr_item.c | 441 ++++++++++++++++++++++++++++++++ fs/xfs/xfs_attr_item.h | 46 ++++ fs/xfs/xfs_attr_list.c | 1 + fs/xfs/xfs_ioctl32.c | 2 + fs/xfs/xfs_iops.c | 2 + fs/xfs/xfs_log.c | 4 + fs/xfs/xfs_log.h | 11 + fs/xfs/xfs_log_recover.c | 2 + fs/xfs/xfs_ondisk.h | 2 + 17 files changed, 646 insertions(+), 6 deletions(-) diff --git a/fs/xfs/Makefile b/fs/xfs/Makefile index 04611a1068b4..b056cfc6398e 100644 --- a/fs/xfs/Makefile +++ b/fs/xfs/Makefile @@ -102,6 +102,7 @@ xfs-y += xfs_log.o \ xfs_buf_item_recover.o \ xfs_dquot_item_recover.o \ xfs_extfree_item.o \ + xfs_attr_item.o \ xfs_icreate_item.o \ xfs_inode_item.o \ xfs_inode_item_recover.o \ diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c index 23502a24ce41..21594f814685 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -24,6 +24,10 @@ #include "xfs_quota.h" #include "xfs_trans_space.h" #include "xfs_trace.h" +#include "xfs_attr_item.h" + +struct kmem_cache *xfs_attri_cache; +struct kmem_cache *xfs_attrd_cache; /* * xfs_attr.c @@ -61,8 +65,6 @@ STATIC int xfs_attr_node_hasname(xfs_da_args_t *args, struct xfs_da_state **state); STATIC int xfs_attr_fillstate(xfs_da_state_t *state); STATIC int xfs_attr_refillstate(xfs_da_state_t *state); -STATIC int xfs_attr_set_iter(struct xfs_delattr_context *dac, - struct xfs_buf **leaf_bp); STATIC int xfs_attr_node_removename(struct xfs_da_args *args, struct xfs_da_state *state); @@ -166,7 +168,7 @@ xfs_attr_get( /* * Calculate how many blocks we need for the new attribute, */ -STATIC int +int xfs_attr_calc_size( struct xfs_da_args *args, int *local) @@ -837,6 +839,40 @@ xfs_attr_set( goto out_unlock; } +int __init +xfs_attri_init_cache(void) +{ + xfs_attri_cache = kmem_cache_create("xfs_attri", + sizeof(struct xfs_attri_log_item), + 0, 0, NULL); + + return xfs_attri_cache != NULL ? 0 : -ENOMEM; +} + +void +xfs_attri_destroy_cache(void) +{ + kmem_cache_destroy(xfs_attri_cache); + xfs_attri_cache = NULL; +} + +int __init +xfs_attrd_init_cache(void) +{ + xfs_attrd_cache = kmem_cache_create("xfs_attrd", + sizeof(struct xfs_attrd_log_item), + 0, 0, NULL); + + return xfs_attrd_cache != NULL ? 0 : -ENOMEM; +} + +void +xfs_attrd_destroy_cache(void) +{ + kmem_cache_destroy(xfs_attrd_cache); + xfs_attrd_cache = NULL; +} + /*======================================================================== * External routines when attribute list is inside the inode *========================================================================*/ diff --git a/fs/xfs/libxfs/xfs_attr.h b/fs/xfs/libxfs/xfs_attr.h index 5e71f719bdd5..80b6f28b0d1a 100644 --- a/fs/xfs/libxfs/xfs_attr.h +++ b/fs/xfs/libxfs/xfs_attr.h @@ -28,6 +28,11 @@ struct xfs_attr_list_context; */ #define ATTR_MAX_VALUELEN (64*1024) /* max length of a value */ +static inline bool xfs_has_larp(struct xfs_mount *mp) +{ + return false; +} + /* * Kernel-internal version of the attrlist cursor. */ @@ -461,6 +466,11 @@ enum xfs_delattr_state { struct xfs_delattr_context { struct xfs_da_args *da_args; + /* + * Used by xfs_attr_set to hold a leaf buffer across a transaction roll + */ + struct xfs_buf *leaf_bp; + /* Used in xfs_attr_rmtval_set_blk to roll through allocating blocks */ struct xfs_bmbt_irec map; xfs_dablk_t lblkno; @@ -474,6 +484,23 @@ struct xfs_delattr_context { enum xfs_delattr_state dela_state; }; +/* + * List of attrs to commit later. + */ +struct xfs_attr_item { + struct xfs_delattr_context xattri_dac; + + /* + * Indicates if the attr operation is a set or a remove + * XFS_ATTR_OP_FLAGS_{SET,REMOVE} + */ + unsigned int xattri_op_flags; + + /* used to log this item to an intent */ + struct list_head xattri_list; +}; + + /*======================================================================== * Function prototypes for the kernel. *========================================================================*/ @@ -490,10 +517,21 @@ int xfs_attr_get_ilocked(struct xfs_da_args *args); int xfs_attr_get(struct xfs_da_args *args); int xfs_attr_set(struct xfs_da_args *args); int xfs_attr_set_args(struct xfs_da_args *args); +int xfs_attr_set_iter(struct xfs_delattr_context *dac, + struct xfs_buf **leaf_bp); int xfs_attr_remove_args(struct xfs_da_args *args); int xfs_attr_remove_iter(struct xfs_delattr_context *dac); bool xfs_attr_namecheck(const void *name, size_t length); void xfs_delattr_context_init(struct xfs_delattr_context *dac, struct xfs_da_args *args); +int xfs_attr_calc_size(struct xfs_da_args *args, int *local); + +extern struct kmem_cache *xfs_attri_cache; +extern struct kmem_cache *xfs_attrd_cache; + +int __init xfs_attri_init_cache(void); +void xfs_attri_destroy_cache(void); +int __init xfs_attrd_init_cache(void); +void xfs_attrd_destroy_cache(void); #endif /* __XFS_ATTR_H__ */ diff --git a/fs/xfs/libxfs/xfs_defer.c b/fs/xfs/libxfs/xfs_defer.c index 5b3f3a7f1f65..91adfb01c848 100644 --- a/fs/xfs/libxfs/xfs_defer.c +++ b/fs/xfs/libxfs/xfs_defer.c @@ -23,6 +23,7 @@ #include "xfs_bmap.h" #include "xfs_alloc.h" #include "xfs_buf.h" +#include "xfs_attr.h" static struct kmem_cache *xfs_defer_pending_cache; @@ -870,7 +871,12 @@ xfs_defer_init_item_caches(void) error = xfs_extfree_intent_init_cache(); if (error) goto err; - + error = xfs_attri_init_cache(); + if (error) + goto err; + error = xfs_attrd_init_cache(); + if (error) + goto err; return 0; err: xfs_defer_destroy_item_caches(); @@ -881,6 +887,8 @@ xfs_defer_init_item_caches(void) void xfs_defer_destroy_item_caches(void) { + xfs_attri_destroy_cache(); + xfs_attrd_destroy_cache(); xfs_extfree_intent_destroy_cache(); xfs_bmap_intent_destroy_cache(); xfs_refcount_intent_destroy_cache(); diff --git a/fs/xfs/libxfs/xfs_defer.h b/fs/xfs/libxfs/xfs_defer.h index 7bb8a31ad65b..fcd23e5cf1ee 100644 --- a/fs/xfs/libxfs/xfs_defer.h +++ b/fs/xfs/libxfs/xfs_defer.h @@ -63,6 +63,8 @@ extern const struct xfs_defer_op_type xfs_refcount_update_defer_type; extern const struct xfs_defer_op_type xfs_rmap_update_defer_type; extern const struct xfs_defer_op_type xfs_extent_free_defer_type; extern const struct xfs_defer_op_type xfs_agfl_free_defer_type; +extern const struct xfs_defer_op_type xfs_attr_defer_type; + /* * Deferred operation item relogging limits. diff --git a/fs/xfs/libxfs/xfs_log_format.h b/fs/xfs/libxfs/xfs_log_format.h index b322db523d65..3301c369e815 100644 --- a/fs/xfs/libxfs/xfs_log_format.h +++ b/fs/xfs/libxfs/xfs_log_format.h @@ -114,7 +114,12 @@ struct xfs_unmount_log_format { #define XLOG_REG_TYPE_CUD_FORMAT 24 #define XLOG_REG_TYPE_BUI_FORMAT 25 #define XLOG_REG_TYPE_BUD_FORMAT 26 -#define XLOG_REG_TYPE_MAX 26 +#define XLOG_REG_TYPE_ATTRI_FORMAT 27 +#define XLOG_REG_TYPE_ATTRD_FORMAT 28 +#define XLOG_REG_TYPE_ATTR_NAME 29 +#define XLOG_REG_TYPE_ATTR_VALUE 30 +#define XLOG_REG_TYPE_MAX 30 + /* * Flags to log operation header @@ -237,6 +242,8 @@ typedef struct xfs_trans_header { #define XFS_LI_CUD 0x1243 #define XFS_LI_BUI 0x1244 /* bmbt update intent */ #define XFS_LI_BUD 0x1245 +#define XFS_LI_ATTRI 0x1246 /* attr set/remove intent*/ +#define XFS_LI_ATTRD 0x1247 /* attr set/remove done */ #define XFS_LI_TYPE_DESC \ { XFS_LI_EFI, "XFS_LI_EFI" }, \ @@ -252,7 +259,9 @@ typedef struct xfs_trans_header { { XFS_LI_CUI, "XFS_LI_CUI" }, \ { XFS_LI_CUD, "XFS_LI_CUD" }, \ { XFS_LI_BUI, "XFS_LI_BUI" }, \ - { XFS_LI_BUD, "XFS_LI_BUD" } + { XFS_LI_BUD, "XFS_LI_BUD" }, \ + { XFS_LI_ATTRI, "XFS_LI_ATTRI" }, \ + { XFS_LI_ATTRD, "XFS_LI_ATTRD" } /* * Inode Log Item Format definitions. @@ -869,4 +878,35 @@ struct xfs_icreate_log { __be32 icl_gen; /* inode generation number to use */ }; +/* + * Flags for deferred attribute operations. + * Upper bits are flags, lower byte is type code + */ +#define XFS_ATTR_OP_FLAGS_SET 1 /* Set the attribute */ +#define XFS_ATTR_OP_FLAGS_REMOVE 2 /* Remove the attribute */ +#define XFS_ATTR_OP_FLAGS_TYPE_MASK 0xFF /* Flags type mask */ + +/* + * This is the structure used to lay out an attr log item in the + * log. + */ +struct xfs_attri_log_format { + uint16_t alfi_type; /* attri log item type */ + uint16_t alfi_size; /* size of this item */ + uint32_t __pad; /* pad to 64 bit aligned */ + uint64_t alfi_id; /* attri identifier */ + uint64_t alfi_ino; /* the inode for this attr operation */ + uint32_t alfi_op_flags; /* marks the op as a set or remove */ + uint32_t alfi_name_len; /* attr name length */ + uint32_t alfi_value_len; /* attr value length */ + uint32_t alfi_attr_flags;/* attr flags */ +}; + +struct xfs_attrd_log_format { + uint16_t alfd_type; /* attrd log item type */ + uint16_t alfd_size; /* size of this item */ + uint32_t __pad; /* pad to 64 bit aligned */ + uint64_t alfd_alf_id; /* id of corresponding attri */ +}; + #endif /* __XFS_LOG_FORMAT_H__ */ diff --git a/fs/xfs/libxfs/xfs_log_recover.h b/fs/xfs/libxfs/xfs_log_recover.h index ff69a0000817..32e216255cb0 100644 --- a/fs/xfs/libxfs/xfs_log_recover.h +++ b/fs/xfs/libxfs/xfs_log_recover.h @@ -72,6 +72,8 @@ extern const struct xlog_recover_item_ops xlog_rui_item_ops; extern const struct xlog_recover_item_ops xlog_rud_item_ops; extern const struct xlog_recover_item_ops xlog_cui_item_ops; extern const struct xlog_recover_item_ops xlog_cud_item_ops; +extern const struct xlog_recover_item_ops xlog_attri_item_ops; +extern const struct xlog_recover_item_ops xlog_attrd_item_ops; /* * Macros, structures, prototypes for internal log manager use. diff --git a/fs/xfs/scrub/common.c b/fs/xfs/scrub/common.c index bf1f3607d0b6..97b54ac3075f 100644 --- a/fs/xfs/scrub/common.c +++ b/fs/xfs/scrub/common.c @@ -23,6 +23,8 @@ #include "xfs_rmap_btree.h" #include "xfs_log.h" #include "xfs_trans_priv.h" +#include "xfs_da_format.h" +#include "xfs_da_btree.h" #include "xfs_attr.h" #include "xfs_reflink.h" #include "xfs_ag.h" diff --git a/fs/xfs/xfs_attr_item.c b/fs/xfs/xfs_attr_item.c new file mode 100644 index 000000000000..00ade15cf1eb --- /dev/null +++ b/fs/xfs/xfs_attr_item.c @@ -0,0 +1,441 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (C) 2022 Oracle. All Rights Reserved. + * Author: Allison Henderson + */ + +#include "xfs.h" +#include "xfs_fs.h" +#include "xfs_format.h" +#include "xfs_trans_resv.h" +#include "xfs_shared.h" +#include "xfs_mount.h" +#include "xfs_defer.h" +#include "xfs_log_format.h" +#include "xfs_trans.h" +#include "xfs_trans_priv.h" +#include "xfs_log.h" +#include "xfs_inode.h" +#include "xfs_da_format.h" +#include "xfs_da_btree.h" +#include "xfs_attr.h" +#include "xfs_attr_item.h" +#include "xfs_trace.h" +#include "xfs_inode.h" +#include "xfs_trans_space.h" +#include "xfs_error.h" +#include "xfs_log_priv.h" +#include "xfs_log_recover.h" + +static const struct xfs_item_ops xfs_attri_item_ops; +static const struct xfs_item_ops xfs_attrd_item_ops; + +static inline struct xfs_attri_log_item *ATTRI_ITEM(struct xfs_log_item *lip) +{ + return container_of(lip, struct xfs_attri_log_item, attri_item); +} + +STATIC void +xfs_attri_item_free( + struct xfs_attri_log_item *attrip) +{ + kmem_free(attrip->attri_item.li_lv_shadow); + kmem_free(attrip); +} + +/* + * Freeing the attrip requires that we remove it from the AIL if it has already + * been placed there. However, the ATTRI may not yet have been placed in the + * AIL when called by xfs_attri_release() from ATTRD processing due to the + * ordering of committed vs unpin operations in bulk insert operations. Hence + * the reference count to ensure only the last caller frees the ATTRI. + */ +STATIC void +xfs_attri_release( + struct xfs_attri_log_item *attrip) +{ + ASSERT(atomic_read(&attrip->attri_refcount) > 0); + if (atomic_dec_and_test(&attrip->attri_refcount)) { + xfs_trans_ail_delete(&attrip->attri_item, + SHUTDOWN_LOG_IO_ERROR); + xfs_attri_item_free(attrip); + } +} + +STATIC void +xfs_attri_item_size( + struct xfs_log_item *lip, + int *nvecs, + int *nbytes) +{ + struct xfs_attri_log_item *attrip = ATTRI_ITEM(lip); + + *nvecs += 2; + *nbytes += sizeof(struct xfs_attri_log_format) + + xlog_calc_iovec_len(attrip->attri_name_len); + + if (!attrip->attri_value_len) + return; + + *nvecs += 1; + *nbytes += xlog_calc_iovec_len(attrip->attri_value_len); +} + +/* + * This is called to fill in the log iovecs for the given attri log + * item. We use 1 iovec for the attri_format_item, 1 for the name, and + * another for the value if it is present + */ +STATIC void +xfs_attri_item_format( + struct xfs_log_item *lip, + struct xfs_log_vec *lv) +{ + struct xfs_attri_log_item *attrip = ATTRI_ITEM(lip); + struct xfs_log_iovec *vecp = NULL; + + attrip->attri_format.alfi_type = XFS_LI_ATTRI; + attrip->attri_format.alfi_size = 1; + + /* + * This size accounting must be done before copying the attrip into the + * iovec. If we do it after, the wrong size will be recorded to the log + * and we trip across assertion checks for bad region sizes later during + * the log recovery. + */ + + ASSERT(attrip->attri_name_len > 0); + attrip->attri_format.alfi_size++; + + if (attrip->attri_value_len > 0) + attrip->attri_format.alfi_size++; + + xlog_copy_iovec(lv, &vecp, XLOG_REG_TYPE_ATTRI_FORMAT, + &attrip->attri_format, + sizeof(struct xfs_attri_log_format)); + xlog_copy_iovec(lv, &vecp, XLOG_REG_TYPE_ATTR_NAME, + attrip->attri_name, + xlog_calc_iovec_len(attrip->attri_name_len)); + if (attrip->attri_value_len > 0) + xlog_copy_iovec(lv, &vecp, XLOG_REG_TYPE_ATTR_VALUE, + attrip->attri_value, + xlog_calc_iovec_len(attrip->attri_value_len)); +} + +/* + * The unpin operation is the last place an ATTRI is manipulated in the log. It + * is either inserted in the AIL or aborted in the event of a log I/O error. In + * either case, the ATTRI transaction has been successfully committed to make + * it this far. Therefore, we expect whoever committed the ATTRI to either + * construct and commit the ATTRD or drop the ATTRD's reference in the event of + * error. Simply drop the log's ATTRI reference now that the log is done with + * it. + */ +STATIC void +xfs_attri_item_unpin( + struct xfs_log_item *lip, + int remove) +{ + xfs_attri_release(ATTRI_ITEM(lip)); +} + + +STATIC void +xfs_attri_item_release( + struct xfs_log_item *lip) +{ + xfs_attri_release(ATTRI_ITEM(lip)); +} + +/* + * Allocate and initialize an attri item. Caller may allocate an additional + * trailing buffer 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; + + if (buffer_size) { + attrip = kmem_alloc(sizeof(struct xfs_attri_log_item) + + buffer_size, KM_NOFS); + if (attrip == NULL) + return NULL; + } else { + attrip = kmem_cache_alloc(xfs_attri_cache, + GFP_NOFS | __GFP_NOFAIL); + } + + xfs_log_item_init(mp, &attrip->attri_item, XFS_LI_ATTRI, + &xfs_attri_item_ops); + attrip->attri_format.alfi_id = (uintptr_t)(void *)attrip; + atomic_set(&attrip->attri_refcount, 2); + + return attrip; +} + +/* + * Copy an attr format buffer from the given buf, and into the destination attr + * format structure. + */ +STATIC int +xfs_attri_copy_format( + struct xfs_log_iovec *buf, + struct xfs_attri_log_format *dst_attr_fmt) +{ + struct xfs_attri_log_format *src_attr_fmt = buf->i_addr; + size_t len; + + len = sizeof(struct xfs_attri_log_format); + if (buf->i_len != len) { + XFS_ERROR_REPORT(__func__, XFS_ERRLEVEL_LOW, NULL); + return -EFSCORRUPTED; + } + + memcpy((char *)dst_attr_fmt, (char *)src_attr_fmt, len); + return 0; +} + +static inline struct xfs_attrd_log_item *ATTRD_ITEM(struct xfs_log_item *lip) +{ + return container_of(lip, struct xfs_attrd_log_item, attrd_item); +} + +STATIC void +xfs_attrd_item_free(struct xfs_attrd_log_item *attrdp) +{ + kmem_free(attrdp->attrd_item.li_lv_shadow); + kmem_free(attrdp); +} + +STATIC void +xfs_attrd_item_size( + struct xfs_log_item *lip, + int *nvecs, + int *nbytes) +{ + *nvecs += 1; + *nbytes += sizeof(struct xfs_attrd_log_format); +} + +/* + * This is called to fill in the log iovecs for the given attrd log item. We use + * only 1 iovec for the attrd_format, and we point that at the attr_log_format + * structure embedded in the attrd item. + */ +STATIC void +xfs_attrd_item_format( + struct xfs_log_item *lip, + struct xfs_log_vec *lv) +{ + struct xfs_attrd_log_item *attrdp = ATTRD_ITEM(lip); + struct xfs_log_iovec *vecp = NULL; + + attrdp->attrd_format.alfd_type = XFS_LI_ATTRD; + attrdp->attrd_format.alfd_size = 1; + + xlog_copy_iovec(lv, &vecp, XLOG_REG_TYPE_ATTRD_FORMAT, + &attrdp->attrd_format, + sizeof(struct xfs_attrd_log_format)); +} + +/* + * The ATTRD is either committed or aborted if the transaction is canceled. If + * the transaction is canceled, drop our reference to the ATTRI and free the + * ATTRD. + */ +STATIC void +xfs_attrd_item_release( + struct xfs_log_item *lip) +{ + struct xfs_attrd_log_item *attrdp = ATTRD_ITEM(lip); + + xfs_attri_release(attrdp->attrd_attrip); + xfs_attrd_item_free(attrdp); +} + +STATIC xfs_lsn_t +xfs_attri_item_committed( + struct xfs_log_item *lip, + xfs_lsn_t lsn) +{ + struct xfs_attri_log_item *attrip = ATTRI_ITEM(lip); + + /* + * The attrip refers to xfs_attr_item memory to log the name and value + * with the intent item. This already occurred when the intent was + * committed so these fields are no longer accessed. Clear them out of + * caution since we're about to free the xfs_attr_item. + */ + attrip->attri_name = NULL; + attrip->attri_value = NULL; + + /* + * The ATTRI is logged only once and cannot be moved in the log, so + * simply return the lsn at which it's been logged. + */ + return lsn; +} + +STATIC bool +xfs_attri_item_match( + struct xfs_log_item *lip, + uint64_t intent_id) +{ + return ATTRI_ITEM(lip)->attri_format.alfi_id == intent_id; +} + +/* Is this recovered ATTRI format ok? */ +static inline bool +xfs_attri_validate( + struct xfs_mount *mp, + struct xfs_attri_log_format *attrp) +{ + unsigned int op = attrp->alfi_op_flags & + XFS_ATTR_OP_FLAGS_TYPE_MASK; + + if (attrp->__pad != 0) + return false; + + /* alfi_op_flags should be either a set or remove */ + if (op != XFS_ATTR_OP_FLAGS_SET && op != XFS_ATTR_OP_FLAGS_REMOVE) + return false; + + if (attrp->alfi_value_len > XATTR_SIZE_MAX) + return false; + + if ((attrp->alfi_name_len > XATTR_NAME_MAX) || + (attrp->alfi_name_len == 0)) + return false; + + return xfs_verify_ino(mp, attrp->alfi_ino); +} + +STATIC int +xlog_recover_attri_commit_pass2( + struct xlog *log, + struct list_head *buffer_list, + struct xlog_recover_item *item, + xfs_lsn_t lsn) +{ + int error; + struct xfs_mount *mp = log->l_mp; + struct xfs_attri_log_item *attrip; + struct xfs_attri_log_format *attri_formatp; + 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 (!xfs_attri_validate(mp, attri_formatp)) { + XFS_ERROR_REPORT(__func__, XFS_ERRLEVEL_LOW, mp); + return -EFSCORRUPTED; + } + + buffer_size = attri_formatp->alfi_name_len + + attri_formatp->alfi_value_len; + + /* memory alloc failure will cause replay to abort */ + 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) + goto out; + + 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 (!xfs_attr_namecheck(name, attrip->attri_name_len)) { + XFS_ERROR_REPORT(__func__, XFS_ERRLEVEL_LOW, mp); + error = -EFSCORRUPTED; + goto out; + } + + 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; +out: + xfs_attri_item_free(attrip); + return error; +} + +/* + * This routine is called when an ATTRD format structure is found in a committed + * transaction in the log. Its purpose is to cancel the corresponding ATTRI if + * it was still in the log. To do this it searches the AIL for the ATTRI with + * an id equal to that in the ATTRD format structure. If we find it we drop + * the ATTRD reference, which removes the ATTRI from the AIL and frees it. + */ +STATIC int +xlog_recover_attrd_commit_pass2( + struct xlog *log, + struct list_head *buffer_list, + struct xlog_recover_item *item, + xfs_lsn_t lsn) +{ + struct xfs_attrd_log_format *attrd_formatp; + + attrd_formatp = item->ri_buf[0].i_addr; + if (item->ri_buf[0].i_len != sizeof(struct xfs_attrd_log_format)) { + XFS_ERROR_REPORT(__func__, XFS_ERRLEVEL_LOW, NULL); + return -EFSCORRUPTED; + } + + xlog_recover_release_intent(log, XFS_LI_ATTRI, + attrd_formatp->alfd_alf_id); + return 0; +} + +static const struct xfs_item_ops xfs_attri_item_ops = { + .iop_size = xfs_attri_item_size, + .iop_format = xfs_attri_item_format, + .iop_unpin = xfs_attri_item_unpin, + .iop_committed = xfs_attri_item_committed, + .iop_release = xfs_attri_item_release, + .iop_match = xfs_attri_item_match, +}; + +const struct xlog_recover_item_ops xlog_attri_item_ops = { + .item_type = XFS_LI_ATTRI, + .commit_pass2 = xlog_recover_attri_commit_pass2, +}; + +static const struct xfs_item_ops xfs_attrd_item_ops = { + .flags = XFS_ITEM_RELEASE_WHEN_COMMITTED, + .iop_size = xfs_attrd_item_size, + .iop_format = xfs_attrd_item_format, + .iop_release = xfs_attrd_item_release, +}; + +const struct xlog_recover_item_ops xlog_attrd_item_ops = { + .item_type = XFS_LI_ATTRD, + .commit_pass2 = xlog_recover_attrd_commit_pass2, +}; diff --git a/fs/xfs/xfs_attr_item.h b/fs/xfs/xfs_attr_item.h new file mode 100644 index 000000000000..c3b779f82adb --- /dev/null +++ b/fs/xfs/xfs_attr_item.h @@ -0,0 +1,46 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later + * + * Copyright (C) 2022 Oracle. All Rights Reserved. + * Author: Allison Henderson + */ +#ifndef __XFS_ATTR_ITEM_H__ +#define __XFS_ATTR_ITEM_H__ + +/* kernel only ATTRI/ATTRD definitions */ + +struct xfs_mount; +struct kmem_zone; + +/* + * This is the "attr intention" log item. It is used to log the fact that some + * extended attribute operations need to be processed. An operation is + * currently either a set or remove. Set or remove operations are described by + * the xfs_attr_item which may be logged to this intent. + * + * During a normal attr operation, name and value point to the name and value + * fields of the caller's xfs_da_args structure. During a recovery, the name + * and value buffers are copied from the log, and stored in a trailing buffer + * attached to the xfs_attr_item until they are committed. They are freed when + * the xfs_attr_item itself is freed when the work is done. + */ +struct xfs_attri_log_item { + struct xfs_log_item attri_item; + atomic_t attri_refcount; + int attri_name_len; + int attri_value_len; + void *attri_name; + void *attri_value; + struct xfs_attri_log_format attri_format; +}; + +/* + * This is the "attr done" log item. It is used to log the fact that some attrs + * earlier mentioned in an attri item have been freed. + */ +struct xfs_attrd_log_item { + struct xfs_log_item attrd_item; + struct xfs_attri_log_item *attrd_attrip; + struct xfs_attrd_log_format attrd_format; +}; + +#endif /* __XFS_ATTR_ITEM_H__ */ diff --git a/fs/xfs/xfs_attr_list.c b/fs/xfs/xfs_attr_list.c index 2d1e5134cebe..90a14e85e76d 100644 --- a/fs/xfs/xfs_attr_list.c +++ b/fs/xfs/xfs_attr_list.c @@ -15,6 +15,7 @@ #include "xfs_inode.h" #include "xfs_trans.h" #include "xfs_bmap.h" +#include "xfs_da_btree.h" #include "xfs_attr.h" #include "xfs_attr_sf.h" #include "xfs_attr_leaf.h" diff --git a/fs/xfs/xfs_ioctl32.c b/fs/xfs/xfs_ioctl32.c index 004ed2a251e8..618a46a1d5fb 100644 --- a/fs/xfs/xfs_ioctl32.c +++ b/fs/xfs/xfs_ioctl32.c @@ -17,6 +17,8 @@ #include "xfs_itable.h" #include "xfs_fsops.h" #include "xfs_rtalloc.h" +#include "xfs_da_format.h" +#include "xfs_da_btree.h" #include "xfs_attr.h" #include "xfs_ioctl.h" #include "xfs_ioctl32.h" diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c index b79b3846e71b..2b6b6f0434ff 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 89fec9a18c34..8ba8563114b9 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.h b/fs/xfs/xfs_log.h index dc1b77b92fc1..fd945eb66c32 100644 --- a/fs/xfs/xfs_log.h +++ b/fs/xfs/xfs_log.h @@ -21,6 +21,17 @@ struct xfs_log_vec { #define XFS_LOG_VEC_ORDERED (-1) +/* + * Calculate the log iovec length for a given user buffer length. Intended to be + * used by ->iop_size implementations when sizing buffers of arbitrary + * alignments. + */ +static inline int +xlog_calc_iovec_len(int len) +{ + return roundup(len, sizeof(int32_t)); +} + static inline void * xlog_prepare_iovec(struct xfs_log_vec *lv, struct xfs_log_iovec **vecp, uint type) diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c index 96c997ed2ec8..f1edb315e341 100644 --- a/fs/xfs/xfs_log_recover.c +++ b/fs/xfs/xfs_log_recover.c @@ -1800,6 +1800,8 @@ static const struct xlog_recover_item_ops *xlog_recover_item_ops[] = { &xlog_cud_item_ops, &xlog_bui_item_ops, &xlog_bud_item_ops, + &xlog_attri_item_ops, + &xlog_attrd_item_ops, }; static const struct xlog_recover_item_ops * diff --git a/fs/xfs/xfs_ondisk.h b/fs/xfs/xfs_ondisk.h index 25991923c1a8..758702b9495f 100644 --- a/fs/xfs/xfs_ondisk.h +++ b/fs/xfs/xfs_ondisk.h @@ -132,6 +132,8 @@ xfs_check_ondisk_structs(void) XFS_CHECK_STRUCT_SIZE(struct xfs_inode_log_format, 56); XFS_CHECK_STRUCT_SIZE(struct xfs_qoff_logformat, 20); XFS_CHECK_STRUCT_SIZE(struct xfs_trans_header, 16); + XFS_CHECK_STRUCT_SIZE(struct xfs_attri_log_format, 40); + XFS_CHECK_STRUCT_SIZE(struct xfs_attrd_log_format, 16); /* * The v5 superblock format extended several v4 header structures with From patchwork Mon Feb 28 19:51:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12763744 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D2E9DC43217 for ; Mon, 28 Feb 2022 19:52:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229817AbiB1TxN (ORCPT ); Mon, 28 Feb 2022 14:53:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36770 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229888AbiB1Twm (ORCPT ); Mon, 28 Feb 2022 14:52:42 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CF983F407E for ; Mon, 28 Feb 2022 11:51:59 -0800 (PST) Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 21SIJHV5010129 for ; Mon, 28 Feb 2022 19:51:59 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=R5DCLNvwvumpCBIyl6hbHekNKdA/OXUU9yNoYpD0DxE=; b=OOnl5LFzVsm7zA/XpBd+mM2NyvE4rtmKoYA4zxBrHRY2/L9OjywdvcN0iwMzDQGw4+dz XUXvb3W01qxJ4yfwPFXhgnKIbCrI8KW7pTT/iLWjrRWjBnQTV3BBwim7oTnly5hYT2KN KXDG6yOABlXhxKN7U4VuuWerl6S/ezaBrGJcvyRUDeR4nstKN1sjS1V/QtViPJO6PWmn Q1goO9WxCsrZ4xIXjnJAm3dZ/WlQ6cwK/YsIFpaHL/ttoYgy6u3EvOsRV3kq5Ko0kXAc T0pp3ky8RwQJMwp3bzz5Zd20YZIMGW3i8xR0//22QZHPeD5XNm9qCEcGjEptTVTrGW5J rQ== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by mx0b-00069f02.pphosted.com with ESMTP id 3eh1k40pq9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 28 Feb 2022 19:51:58 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 21SJkltl076550 for ; Mon, 28 Feb 2022 19:51:57 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2170.outbound.protection.outlook.com [104.47.59.170]) by aserp3020.oracle.com with ESMTP id 3efc13e3fr-6 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 28 Feb 2022 19:51:57 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Zv8hO4ND5V7GnH5l27smOEOXdjBz4TB4p54xoOnxa+UFhuv/ZVEvmkQOEfrqav0dqO5CHahHVCwusYk2PDg7qPWpTaCAvj+2a7c+BhVLz1qg0klJqUDMQjABHDyp6aBhjWrJLxC5UypUSU6g9qL9ls5we343HhK+a+RjaDywn6+Ezy6QYY9wNarQlD4vMjFifVo61Fpvn+EddmqtEg9NesWE5114yShTZM6nTGamq4GPYmJIP/gh1Qlj1nckDf0ZogXkBXzBrEiEtKRFbApaBKMrMVbFymtEIJPs5Y6oWi9Uf0n1v2jnIyNaTx+2Nh8SqpZ3Ew50tZ0FM0YpAOTWTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=R5DCLNvwvumpCBIyl6hbHekNKdA/OXUU9yNoYpD0DxE=; b=R61WBnX3NWr6XSaVo3vgNZD2nCIGEg6//xYeAjHi4LkPAvGmU4h+VaA45d6ykX2LizxbYQ4iQe4irQVNMKggewMy5hQ3nYl5g9IIU4dfBXK0x2rqSRvtz3q4xzTuTaWoECtcye+Yi4Lr7YNIDtoGuKurPppr/J/+qq3Wo1goTg2WW5sWxJoDxUutDrMQMVkPld0ghO7MFHllWFACQQSXagB26T8gUrx32g3xs58FzTGxMAxSMv71S73obpP4/Pr9DKISRxaitZ59IgHvUlGy/kas65P01r1+PYGKwjHZwhdopKxxj0pxpIuwqRECttMMSEQaxRlaELIJs6kpnIFBXg== 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=R5DCLNvwvumpCBIyl6hbHekNKdA/OXUU9yNoYpD0DxE=; b=eP8Cmvoro7zEa7S0D52PxsaAkBpoesSQygaPZ1T3Hw/42FQzGhjtVhZycFH8gUSdWLB2N4JLQ10e7g78/EqxycXkAEpR96+VPDhAFy/6sICOu9I0EBad8G7g0JdmjEy3XJ17aLRv230DsEtDklQvM9pcUN553vXTLefc8kTSCz8= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by PH0PR10MB5612.namprd10.prod.outlook.com (2603:10b6:510:fa::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5017.26; Mon, 28 Feb 2022 19:51:55 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::a91b:c130:5e3f:119]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::a91b:c130:5e3f:119%7]) with mapi id 15.20.5017.027; Mon, 28 Feb 2022 19:51:55 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v28 05/15] xfs: Implement attr logging and replay Date: Mon, 28 Feb 2022 12:51:37 -0700 Message-Id: <20220228195147.1913281-6-allison.henderson@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220228195147.1913281-1-allison.henderson@oracle.com> References: <20220228195147.1913281-1-allison.henderson@oracle.com> X-ClientProxiedBy: BY5PR03CA0023.namprd03.prod.outlook.com (2603:10b6:a03:1e0::33) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d5fa0d63-2fda-4b6a-9d78-08d9faf3c5f0 X-MS-TrafficTypeDiagnostic: PH0PR10MB5612:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 88h/xZ/GLzMQTwEAf8B7sjWWD0zKgn61xbqPi1qylGikqKUXbLF624SJ6lbCHI8cUDf4C7EREEsXBRXeMWccjthrDxAQcx7ztkjwZR/e5Xn9OiaavTEXqozQcfroHdMKNugoLF3We5HrXO+TkX4XX4aobDch/iHYcgtZqEfSCzgMZW+xZC46HMyo/MXpyr8qQwsXf97sQsLAOhguuBvqFugj6rBf1/AST+pChwr/S988EF8ZaWTIa/Zm6ITwMUEoCNvJo0JBTywr+qsKc9OFBjv6/EJhAKwRINFArXSNea4/Uj/IRkywfeDmvsoY3bVM366XsFz6+17m827BVRphQW78mZ7Njbbjmov0y0CNX8RC3xMfj1yk24h1b/b9Ur0M66oyKwmvDJ37zXdqh3Nd92gOxbMocl5sDKcy2eU59aS3suPOWIAd9jcv99HyTL145nOKHo/OKZ0OFgLubnrkzU4zICArQ0EQyxpK8vh6zGF/Wp89d2FdN2KSlHIHIbdFyFgtn0H0sHhP3tkV5xV9AeqyohJHkcWon1TS88sercj/lsvk/2npY53juII6PneWzBY5tQDtUc6jq3eJCb0XcrK+GC8Dd0aT55p4RxntHUOy0EFxl6EU45W3sENRzY+cOiAbEekpztbZxSTZv2Pw/SFrfNnZWW+x+trdmTljxCyJAPvhKR3UZTxVir7vyTCErS/BrP+XyiETHyPhGpT9ig== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(366004)(26005)(86362001)(186003)(8676002)(6916009)(1076003)(316002)(66946007)(66476007)(66556008)(2906002)(2616005)(6486002)(6666004)(6512007)(52116002)(30864003)(8936002)(508600001)(5660300002)(38350700002)(44832011)(83380400001)(38100700002)(6506007)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: pZIXThK5/iBuxkeYik1mpLVHhH8haFqTe6+r7W0Qb5/yMev848MCuBIebt1CD29J1GTucTaYb0AXcwO8lqgdQtGEmq7lkFuD/umcycxLJ7tvDMZ6KTC8Hz9Ri6/+ypqZioiKpJuBaUEYjw8ZmKV4YAWq0aY+LlrSNWx1MKMU1UNeBTWgER6b6vPGfwyOtMsW+AqGAPD0CshZcrwZbAjZS7AzBBPSSp3IevjvutbQCjkahrei5OsEHpsRuG2tKNle64EXi0SPoCOVJaHC+bUGeoWp6aDU5yRoA/gJLZzo6cCGVvLwtSqsHiS6EL0A01derJ/ciUI+ZWnw34UmA+JE12BlSdSa5O+VdPikA2Ms2s4KNbIf73A9DxRXfBf5woV3evRASB7Zcgw7YwndeHWZSgDuijlNv1093IkTJEXDE0gErkPoGFf6tpJOT7qPlJ4T3qtso/c3pUqlD93pSPocITaF8P0QbPfTxkDUsHg8/gBb6DVaSpircgBsVZEygYttBcQnqIVK3+TPlZrjTIaDDRTOrCbvVtKfdJp1iWQM973CsePUqWbibdlbOAGk/j5LXc3T4edfEQgb8dVBJDq0iqb+9UMlc8gYS+lSU0K0o8zd2lel81Oc6vAMiQGa+4oK03AQb/0TQxvStoqG/uerAQlnHQewH54dM2c5eBMpDnW9Tz0IhW2U9WN3dd/nV8YKvjVa8awJGM63HpVqZjfgb/UZFF/kLiI8DZT5HKCtQxk4qxVJ1suhTwpAUOJh8w9OYLr9AQSxt6Ry7EMrALGtBLkm28DtGURLf7rZycVFItvMnlLCTNeWqJ/QqND6MVnyiv4XHzlOehKCqdYeSPcouOZTasX/lD1UHKcI7e8olaPNUILfV0aYI1eA4MXm3jIIBYQwiNxxUw+q+S9BXy5iR4960Cr1/kwCBHGAvIxaxpMJ80sSvollM2rOqKDoAVmHf5GkvLIfv0UIUwFQpG5AJDnCR07J5FQ72nmvs0BGHqs6YwlkDszWT+cYuoGAcmYak83HY+xiUBiST5z55mbDQh8H54BnXzDx7ODUz/Oybv/NXrEYef2zKV1WNV3WO4fObFAoOq7+XKKRpwpZGgL1olJ3X7Ku6qf2nkSNe9ECltHOAU5NIxrn7XRWEgvOAViGe4O0t1xlPQf+TqBBS6QYM3Rh4bqAtsJZu3QNEJRVqbadzSDoecK/8INBZVMoiubLqf7EcDRiXjMVmcH55oIWxCHvzf7YgiGYK5fbqPDxX4LfEpG/OhaSc0Yi/+WMYV8GOQd2+ZbnS4QeEhIR9nYI6I8vqdIIJ9pxrauNoHyxVzQ3EjcyUJafHKdSCqURSwt9FS2VnqeRkvwInfUosj5WRz3q1mVjX1dOUrkfKm4yB+wlj8kwv3Z4DlLG1e+Pn1m6tUnANeTtXJMkpWoEMAosDi4lVw4lAHijJUzW8rM0CoFQlSj3nNZ8BfL94a6tbg4iy6wFt0vI8DIe2mdyu4CB/V+EKFUmibMCg1jTRUSV0UgP0gY6Z0lHhM18fORtNA4eQJbMaa4EyPrn3pdgIB2gpbMfhfxhgvbp/YHGCUpZRSypNb7tGh0pxAOgQgmYf/uj/+hw43iw7mpEh9H7xfhGRH5VDGjvybFsj2/fd9tGOvV8WNZ7ANcgENbyqQ2dA1ypypjKpEwWoOi0SAnRnCodog== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: d5fa0d63-2fda-4b6a-9d78-08d9faf3c5f0 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Feb 2022 19:51:55.6544 (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: /U4kTRtgMHpfm+jbl0udPPkjPcd8ALURyzynUifMBTL5vFpXVGGbONEK7NJkDtL9ZmY+lF0AYWEOOzs7DWngVzVqtxGh1gFpZeBfMP+Lm3E= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB5612 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10272 signatures=684655 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxscore=0 phishscore=0 bulkscore=0 adultscore=0 spamscore=0 suspectscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2202280097 X-Proofpoint-ORIG-GUID: SkpFWklF9HCMHrSIWeGJr5bN2XVuawhZ X-Proofpoint-GUID: SkpFWklF9HCMHrSIWeGJr5bN2XVuawhZ Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org This patch adds the needed routines to create, log and recover logged extended attribute intents. Signed-off-by: Allison Henderson Reviewed-by: Chandan Babu R Reviewed-by: Darrick J. Wong --- fs/xfs/libxfs/xfs_defer.c | 1 + fs/xfs/libxfs/xfs_defer.h | 1 + fs/xfs/libxfs/xfs_format.h | 9 +- fs/xfs/xfs_attr_item.c | 360 +++++++++++++++++++++++++++++++++++++ 4 files changed, 370 insertions(+), 1 deletion(-) diff --git a/fs/xfs/libxfs/xfs_defer.c b/fs/xfs/libxfs/xfs_defer.c index 91adfb01c848..d15c39d21e86 100644 --- a/fs/xfs/libxfs/xfs_defer.c +++ b/fs/xfs/libxfs/xfs_defer.c @@ -186,6 +186,7 @@ static const struct xfs_defer_op_type *defer_op_types[] = { [XFS_DEFER_OPS_TYPE_RMAP] = &xfs_rmap_update_defer_type, [XFS_DEFER_OPS_TYPE_FREE] = &xfs_extent_free_defer_type, [XFS_DEFER_OPS_TYPE_AGFL_FREE] = &xfs_agfl_free_defer_type, + [XFS_DEFER_OPS_TYPE_ATTR] = &xfs_attr_defer_type, }; static void diff --git a/fs/xfs/libxfs/xfs_defer.h b/fs/xfs/libxfs/xfs_defer.h index fcd23e5cf1ee..114a3a4930a3 100644 --- a/fs/xfs/libxfs/xfs_defer.h +++ b/fs/xfs/libxfs/xfs_defer.h @@ -19,6 +19,7 @@ enum xfs_defer_ops_type { XFS_DEFER_OPS_TYPE_RMAP, XFS_DEFER_OPS_TYPE_FREE, XFS_DEFER_OPS_TYPE_AGFL_FREE, + XFS_DEFER_OPS_TYPE_ATTR, XFS_DEFER_OPS_TYPE_MAX, }; diff --git a/fs/xfs/libxfs/xfs_format.h b/fs/xfs/libxfs/xfs_format.h index d665c04e69dd..302b50bc5830 100644 --- a/fs/xfs/libxfs/xfs_format.h +++ b/fs/xfs/libxfs/xfs_format.h @@ -388,7 +388,9 @@ xfs_sb_has_incompat_feature( return (sbp->sb_features_incompat & feature) != 0; } -#define XFS_SB_FEAT_INCOMPAT_LOG_ALL 0 +#define XFS_SB_FEAT_INCOMPAT_LOG_XATTRS (1 << 0) /* Delayed Attributes */ +#define XFS_SB_FEAT_INCOMPAT_LOG_ALL \ + (XFS_SB_FEAT_INCOMPAT_LOG_XATTRS) #define XFS_SB_FEAT_INCOMPAT_LOG_UNKNOWN ~XFS_SB_FEAT_INCOMPAT_LOG_ALL static inline bool xfs_sb_has_incompat_log_feature( @@ -413,6 +415,11 @@ xfs_sb_add_incompat_log_features( sbp->sb_features_log_incompat |= features; } +static inline bool xfs_sb_version_haslogxattrs(struct xfs_sb *sbp) +{ + return xfs_sb_is_v5(sbp) && (sbp->sb_features_log_incompat & + XFS_SB_FEAT_INCOMPAT_LOG_XATTRS); +} static inline bool xfs_is_quota_inode(struct xfs_sb *sbp, xfs_ino_t ino) diff --git a/fs/xfs/xfs_attr_item.c b/fs/xfs/xfs_attr_item.c index 00ade15cf1eb..6e4c65d82db5 100644 --- a/fs/xfs/xfs_attr_item.c +++ b/fs/xfs/xfs_attr_item.c @@ -13,6 +13,7 @@ #include "xfs_defer.h" #include "xfs_log_format.h" #include "xfs_trans.h" +#include "xfs_bmap_btree.h" #include "xfs_trans_priv.h" #include "xfs_log.h" #include "xfs_inode.h" @@ -29,6 +30,8 @@ static const struct xfs_item_ops xfs_attri_item_ops; static const struct xfs_item_ops xfs_attrd_item_ops; +static struct xfs_attrd_log_item *xfs_trans_get_attrd(struct xfs_trans *tp, + struct xfs_attri_log_item *attrip); static inline struct xfs_attri_log_item *ATTRI_ITEM(struct xfs_log_item *lip) { @@ -257,6 +260,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_xattri_finish_update( + struct xfs_delattr_context *dac, + struct xfs_attrd_log_item *attrdp, + struct xfs_buf **leaf_bp, + uint32_t op_flags) +{ + struct xfs_da_args *args = dac->da_args; + unsigned int op = op_flags & + XFS_ATTR_OP_FLAGS_TYPE_MASK; + int error; + + switch (op) { + case XFS_ATTR_OP_FLAGS_SET: + error = xfs_attr_set_iter(dac, leaf_bp); + break; + case XFS_ATTR_OP_FLAGS_REMOVE: + ASSERT(XFS_IFORK_Q(args->dp)); + error = xfs_attr_remove_iter(dac); + break; + default: + error = -EFSCORRUPTED; + break; + } + + /* + * Mark the transaction dirty, even on error. This ensures the + * transaction is aborted, which: + * + * 1.) releases the ATTRI and frees the ATTRD + * 2.) shuts down the filesystem + */ + args->trans->t_flags |= XFS_TRANS_DIRTY; + + /* + * attr intent/done items are null when logged attributes are disabled + */ + if (attrdp) + set_bit(XFS_LI_DIRTY, &attrdp->attrd_item.li_flags); + + return error; +} + +/* Log an attr to the intent item. */ +STATIC void +xfs_attr_log_item( + struct xfs_trans *tp, + struct xfs_attri_log_item *attrip, + struct xfs_attr_item *attr) +{ + struct xfs_attri_log_format *attrp; + + tp->t_flags |= XFS_TRANS_DIRTY; + set_bit(XFS_LI_DIRTY, &attrip->attri_item.li_flags); + + /* + * At this point the xfs_attr_item has been constructed, and we've + * created the log intent. Fill in the attri log item and log format + * structure with fields from this xfs_attr_item + */ + attrp = &attrip->attri_format; + attrp->alfi_ino = attr->xattri_dac.da_args->dp->i_ino; + attrp->alfi_op_flags = attr->xattri_op_flags; + attrp->alfi_value_len = attr->xattri_dac.da_args->valuelen; + attrp->alfi_name_len = attr->xattri_dac.da_args->namelen; + attrp->alfi_attr_flags = attr->xattri_dac.da_args->attr_filter; + + 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 (!xfs_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_xattri_finish_update(dac, done_item, &dac->leaf_bp, + attr->xattri_op_flags); + if (error != -EAGAIN) + kmem_free(attr); + + return error; +} + +/* Abort all pending ATTRs. */ +STATIC void +xfs_attr_abort_intent( + struct xfs_log_item *intent) +{ + xfs_attri_release(ATTRI_ITEM(intent)); +} + +/* Cancel an attr */ +STATIC void +xfs_attr_cancel_item( + struct list_head *item) +{ + struct xfs_attr_item *attr; + + attr = container_of(item, struct xfs_attr_item, xattri_list); + kmem_free(attr); +} + STATIC xfs_lsn_t xfs_attri_item_committed( struct xfs_log_item *lip, @@ -314,6 +474,160 @@ 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, attrp) || + !xfs_attr_namecheck(attrip->attri_name, attrip->attri_name_len)) + return -EFSCORRUPTED; + + error = xlog_recover_iget(mp, attrp->alfi_ino, &ip); + if (error) + return error; + + attr = kmem_zalloc(sizeof(struct xfs_attr_item) + + sizeof(struct xfs_da_args), KM_NOFS); + args = (struct xfs_da_args *)(attr + 1); + + attr->xattri_dac.da_args = args; + attr->xattri_op_flags = attrp->alfi_op_flags; + + args->dp = ip; + args->geo = mp->m_attr_geo; + args->whichfork = XFS_ATTR_FORK; + args->name = attrip->attri_name; + args->namelen = attrp->alfi_name_len; + args->hashval = xfs_da_hashname(args->name, args->namelen); + args->attr_filter = attrp->alfi_attr_flags; + + if (attrp->alfi_op_flags == XFS_ATTR_OP_FLAGS_SET) { + args->value = attrip->attri_value; + args->valuelen = attrp->alfi_value_len; + args->total = xfs_attr_calc_size(args, &local); + + tres.tr_logres = M_RES(mp)->tr_attrsetm.tr_logres + + M_RES(mp)->tr_attrsetrt.tr_logres * + args->total; + tres.tr_logcount = XFS_ATTRSET_LOG_COUNT; + tres.tr_logflags = XFS_TRANS_PERM_LOG_RES; + total = args->total; + } else { + tres = M_RES(mp)->tr_attrrm; + total = XFS_ATTRRM_SPACE_RES(mp); + } + error = xfs_trans_alloc(mp, &tres, total, 0, XFS_TRANS_RESERVE, &tp); + if (error) + goto out; + + args->trans = tp; + done_item = xfs_trans_get_attrd(tp, attrip); + + xfs_ilock(ip, XFS_ILOCK_EXCL); + xfs_trans_ijoin(tp, ip, 0); + + ret = xfs_xattri_finish_update(&attr->xattri_dac, done_item, + &attr->xattri_dac.leaf_bp, + attrp->alfi_op_flags); + if (ret == -EAGAIN) { + /* There's more work to do, so add it to this transaction */ + xfs_defer_add(tp, XFS_DEFER_OPS_TYPE_ATTR, &attr->xattri_list); + } else + error = ret; + + if (error) { + xfs_trans_cancel(tp); + goto out_unlock; + } + + error = xfs_defer_ops_capture_and_commit(tp, capture_list); + +out_unlock: + if (attr->xattri_dac.leaf_bp) + xfs_buf_relse(attr->xattri_dac.leaf_bp); + + xfs_iunlock(ip, XFS_ILOCK_EXCL); + xfs_irele(ip); +out: + if (ret != -EAGAIN) + kmem_free(attr); + return error; +} + +/* Re-log an intent item to push the log tail forward. */ +static struct xfs_log_item * +xfs_attri_item_relog( + struct xfs_log_item *intent, + struct xfs_trans *tp) +{ + struct xfs_attrd_log_item *attrdp; + struct xfs_attri_log_item *old_attrip; + struct xfs_attri_log_item *new_attrip; + struct xfs_attri_log_format *new_attrp; + struct xfs_attri_log_format *old_attrp; + 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 int xlog_recover_attri_commit_pass2( struct xlog *log, @@ -387,6 +701,50 @@ xlog_recover_attri_commit_pass2( return error; } +/* + * This routine is called to allocate an "attr free done" log item. + */ +static struct xfs_attrd_log_item * +xfs_trans_get_attrd(struct xfs_trans *tp, + struct xfs_attri_log_item *attrip) +{ + struct xfs_attrd_log_item *attrdp; + + ASSERT(tp != NULL); + + attrdp = kmem_cache_alloc(xfs_attrd_cache, GFP_NOFS | __GFP_NOFAIL); + + xfs_log_item_init(tp->t_mountp, &attrdp->attrd_item, XFS_LI_ATTRD, + &xfs_attrd_item_ops); + attrdp->attrd_attrip = attrip; + attrdp->attrd_format.alfd_alf_id = attrip->attri_format.alfi_id; + + xfs_trans_add_item(tp, &attrdp->attrd_item); + return attrdp; +} + +/* Get an ATTRD so we can process all the attrs. */ +static struct xfs_log_item * +xfs_attr_create_done( + struct xfs_trans *tp, + struct xfs_log_item *intent, + unsigned int count) +{ + if (!intent) + return NULL; + + return &xfs_trans_get_attrd(tp, ATTRI_ITEM(intent))->attrd_item; +} + +const struct xfs_defer_op_type xfs_attr_defer_type = { + .max_items = 1, + .create_intent = xfs_attr_create_intent, + .abort_intent = xfs_attr_abort_intent, + .create_done = xfs_attr_create_done, + .finish_item = xfs_attr_finish_item, + .cancel_item = xfs_attr_cancel_item, +}; + /* * This routine is called when an ATTRD format structure is found in a committed * transaction in the log. Its purpose is to cancel the corresponding ATTRI if @@ -420,7 +778,9 @@ static const struct xfs_item_ops xfs_attri_item_ops = { .iop_unpin = xfs_attri_item_unpin, .iop_committed = xfs_attri_item_committed, .iop_release = xfs_attri_item_release, + .iop_recover = xfs_attri_item_recover, .iop_match = xfs_attri_item_match, + .iop_relog = xfs_attri_item_relog, }; const struct xlog_recover_item_ops xlog_attri_item_ops = { From patchwork Mon Feb 28 19:51:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12763743 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 25FC0C433EF for ; Mon, 28 Feb 2022 19:52:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229811AbiB1TxM (ORCPT ); Mon, 28 Feb 2022 14:53:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42300 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229885AbiB1Twm (ORCPT ); Mon, 28 Feb 2022 14:52:42 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C3B6EECC54 for ; Mon, 28 Feb 2022 11:51:59 -0800 (PST) Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 21SIJKSa018833 for ; Mon, 28 Feb 2022 19:51:59 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2021-07-09; bh=piXmY+S1S6x5J8G42q3OPS42p4KfHP7SjH6+nGTm5Xw=; b=c8n2vFh7YzSNIAATmmQodC3Ko87aiaeqDA8D6r6bWtjFFrluYQ89w4pLJAAAfxM3Bkz4 FNAmU+kRwgI80XIkAbpQZ+RGURjdo+5yE8Ky5UPi6/Z/Z2kkL/qA3ZmNWXyE5cqBx83m o91kuHqWW0dmbIIQ0125Rgbr2NyIRkpyrv0kFpy6H6uB7r1hVyJOyt7M2h7fMq6SP6Wl YFAK2SKlkL9Yod2x68kgFBkXPSQ50izLsOUcjwu0JHPHZMosiYzCvUG5rMfrnYwlEVud OoS4lw00WSDNL/4RV4mcudGoVjS9CgBRndxrw7LkfVE4066RklekUwZu823FZvHopiTs 9Q== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by mx0b-00069f02.pphosted.com with ESMTP id 3eh15agqt0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 28 Feb 2022 19:51:59 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 21SJkltm076550 for ; Mon, 28 Feb 2022 19:51:58 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2170.outbound.protection.outlook.com [104.47.59.170]) by aserp3020.oracle.com with ESMTP id 3efc13e3fr-7 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 28 Feb 2022 19:51:58 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nnjqogAiwdStDZehueG+SyqGdvvIDISxZMkotd21YP/T5jOjcxGFxqP52IrTRG+3q4doqva2XUGa+LzdvBeP7k77X+j1IyhkeWVDgCNfetU0MAJRBQArbk4Isa62tDBmUEIaGbe+hrfaemBO+pwbuzLMEvrDxcgb2pfUwrVV3KdCohquWUgPa8HYfJSdH2G4BziOawi4Cf53mOUFV/mvWgej093T09qFbB3yGmmEM3jHsVG68apRvqP404ExmQUEK8218ci/maec5lBuabsK2sbl/H30al9Z9U7lX6zirkgiKv3iSZwgBU0h7vQVWwiPhHHrmtBbKn2IuoBVswicWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=piXmY+S1S6x5J8G42q3OPS42p4KfHP7SjH6+nGTm5Xw=; b=CaIw/bwB2E9venSg7QYpqexWuP06QldOOdX5dDvKBHxHvyGRpbQQEtXlMnqM58o5kdKpMRXNLvIq9oY2gJr/pjo46gelifoX3DF34jXYYdwdmwFgoGTVJ4NpT/w7QBK8HCd1TEVL6+yfYQVrw8FoToZFeorVhtQuEjDHdcOMOjpMUCL0NlJL8ndm+1/U1TAUiEO0HcYPjr3TWsZS+Kh6looitaFIUi+SwK2kkeXtONVS1DyP6tix+4Dnvg6AgL9MsAfeHwQupC+9lQEaRpbBUAzHEggfqdT7GepD9B9PygzpcuVjF7/pwgd5YqKRcj2aLkjMx1QSsMzrC/uWzba1wA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=piXmY+S1S6x5J8G42q3OPS42p4KfHP7SjH6+nGTm5Xw=; b=J1I787qUVvFNn5Pw9fO7gxFI8W+egkgKh59OPxljiJKjomtzSrHnISnS0bu1qI4WulI2lgA4qsLfNuZgeIqgk0odSreXJIBSx1vN+KAvMaqrO0AdC1PTrI8GD94GxrI3BoqBVndN9VFu0EORyvpNBSyl7qLXCqmgGjWOKvgngao= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by PH0PR10MB5612.namprd10.prod.outlook.com (2603:10b6:510:fa::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5017.26; Mon, 28 Feb 2022 19:51:56 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::a91b:c130:5e3f:119]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::a91b:c130:5e3f:119%7]) with mapi id 15.20.5017.027; Mon, 28 Feb 2022 19:51:56 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v28 06/15] xfs: Skip flip flags for delayed attrs Date: Mon, 28 Feb 2022 12:51:38 -0700 Message-Id: <20220228195147.1913281-7-allison.henderson@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220228195147.1913281-1-allison.henderson@oracle.com> References: <20220228195147.1913281-1-allison.henderson@oracle.com> X-ClientProxiedBy: BY5PR03CA0023.namprd03.prod.outlook.com (2603:10b6:a03:1e0::33) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4939e3c5-8ca9-4414-fa05-08d9faf3c630 X-MS-TrafficTypeDiagnostic: PH0PR10MB5612:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ieLGStJBhA6joUEf+Gixa4Iss2cCnDQVxFfzAZiNYHUTvhplqpTzLNMi50XuJCFicqJIrA3OE+sWJXX/fgl+ncRFtAiSdzzWCb27KedmbO+b926Zb1GVFrcH0Q4qnVTiN06yj4a/6gZhjT++a3uLwei3K07SWH2HLZo0yVSGIsjjcxnrtcTHJKbPsTtcTXNAm6CThq84IHJbz4UnUX2I35t4ZSCCTpx3E8jIakHmfcQun5NDCVu4Spa3E8soqhqtZZK3LER+2gAnA7yhTiDdwUZ+jkENlzBU3/rPVUS5w+aMU3qF+s0DPCRFi6o3sh+nCK4WhBMvmTw5Ui7bg3zNHjG/NeqOoFIf6kWjwy3Pg0MbEEazOgMfgMD8qjV7paf0EqslRd5Tzspv2viyR9BgPwGG6xutly9h0WxGmgrxIN2G4/yXUMfMI1Dnql5evRRnda7a89vr0XbY7762y+JHANSugI179zpmp7u0I6p13MeU3gn9XS7PECy984cPWZbYNDZOUrcr5iX/o+v1sSECuIvijA2Is0es7rjNRqmWMktdYeqkCOWmQC0uGHC7kcZJrWZPHClPQOYc3fZt3Dmy3Y1O0/R6hZDnIBAk67wCA21S4AFwM9BVdnj/kegf0VwrVA1h6EdZzI7UGzJB4ppxc5A7EIkcVBWJFRGFOQpwdTu9oc3w6llVLMCapjBG/3jCoBcsa0kwXGluscG5L+ItMQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(366004)(26005)(86362001)(186003)(8676002)(6916009)(1076003)(316002)(66946007)(66476007)(66556008)(2906002)(2616005)(6486002)(6666004)(6512007)(52116002)(8936002)(508600001)(5660300002)(38350700002)(44832011)(83380400001)(38100700002)(6506007)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 5LNg8RDvQ0G2SChhB+seuXQ9i8iJ319A4oU8VY3fdS3fxrjde4VKxcOLJ+b/ptW2J98OjF83rSyiqMEWL7+wff3eHW6sXp8q4rHQnv+JnhCUSiyg3zj+LD8tLmNH3HqLs6mtSHEZCM2ScZ2DoQlPZf1B6IEvYzhyh5YaKn471Lgzm1pcnuYkKJ6qBvswA5hkUlXI+HEN1fvIDSFPbI+AQHzxLgu1PxWs6dH+PimZsrZ62J37jap4UkMuN4b6VHjyGPYZ0ptMVOZ3uCkJeqm+CijdbpTqEGnJDOCM53WqUDfYWz9F9bRz13ZCp2qfDzZkucjQYbidGCPLs4iL4e5x4GIRSs23nhncnVj3ENdrl4UVKd8NqPnYM2onggma9aa+Su4sWFb1Gc8Tkz83wiTmZH/u6t9ggeHYo3l7rtivm5719UUsXI26N+NDM5tM742Dh+bHfIY1fXhNqhamTzKxy+P4KiWHSwF3mq3APd29buYgN2hUFVIKw++D3VnExA7bhELcDxBmDp6AeSAr0Es4o5caQ0yY4on+tDKAbZZr2VaX5UXfWZBmjkeVRYXwTgajqrFv3EQIkcbuu6/xFHO+zJw3wyU/PI56QfypldbMUyyLxk1GKQb6F171c2I3/tW0rK0bMVQMV6RZUCRHPDHBysUYMll4rRIuO9xdvCmhXz7gJqy4dyfxrfMPOU+irDbo7FUlKziK0KXsv2W0i+KIT7dKj+UvBX0VcvjVbEvwuj/Y9/v+MKlzFiUmoVOnRo3YUOR0Pu0171IgY7YnqzfKqHfqkJdUeiQURNPL48hk6trjN+Sfw/JFovJUsB6/gy9gDgGJWsRXBLnxBVy+17rNBLioIq/YBRnaqYrHyJ7aXMyqHWOsfdRoz20Gntf3HVhNvwsnNuucErpEnn+vGlvnsGHFYyGTgz+tsV/q2568wRjz2ZTN5TxC2zQKIWWM2c7LJ/7/U73TT8J8BIZPFkKStu6EO6j4nu9h9GvaKLYwFeglm9bj7DkTmhmwV6JNaDxY4l8QlRX+dHjVqfEaNEt4+D/R8xTf7r4xBXg3VTg2Z+l9gOzQltED/EJmoqYjU+dRyi9bd2LrlmmFzOKglK8z3yG1vpFoI0Yezr/RvTAXMfSsQnrk7J2C757deGe6pQ/H6NbvXsKErzJi1ZIMh1xoQhJQMW4C5c/kVQN2FR+5z7ZCj/I/pyzTRkbfejxXHHLzeCuhLJhfNKBJxAD7YQychSTc0u8COYjzzjby02Y1wf+N7nAbfB6IRoWKoD3PH9lbzBOIoszMtMcvpg14A/TlEQvKL3iLW5tARmhwBl2qg+3Fjnb3Ae36xP6+ZZbJblfhE+A22Oe5k3qdeUcP4SHQ9UnVF6U0creKJLknAF0UWdY0GeP08EijjGB8I+Wu5BJtlHL/YmhNEptXWnPRfPKdTPAt6GX42frijounxDpkRq4kFBcBA1rc4PPGUt2OVFzpbv/L6L9CeBrohZcpgE7QjAydLBxrLaMXrGQrdLufmdjUWtjTHEMZwPn+xnSOegLrzx2EnXps+ro9vCQVWke0yCJsL3GqQbCm4/oo8A0cpLk+8cKO55luz6B4n1c+bnx7q9l8OFcTLVMRGMLQdknoJMaXiTlTehd9IZ9qyN0U/c6LGwAAHYvS7b6BZIfbQIwajClYimHnQ1ViCFjK0XGKxA== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4939e3c5-8ca9-4414-fa05-08d9faf3c630 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Feb 2022 19:51:56.1387 (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: D4Wc2wFbt5xqMhTGpAqYifWXggdr5bIERK7TlB45Pn/nviRnhY363hB6rfBGbzRiANrIqlXljmAhXiOLHWfEqFVRdE15b7yJ5gKGXfDzeaE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB5612 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10272 signatures=684655 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxscore=0 phishscore=0 bulkscore=0 adultscore=0 spamscore=0 suspectscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2202280097 X-Proofpoint-ORIG-GUID: lSHSwpq0nKy0B2IAmdoot8MMSluhY5RK X-Proofpoint-GUID: lSHSwpq0nKy0B2IAmdoot8MMSluhY5RK Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org This is a clean up patch that skips the flip flag logic for delayed attr renames. Since the log replay keeps the inode locked, we do not need to worry about race windows with attr lookups. So we can skip over flipping the flag and the extra transaction roll for it Signed-off-by: Allison Henderson Reviewed-by: Darrick J. Wong Reviewed-by: Chandan Babu R --- fs/xfs/libxfs/xfs_attr.c | 54 +++++++++++++++++++++-------------- fs/xfs/libxfs/xfs_attr_leaf.c | 3 +- 2 files changed, 35 insertions(+), 22 deletions(-) diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c index 21594f814685..da257ad22f1f 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -358,6 +358,7 @@ xfs_attr_set_iter( struct xfs_inode *dp = args->dp; struct xfs_buf *bp = NULL; int forkoff, error = 0; + struct xfs_mount *mp = args->dp->i_mount; /* State machine switch */ switch (dac->dela_state) { @@ -480,16 +481,21 @@ xfs_attr_set_iter( * In a separate transaction, set the incomplete flag on the * "old" attr and clear the incomplete flag on the "new" attr. */ - error = xfs_attr3_leaf_flipflags(args); - if (error) - return error; - /* - * Commit the flag value change and start the next trans in - * series. - */ - dac->dela_state = XFS_DAS_FLIP_LFLAG; - trace_xfs_attr_set_iter_return(dac->dela_state, args->dp); - return -EAGAIN; + if (!xfs_has_larp(mp)) { + error = xfs_attr3_leaf_flipflags(args); + if (error) + return error; + /* + * Commit the flag value change and start the next trans + * in series. + */ + dac->dela_state = XFS_DAS_FLIP_LFLAG; + trace_xfs_attr_set_iter_return(dac->dela_state, + args->dp); + return -EAGAIN; + } + + fallthrough; case XFS_DAS_FLIP_LFLAG: /* * Dismantle the "old" attribute/value pair by removing a @@ -592,17 +598,21 @@ xfs_attr_set_iter( * In a separate transaction, set the incomplete flag on the * "old" attr and clear the incomplete flag on the "new" attr. */ - error = xfs_attr3_leaf_flipflags(args); - if (error) - goto out; - /* - * Commit the flag value change and start the next trans in - * series - */ - dac->dela_state = XFS_DAS_FLIP_NFLAG; - trace_xfs_attr_set_iter_return(dac->dela_state, args->dp); - return -EAGAIN; + if (!xfs_has_larp(mp)) { + error = xfs_attr3_leaf_flipflags(args); + if (error) + goto out; + /* + * Commit the flag value change and start the next trans + * in series + */ + dac->dela_state = XFS_DAS_FLIP_NFLAG; + trace_xfs_attr_set_iter_return(dac->dela_state, + args->dp); + return -EAGAIN; + } + fallthrough; case XFS_DAS_FLIP_NFLAG: /* * Dismantle the "old" attribute/value pair by removing a @@ -1270,6 +1280,7 @@ xfs_attr_node_addname_clear_incomplete( { struct xfs_da_args *args = dac->da_args; struct xfs_da_state *state = NULL; + struct xfs_mount *mp = args->dp->i_mount; int retval = 0; int error = 0; @@ -1277,7 +1288,8 @@ xfs_attr_node_addname_clear_incomplete( * Re-find the "old" attribute entry after any split ops. The INCOMPLETE * flag means that we will find the "old" attr, not the "new" one. */ - args->attr_filter |= XFS_ATTR_INCOMPLETE; + if (!xfs_has_larp(mp)) + args->attr_filter |= XFS_ATTR_INCOMPLETE; state = xfs_da_state_alloc(args); state->inleaf = 0; error = xfs_da3_node_lookup_int(state, &retval); diff --git a/fs/xfs/libxfs/xfs_attr_leaf.c b/fs/xfs/libxfs/xfs_attr_leaf.c index 014daa8c542d..74b76b09509f 100644 --- a/fs/xfs/libxfs/xfs_attr_leaf.c +++ b/fs/xfs/libxfs/xfs_attr_leaf.c @@ -1487,7 +1487,8 @@ xfs_attr3_leaf_add_work( if (tmp) entry->flags |= XFS_ATTR_LOCAL; if (args->op_flags & XFS_DA_OP_RENAME) { - entry->flags |= XFS_ATTR_INCOMPLETE; + if (!xfs_has_larp(mp)) + entry->flags |= XFS_ATTR_INCOMPLETE; if ((args->blkno2 == args->blkno) && (args->index2 <= args->index)) { args->index2++; From patchwork Mon Feb 28 19:51:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12763741 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 80A32C4332F for ; Mon, 28 Feb 2022 19:52:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229790AbiB1TxL (ORCPT ); Mon, 28 Feb 2022 14:53:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36772 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229892AbiB1Twn (ORCPT ); Mon, 28 Feb 2022 14:52:43 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F1057CA71F for ; Mon, 28 Feb 2022 11:52:01 -0800 (PST) Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 21SIJIAt010136 for ; Mon, 28 Feb 2022 19:52:00 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=NgASYlGXeCI2OjdBzTPcOoAwcBW1hYgdU7d7rd86Q+g=; b=Mg/fNVMN/A9qvgRJ5pZz9zMBSqum+Tbkq7eDkf3BYL2rdEtO97x57YxAgrEt69GnD648 1yzElGTKVACYiBkIYEMGLzgnNGx+ZEOILagmLd2YwbepnEeiBDa4pzOHR1BLuBrlluD2 Lpjg9wXgR9UgoJaQo97YEul7nLAWE92IhRNAgv8epzEGWwzlsvK5NSjkdlaPWFlXiD9C 0O6dne2t3YTMG9BrUzef2ZYcy0E84p6S0FD1D8gHvv0f65Fgp8sCNqo6gKotCNPyJOtK d4tFSgOelAtH3cUCyeNRTWw4L2PFCT7nGtDS1UVPzypwNUIJLUjVlf8WCq3fwxe+abtH Lg== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by mx0b-00069f02.pphosted.com with ESMTP id 3eh1k40pqe-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 28 Feb 2022 19:51:59 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 21SJkltn076550 for ; Mon, 28 Feb 2022 19:51:58 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2170.outbound.protection.outlook.com [104.47.59.170]) by aserp3020.oracle.com with ESMTP id 3efc13e3fr-8 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 28 Feb 2022 19:51:58 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fYb0mJJc04e19qqTFsoJX2g/0+/HxO/qtYlThpzUgxYu8+jZynjeQHbUsAot1WqgxoAIvbEjTNUYdUZBNqqHNCu9JE2hko/JgGPaaHJSmMrTPr7OFmHXcR35HrP+zYHasepjii2ZpvS+Bjvvvf9TZ+zqvPah0f4t8e+B0/Lebf2iH8/N6U0uWZHcl+Jo0Q+WYl28W7ly2p77FNju3ecOF/gyNWRuBqYxUiU/tZxIEruY4dgldOXFiqDiwlP79rKJIccFY1kxtmuO7t+SjrhpmYcn4IuIb5nkhMAtW3lI15iDsgf8JHI3SpgbyjObAVw+ohNn7De9uExl+ff6gs5v6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=NgASYlGXeCI2OjdBzTPcOoAwcBW1hYgdU7d7rd86Q+g=; b=Z3zjbLlrPgHxAXqA9Own6xHspwhe/oB9tYLK6N5oBEXGmH4glxA4dZoJ/CZOw2Sk8EznxqO5kPgQZasXRzUIXik7XVbnY67kvNswFgeLYBZY6Mgwfxv2fs8UBdH2uWJ+VHz0OukUHeEy3oxewv9UVH3Mvj6AaZnFxw/zZ/s9siufxbYp53nbFelTw5fwngcx59R55qrKZ1yfdzzXDxQCY1jRcKqDPlARoM8I8omHOda7l4/xFI/GvfAlYg3ZxAVHLMiEN4ebXfTfy3U62DsUwo5pXkbeOER0QJ7+stuDEMF+BKHWhksNg8+tkHy7EVxDb6rtKm6MrHPHYWMhXTd2NQ== 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=NgASYlGXeCI2OjdBzTPcOoAwcBW1hYgdU7d7rd86Q+g=; b=T5xSiXhyRo1m4Q4u9jQlAp+qQGkkG3uiPSffcDPRqvZC3K53SvzXp4XSn9N5wvZCVSdw+hY9Dbq08F9coTF7KFWE4PVHcc/fDD6cmrATOIHNyvA5j4w66jCDJMLSiHDpD30boHxvljSat0k3jAOV9kdzm8ZEBZhiEYnaB11gi6I= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by PH0PR10MB5612.namprd10.prod.outlook.com (2603:10b6:510:fa::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5017.26; Mon, 28 Feb 2022 19:51:56 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::a91b:c130:5e3f:119]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::a91b:c130:5e3f:119%7]) with mapi id 15.20.5017.027; Mon, 28 Feb 2022 19:51:56 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v28 07/15] xfs: Add xfs_attr_set_deferred and xfs_attr_remove_deferred Date: Mon, 28 Feb 2022 12:51:39 -0700 Message-Id: <20220228195147.1913281-8-allison.henderson@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220228195147.1913281-1-allison.henderson@oracle.com> References: <20220228195147.1913281-1-allison.henderson@oracle.com> X-ClientProxiedBy: BY5PR03CA0023.namprd03.prod.outlook.com (2603:10b6:a03:1e0::33) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8439ad23-1f5e-49c6-1ec7-08d9faf3c676 X-MS-TrafficTypeDiagnostic: PH0PR10MB5612:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: OAxfIuxgFbAeAc9o1hR2IKN9cqhVlsPjgR03/J0M5xEKKFur/o7+0xi5sknxv96t9vgoONV/8R3mCVkNMWuDWN3ld73kHNENir6cxAUamQRVhXdCVT+aofSqsks7h7mhpE/YRneOdFvF+XiWTQ5g5KL9+bncqztSaOIAq2aeEBm8Xc5rsr5cpjGkLV+Le24rbIfzaS0RUhf47ueR3947+Rzt1lp2GCuJ5uHGuOx5C7EoD2cO8/Np52rAic09E3yO9mxCyAAUh7azeeIK7MPABRBQdh/p2fWPWaiA8NydRiZwSXz66yYymSsgp8PApqLxH/FkVizD/1sd63mrKt6L0Ubvcq1XxzAwmN6CxdsbbhjohDKuFF7HbcnU4LuBFLtC5L9TSxyLwXWprULIafS9qyA5Ex7e0ojZrTVAyrJorahgvIsmDk9Krr5w0hKCnZrGZTqjmTctx6xLd8u0VXub9tEyTVZFFAUatV4TjNTybK8EJNaEdWNBiTgtJlnk+hivqaVq8kE8u0EHyLxstlifZQj5Ofbiwh0oSmDew+d7vgIC58W1CeCgCSgB246tgC5i85v5bGVzKziD4Q9QojtTMBTO3tMtxYjuF4Gi9qYAnJCIQ7eA3ixjJz0aDBLnyZVrnHuZqBdxKx/0Bn3OxZw3kfGO879q5aWUTkDyiCm0LQyAHCO4+HP8QJm1wAKyLhX3rvXOdJ3DYQNZaMi9FY0ILA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(366004)(26005)(86362001)(186003)(8676002)(6916009)(1076003)(316002)(66946007)(66476007)(66556008)(2906002)(2616005)(6486002)(6666004)(6512007)(52116002)(8936002)(508600001)(5660300002)(38350700002)(44832011)(83380400001)(38100700002)(6506007)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: XJU5tOdGgcrfjFF+8SGnoT0REtnsWTYOtH0Ddma2EACMHNltnPBg2oFwSI4HSafJUz/vUORg2gUg3wkNp95sbL6N2590xxmkh4u2wJTRmV3yt8ihnKU1qQspHSsBrEE6mbN1pdi2nQ74e7geOnvf6Aii9rC1XjeALvk0MKGTO30R032NV2PeWYynRNik6yKdZ74ROsRUpajShMChUDGuGJi055x2xsXYRR4Sn7/di96zD8d+iIcDiQfsEA5HSworGGNTDVVJxni9VEJfqPvbf9OD5x5ng0tLwBdTc+zhhJGr/gVUj+HN6NqG82C90NHmoifkOXRK1vjBAf4GiuD1nnNPzhc/ITtFODeUxon3Hx6n+dUPiXl0JMOguuFBEJyFIIYFoFF6mKvlSU15313lNrJhMCkey08hLRLhuIuI7WVIqh7ggoWClixY88+FmO/8sDNvVnmu7On9A8AGF1YN9ZJkPgjdvWAiT/lZptTDQivff9zcAZkDHkBcUz0soj5PiGzkaqs8Yx/hYsiQVBpGsuoQ5xM20jWjRmKW8WXa3eoHfFXNb3tq+QVL3vcnLap4+lujIv9F47p50XYcyalSqFcQ/EKdRU/EbyfSF3S1mkGN/hc/8MeSzvkqoHvptVlDMzhU3NnzWlCtfNVtmKsIsMmqtAUVJsMQTMMYP37H+mPwf8QxTSJE3XZPTjmMoDSiqI4NZOQto2qBXB5QQITPXwS+rHadNDO5ppOF4SxOf0Vs/muKwG6/9DPwjk0h5ZYRS+gd36nMMXy5kbib2Sb42oO1lOVYGcMHS08BXSlCOtvsfLDr0pG46atR3SoY1+iFbpsCoR3Dkzj6RKyRf0fhHC3h5PWSCQyXgTNvOjK5o4w9tyJ+QILzdCPD2kvx/qw453Dm3K25b1e+nRF6de+Aj8zsVLWVVFE1l87s7wGwnWnVYPqrRPCXWHlleYMw0eo7CF3zqfbl2VaoUSJiROJUHhXHPz4b2Tf3G88vY/nmp04NpTBOnXGPMRoCriK0Zuu1M0PvznhcZzrIgpsj1cUfFZFaG0Rc93P5Sy6o/IEltlswYPzzg/3/1XZZdY5aeIUfUOvXHnhcWasof1fcdGKYbIZJZ33TsMWirbiqoalOHYnfTB9fPnI/6PK1tvsgBThODxnJa/6RJT354fTrROfBtAOdQXt1rOxriJLo3fT6FurMvOQPp9R3LKqmgpHnLomMf6CBeKtbiySifwS7n1RrDwK26wk64L/Qbqwnd31sZwwF+vUxIzU6p1hc228js0nh9x99EXvoVp5DKvhmzuqwZVhDA0MBLXdRGa2unnQbp2iw2gyYrRRKKqlHsBFybdGR+gvKDCpUH4sORUDsorymUrYElYvyl1Sp85o2gvZMC3rUFOY5sGV8Et7QnmmPTzxYiWFyHX8Ix0jkgD6up99n71wfRcOGqXHWqJOAbRVTHl/KksollMJnWMxuNuKx+IAx6Lk4TppjzbsXLxIDE6SoqhdhttZkrwAJCxBsk3alJtUsv4NDQpSC7bTrD7mgDCUxkRAEx6Fw3Vkn6VbKeJQT1I0o2/IJ6GjZa83lawFX6VRW2T7NkLiZLVv77poBM38fvTyXtPB2EXYOu9xdk9qL3Y5t1rTaYI70Sbp2AGAc4xWfRrcD91RSpg1UCJTZxzMKD0bK29h92EgKzJyLAz5Nag== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8439ad23-1f5e-49c6-1ec7-08d9faf3c676 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Feb 2022 19:51:56.5280 (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: VKoreB6rqJXoKM5Wt0BkSLryDzaW71F00UwNt5Ly9nuefDJyT8QVXl7oPjySmRGXmQrPwpNyIW6lcNXjjYR8ppmqbdBS/PXJdnhmkf8bAd4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB5612 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10272 signatures=684655 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxscore=0 phishscore=0 bulkscore=0 adultscore=0 spamscore=0 suspectscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2202280097 X-Proofpoint-ORIG-GUID: 8_A54Dfw6_hFNBO_qbwm5tqOwLfegXWx X-Proofpoint-GUID: 8_A54Dfw6_hFNBO_qbwm5tqOwLfegXWx Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org These routines set up and queue a new deferred attribute operations. These functions are meant to be called by any routine needing to initiate a deferred attribute operation as opposed to the existing inline operations. New helper function xfs_attr_item_init also added. Finally enable delayed attributes in xfs_attr_set and xfs_attr_remove. Signed-off-by: Allison Henderson Reviewed-by: Darrick J. Wong Reviewed-by: Chandan Babu R --- fs/xfs/libxfs/xfs_attr.c | 71 ++++++++++++++++++++++++++++++++++++++-- fs/xfs/libxfs/xfs_attr.h | 2 ++ fs/xfs/xfs_log.c | 41 +++++++++++++++++++++++ fs/xfs/xfs_log.h | 1 + 4 files changed, 112 insertions(+), 3 deletions(-) diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c index da257ad22f1f..848c19b34809 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -25,6 +25,8 @@ #include "xfs_trans_space.h" #include "xfs_trace.h" #include "xfs_attr_item.h" +#include "xfs_attr.h" +#include "xfs_log.h" struct kmem_cache *xfs_attri_cache; struct kmem_cache *xfs_attrd_cache; @@ -729,6 +731,7 @@ xfs_attr_set( int error, local; int rmt_blks = 0; unsigned int total; + int delayed = xfs_has_larp(mp); if (xfs_is_shutdown(dp->i_mount)) return -EIO; @@ -785,13 +788,19 @@ xfs_attr_set( rmt_blks = xfs_attr3_rmt_blocks(mp, XFS_XATTR_SIZE_MAX); } + if (delayed) { + error = xfs_attr_use_log_assist(mp); + if (error) + return error; + } + /* * Root fork attributes can use reserved data blocks for this * operation if necessary */ error = xfs_trans_alloc_inode(dp, &tres, total, 0, rsvd, &args->trans); if (error) - return error; + goto drop_incompat; if (args->value || xfs_inode_hasattr(dp)) { error = xfs_iext_count_may_overflow(dp, XFS_ATTR_FORK, @@ -809,9 +818,10 @@ xfs_attr_set( if (error != -ENOATTR && error != -EEXIST) goto out_trans_cancel; - error = xfs_attr_set_args(args); + error = xfs_attr_set_deferred(args); if (error) goto out_trans_cancel; + /* shortform attribute has already been committed */ if (!args->trans) goto out_unlock; @@ -819,7 +829,7 @@ xfs_attr_set( if (error != -EEXIST) goto out_trans_cancel; - error = xfs_attr_remove_args(args); + error = xfs_attr_remove_deferred(args); if (error) goto out_trans_cancel; } @@ -841,6 +851,9 @@ xfs_attr_set( error = xfs_trans_commit(args->trans); out_unlock: xfs_iunlock(dp, XFS_ILOCK_EXCL); +drop_incompat: + if (delayed) + xlog_drop_incompat_feat(mp->m_log); return error; out_trans_cancel: @@ -883,6 +896,58 @@ xfs_attrd_destroy_cache(void) xfs_attrd_cache = NULL; } +STATIC int +xfs_attr_item_init( + struct xfs_da_args *args, + unsigned int op_flags, /* op flag (set or remove) */ + struct xfs_attr_item **attr) /* new xfs_attr_item */ +{ + + struct xfs_attr_item *new; + + new = kmem_zalloc(sizeof(struct xfs_attr_item), KM_NOFS); + new->xattri_op_flags = op_flags; + new->xattri_dac.da_args = args; + + *attr = new; + return 0; +} + +/* Sets an attribute for an inode as a deferred operation */ +int +xfs_attr_set_deferred( + struct xfs_da_args *args) +{ + struct xfs_attr_item *new; + int error = 0; + + error = xfs_attr_item_init(args, XFS_ATTR_OP_FLAGS_SET, &new); + if (error) + return error; + + xfs_defer_add(args->trans, XFS_DEFER_OPS_TYPE_ATTR, &new->xattri_list); + + return 0; +} + +/* Removes an attribute for an inode as a deferred operation */ +int +xfs_attr_remove_deferred( + struct xfs_da_args *args) +{ + + struct xfs_attr_item *new; + int error; + + error = xfs_attr_item_init(args, XFS_ATTR_OP_FLAGS_REMOVE, &new); + if (error) + return error; + + xfs_defer_add(args->trans, XFS_DEFER_OPS_TYPE_ATTR, &new->xattri_list); + + return 0; +} + /*======================================================================== * External routines when attribute list is inside the inode *========================================================================*/ diff --git a/fs/xfs/libxfs/xfs_attr.h b/fs/xfs/libxfs/xfs_attr.h index 80b6f28b0d1a..b52156ad8e6e 100644 --- a/fs/xfs/libxfs/xfs_attr.h +++ b/fs/xfs/libxfs/xfs_attr.h @@ -525,6 +525,8 @@ bool xfs_attr_namecheck(const void *name, size_t length); void xfs_delattr_context_init(struct xfs_delattr_context *dac, struct xfs_da_args *args); int xfs_attr_calc_size(struct xfs_da_args *args, int *local); +int xfs_attr_set_deferred(struct xfs_da_args *args); +int xfs_attr_remove_deferred(struct xfs_da_args *args); extern struct kmem_cache *xfs_attri_cache; extern struct kmem_cache *xfs_attrd_cache; diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c index 8ba8563114b9..fdfafc7df1dc 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 (xfs_sb_version_haslogxattrs(&mp->m_sb)) + return 0; + + /* Enable log-assisted xattrs. */ + error = xfs_add_incompat_log_feature(mp, + XFS_SB_FEAT_INCOMPAT_LOG_XATTRS); + if (error) + goto drop_incompat; + + xfs_warn_once(mp, +"EXPERIMENTAL logged extended attributes feature added. Use at your own risk!"); + + return 0; +drop_incompat: + xlog_drop_incompat_feat(mp->m_log); + return error; +} diff --git a/fs/xfs/xfs_log.h b/fs/xfs/xfs_log.h index fd945eb66c32..053dad8d11a9 100644 --- a/fs/xfs/xfs_log.h +++ b/fs/xfs/xfs_log.h @@ -155,5 +155,6 @@ bool xlog_force_shutdown(struct xlog *log, int shutdown_flags); void xlog_use_incompat_feat(struct xlog *log); void xlog_drop_incompat_feat(struct xlog *log); +int xfs_attr_use_log_assist(struct xfs_mount *mp); #endif /* __XFS_LOG_H__ */ From patchwork Mon Feb 28 19:51:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12763734 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 58EF1C433EF for ; Mon, 28 Feb 2022 19:52:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229678AbiB1Twt (ORCPT ); Mon, 28 Feb 2022 14:52:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44258 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229794AbiB1Twn (ORCPT ); Mon, 28 Feb 2022 14:52:43 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 01D5ECA73F for ; Mon, 28 Feb 2022 11:52:01 -0800 (PST) Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 21SIJpnH009902 for ; Mon, 28 Feb 2022 19:52:01 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=6oksdl0xSeED8x8EbDpEW73VohtH6i/Cuf108ctLttU=; b=xcS/PqFw9tRaGDEC8SruWPj0i7BOhm8lQaOJ7SrOoZQQeQ9CYv8RxSJrLSGP9JShNtZR +s529iSv5HX2HsRQw3cwdnKWtv9583yt1/PgABRDxhUjSf881UGFozObHwo8977hYGY9 3fcc0WSRSbY594/frQ574j8sShPZG+cibJoNfX2OUibvGq1/pt753lF8ISjBNPDj0Ktz Ws3Itv5jC51M5YT9f+QlwAy0IxPuXUay5JBsVaDqrr75XRDCm4cD6+DKxOHzNfuNQvS+ TMyGadJrlcrqKpn1Ryu7gQlCJmYfcTa5Wu7vYsJHV1HxwLqu2jzIFJhLfGMJ5aIdo22k QA== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by mx0b-00069f02.pphosted.com with ESMTP id 3eh14brsj0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 28 Feb 2022 19:52:00 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 21SJklto076550 for ; Mon, 28 Feb 2022 19:51:59 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2170.outbound.protection.outlook.com [104.47.59.170]) by aserp3020.oracle.com with ESMTP id 3efc13e3fr-9 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 28 Feb 2022 19:51:59 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=A3afVPP02b28zUwToON/eoJzuPy497hWxlkSxpDRpEmRWoapdP7mxG0tKcoxh9cXn+EDe0deD6SROtGTXv3SdpI0gikwyBoO+wPa5rUNzGu30XmI2jl7xXn8fO7lNmyvr67p0tTFcXPfLMjtcNKpDOOU8qOoUUQEmG2c/LK+wNhTtKNNMLe27Gi0WUf+7ofsPE7TmerT/Ah8bfu3NI+6LjmExspcT9PQNBGtvM/5zPBhCG/EoXhmppPiH/mM7vOOxj7TOhURZ1KCIPdDUmJkoPD1sO89gLA/JQDx2Yss3mKXbPgXbtpGaoc0RIePL7oE8Ic7a5iwTPH3ZoUgbkbumQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=6oksdl0xSeED8x8EbDpEW73VohtH6i/Cuf108ctLttU=; b=RgW1tQ529S/F4Qtkkjtb10ARUkwSWh2NZs6L3LYm/sGdH4L4flN+jAo2s6d4iHlHTFtcXe16ORsZEDdVJJeRxsT9DY4nPkPDjxQGyAWsLXzjVHRu5z/YHDzOCy6UDd1aTcz52im4YJQOwhX+mTCA61k/T5fXIu/fqMRKhQlMOkEhAy7duQ0N8YBE/NnOPyFTISGWMh+C6NFSwbRiIfUfbV9JqDHYoOeUYYFuH+jVQEELZkhYLErwLh7Myk//jKl71P0LXZIvUy7i1b8hV2rrwP60iLC0S7eKzdpCtFAndlARdlvqde2jvn71UhCQDs8mkhJtIXW8lC9vM3nZiPRqcQ== 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=6oksdl0xSeED8x8EbDpEW73VohtH6i/Cuf108ctLttU=; b=oIGR9RzVeArEZUSMNBc+KFg6mXfZI3Y87r5KRsDAeSoQQDIT9eLQEiESpStH4DDrzPkhBmZu1paZOLIrkPxfJQIENYUVc1R2SkxNfk8ViBzK94RYd+WzZvDRrLJsMVjNlwWAjIBjGB9rtxaDcWPAZD+oCVtO5whgYUvs9/uCBtA= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by PH0PR10MB5612.namprd10.prod.outlook.com (2603:10b6:510:fa::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5017.26; Mon, 28 Feb 2022 19:51:57 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::a91b:c130:5e3f:119]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::a91b:c130:5e3f:119%7]) with mapi id 15.20.5017.027; Mon, 28 Feb 2022 19:51:57 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v28 08/15] xfs: Remove unused xfs_attr_*_args Date: Mon, 28 Feb 2022 12:51:40 -0700 Message-Id: <20220228195147.1913281-9-allison.henderson@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220228195147.1913281-1-allison.henderson@oracle.com> References: <20220228195147.1913281-1-allison.henderson@oracle.com> X-ClientProxiedBy: BY5PR03CA0023.namprd03.prod.outlook.com (2603:10b6:a03:1e0::33) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0c763ce3-a953-4a5d-0cb0-08d9faf3c6bb X-MS-TrafficTypeDiagnostic: PH0PR10MB5612:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9kV/EvPpB4sJJN85lX6QshnYy5m2R0y6puTW+kZ6Mv5despsVMjVLfUOFaVJlRAiR0id94Ui3YqMqSx4Cb9GYde4v7bt8FSmqlTMvpH/F7F+SYqIxHHWZP8bCi0Rb+yVMITmHLeEjX+Tp8M7HkmHtI7CZ4scCbIzmLmmLFa+qKXm3d56zxEv7ApNyJPB9JwO43VfyolpJhbkHcH5PddQLwyh/JEsAhoUwp331SLlxlMuv5n/Zi+h0I/7G5SYXsBT15lNpCnGmIZXg6cCq9KheKziuuiKvrOy6O9D1wt/G3vHTuxafuPZebEzq/AXJ+IYJy4OnlIasPtWKrF7YqOuqF63qTr3HeuOLZgWcSDIv1fogyv9wBHHD2FrWVhq1b7+6602VHCa5GNSSWre/gCmdQsXzObxbe3gYK77lL29J+Pb6KX+WNYVL/18OvVWp0KrFepf7VjY0e3wF8y3Sz8T2fowL7d6vqe3FLNIF9MkPmUso9Gb6I7NABAcW0WU6Qy4XALXRjBZTKnpvK4qEY1MsuzLfshLnPHgU7UJhX+T/Hi2SQDOJJTV+uU7kdtuTevkAaKJDyok3ayiYJ2stxIavI7Tb5wEHmvDzlRLB39X80Oy6uY17LFLUloLJNtfQZxvWnkFUDqB0kp7a7LezMSbm/dc/BFyn3NVuljvEX3NbNp1OI3a4oE+gcMxk1/yMykb8fuu6J/QlDSmE7hgBfMf+A== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(366004)(26005)(86362001)(186003)(8676002)(6916009)(1076003)(316002)(66946007)(66476007)(66556008)(2906002)(2616005)(6486002)(6666004)(6512007)(52116002)(8936002)(508600001)(5660300002)(38350700002)(44832011)(83380400001)(38100700002)(6506007)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: U1KxYFM3NBsYe0WoOKgD5jkmXzRDyJuWDRidvQf7poiXfVk0YupMXwk21BSE0PhXyzD68TsP/ayVTA0tm/q2ZmD3DjUHcvdsBRgwrl6Xk+Ax7p5f6KUmbuZf+oYeEP9XPkcsfix/x1AknfsiB7g+3j0wvFQJADra7O2pj5bhSJbyJnUsllzGqUg3BGrrXc0+jjq4iIGi64ipJhWO5/nMULkNCELnSbTQKnNrLh2+Kv27PiZyY353/1OQoxl/OCZH1Yhh0yBvwV+7c98PF86Iz4W0mNjihNt0yvWYuhX0b7qkcAi7iOpCh+hIqi7ibwp2NlpZeaG0wJAUHhlgtWgGyJHOUqArPYx/JC6ErPgsy/s4b5vSXQBHe3O/mQNGaKk5mHj2MTyPbdk2PwWjq1oaQzArHpUXGVzdBEOIEf7ktZ/+ZeOXbNRntB1UlZ98CzQ8I9MFL7G3TJI4fjO+l9J9ZLlUyRVt4lj+QfmEQ1mYj5WYQD4ugFNxJIKSFSBgNpSQay80ofNjA+TwpQaVO9wh1B+hH6xgP0MznLjfMXyMDLrLEQp1ZXlsvwQXtztU4yFId7lejRTbvOhgVisLamh/satscQrD8FZK2BbjeKL5NdV2FV7g/IeRGGaLvsJ1NSdOXzNHoOeegay0/rGMa2FDKz5aAoX0e2QFoT7g3cozHHoe13JDLq8hWNxRUvK20u2zXUS5wNIFuS5qTezBUP3+S0hRf5vhbDwt8ruodLm65mElbiL1QSIWiGTfWEnA8hC51cBrZRq6MDD9OvK6rBdqcHHhan5p3OVdHLchEDZikglNfMf3Ky6patmkxnEAlrp2fsG9f17+6X7wqcFr/BZFZ6KjFPBjKvn+Z9ma6gyWPjRmdNccaoGKgxe9zJEFDFp5cfRP4LLmQQvqIJ7goydzep/8g2g6EuUIMVjbhnY/RELbHHmCpSNqOJ31cJmaQVBjcHrOr/NO1hHfH81DKTtQlNR4ZTqyMo2EchLN+WZNNT4IXzsWFKkhYaZ4U+bH3NK6rIP3UyDiE21OeNxL2TwLa1pMW6MMNIzEpaBN8NNU2w4xU+FZ0kzT9blYNa385st0Gsk4ewOH2eA9QIBvJ1WUYtTwQbL9fe4cVvtLh0AeTGcWY2VkF8VMIxvGU6GCPB0VfRxKKzZXqpAfLB0aMqfbBaK8PcRrjGnbybmeYE4fnGGdec3V6odil/aXnSGSMqNLVTvmDV3eiKia5j51441RTxDJdyRD8eH3WaKwe9xxw1bgWTxyqKHUoLLp1wBIfBwbb9XPUOFnlLw9/TazOOIk1goS4JV7QWWGFdhfS60vPDxuMycMXk2drQpgMEOUQw6ifjqHeEGr+3DXcI78VcrEd+uxQsbB6jPPpJ5/sDKv0SKvtCaopsLGz0k2wcO4LnEbO12fPZWPj3tedSOPwE2Lik5fFuOTorULg9OyhKr0rIXn4ZR8tl8bnQulpI1W+j0UBUy+6V4JghBK89+XSsQ/sN2vF+NxzH3WeSpzBflOcI8AE+675uevcsq8HLmIOt7ZTyYPbHdAXQf6J/16QNknud66oF9UojGT+yh95InyknutfDZlkYakMDhRqhoMiqV14LCi1x4HN0wUfGYik0Uln5qSUyikIfFB45ngV/gLgr2JQPGiZS9hjwSKF2inRsQn30FVzJzozHy2kcuIgYtygw== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0c763ce3-a953-4a5d-0cb0-08d9faf3c6bb X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Feb 2022 19:51:57.0279 (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: MRFkPsV2Q9eJWyZV+hR3P59NjXxAJLvANmJ+D+QFcJ3soTUZTObPjm/44Xs68FYmtciz1eLmwNhyBpf1k8vunpe/FyTBUeYeLRI3wRmDyCg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB5612 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10272 signatures=684655 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxscore=0 phishscore=0 bulkscore=0 adultscore=0 spamscore=0 suspectscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2202280097 X-Proofpoint-GUID: svDCPVw8KMBilYY5xYk3tHDfXMJ2qTbD X-Proofpoint-ORIG-GUID: svDCPVw8KMBilYY5xYk3tHDfXMJ2qTbD Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org Remove xfs_attr_set_args, xfs_attr_remove_args, and xfs_attr_trans_roll. These high level loops are now driven by the delayed operations code, and can be removed. Additionally collapse in the leaf_bp parameter of xfs_attr_set_iter since we only have one caller that passes dac->leaf_bp Signed-off-by: Allison Henderson Reviewed-by: Darrick J. Wong Reviewed-by: Chandan Babu R --- fs/xfs/libxfs/xfs_attr.c | 106 +++----------------------------- fs/xfs/libxfs/xfs_attr.h | 8 +-- fs/xfs/libxfs/xfs_attr_remote.c | 1 - fs/xfs/xfs_attr_item.c | 9 +-- 4 files changed, 14 insertions(+), 110 deletions(-) diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c index 848c19b34809..3d7531817e74 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -247,64 +247,9 @@ xfs_attr_is_shortform( ip->i_afp->if_nextents == 0); } -/* - * Checks to see if a delayed attribute transaction should be rolled. If so, - * transaction is finished or rolled as needed. - */ -STATIC int -xfs_attr_trans_roll( - struct xfs_delattr_context *dac) -{ - struct xfs_da_args *args = dac->da_args; - int error; - - if (dac->flags & XFS_DAC_DEFER_FINISH) { - /* - * The caller wants us to finish all the deferred ops so that we - * avoid pinning the log tail with a large number of deferred - * ops. - */ - dac->flags &= ~XFS_DAC_DEFER_FINISH; - error = xfs_defer_finish(&args->trans); - } else - error = xfs_trans_roll_inode(&args->trans, args->dp); - - return error; -} - -/* - * Set the attribute specified in @args. - */ -int -xfs_attr_set_args( - struct xfs_da_args *args) -{ - struct xfs_buf *leaf_bp = NULL; - int error = 0; - struct xfs_delattr_context dac = { - .da_args = args, - }; - - do { - error = xfs_attr_set_iter(&dac, &leaf_bp); - if (error != -EAGAIN) - break; - - error = xfs_attr_trans_roll(&dac); - if (error) { - if (leaf_bp) - xfs_trans_brelse(args->trans, leaf_bp); - return error; - } - } while (true); - - return error; -} - STATIC int xfs_attr_sf_addname( - struct xfs_delattr_context *dac, - struct xfs_buf **leaf_bp) + struct xfs_delattr_context *dac) { struct xfs_da_args *args = dac->da_args; struct xfs_inode *dp = args->dp; @@ -323,7 +268,7 @@ xfs_attr_sf_addname( * It won't fit in the shortform, transform to a leaf block. GROT: * another possible req'mt for a double-split btree op. */ - error = xfs_attr_shortform_to_leaf(args, leaf_bp); + error = xfs_attr_shortform_to_leaf(args, &dac->leaf_bp); if (error) return error; @@ -332,7 +277,7 @@ xfs_attr_sf_addname( * push cannot grab the half-baked leaf buffer and run into problems * with the write verifier. */ - xfs_trans_bhold(args->trans, *leaf_bp); + xfs_trans_bhold(args->trans, dac->leaf_bp); /* * We're still in XFS_DAS_UNINIT state here. We've converted @@ -340,7 +285,6 @@ xfs_attr_sf_addname( * add. */ trace_xfs_attr_sf_addname_return(XFS_DAS_UNINIT, args->dp); - dac->flags |= XFS_DAC_DEFER_FINISH; return -EAGAIN; } @@ -353,8 +297,7 @@ xfs_attr_sf_addname( */ int xfs_attr_set_iter( - struct xfs_delattr_context *dac, - struct xfs_buf **leaf_bp) + struct xfs_delattr_context *dac) { struct xfs_da_args *args = dac->da_args; struct xfs_inode *dp = args->dp; @@ -373,14 +316,14 @@ xfs_attr_set_iter( * release the hold once we return with a clean transaction. */ if (xfs_attr_is_shortform(dp)) - return xfs_attr_sf_addname(dac, leaf_bp); - if (*leaf_bp != NULL) { - xfs_trans_bhold_release(args->trans, *leaf_bp); - *leaf_bp = NULL; + return xfs_attr_sf_addname(dac); + if (dac->leaf_bp != NULL) { + xfs_trans_bhold_release(args->trans, dac->leaf_bp); + dac->leaf_bp = NULL; } if (xfs_attr_is_leaf(dp)) { - error = xfs_attr_leaf_try_add(args, *leaf_bp); + error = xfs_attr_leaf_try_add(args, dac->leaf_bp); if (error == -ENOSPC) { error = xfs_attr3_leaf_to_node(args); if (error) @@ -399,7 +342,6 @@ xfs_attr_set_iter( * be a node, so we'll fall down into the node * handling code below */ - dac->flags |= XFS_DAC_DEFER_FINISH; trace_xfs_attr_set_iter_return( dac->dela_state, args->dp); return -EAGAIN; @@ -690,32 +632,6 @@ xfs_attr_lookup( return xfs_attr_node_hasname(args, NULL); } -/* - * Remove the attribute specified in @args. - */ -int -xfs_attr_remove_args( - struct xfs_da_args *args) -{ - int error; - struct xfs_delattr_context dac = { - .da_args = args, - }; - - do { - error = xfs_attr_remove_iter(&dac); - if (error != -EAGAIN) - break; - - error = xfs_attr_trans_roll(&dac); - if (error) - return error; - - } while (true); - - return error; -} - /* * Note: If args->value is NULL the attribute will be removed, just like the * Linux ->setattr API. @@ -1309,7 +1225,6 @@ xfs_attr_node_addname( * this. dela_state is still unset by this function at * this point. */ - dac->flags |= XFS_DAC_DEFER_FINISH; trace_xfs_attr_node_addname_return( dac->dela_state, args->dp); return -EAGAIN; @@ -1324,7 +1239,6 @@ xfs_attr_node_addname( error = xfs_da3_split(state); if (error) goto out; - dac->flags |= XFS_DAC_DEFER_FINISH; } else { /* * Addition succeeded, update Btree hashvals. @@ -1578,7 +1492,6 @@ xfs_attr_remove_iter( if (error) goto out; dac->dela_state = XFS_DAS_RM_NAME; - dac->flags |= XFS_DAC_DEFER_FINISH; trace_xfs_attr_remove_iter_return(dac->dela_state, args->dp); return -EAGAIN; } @@ -1606,7 +1519,6 @@ xfs_attr_remove_iter( if (error) goto out; - dac->flags |= XFS_DAC_DEFER_FINISH; dac->dela_state = XFS_DAS_RM_SHRINK; trace_xfs_attr_remove_iter_return( dac->dela_state, args->dp); diff --git a/fs/xfs/libxfs/xfs_attr.h b/fs/xfs/libxfs/xfs_attr.h index b52156ad8e6e..5331551d5939 100644 --- a/fs/xfs/libxfs/xfs_attr.h +++ b/fs/xfs/libxfs/xfs_attr.h @@ -457,8 +457,7 @@ enum xfs_delattr_state { /* * Defines for xfs_delattr_context.flags */ -#define XFS_DAC_DEFER_FINISH 0x01 /* finish the transaction */ -#define XFS_DAC_LEAF_ADDNAME_INIT 0x02 /* xfs_attr_leaf_addname init*/ +#define XFS_DAC_LEAF_ADDNAME_INIT 0x01 /* xfs_attr_leaf_addname init*/ /* * Context used for keeping track of delayed attribute operations @@ -516,10 +515,7 @@ bool xfs_attr_is_leaf(struct xfs_inode *ip); int xfs_attr_get_ilocked(struct xfs_da_args *args); int xfs_attr_get(struct xfs_da_args *args); int xfs_attr_set(struct xfs_da_args *args); -int xfs_attr_set_args(struct xfs_da_args *args); -int xfs_attr_set_iter(struct xfs_delattr_context *dac, - struct xfs_buf **leaf_bp); -int xfs_attr_remove_args(struct xfs_da_args *args); +int xfs_attr_set_iter(struct xfs_delattr_context *dac); int xfs_attr_remove_iter(struct xfs_delattr_context *dac); bool xfs_attr_namecheck(const void *name, size_t length); void xfs_delattr_context_init(struct xfs_delattr_context *dac, diff --git a/fs/xfs/libxfs/xfs_attr_remote.c b/fs/xfs/libxfs/xfs_attr_remote.c index 83b95be9ded8..c806319134fb 100644 --- a/fs/xfs/libxfs/xfs_attr_remote.c +++ b/fs/xfs/libxfs/xfs_attr_remote.c @@ -695,7 +695,6 @@ xfs_attr_rmtval_remove( * the parent */ if (!done) { - dac->flags |= XFS_DAC_DEFER_FINISH; trace_xfs_attr_rmtval_remove_return(dac->dela_state, args->dp); return -EAGAIN; } diff --git a/fs/xfs/xfs_attr_item.c b/fs/xfs/xfs_attr_item.c index 6e4c65d82db5..468358f44a8f 100644 --- a/fs/xfs/xfs_attr_item.c +++ b/fs/xfs/xfs_attr_item.c @@ -270,7 +270,6 @@ STATIC int xfs_xattri_finish_update( struct xfs_delattr_context *dac, struct xfs_attrd_log_item *attrdp, - struct xfs_buf **leaf_bp, uint32_t op_flags) { struct xfs_da_args *args = dac->da_args; @@ -280,7 +279,7 @@ xfs_xattri_finish_update( switch (op) { case XFS_ATTR_OP_FLAGS_SET: - error = xfs_attr_set_iter(dac, leaf_bp); + error = xfs_attr_set_iter(dac); break; case XFS_ATTR_OP_FLAGS_REMOVE: ASSERT(XFS_IFORK_Q(args->dp)); @@ -390,8 +389,7 @@ xfs_attr_finish_item( */ dac->da_args->trans = tp; - error = xfs_xattri_finish_update(dac, done_item, &dac->leaf_bp, - attr->xattri_op_flags); + error = xfs_xattri_finish_update(dac, done_item, attr->xattri_op_flags); if (error != -EAGAIN) kmem_free(attr); @@ -550,8 +548,7 @@ xfs_attri_item_recover( xfs_trans_ijoin(tp, ip, 0); ret = xfs_xattri_finish_update(&attr->xattri_dac, done_item, - &attr->xattri_dac.leaf_bp, - attrp->alfi_op_flags); + attrp->alfi_op_flags); if (ret == -EAGAIN) { /* There's more work to do, so add it to this transaction */ xfs_defer_add(tp, XFS_DEFER_OPS_TYPE_ATTR, &attr->xattri_list); From patchwork Mon Feb 28 19:51:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12763742 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CF40BC433FE for ; Mon, 28 Feb 2022 19:52:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229794AbiB1TxM (ORCPT ); Mon, 28 Feb 2022 14:53:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44186 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229643AbiB1Twn (ORCPT ); Mon, 28 Feb 2022 14:52:43 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4B19BE00B for ; Mon, 28 Feb 2022 11:52:02 -0800 (PST) Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 21SIJHox010124 for ; Mon, 28 Feb 2022 19:52:02 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=O+6Y00U7BLZAyS8UvwlS2YOYLgiyr3B3vi5cG63Sy5U=; b=Opr/Kee26wdgY0MD1fmp3d04wCS26srrUOZfDexSant7W8GydR6nQP4+u2pWyteHS3Hd JVZOvDxujBocUS9giQi68vTLUjkZBVpfat5J5ewN5Dcf3xZQ8cmwtLiQDZX/HClUQ5nm r+VJeaIXO2+Dp/HWAoSiSXwfaa9pFfBVBSJ1xupkGpdnKh763dMN1DA5m7ii1Q0tF3Xm JfCsmE6RFGdIQiWiHffCPXcuDDsyy1HyP96rMHI6De55Z/w8/hOLZNi58ILSXOICcPJP CCytjiv0BH/YLIY/dimjlvrEaJPUnfakF9wePDJ/wNMeu1SWnIYOgDAdN5UJkSCf5GF+ CA== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by mx0b-00069f02.pphosted.com with ESMTP id 3eh1k40pqj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 28 Feb 2022 19:52:01 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 21SJkltp076550 for ; Mon, 28 Feb 2022 19:51:59 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2170.outbound.protection.outlook.com [104.47.59.170]) by aserp3020.oracle.com with ESMTP id 3efc13e3fr-10 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 28 Feb 2022 19:51:59 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=f+cRuaxEY82GYV3UErTu6QpNgAsd0+WcLwM3WHQqGCf0oAIPdfQcR5JQIeXhEut7LEzmkxBHNW1XvuIDLyHt/O/n4pBedVaE2QnLQZceu6HgHRtuQBF3XYQc9RfSDsfc9x5Ht2JMSaV0FKmDdCUP+pW3rXVczniDOv77H9Qyze6CLBZq15znP1JCAw71jHPbeCabdt/nGfuwGi9/XwPb0G/Mext6ARngkH5JQbXVlEvpt1IDmWqhsHXYNkufLuIZfVOsHNcPZ5EHqSuTsq3zX2tAQ6f4U/VOkoIvSRV/Sby1tN/TlZwERIyRZT3tma7hW0Tq9yiCz2E8kaVLRgh4TQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=O+6Y00U7BLZAyS8UvwlS2YOYLgiyr3B3vi5cG63Sy5U=; b=S60SIvRZT3sBI7NSoJz4H2TmkK/XlQp4fKeTmAaK8Kiwx4G3MGOI2XGiiGC+qW0cDmIvxdgDv3sGuuHhooPEKu3z2YwTbwcqp4tpns0QgQZt3g4gIH0BQftKsGJDEzodlpt3Vv2D8saQYskwkFniSSSGGCEVry09V2/iLYuoBDVmpNwCnBbB/ZtOZQZmjpDapx5HJ94tvZ6iVMNP5E3h4SVe3emLMZdZcVb+cSaru92J7cXv7Af0P4Ch/AgNCZQjvkJ1KE8m6490qcMEcVwxZKnk3tt+eExGO6PJQj04/vxNrULDqrhX4mhbTRfuKu2betNdWrHguQpYGlbcqwu3fw== 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=O+6Y00U7BLZAyS8UvwlS2YOYLgiyr3B3vi5cG63Sy5U=; b=cG3udgdN69TMAVNLY37kBITpO0iJLu5RpbSo04edknbfwcLKtKPRHNGINtE4awKM4xaWL8FleXcsAxLW3RkF2G7sdFHneMpWlduC771b/0wejESzEx7PMxzPwWZiax6lvO9JA0nKBcHHUaG6SLGG4fjkUFO5a4BCP9aOL6cd1tA= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by PH0PR10MB5612.namprd10.prod.outlook.com (2603:10b6:510:fa::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5017.26; Mon, 28 Feb 2022 19:51:57 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::a91b:c130:5e3f:119]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::a91b:c130:5e3f:119%7]) with mapi id 15.20.5017.027; Mon, 28 Feb 2022 19:51:57 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v28 09/15] xfs: Add log attribute error tag Date: Mon, 28 Feb 2022 12:51:41 -0700 Message-Id: <20220228195147.1913281-10-allison.henderson@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220228195147.1913281-1-allison.henderson@oracle.com> References: <20220228195147.1913281-1-allison.henderson@oracle.com> X-ClientProxiedBy: BY5PR03CA0023.namprd03.prod.outlook.com (2603:10b6:a03:1e0::33) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f08aba81-bcc0-4c96-6944-08d9faf3c6fb X-MS-TrafficTypeDiagnostic: PH0PR10MB5612:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: HiMPcXLUwfyNe/7eXFhwTXCN/kTWQ/7lxJuQGchoF72uQUfGJz77TX3rl/Y5eAeDDGwVMaGD/p9kon+Bs0HFEEJpQqn/gkXXdLNnQ5yYW+nJgHGYI7ZggsmGJKFuFPKcqZ/jSHcz4w1EBslA4svT6KbG+NEeRwWHZGtYoZzcs8GWMLvhwS7bTag2ZFdDAJodaClgEmwWlIYCNnYabnpo+UJ2gSwxbf8p3tf54KTEV+umhTRopoxqYsO2wFNuFVBAm+ChGWK9oUv099qS1aiNI50IA2Mgw8eS5kPX53tnVRAvy/I7mcopj+vljwrCth9kOGsdP3Uw1qPK8HxZCiB1DWKvItvCPrCiauRdM6wQPoFSJq3FUA7xqXRMrUS5woohFV/+/ZaXIZyOEfGIRogAh/Xap6pWpw39caV0YYB7pQPN4ILCSrSiex8z0kFCjb6bpeD8Vblu/TBhMZNzEwGPt664DSg4wx0VS93ny+k+lL+yQZg0Y2e+F2FZaPT4Jg+pIzasfkaff75UwvCR8IfawSZ3ZYgdZd1WKvars/WDdQiz3R0xW9xf7+ZcYDWxPLq+j5JeCO1UJ5Ef2qeT2V9ILccCPXErTH/1O4KcB2BypDdtsJbbuLBnZJznu5IEbJb/g1ovrXhCiHi4WLk0IPzA2S7hdGS/zwLliP298tf1vmhagRhpgVLaj6ugW4Pv5cCHq7gEMsZPbyqZ701bLg/Wig== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(366004)(26005)(86362001)(186003)(8676002)(6916009)(1076003)(316002)(66946007)(66476007)(66556008)(2906002)(2616005)(6486002)(6666004)(6512007)(52116002)(8936002)(508600001)(5660300002)(38350700002)(44832011)(83380400001)(38100700002)(6506007)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: XQOEDSPVajRO9FGTSeDajI/EnoafH2a+EtHVIR3saYvVYuiakrTg3xt2k3kHEdAqeMa5sm09BcYe1b3aJb7fkIAOGWqew0K/gpeZVaetiomz+z0PBLYLAGczVKK2FEhjnngswJa2dhHoy6InN+6ScuYtb+YWZpb5yQ8JZwq86hWsphd2fpf6yozyrg5Ua+JkmtxURn0O9vZfUKcVLpMQeDb75POheX1Tn8YqLaDqZvchOyPyOGnoNVUIOylrTksZYkyzyMz7BS91GWaHnFRuGa4MiW2LBoW+03l2Km0C/jqhd3bZQdyTIPf/DFh8z3KxxcYX2t2kRJCyDAUT0yJxB319jv/9GXS6IlYCweHJ0S5uu5sPo8DJtTf+PmEqSf34tlOBqsJatpAWTzIC5QXHH1qykEcwbep8U1ueN5YBpjuxoDCX5pxJYIVHvXWf8bv8UIVq5sJxvslVDRz+OFI60IaXtiHowq5NhdMgZWhiKlrBd9QPNSTJVUspHPfTqBsqCjOrb2ItSEOz/YyGQh2j8M2dRWc+NyysWC51sknhokN4dN6sVBeWvp0LDJ7ZIjTUmYjaZ62fIy1lnP3pPHou3WvWL7zrWgXlMBXZcorXgjS6soLHqE/i0dCVD/CFEnN5dXFOJ1WaE3FMkDvQd1xnY76ePwQPO1peFL+eSMqt7Ra0v1wYjaNBGlKAqERn8XMwROnBI0Wz7O1pCOPnVTawDscKUbMqUemuu7gXaFMEfmk5a/r3lG2GpJKNj4VtlABWNCRRQYmIu2PiE9sHeMZJU2Yvr8kx/vDZ5NC1Ud/0yCHP2v4FjY1YmkdFENnX86wh3WjpQT0K+aNaVHBlOgnfFH5IFmdYhgLDOGkzl/6Ibq4ztHkEoRXSRihAlNMFrKp/Q/ElYP10bduTZkkqO1urJPbO7iqNdXP8cT6tqSekYmp5Hb5+SlI+CCpB8go4t3/FFm+PBdj41dfHz3OOntEHscNVp7a391V+aCc3baw2ul+omj3f4aRaHU1ZgVqeP43yhMp5o4dfBciVHNjYNf331EproY7cF8GI3ICTPYZmPgbM/f7mJ0yawhObWOxxDCgAumXsFJc5hmr5L3OE0XCjnRYW4RhrECs1b70T/uI6gp4kIAvUvcDeQSUPQy5qTpPibWh3+osKC4qBJjpgNSpelmafMYB6kd6Q/lKbDNy28VcaCgSfHBGS7H3dfihuVIyX9ema6w47j8SWVt1meAx8M3hQ2SK2ohaCeWmWYf08qbZaEHW6hyCQB0JV0+v+RPi8OCQPRjXehZfCQDZSC8A03ul8zvNzNHeGe1XvcS7KwD2MIopgCL60rPQ5ZxkbUZ0sRer1DCJ40JPlmLlh8kj9t7OmQOzOX6vOfsox9t21Sb/SAp/Kob7/RQLkvr4/1sKMHUW3V8c/Xsh4ovAY5udWaKFHlqwdmOgnay9blKlbBrma4Xrp7ZLfBfngRocWdAGfbIdRuaBh2+RMJGApQVhFCT+0bjJlIazD4w9ufS8c7vOau9r9u/Nog+4ZiQZHhP1kSp+tRttF3VY1pHPAkCo0occXHSDAhQPftZk1zYeFsp1eDYKh7kpRQ15WKRq6aUzI45lclX7cufJhobUVLcIpHl0o7t1zANQac6mNApjtnB0YqIhLSJ6F6BQ66mH1MzjRovIYu9iM2qbnn+p3th3jHA== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: f08aba81-bcc0-4c96-6944-08d9faf3c6fb X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Feb 2022 19:51:57.3560 (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: C1HbmSUloLzfJLPMmL+P0tuWPJRCVz47r4t790Kkcb/sePvjc8HIeesp0OV0eAON+UwFAtTmUpyHbrE2XpwLzy4ou9gf6aZAoApk4QGrc1w= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB5612 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10272 signatures=684655 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxscore=0 phishscore=0 bulkscore=0 adultscore=0 spamscore=0 suspectscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2202280097 X-Proofpoint-ORIG-GUID: BxCsLhPMQqCbz5pdlaTZYXCdT6tGeoOq X-Proofpoint-GUID: BxCsLhPMQqCbz5pdlaTZYXCdT6tGeoOq 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 468358f44a8f..71567ec42dfc 100644 --- a/fs/xfs/xfs_attr_item.c +++ b/fs/xfs/xfs_attr_item.c @@ -24,6 +24,7 @@ #include "xfs_trace.h" #include "xfs_inode.h" #include "xfs_trans_space.h" +#include "xfs_errortag.h" #include "xfs_error.h" #include "xfs_log_priv.h" #include "xfs_log_recover.h" @@ -277,6 +278,11 @@ xfs_xattri_finish_update( XFS_ATTR_OP_FLAGS_TYPE_MASK; int error; + if (XFS_TEST_ERROR(false, args->dp->i_mount, XFS_ERRTAG_LARP)) { + error = -EIO; + goto out; + } + switch (op) { case XFS_ATTR_OP_FLAGS_SET: error = xfs_attr_set_iter(dac); @@ -290,6 +296,7 @@ xfs_xattri_finish_update( break; } +out: /* * Mark the transaction dirty, even on error. This ensures the * transaction is aborted, which: diff --git a/fs/xfs/xfs_error.c b/fs/xfs/xfs_error.c index 749fd18c4f32..666f4837b1e1 100644 --- a/fs/xfs/xfs_error.c +++ b/fs/xfs/xfs_error.c @@ -57,6 +57,7 @@ static unsigned int xfs_errortag_random_default[] = { XFS_RANDOM_REDUCE_MAX_IEXTENTS, XFS_RANDOM_BMAP_ALLOC_MINLEN_EXTENT, XFS_RANDOM_AG_RESV_FAIL, + XFS_RANDOM_LARP, }; struct xfs_errortag_attr { @@ -170,6 +171,7 @@ XFS_ERRORTAG_ATTR_RW(buf_ioerror, XFS_ERRTAG_BUF_IOERROR); XFS_ERRORTAG_ATTR_RW(reduce_max_iextents, XFS_ERRTAG_REDUCE_MAX_IEXTENTS); XFS_ERRORTAG_ATTR_RW(bmap_alloc_minlen_extent, XFS_ERRTAG_BMAP_ALLOC_MINLEN_EXTENT); XFS_ERRORTAG_ATTR_RW(ag_resv_fail, XFS_ERRTAG_AG_RESV_FAIL); +XFS_ERRORTAG_ATTR_RW(larp, XFS_ERRTAG_LARP); static struct attribute *xfs_errortag_attrs[] = { XFS_ERRORTAG_ATTR_LIST(noerror), @@ -211,6 +213,7 @@ static struct attribute *xfs_errortag_attrs[] = { XFS_ERRORTAG_ATTR_LIST(reduce_max_iextents), XFS_ERRORTAG_ATTR_LIST(bmap_alloc_minlen_extent), XFS_ERRORTAG_ATTR_LIST(ag_resv_fail), + XFS_ERRORTAG_ATTR_LIST(larp), NULL, }; ATTRIBUTE_GROUPS(xfs_errortag); From patchwork Mon Feb 28 19:51:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12763735 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A2466C43217 for ; Mon, 28 Feb 2022 19:52:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229770AbiB1TxH (ORCPT ); Mon, 28 Feb 2022 14:53:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44266 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229732AbiB1Twn (ORCPT ); Mon, 28 Feb 2022 14:52:43 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 022E41052A1 for ; Mon, 28 Feb 2022 11:52:01 -0800 (PST) Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 21SIJHtT010133 for ; Mon, 28 Feb 2022 19:52:01 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2021-07-09; bh=3CKt3Kwzn19dUSRfAM8d8zKP6m2jL9pOOdLbeTl0s6g=; b=swziiAgR6/RdlGZSdzXIDHijT2IA7nWmXPVttaQg+RZKP4dOcU/5csBFLwQfLPpTMtDo gQdGezDrO94dvNcby4OYcdikm5XJ9SzM/jF30VqmIcv0bHqgA6qULyLAN8b/oZ6mDFZi KvisvWSU4abFmXn369kbll/L6SLLjhYhCpGtpmh04fa4Kk5cNA9FtiYCB8u/0OhOHNe6 y/6koFO1/ggUJqpJtUnAuiKp8xBxEoaJLXPbpGfPHTb/440K3wDdnYWnZebDEY42bpR/ awDuK5MzzXcRG921MmfVVKi0nsfEY23I/DwTk4OjKYNhojjVzI7bDRwpg38G/7ZsBQjP IA== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by mx0b-00069f02.pphosted.com with ESMTP id 3eh1k40pqm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 28 Feb 2022 19:52:01 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 21SJkltq076550 for ; Mon, 28 Feb 2022 19:52:00 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2170.outbound.protection.outlook.com [104.47.59.170]) by aserp3020.oracle.com with ESMTP id 3efc13e3fr-11 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 28 Feb 2022 19:52:00 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=W2XaXW83rGTtLE/WHF4BY44YPgJM2Xn8CKdDIdeGC+twyNanHCrdLbiRXTLn6eFccq4BgFSaIl38X7k2/yEZ4pzh4co5YS/8lxSR/ZzUT7vf2zdglNOfsWJB++DFxcOaXs1IfkJUAVPjM6ybotvUI631ZWBJ2GV9Kkznty48nmRTUaTgmjfLUuCOtmuTZA1NyZjB9OOcjYWYpYkbKnrxQkijNafhs3ChXo/pqYAIxz/zADMtel67QaOANtRyzmJUjVt7AwbQcQlroJWObYiJqOsEjBDl8W9pG5p1OpKgxyjbhoJMg2L9NT5+POGswgTSuqOuZdFp18QCOjzOzSzBZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=3CKt3Kwzn19dUSRfAM8d8zKP6m2jL9pOOdLbeTl0s6g=; b=NcAuMy26CyGwM1+gl8guJVm2PI0iE9R76l3nsU1dL5LS53PnxOefmUw5dQcEkUbeoEHwfUUAZmRbo5g6k9QB3isg6rCEcES7vLocC29JEFxk3JRV3z6eijOuzX/kcqp8hBkQLqny2DvUdum5xVzg1q1EN0RqXtcXuseQKP/tPJnBIZ0WHjX4tqVEd94Pzb2BZPlTD+uITUl8V/5UFJUuv1Ph8MskOdp1MaZdZNFtujOFHtrcSgfAx4I5L7A5aTg5Rn/riHAGw7HrjDxDJUKwHbpnHiui0g6iIE721Lsx+NCj5NVjTUPSHwtD8YBk76MWmVG1GaNlOrohhP636FFIBA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=3CKt3Kwzn19dUSRfAM8d8zKP6m2jL9pOOdLbeTl0s6g=; b=Y6mblRJkzfQGTGwkCpYaIa99jvKpErpJzZ9RCIsq48P468lEoD86c31ybKNm+aDJf309qblYnj1f0tHAsWFB5YlxnTtVBFeBIA34csWC4u3tj4o8JyLZUD8dBjLrZoNcEx+9US8MJ9T3Yyf5jTszHRgyS7N+nOfcqsea5iPzXaQ= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by PH0PR10MB5612.namprd10.prod.outlook.com (2603:10b6:510:fa::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5017.26; Mon, 28 Feb 2022 19:51:58 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::a91b:c130:5e3f:119]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::a91b:c130:5e3f:119%7]) with mapi id 15.20.5017.027; Mon, 28 Feb 2022 19:51:57 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v28 10/15] xfs: Add larp debug option Date: Mon, 28 Feb 2022 12:51:42 -0700 Message-Id: <20220228195147.1913281-11-allison.henderson@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220228195147.1913281-1-allison.henderson@oracle.com> References: <20220228195147.1913281-1-allison.henderson@oracle.com> X-ClientProxiedBy: BY5PR03CA0023.namprd03.prod.outlook.com (2603:10b6:a03:1e0::33) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7bfbc535-fba3-4427-da92-08d9faf3c72f X-MS-TrafficTypeDiagnostic: PH0PR10MB5612:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: uHKOIq5pmc4xmFvLDX8Gbuf9QvvCgNcx+l3fwrtDsTN9fhcErc33O2HuZrihCK2vlazsl63IY78QOVlGogywMUJX9v/iyJCr8tJo+0cn9m03Fo5V8J5gdWjD7RyQnFumcpyEZsnFjPFtgvCoRUSoD7KrlfM8c5MoaJqwTBALoonHfFY6PVdhQ4tDFlF+coJzSjB00MJeNJWnSRtNrIisKkiz0jQoQeYuWtYMMm3JgH7spVscje6bOMt0RCrbr7aXC0pxq4jbk+Y2QvepXph616DqEMiC9LSYJ46NKYa0glwj3//SMWfGOeRFt5REn67r8GFhT3G2fROrx/kz5dJDs6DPyw77j+q+9P3O4InNHlFxWSEDfp/Zo/fN0qoY/bp5RVkigj6YB/V5b1/7fpz3FFBuC9MHxSJ60JMeIjXVdOX0R6cwFlMvJv2ytg/ZBnIkWqeD3wO4OhSnmGQFRKjBsR332hZQS4fQOFAkEtcLwv9LrVMVz61MLGwF5XA0eQr9DbFmSw9DpuWfF5vIRC/7bSEv8MfJwthQlx47WpYda72Oi2mMFd3CmUbUmyUNWrz0j3rcxgcLDmVtIC8WLvY51nAVJpbGRJqGhS0G0O1a/NY4gr7e1snzr5qPtiLIEKETjFiLVw3x/s+MpBIC8U9M2dg/z4MCZ/Z26B5Fll2jKcRtSztgFNQQhMIhv+hGratl0KO0DP4GmbhrH6s8pDUJBA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(366004)(26005)(86362001)(186003)(8676002)(6916009)(1076003)(316002)(66946007)(66476007)(66556008)(2906002)(2616005)(6486002)(6666004)(6512007)(52116002)(8936002)(508600001)(5660300002)(38350700002)(44832011)(83380400001)(38100700002)(6506007)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: hFPagX+85FlhS+LeSjOMKunhS/BXcsaJ5+gRulv0SinlLvEr7EJ+dpquiiGtHIGGm4RbjI6xP+ZHo1YDZ6KGtsEp7gzsBpSgA9TPAuHohdWgu2QMhNFyM4SZzRRIdhSlxO8GEBilxWJAAIoMuyH9OWsUmjvE8NrFFFRpARtJM0BRqNFvWB6Or+oPxLKvGA5bZnIclnEOezWeVeQQuAodBfEXrqIR2N5+qWzGvcz/XIeS+nc3VICvdRPv8wibJNUWJkN7i8Sj6yV3JA6vvFz4U8ZApZ8BBq11VC819RfwnyOgKXK8nfuK6ZRSuYq0j9iWF2M6JahHJUAA6r/94ln19eT7N2K8VkZdEFc6pZ1XcE3aEEWqVg8KI94+euAVZZxzJyt21b91Qrzyercq/MTlO8DLB5YO9LOppdN7dVOKL13hOkj53SvUa222CFmObt1M9G4GebaMBDyB5qXVqxq4A0bd5OUPB6uSA53yL7w1saAElK5JS1gngktyBtOONRe15fD+bYoN9mtPmW68CgkGzmJWOdtU1JJKCvrWF7IYw9rqErFQHYuYg/wpS9b+TeJhA47GYxQQCPW0E+9csZsuldFKc+VVjM6eb9AHtkarYWJ3ZyAOZ/jdPmfRirKO5M2EIFJO49BqYVvE8TR93Isp/3Zeg+AWOckI/Boya/XADRohX/YH0g4yQSG3m3AFk0ngqOsOu4oJDLIUkeCWKUG92QFZ8C9VdU20zy2P+ctAX29wZToWJovp5DSbUF8mEnltpqVUC3As26g1knLCkkIpKsaVM88+eVl6QRjZJnovcrlIkdpY0JcAna3okPKV8uly7VECqp/Ds5+eRQCww0/ILRMH6zYYD7M9pWEbuUTnxTRtXvHu9MYSBdg3IHifsAjOEw0d67idtrhZWIQmMbRTX5h2bew1SUCIsaJ7njU2wBqLsmM/cU6nAhpvzaB96Ju3EMBmF1lUffXtpNqrQ7LwqXcgaro69jf4oA8cux13SL0GfhsamA0mNfzIxOiPwR6pxsxO+JGnZFA3NqDed5ejUi8oImUiX5ZW02VTQrAt8J0+NzlcyxT4vbdzNx0Q6wLFTPd5BzudgRYvWkCOeIHo4Z7dZt2AqpUjmzKEyriSs2T8hz1U0WcNDid61Pj87rfCPFdr7KjKClAZf0vjHXQasRT89Ggf3MQ0lB2CV/q3cH9raRNurDzaBRicnG25uhqypn7vWsSjj2pFVF7eBI9I8Gf/4GkynkAqh0kXWpZWYQ62amwZBUQ5wm2not4WVpODWMF8OG6niPHQfKOufHZuMq+Mn+Cj+h7SzklX1CHKsC+4Cp3VutGy05x06u5StYOkgqItGJzKLEUVMdtZUk4hg5ZdM/R5K0RwCvcsuIRGrCK2Did4lO1KZBFdKrtwm0md5JWlUbxccCYttHsAGnn8apziZSHN8ST7EcgbPfDTdrZD8nSbvBp/utzlY8PygX6c1kNIYEThgDoyXg+5dMATWIV6AD3wHZTBoGoMfVfbv2obI7rKPLO5p9drFFyWwCInQZ86V9X+c/2I4NZMPCXivRCnkDrYxXyIjvHMWJXfEmUkckKmt3jwCFhIDTjQGGTVjxtV9d2FLXqCc1Qa91mHbDj3UctCmdivtjUmY3EQADuc26jfCH+AV10Gul9awQ84Ls6loQA0siHw4pqcJ0/tDw== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7bfbc535-fba3-4427-da92-08d9faf3c72f X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Feb 2022 19:51:57.6840 (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: dZGnlBaHXg3tLxLjiLZ93U0Jb++BUWtQNuOYCzXhl7FlG9ewP+0gHb6Ba9tNcts9/AQNryDJDl4HDPe+ku07iRMMxFX38ALG9Yq34fQOeaU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB5612 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10272 signatures=684655 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxscore=0 phishscore=0 bulkscore=0 adultscore=0 spamscore=0 suspectscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2202280097 X-Proofpoint-ORIG-GUID: wVv9SwjyFGkBpcbWeVC6PCzyd39mrbKj X-Proofpoint-GUID: wVv9SwjyFGkBpcbWeVC6PCzyd39mrbKj Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org This patch adds a debug option to enable log attribute replay. Eventually this can be removed when delayed attrs becomes permanent. Signed-off-by: Allison Henderson Reviewed-by: Chandan Babu R Reviewed-by: Darrick J. Wong --- fs/xfs/libxfs/xfs_attr.h | 4 ++++ fs/xfs/xfs_globals.c | 1 + fs/xfs/xfs_sysctl.h | 1 + fs/xfs/xfs_sysfs.c | 24 ++++++++++++++++++++++++ 4 files changed, 30 insertions(+) diff --git a/fs/xfs/libxfs/xfs_attr.h b/fs/xfs/libxfs/xfs_attr.h index 5331551d5939..78884e826ca4 100644 --- a/fs/xfs/libxfs/xfs_attr.h +++ b/fs/xfs/libxfs/xfs_attr.h @@ -30,7 +30,11 @@ struct xfs_attr_list_context; static inline bool xfs_has_larp(struct xfs_mount *mp) { +#ifdef DEBUG + return xfs_globals.larp; +#else return false; +#endif } /* diff --git a/fs/xfs/xfs_globals.c b/fs/xfs/xfs_globals.c index f62fa652c2fd..4d0a98f920ca 100644 --- a/fs/xfs/xfs_globals.c +++ b/fs/xfs/xfs_globals.c @@ -41,5 +41,6 @@ struct xfs_globals xfs_globals = { #endif #ifdef DEBUG .pwork_threads = -1, /* automatic thread detection */ + .larp = false, /* log attribute replay */ #endif }; diff --git a/fs/xfs/xfs_sysctl.h b/fs/xfs/xfs_sysctl.h index 7692e76ead33..f78ad6b10ea5 100644 --- a/fs/xfs/xfs_sysctl.h +++ b/fs/xfs/xfs_sysctl.h @@ -83,6 +83,7 @@ extern xfs_param_t xfs_params; struct xfs_globals { #ifdef DEBUG int pwork_threads; /* parallel workqueue threads */ + bool larp; /* log attribute replay */ #endif int log_recovery_delay; /* log recovery delay (secs) */ int mount_delay; /* mount setup delay (secs) */ diff --git a/fs/xfs/xfs_sysfs.c b/fs/xfs/xfs_sysfs.c index 574b80c29fe1..f7faf6e70d7f 100644 --- a/fs/xfs/xfs_sysfs.c +++ b/fs/xfs/xfs_sysfs.c @@ -228,6 +228,29 @@ pwork_threads_show( return sysfs_emit(buf, "%d\n", xfs_globals.pwork_threads); } XFS_SYSFS_ATTR_RW(pwork_threads); + +static ssize_t +larp_store( + struct kobject *kobject, + const char *buf, + size_t count) +{ + ssize_t ret; + + ret = kstrtobool(buf, &xfs_globals.larp); + if (ret < 0) + return ret; + return count; +} + +STATIC ssize_t +larp_show( + struct kobject *kobject, + char *buf) +{ + return snprintf(buf, PAGE_SIZE, "%d\n", xfs_globals.larp); +} +XFS_SYSFS_ATTR_RW(larp); #endif /* DEBUG */ static struct attribute *xfs_dbg_attrs[] = { @@ -237,6 +260,7 @@ static struct attribute *xfs_dbg_attrs[] = { ATTR_LIST(always_cow), #ifdef DEBUG ATTR_LIST(pwork_threads), + ATTR_LIST(larp), #endif NULL, }; From patchwork Mon Feb 28 19:51:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12763740 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5D41FC4321E for ; Mon, 28 Feb 2022 19:52:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229798AbiB1TxJ (ORCPT ); Mon, 28 Feb 2022 14:53:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45492 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229817AbiB1Twn (ORCPT ); Mon, 28 Feb 2022 14:52:43 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BD61DC7E4C for ; Mon, 28 Feb 2022 11:52:02 -0800 (PST) Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 21SIJHtU010133 for ; Mon, 28 Feb 2022 19:52:02 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=81CiBT3zURwxTjFTY8vMCZC7Ut5ifRzQ27IZt5OPKS4=; b=IK8uSiF6Ir0b8BDqQJGlFjclZJGtjbRWl01WCY9bG4DUkCT7eB1OG8WyINMd730WjADF YbLQcffFGqCocQ4gpXaLzlDgBZboH0zt6MYZ2foNhTQglEzczjMS1QfnJ4z4ifRFaRGi vGxQ5hsj6Ln451zDhOFLkSC7Qip+fJ1FDKn98YQFjN9ZLGfA/XDGbITgR3vKNePCPIFY TPCscNjH2Jh3H+7TUdRD2o/lmzXTMxTMinj6BH6uJR3ljYr+GLG6Vet0TZH+4EsmU1DD earj8H3i6lRMotldZ3VsVlvY51fksA+EzcfR/zF8byMexRL0dfmYA1kqW4LZhuSSni5q yw== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by mx0b-00069f02.pphosted.com with ESMTP id 3eh1k40pqq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 28 Feb 2022 19:52:01 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 21SJkltr076550 for ; Mon, 28 Feb 2022 19:52:00 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2170.outbound.protection.outlook.com [104.47.59.170]) by aserp3020.oracle.com with ESMTP id 3efc13e3fr-12 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 28 Feb 2022 19:52:00 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aw2yK66JUfUlY2Rm4xGNdbU0Ix5/CIEMR0H8bfRSZsc0cGoJnZ3omHfNr+fYCMHWN8ZxElzc3JXNQbjrliDmNb2szRgbgiziVHympiyqsYIiDYGRyYTu9DR7c5Z5TjfX7BA6es+7+kYiWya1+kgT+7VCVBYRflSTXBRvlC64hqPJc9IGlz5JmHDaq5Q3vB9+fJ0OYNOaLmYGhJ4YOr18/fbL4JKozbU/l6hagOaCWdtuRqeguvk1ekxAajhy2gKUakDQYMXWBlnTb+tub4uBY8Bwk0i+PdqoZMBwPpA4KzvM6EyHJ93Mgfv1MkNTyZL5O5JfZMwq3xLIHgxVTT8gqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=81CiBT3zURwxTjFTY8vMCZC7Ut5ifRzQ27IZt5OPKS4=; b=Pwu1xmUtCZtb7ARFycaVZj1G9WOVQvEWCwZf1dV5Oqh9xoDoWj0JxuCpqM2yFLAzARbEzUuMzq/U5GbPy9L1J4PXIrysEzQXWo9Pj1vj7S5P6SK33nMJOtn2g8AiZ+8z8AeH7J6zZOmOdFmLHjlDzUP4L97t2ohPqu3Vye88CNxBRFCUdHVi6NjVLsI0z41CiXhhbdAiCqH7e1s5XYmuSGJAGlexQ6WYjelph4oLbaDrlcT8HhjdLqbLkzotQspjb5nc+XDvssdWqKyN8nHYfJEmpAl9uryjy0MiGWHDmZnhdokCqC8xzNiQ2iI0UtbqKrNl8crkVSpKUbGBqyVcbw== 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=81CiBT3zURwxTjFTY8vMCZC7Ut5ifRzQ27IZt5OPKS4=; b=vm3jbzB7LyQVLJzgx2STNxU+W373nWm+mFJ5/gmjh344pc1joHLESbsV6mSC55SI5ZWlZ+cPmjEXb4PUMntUqUn9KZSWi/huevZv9mcTYdCmN81kVs3bV2GANwVt7EZc7YXfFTDQbrO62BmHhUlskGdWmiZmtPeP8B6aBwac+lA= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by PH0PR10MB5612.namprd10.prod.outlook.com (2603:10b6:510:fa::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5017.26; Mon, 28 Feb 2022 19:51:58 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::a91b:c130:5e3f:119]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::a91b:c130:5e3f:119%7]) with mapi id 15.20.5017.027; Mon, 28 Feb 2022 19:51:58 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v28 11/15] xfs: Merge xfs_delattr_context into xfs_attr_item Date: Mon, 28 Feb 2022 12:51:43 -0700 Message-Id: <20220228195147.1913281-12-allison.henderson@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220228195147.1913281-1-allison.henderson@oracle.com> References: <20220228195147.1913281-1-allison.henderson@oracle.com> X-ClientProxiedBy: BY5PR03CA0023.namprd03.prod.outlook.com (2603:10b6:a03:1e0::33) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 96de3c17-179e-452e-876a-08d9faf3c75f X-MS-TrafficTypeDiagnostic: PH0PR10MB5612:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ztPU0ENJp3c/0TB6TtxzR2nYar45zPAq/SZRkei7MV/l5mOsD5xFfYIZo20milU79vzQnj/BxkCwu3S5pqkP8rzWWogZoTYs2hLbCNYDdeH4ffWX33pE/+5LA1Lb24C1GwYT5z6LsDYwd5zBOC7h/1RiLx5sEqtIwzvYXowk0bYNTNY/rWEaLV5Eed9tdCMlY9K4Zlw7wG5NuKFnDYPKYhMChny7+WrobSOT1w5UEYQa/c59bVn6GVh+GkrNlC1j1O2m+TJM7K7z8Ooy9Ql0aOTaouzv537AfwCZ0TRiBsfWl8i66bnJ3qwDVgK8fTvalcLat4D7bVtyhECjlWtDQuPBiVhM+790EpNLpLfLplNXGPTihiyhYir2zozckT8hmnqWtlccNc91a9DxyKRQTtKViQJCbj6QUh5UE+WOFKJtTvEfbXqtSkMBa5YfvEWeAiiSqMx4eKL54D83k4/IOxBNhlTwjz6hdyR+NAEZJEfB7+CSqB8I6+gzfOmSq2bprFr8BecTp1y1x2ZB0MY+fntEWTjYZJhi3SkCNyoOeT7rhG8v6gzucqL14RO5DEgOfYRI1epOiSEGq0XxcPlRvyqeimCHiy2WJ4LWz9Szslp5rP+7qFCMuOmFoZ8n1cBy1gpAKUi7SzKHSjY9N8TIw6xOpHX9e3ZFgEjiM6sN0/Kb2KNBI1fySdsFdr5Hww10POzsKzVRwhbFtOpJfmmIOg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(366004)(26005)(86362001)(186003)(8676002)(6916009)(1076003)(316002)(66946007)(66476007)(66556008)(2906002)(2616005)(6486002)(6666004)(6512007)(52116002)(30864003)(8936002)(508600001)(5660300002)(38350700002)(44832011)(83380400001)(38100700002)(6506007)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: lliyuR1aaGaGrLI60wtuIcWJIK8e5cPKI9WsscUvfQU6v67rguWShb2VCW+pJrwQ//tlPZVV/0pwZAiveAWw4LtOCG88lWmArjpfm5iprNkfo+3ssIPUuShUXwXDBQU1bbcwPMnvy92hXWT4uo3R/xbxvpJQE1XScm2oXybgDa0X94cXjfiVvR8AbiYV7k+dSMrzzc9ecQPSsviHEdYMVLajAq0B3mi2jaD0l9Hzevx138F0SprC0aXTuW5kAQQJhOrTuULWSGcwj5dnyPjji0yrz0lQcqdUwmGMbPs1mprMoj6iN4/fxfTqkOKUHf3mwmso1OL8p9hYWUSkzNr5sEy/l/4TmNROQ4B2gE/Vpk7SUlwUMubwLX1euNC5bVku+7FwTffFgvCPc4MBcaEg8Tjg8IlGXOAWfMn4yDW/zaH1cjqbiK04sRMwYfLD1sL7gJQgFxEFEgCtLdpQRN9bD1JANOjp0m5Ah3FlNg8DLmiXp2p8AQg9eWQYO05Dzr0V/V+TwwOJkFdIdKumY1x1FSaZLpbid5Ij4Ijgxc0oKXveC027lGWgrZDoQs7mFdZ7UFN81BW8SDv+uiOxm6JWk5OZzaoWqLEKxRwcgmRpoTL+GQL7SurVM4WI+PlasLm2vJtNuXlnGyFCnsysWzNxANJiszCCvvn2C8+nzvO/5qfdr/izVj+TsKcomK15JHfUabgi9ge8J7aIcikhwHRRxxTdJmNf3h7Lc9hwpHwB0eL96/gbNeqb1ojvMCWv9W3I74gT3khCzMLFIKXs2kxmguxz4bIbPJWAD4Ch4aCUdParsnZRZGXMjHXj0Penh4TJJIx4Yayw4MOKzs1GLnHWc+IBD2H12zs6rEoUpbuJuz6PNXL49ePKmFW8nObHbiTwzXkjmIUiwkVh+kmeCVgmSZiKhmugJgzxnFOzKt7CL+MjAraV8tuJaaqlBtCKh2aZmj27W69XDdiTeYFRpR4CT/yFzkW9peyYhjSX4Y9FnhbNSF1/DSxGh4EjBwMb0T396gUF8C3bgvPihJa12R639zg9wMo6wWleH8SWQ5r9KddEmXHvSkVYR3LpIDZSeDk+0Jii8z6zgW6V0ySa9Pf0EEdcYf2P5ec9aGiaIqpTn31NHQkvyY89mu9g4GvEv5Pv8nE+Yva1gHC0p0nTr6+5A6hEFoiBJrUMuc+EQoRJ1xRla/fogkloVeJAgaoNrkNuNFk6q7G7OQYjB/9oxpKWz6wx/NqunBODQLMIrnY4vQ8LlcGBT/8jpYV7dtSh6ox+K8vKqpvlyI3qFkwq+JC4wGPDvepGJP5D3D0ZvK9E6AGN4BRndkEEDk77x9PXF+wqTVe9iUmtUq9IO9SEzlNpLrQrzNO03SjZc9KLU91PeLi9QIWybN2pI+Xwyycv/IIq7Gp+ZIHi5h6mH4g1fzGgj7bj7mEbFJ9pgFcVy2YqahK5r+bCPc9ctZxjipQlS2pDV1QV9/W1aSZSmejPevW7g/qroNku4YS5chMHa5imLpSEZU7flsWPF72Nf7epbtiW1MBX2aUK/+ILwPRtuqYP1Ggldl1WaynX6U5MBBXUrSfzG/kpnGtAR0505KHoMxKC8Kb73C6vSikPF7a8pfu46an4NrXpXhlEn07GGGhdQeAMQ7CPrPjlRN2dHoEno6V+bcSTiuco+Zn4QzoRalJE/g== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 96de3c17-179e-452e-876a-08d9faf3c75f X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Feb 2022 19:51:58.0746 (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: f9h5uxH7Rd7QzemyZnUq5kaok7AWOI2gaQaD2nd+xGsxANqVT8/eFXpCgAMrXL8u/HMxLlIipTM2IglSuBdHc6VTrukYsP0k5staf3QipRQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB5612 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10272 signatures=684655 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxscore=0 phishscore=0 bulkscore=0 adultscore=0 spamscore=0 suspectscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2202280097 X-Proofpoint-ORIG-GUID: 5vE7JGpLG4ZT-bFpZLPCdeSyRnzxmxoU X-Proofpoint-GUID: 5vE7JGpLG4ZT-bFpZLPCdeSyRnzxmxoU 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 | 42 ++++----- 5 files changed, 143 insertions(+), 143 deletions(-) diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c index 3d7531817e74..1b1aa3079469 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -59,10 +59,9 @@ STATIC int xfs_attr_leaf_try_add(struct xfs_da_args *args, struct xfs_buf *bp); */ STATIC int xfs_attr_node_get(xfs_da_args_t *args); STATIC void xfs_attr_restore_rmt_blk(struct xfs_da_args *args); -STATIC int xfs_attr_node_addname(struct xfs_delattr_context *dac); -STATIC int xfs_attr_node_addname_find_attr(struct xfs_delattr_context *dac); -STATIC int xfs_attr_node_addname_clear_incomplete( - struct xfs_delattr_context *dac); +STATIC int xfs_attr_node_addname(struct xfs_attr_item *attr); +STATIC int xfs_attr_node_addname_find_attr(struct xfs_attr_item *attr); +STATIC int xfs_attr_node_addname_clear_incomplete(struct xfs_attr_item *attr); STATIC int xfs_attr_node_hasname(xfs_da_args_t *args, struct xfs_da_state **state); STATIC int xfs_attr_fillstate(xfs_da_state_t *state); @@ -249,9 +248,9 @@ xfs_attr_is_shortform( STATIC int xfs_attr_sf_addname( - struct xfs_delattr_context *dac) + struct xfs_attr_item *attr) { - struct xfs_da_args *args = dac->da_args; + struct xfs_da_args *args = attr->xattri_da_args; struct xfs_inode *dp = args->dp; int error = 0; @@ -268,7 +267,7 @@ xfs_attr_sf_addname( * It won't fit in the shortform, transform to a leaf block. GROT: * another possible req'mt for a double-split btree op. */ - error = xfs_attr_shortform_to_leaf(args, &dac->leaf_bp); + error = xfs_attr_shortform_to_leaf(args, &attr->xattri_leaf_bp); if (error) return error; @@ -277,7 +276,7 @@ xfs_attr_sf_addname( * push cannot grab the half-baked leaf buffer and run into problems * with the write verifier. */ - xfs_trans_bhold(args->trans, dac->leaf_bp); + xfs_trans_bhold(args->trans, attr->xattri_leaf_bp); /* * We're still in XFS_DAS_UNINIT state here. We've converted @@ -297,16 +296,16 @@ xfs_attr_sf_addname( */ int xfs_attr_set_iter( - struct xfs_delattr_context *dac) + struct xfs_attr_item *attr) { - struct xfs_da_args *args = dac->da_args; + struct xfs_da_args *args = attr->xattri_da_args; struct xfs_inode *dp = args->dp; struct xfs_buf *bp = NULL; int forkoff, error = 0; struct xfs_mount *mp = args->dp->i_mount; /* State machine switch */ - switch (dac->dela_state) { + switch (attr->xattri_dela_state) { case XFS_DAS_UNINIT: /* * If the fork is shortform, attempt to add the attr. If there @@ -316,14 +315,16 @@ xfs_attr_set_iter( * release the hold once we return with a clean transaction. */ if (xfs_attr_is_shortform(dp)) - return xfs_attr_sf_addname(dac); - if (dac->leaf_bp != NULL) { - xfs_trans_bhold_release(args->trans, dac->leaf_bp); - dac->leaf_bp = NULL; + return xfs_attr_sf_addname(attr); + if (attr->xattri_leaf_bp != NULL) { + xfs_trans_bhold_release(args->trans, + attr->xattri_leaf_bp); + attr->xattri_leaf_bp = NULL; } if (xfs_attr_is_leaf(dp)) { - error = xfs_attr_leaf_try_add(args, dac->leaf_bp); + error = xfs_attr_leaf_try_add(args, + attr->xattri_leaf_bp); if (error == -ENOSPC) { error = xfs_attr3_leaf_to_node(args); if (error) @@ -343,19 +344,19 @@ xfs_attr_set_iter( * handling code below */ trace_xfs_attr_set_iter_return( - dac->dela_state, args->dp); + attr->xattri_dela_state, args->dp); return -EAGAIN; } else if (error) { return error; } - dac->dela_state = XFS_DAS_FOUND_LBLK; + attr->xattri_dela_state = XFS_DAS_FOUND_LBLK; } else { - error = xfs_attr_node_addname_find_attr(dac); + error = xfs_attr_node_addname_find_attr(attr); if (error) return error; - error = xfs_attr_node_addname(dac); + error = xfs_attr_node_addname(attr); if (error) return error; @@ -367,9 +368,10 @@ xfs_attr_set_iter( !(args->op_flags & XFS_DA_OP_RENAME)) return 0; - dac->dela_state = XFS_DAS_FOUND_NBLK; + attr->xattri_dela_state = XFS_DAS_FOUND_NBLK; } - trace_xfs_attr_set_iter_return(dac->dela_state, args->dp); + trace_xfs_attr_set_iter_return(attr->xattri_dela_state, + args->dp); return -EAGAIN; case XFS_DAS_FOUND_LBLK: /* @@ -380,10 +382,10 @@ xfs_attr_set_iter( */ /* Open coded xfs_attr_rmtval_set without trans handling */ - if ((dac->flags & XFS_DAC_LEAF_ADDNAME_INIT) == 0) { - dac->flags |= XFS_DAC_LEAF_ADDNAME_INIT; + if ((attr->xattri_flags & XFS_DAC_LEAF_ADDNAME_INIT) == 0) { + attr->xattri_flags |= XFS_DAC_LEAF_ADDNAME_INIT; if (args->rmtblkno > 0) { - error = xfs_attr_rmtval_find_space(dac); + error = xfs_attr_rmtval_find_space(attr); if (error) return error; } @@ -393,11 +395,11 @@ xfs_attr_set_iter( * Repeat allocating remote blocks for the attr value until * blkcnt drops to zero. */ - if (dac->blkcnt > 0) { - error = xfs_attr_rmtval_set_blk(dac); + if (attr->xattri_blkcnt > 0) { + error = xfs_attr_rmtval_set_blk(attr); if (error) return error; - trace_xfs_attr_set_iter_return(dac->dela_state, + trace_xfs_attr_set_iter_return(attr->xattri_dela_state, args->dp); return -EAGAIN; } @@ -433,8 +435,8 @@ xfs_attr_set_iter( * Commit the flag value change and start the next trans * in series. */ - dac->dela_state = XFS_DAS_FLIP_LFLAG; - trace_xfs_attr_set_iter_return(dac->dela_state, + attr->xattri_dela_state = XFS_DAS_FLIP_LFLAG; + trace_xfs_attr_set_iter_return(attr->xattri_dela_state, args->dp); return -EAGAIN; } @@ -453,17 +455,18 @@ xfs_attr_set_iter( fallthrough; case XFS_DAS_RM_LBLK: /* Set state in case xfs_attr_rmtval_remove returns -EAGAIN */ - dac->dela_state = XFS_DAS_RM_LBLK; + attr->xattri_dela_state = XFS_DAS_RM_LBLK; if (args->rmtblkno) { - error = xfs_attr_rmtval_remove(dac); + error = xfs_attr_rmtval_remove(attr); if (error == -EAGAIN) trace_xfs_attr_set_iter_return( - dac->dela_state, args->dp); + attr->xattri_dela_state, args->dp); if (error) return error; - dac->dela_state = XFS_DAS_RD_LEAF; - trace_xfs_attr_set_iter_return(dac->dela_state, args->dp); + attr->xattri_dela_state = XFS_DAS_RD_LEAF; + trace_xfs_attr_set_iter_return(attr->xattri_dela_state, + args->dp); return -EAGAIN; } @@ -494,7 +497,7 @@ xfs_attr_set_iter( * state. */ if (args->rmtblkno > 0) { - error = xfs_attr_rmtval_find_space(dac); + error = xfs_attr_rmtval_find_space(attr); if (error) return error; } @@ -507,14 +510,14 @@ xfs_attr_set_iter( * after we create the attribute so that we don't overflow the * maximum size of a transaction and/or hit a deadlock. */ - dac->dela_state = XFS_DAS_ALLOC_NODE; + attr->xattri_dela_state = XFS_DAS_ALLOC_NODE; if (args->rmtblkno > 0) { - if (dac->blkcnt > 0) { - error = xfs_attr_rmtval_set_blk(dac); + if (attr->xattri_blkcnt > 0) { + error = xfs_attr_rmtval_set_blk(attr); if (error) return error; trace_xfs_attr_set_iter_return( - dac->dela_state, args->dp); + attr->xattri_dela_state, args->dp); return -EAGAIN; } @@ -550,8 +553,8 @@ xfs_attr_set_iter( * Commit the flag value change and start the next trans * in series */ - dac->dela_state = XFS_DAS_FLIP_NFLAG; - trace_xfs_attr_set_iter_return(dac->dela_state, + attr->xattri_dela_state = XFS_DAS_FLIP_NFLAG; + trace_xfs_attr_set_iter_return(attr->xattri_dela_state, args->dp); return -EAGAIN; } @@ -571,18 +574,19 @@ xfs_attr_set_iter( fallthrough; case XFS_DAS_RM_NBLK: /* Set state in case xfs_attr_rmtval_remove returns -EAGAIN */ - dac->dela_state = XFS_DAS_RM_NBLK; + attr->xattri_dela_state = XFS_DAS_RM_NBLK; if (args->rmtblkno) { - error = xfs_attr_rmtval_remove(dac); + error = xfs_attr_rmtval_remove(attr); if (error == -EAGAIN) trace_xfs_attr_set_iter_return( - dac->dela_state, args->dp); + attr->xattri_dela_state, args->dp); if (error) return error; - dac->dela_state = XFS_DAS_CLR_FLAG; - trace_xfs_attr_set_iter_return(dac->dela_state, args->dp); + attr->xattri_dela_state = XFS_DAS_CLR_FLAG; + trace_xfs_attr_set_iter_return(attr->xattri_dela_state, + args->dp); return -EAGAIN; } @@ -592,7 +596,7 @@ xfs_attr_set_iter( * The last state for node format. Look up the old attr and * remove it. */ - error = xfs_attr_node_addname_clear_incomplete(dac); + error = xfs_attr_node_addname_clear_incomplete(attr); break; default: ASSERT(0); @@ -823,7 +827,7 @@ xfs_attr_item_init( new = kmem_zalloc(sizeof(struct xfs_attr_item), KM_NOFS); new->xattri_op_flags = op_flags; - new->xattri_dac.da_args = args; + new->xattri_da_args = args; *attr = new; return 0; @@ -1133,16 +1137,16 @@ xfs_attr_node_hasname( STATIC int xfs_attr_node_addname_find_attr( - struct xfs_delattr_context *dac) + struct xfs_attr_item *attr) { - struct xfs_da_args *args = dac->da_args; + struct xfs_da_args *args = attr->xattri_da_args; int retval; /* * Search to see if name already exists, and get back a pointer * to where it should go. */ - retval = xfs_attr_node_hasname(args, &dac->da_state); + retval = xfs_attr_node_hasname(args, &attr->xattri_da_state); if (retval != -ENOATTR && retval != -EEXIST) goto error; @@ -1170,8 +1174,8 @@ xfs_attr_node_addname_find_attr( return 0; error: - if (dac->da_state) - xfs_da_state_free(dac->da_state); + if (attr->xattri_da_state) + xfs_da_state_free(attr->xattri_da_state); return retval; } @@ -1192,10 +1196,10 @@ xfs_attr_node_addname_find_attr( */ STATIC int xfs_attr_node_addname( - struct xfs_delattr_context *dac) + struct xfs_attr_item *attr) { - struct xfs_da_args *args = dac->da_args; - struct xfs_da_state *state = dac->da_state; + struct xfs_da_args *args = attr->xattri_da_args; + struct xfs_da_state *state = attr->xattri_da_state; struct xfs_da_state_blk *blk; int error; @@ -1226,7 +1230,7 @@ xfs_attr_node_addname( * this point. */ trace_xfs_attr_node_addname_return( - dac->dela_state, args->dp); + attr->xattri_dela_state, args->dp); return -EAGAIN; } @@ -1255,9 +1259,9 @@ xfs_attr_node_addname( STATIC int xfs_attr_node_addname_clear_incomplete( - struct xfs_delattr_context *dac) + struct xfs_attr_item *attr) { - struct xfs_da_args *args = dac->da_args; + struct xfs_da_args *args = attr->xattri_da_args; struct xfs_da_state *state = NULL; struct xfs_mount *mp = args->dp->i_mount; int retval = 0; @@ -1361,10 +1365,10 @@ xfs_attr_leaf_mark_incomplete( */ STATIC int xfs_attr_node_removename_setup( - struct xfs_delattr_context *dac) + struct xfs_attr_item *attr) { - struct xfs_da_args *args = dac->da_args; - struct xfs_da_state **state = &dac->da_state; + struct xfs_da_args *args = attr->xattri_da_args; + struct xfs_da_state **state = &attr->xattri_da_state; int error; error = xfs_attr_node_hasname(args, state); @@ -1423,16 +1427,16 @@ xfs_attr_node_removename( */ int xfs_attr_remove_iter( - struct xfs_delattr_context *dac) + struct xfs_attr_item *attr) { - struct xfs_da_args *args = dac->da_args; - struct xfs_da_state *state = dac->da_state; + struct xfs_da_args *args = attr->xattri_da_args; + struct xfs_da_state *state = attr->xattri_da_state; int retval, error = 0; struct xfs_inode *dp = args->dp; trace_xfs_attr_node_removename(args); - switch (dac->dela_state) { + switch (attr->xattri_dela_state) { case XFS_DAS_UNINIT: if (!xfs_inode_hasattr(dp)) return -ENOATTR; @@ -1451,16 +1455,16 @@ xfs_attr_remove_iter( * Node format may require transaction rolls. Set up the * state context and fall into the state machine. */ - if (!dac->da_state) { - error = xfs_attr_node_removename_setup(dac); + if (!attr->xattri_da_state) { + error = xfs_attr_node_removename_setup(attr); if (error) return error; - state = dac->da_state; + state = attr->xattri_da_state; } fallthrough; case XFS_DAS_RMTBLK: - dac->dela_state = XFS_DAS_RMTBLK; + attr->xattri_dela_state = XFS_DAS_RMTBLK; /* * If there is an out-of-line value, de-allocate the blocks. @@ -1473,10 +1477,10 @@ xfs_attr_remove_iter( * May return -EAGAIN. Roll and repeat until all remote * blocks are removed. */ - error = xfs_attr_rmtval_remove(dac); + error = xfs_attr_rmtval_remove(attr); if (error == -EAGAIN) { trace_xfs_attr_remove_iter_return( - dac->dela_state, args->dp); + attr->xattri_dela_state, args->dp); return error; } else if (error) { goto out; @@ -1491,8 +1495,10 @@ xfs_attr_remove_iter( error = xfs_attr_refillstate(state); if (error) goto out; - dac->dela_state = XFS_DAS_RM_NAME; - trace_xfs_attr_remove_iter_return(dac->dela_state, args->dp); + + attr->xattri_dela_state = XFS_DAS_RM_NAME; + trace_xfs_attr_remove_iter_return( + attr->xattri_dela_state, args->dp); return -EAGAIN; } @@ -1502,7 +1508,7 @@ xfs_attr_remove_iter( * If we came here fresh from a transaction roll, reattach all * the buffers to the current transaction. */ - if (dac->dela_state == XFS_DAS_RM_NAME) { + if (attr->xattri_dela_state == XFS_DAS_RM_NAME) { error = xfs_attr_refillstate(state); if (error) goto out; @@ -1519,9 +1525,9 @@ xfs_attr_remove_iter( if (error) goto out; - dac->dela_state = XFS_DAS_RM_SHRINK; + attr->xattri_dela_state = XFS_DAS_RM_SHRINK; trace_xfs_attr_remove_iter_return( - dac->dela_state, args->dp); + attr->xattri_dela_state, args->dp); return -EAGAIN; } diff --git a/fs/xfs/libxfs/xfs_attr.h b/fs/xfs/libxfs/xfs_attr.h index 78884e826ca4..1ef58d34eb59 100644 --- a/fs/xfs/libxfs/xfs_attr.h +++ b/fs/xfs/libxfs/xfs_attr.h @@ -434,7 +434,7 @@ struct xfs_attr_list_context { */ /* - * Enum values for xfs_delattr_context.da_state + * Enum values for xfs_attr_item.xattri_da_state * * These values are used by delayed attribute operations to keep track of where * they were before they returned -EAGAIN. A return code of -EAGAIN signals the @@ -459,39 +459,32 @@ enum xfs_delattr_state { }; /* - * Defines for xfs_delattr_context.flags + * Defines for xfs_attr_item.xattri_flags */ #define XFS_DAC_LEAF_ADDNAME_INIT 0x01 /* xfs_attr_leaf_addname init*/ /* * Context used for keeping track of delayed attribute operations */ -struct xfs_delattr_context { - struct xfs_da_args *da_args; +struct xfs_attr_item { + struct xfs_da_args *xattri_da_args; /* * Used by xfs_attr_set to hold a leaf buffer across a transaction roll */ - struct xfs_buf *leaf_bp; + struct xfs_buf *xattri_leaf_bp; /* Used in xfs_attr_rmtval_set_blk to roll through allocating blocks */ - struct xfs_bmbt_irec map; - xfs_dablk_t lblkno; - int blkcnt; + struct xfs_bmbt_irec xattri_map; + xfs_dablk_t xattri_lblkno; + int xattri_blkcnt; /* Used in xfs_attr_node_removename to roll through removing blocks */ - struct xfs_da_state *da_state; + struct xfs_da_state *xattri_da_state; /* Used to keep track of current state of delayed operation */ - unsigned int flags; - enum xfs_delattr_state dela_state; -}; - -/* - * List of attrs to commit later. - */ -struct xfs_attr_item { - struct xfs_delattr_context xattri_dac; + unsigned int xattri_flags; + enum xfs_delattr_state xattri_dela_state; /* * Indicates if the attr operation is a set or a remove @@ -499,7 +492,10 @@ struct xfs_attr_item { */ unsigned int xattri_op_flags; - /* used to log this item to an intent */ + /* + * used to log this item to an intent containing a list of attrs to + * commit later + */ struct list_head xattri_list; }; @@ -519,11 +515,9 @@ bool xfs_attr_is_leaf(struct xfs_inode *ip); int xfs_attr_get_ilocked(struct xfs_da_args *args); int xfs_attr_get(struct xfs_da_args *args); int xfs_attr_set(struct xfs_da_args *args); -int xfs_attr_set_iter(struct xfs_delattr_context *dac); -int xfs_attr_remove_iter(struct xfs_delattr_context *dac); +int xfs_attr_set_iter(struct xfs_attr_item *attr); +int xfs_attr_remove_iter(struct xfs_attr_item *attr); bool xfs_attr_namecheck(const void *name, size_t length); -void xfs_delattr_context_init(struct xfs_delattr_context *dac, - struct xfs_da_args *args); int xfs_attr_calc_size(struct xfs_da_args *args, int *local); int xfs_attr_set_deferred(struct xfs_da_args *args); int xfs_attr_remove_deferred(struct xfs_da_args *args); diff --git a/fs/xfs/libxfs/xfs_attr_remote.c b/fs/xfs/libxfs/xfs_attr_remote.c index c806319134fb..4250159ecced 100644 --- a/fs/xfs/libxfs/xfs_attr_remote.c +++ b/fs/xfs/libxfs/xfs_attr_remote.c @@ -568,14 +568,14 @@ xfs_attr_rmtval_stale( */ int xfs_attr_rmtval_find_space( - struct xfs_delattr_context *dac) + struct xfs_attr_item *attr) { - struct xfs_da_args *args = dac->da_args; - struct xfs_bmbt_irec *map = &dac->map; + struct xfs_da_args *args = attr->xattri_da_args; + struct xfs_bmbt_irec *map = &attr->xattri_map; int error; - dac->lblkno = 0; - dac->blkcnt = 0; + attr->xattri_lblkno = 0; + attr->xattri_blkcnt = 0; args->rmtblkcnt = 0; args->rmtblkno = 0; memset(map, 0, sizeof(struct xfs_bmbt_irec)); @@ -584,8 +584,8 @@ xfs_attr_rmtval_find_space( if (error) return error; - dac->blkcnt = args->rmtblkcnt; - dac->lblkno = args->rmtblkno; + attr->xattri_blkcnt = args->rmtblkcnt; + attr->xattri_lblkno = args->rmtblkno; return 0; } @@ -598,17 +598,18 @@ xfs_attr_rmtval_find_space( */ int xfs_attr_rmtval_set_blk( - struct xfs_delattr_context *dac) + struct xfs_attr_item *attr) { - struct xfs_da_args *args = dac->da_args; + struct xfs_da_args *args = attr->xattri_da_args; struct xfs_inode *dp = args->dp; - struct xfs_bmbt_irec *map = &dac->map; + struct xfs_bmbt_irec *map = &attr->xattri_map; int nmap; int error; nmap = 1; - error = xfs_bmapi_write(args->trans, dp, (xfs_fileoff_t)dac->lblkno, - dac->blkcnt, XFS_BMAPI_ATTRFORK, args->total, + error = xfs_bmapi_write(args->trans, dp, + (xfs_fileoff_t)attr->xattri_lblkno, + attr->xattri_blkcnt, XFS_BMAPI_ATTRFORK, args->total, map, &nmap); if (error) return error; @@ -618,8 +619,8 @@ xfs_attr_rmtval_set_blk( (map->br_startblock != HOLESTARTBLOCK)); /* roll attribute extent map forwards */ - dac->lblkno += map->br_blockcount; - dac->blkcnt -= map->br_blockcount; + attr->xattri_lblkno += map->br_blockcount; + attr->xattri_blkcnt -= map->br_blockcount; return 0; } @@ -673,9 +674,9 @@ xfs_attr_rmtval_invalidate( */ int xfs_attr_rmtval_remove( - struct xfs_delattr_context *dac) + struct xfs_attr_item *attr) { - struct xfs_da_args *args = dac->da_args; + struct xfs_da_args *args = attr->xattri_da_args; int error, done; /* @@ -695,7 +696,8 @@ xfs_attr_rmtval_remove( * the parent */ if (!done) { - trace_xfs_attr_rmtval_remove_return(dac->dela_state, args->dp); + trace_xfs_attr_rmtval_remove_return(attr->xattri_dela_state, + args->dp); return -EAGAIN; } diff --git a/fs/xfs/libxfs/xfs_attr_remote.h b/fs/xfs/libxfs/xfs_attr_remote.h index d72eff30ca18..62b398edec3f 100644 --- a/fs/xfs/libxfs/xfs_attr_remote.h +++ b/fs/xfs/libxfs/xfs_attr_remote.h @@ -12,9 +12,9 @@ int xfs_attr_rmtval_get(struct xfs_da_args *args); int xfs_attr_rmtval_stale(struct xfs_inode *ip, struct xfs_bmbt_irec *map, xfs_buf_flags_t incore_flags); int xfs_attr_rmtval_invalidate(struct xfs_da_args *args); -int xfs_attr_rmtval_remove(struct xfs_delattr_context *dac); +int xfs_attr_rmtval_remove(struct xfs_attr_item *attr); int xfs_attr_rmt_find_hole(struct xfs_da_args *args); int xfs_attr_rmtval_set_value(struct xfs_da_args *args); -int xfs_attr_rmtval_set_blk(struct xfs_delattr_context *dac); -int xfs_attr_rmtval_find_space(struct xfs_delattr_context *dac); +int xfs_attr_rmtval_set_blk(struct xfs_attr_item *attr); +int xfs_attr_rmtval_find_space(struct xfs_attr_item *attr); #endif /* __XFS_ATTR_REMOTE_H__ */ diff --git a/fs/xfs/xfs_attr_item.c b/fs/xfs/xfs_attr_item.c index 71567ec42dfc..878f50babb23 100644 --- a/fs/xfs/xfs_attr_item.c +++ b/fs/xfs/xfs_attr_item.c @@ -269,11 +269,11 @@ xfs_attrd_item_release( */ STATIC int xfs_xattri_finish_update( - struct xfs_delattr_context *dac, + struct xfs_attr_item *attr, struct xfs_attrd_log_item *attrdp, uint32_t op_flags) { - struct xfs_da_args *args = dac->da_args; + struct xfs_da_args *args = attr->xattri_da_args; unsigned int op = op_flags & XFS_ATTR_OP_FLAGS_TYPE_MASK; int error; @@ -285,11 +285,11 @@ xfs_xattri_finish_update( switch (op) { case XFS_ATTR_OP_FLAGS_SET: - error = xfs_attr_set_iter(dac); + error = xfs_attr_set_iter(attr); break; case XFS_ATTR_OP_FLAGS_REMOVE: ASSERT(XFS_IFORK_Q(args->dp)); - error = xfs_attr_remove_iter(dac); + error = xfs_attr_remove_iter(attr); break; default: error = -EFSCORRUPTED; @@ -333,16 +333,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. */ @@ -383,10 +383,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); @@ -394,9 +392,10 @@ xfs_attr_finish_item( * Always reset trans after EAGAIN cycle * since the transaction is new */ - dac->da_args->trans = tp; + attr->xattri_da_args->trans = tp; - error = xfs_xattri_finish_update(dac, done_item, attr->xattri_op_flags); + error = xfs_xattri_finish_update(attr, done_item, + attr->xattri_op_flags); if (error != -EAGAIN) kmem_free(attr); @@ -518,7 +517,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; @@ -554,8 +553,7 @@ xfs_attri_item_recover( xfs_ilock(ip, XFS_ILOCK_EXCL); xfs_trans_ijoin(tp, ip, 0); - ret = xfs_xattri_finish_update(&attr->xattri_dac, done_item, - attrp->alfi_op_flags); + ret = xfs_xattri_finish_update(attr, done_item, attrp->alfi_op_flags); if (ret == -EAGAIN) { /* There's more work to do, so add it to this transaction */ xfs_defer_add(tp, XFS_DEFER_OPS_TYPE_ATTR, &attr->xattri_list); @@ -570,8 +568,8 @@ xfs_attri_item_recover( error = xfs_defer_ops_capture_and_commit(tp, capture_list); out_unlock: - if (attr->xattri_dac.leaf_bp) - xfs_buf_relse(attr->xattri_dac.leaf_bp); + if (attr->xattri_leaf_bp) + xfs_buf_relse(attr->xattri_leaf_bp); xfs_iunlock(ip, XFS_ILOCK_EXCL); xfs_irele(ip); From patchwork Mon Feb 28 19:51:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12763738 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6C90BC433FE for ; Mon, 28 Feb 2022 19:52:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229732AbiB1TxI (ORCPT ); Mon, 28 Feb 2022 14:53:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44652 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229798AbiB1Twn (ORCPT ); Mon, 28 Feb 2022 14:52:43 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6BC07CA335 for ; Mon, 28 Feb 2022 11:52:03 -0800 (PST) Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 21SIJHV9010129 for ; Mon, 28 Feb 2022 19:52:03 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=yluYH/y/nDVVHizcZZ9R5ja+IfwuIadclopKpGEkWOg=; b=fAqG9KD5+AW0YeNbLHJ3imoO7U7iqi9dFOscqLbWU/J58Wk1hhhpkcLVrXeF2IvZThkd bvsd4RVo8qj8IbwSA6s6ktXf4N82gJgbjdVFiDRte97S+7dfeJxIQ9zE5YEQW+Z3ufKN VqMtLKhkz1qKGxHkRv9zlfJiIjI8EIfXh1+FFLwo83sgGXVtXpjjz21U/OYL4l2z1w2c ohoNLov7DqdqmPo+5+pmwhLfT3q0+pQDp0vJWkWT7fZl4hHSrmLkENK6hGcOv+M5jB72 dlty0AfajWHKdKAJLYPbeI7AgACEpSA932PIRHETkxVdEY9F6zkITAz4ddCKx+HzSGFf AQ== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by mx0b-00069f02.pphosted.com with ESMTP id 3eh1k40pqs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 28 Feb 2022 19:52:02 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 21SJjsZ5061244 for ; Mon, 28 Feb 2022 19:52:01 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2109.outbound.protection.outlook.com [104.47.58.109]) by userp3030.oracle.com with ESMTP id 3ef9aw0y4u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 28 Feb 2022 19:52:01 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ks/H7xii0mvxqImeAfqUR8Ynx242ZW6dP7qLGw1K8tt5DRFgiN5hoz4dkQIM/l75zpLOscyxx9zkHkRnbGRoWlLYawT3zVW4TR/B6f4295kH9o3L5UDeDEP5JPWGjab7nNK9cAQQZG5OIt9mtjyiQQl1/RBSexp+n191ZQdUZs55sg/Dw0dm6FGZeg4X4HOaiazY82iOpYUGW5vl9hxqZF+VmuJ/AAT1qBMSoILGmKz+Er9GRTl/YN/MZGyaR/9FsWnixiHDoEyaRrIHA5gMNytfLalrkzP/BbgDOqEdq0zy16HseiOZ3tpe73Kz5x0TNvftHTeYCK0nb0VrmKUP4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=yluYH/y/nDVVHizcZZ9R5ja+IfwuIadclopKpGEkWOg=; b=FMSIb+7+aFfw3JtseX7Ax7wCZEvP6ICjbHq2AbXkEoPUmJWM1PPfSkfp4B83evSaRW2Ck/In/6Sjc9t96QrEWlgCvZ5lDVuDvkBADJATH57yzfRmbWpg+NCbDkvcGdbXYNB3zgevZlQbi8W2AFbxzIxD9Vsworjfa+Yd3ym6R/jN7qpxJP3o/0Kzg43m0FH+ejtShMMN5Kp/w/tDJOLO36TZ4afw92rXmWigdNZM1xDod/JkN8ogcydwC0PBXFuJI0xwhZLq9KFXAwYjKVr0QXyu79Y8+DYB9StNOpA+r0dxbPjD7XeRbh0c5fnvu5AQPDesQXeusFw9Wc1Oxcgx/w== 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=yluYH/y/nDVVHizcZZ9R5ja+IfwuIadclopKpGEkWOg=; b=WdwBslDzyR56/E36VnsIa8yAcr4Qj6yKhgCL6TX8Z48cI4YPl0GpKrFIaNuT+7iDhWr6uMPvKbbuYS7tC9CADPsaeygqV9ZEpYXZpWvwNGy9gaDk00e4Dq6OQoIRwkj49GJrO6UXvm0rBR1Ff8Blq7a8sAhSEJCcFSQ/FvhbvmU= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by BN6PR10MB1732.namprd10.prod.outlook.com (2603:10b6:405:9::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5017.21; Mon, 28 Feb 2022 19:51:58 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::a91b:c130:5e3f:119]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::a91b:c130:5e3f:119%7]) with mapi id 15.20.5017.027; Mon, 28 Feb 2022 19:51:58 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v28 12/15] xfs: Add helper function xfs_attr_leaf_addname Date: Mon, 28 Feb 2022 12:51:44 -0700 Message-Id: <20220228195147.1913281-13-allison.henderson@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220228195147.1913281-1-allison.henderson@oracle.com> References: <20220228195147.1913281-1-allison.henderson@oracle.com> X-ClientProxiedBy: BY5PR03CA0023.namprd03.prod.outlook.com (2603:10b6:a03:1e0::33) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 666c707f-5821-4a6a-1f7c-08d9faf3c79b X-MS-TrafficTypeDiagnostic: BN6PR10MB1732:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: BVmDfuJYYWcWLxpssJ/fSlDpwLBQ7t2CIjzt/45s8r1ZEwoZtuYhxYZ9loUO6G/y8w4cjxNAD4F3fLnLh3S3cMIdNiWSg16vuKgQjCb1xJVTXeuhjmo/TA4MM44SyThXjKXcnjfcXj6L+oU8pI0wS8AvBrIuZ3J3QOB+RIzTB4w5bjoQ6MohLNXOymegq/4prniVv7nuRFTJw3lxqeFxK//bmtQNAcsHmQVi1rrXTBcXVwH5CUqT3P1n8QzuloYj+Z4K0eCEkViBqMt4GN3gIbfjhpWCuPI09H9sr9BNqEm7lg/fZHIfKmnleUuH/h/J+jWNG+1ptjmDxPXDdsypRlLMt+QpaFyLS8pjTfTZhsvwUtfmUIB+i8c0XJXwl64tAQJwDshO/LnZMpDSQPK3FOfUdCoqt0zmUqTvdG0N3feVBgZa9+quJHFHvtc590vy9NYHGgYozqOiJAl2+HbvLy6TDVz1dvnERJeGlGe0YC0ezBo53NsqGmpbgmTYka3CaHH7/9EijrczTMVUzRP8hhho7xZ1eExs07wvx5QZHrgVSIxopifkQgYIR05OxpZ2zRP0gdxSENlnM4dh/vITYIBQaAIJIifYPz7O5IAiosm2jtXKjFLNEyPJqhtCobHseGTVWZHWg6LA0g1GVojBk/L42/ph9ptdzbJgUQdKt6Iw91KlCpDw9NBDcY/8sZbHipOfn6YkR0d4WHZYaaHCpg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(366004)(36756003)(6486002)(86362001)(6666004)(1076003)(52116002)(2616005)(6506007)(508600001)(26005)(186003)(83380400001)(6916009)(66556008)(66476007)(8676002)(66946007)(38100700002)(38350700002)(5660300002)(44832011)(8936002)(6512007)(316002)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 9q18ThPQ8zn+lwHyRpy8nY4f9y2hDi0DwlCBViqXWffQkh/CMWpK1vtB7b2ldGiU/nLrw68q1B1cLpD8PZC4ngFC/c4ccSa5QI21Vf6nfOLDrPy6Wmob63Rqrnwv6IQ76o6q/+UucdZmNHSjY9i+z/XE7lXemCs0X9iBFfst12w+k0Z+3esC+mnOt5FYbQ52kHePCaXkzQ3aWJrM4WwKwcZSuoTupub6+Q8TZZ5LeQ6yEgwZ3erA7AH/crma7CvYjP17Owgq2kaAQhaYgdWTS3ueXVryJRR9FwcvJlbiwSmeky9Vmfc6YSClYj/iBYWiSFiNRiqOHPYoHq2E9XxNdTNpDQ+1jqNTfC7uKVBKoC4f7Y0Bvld5P/51Efb0fQRrH5nW7gQV0kqtGFUay77RtE2gmj6+ev1DxeoJMCcfiPhnuxAZF2WjuFHCiKQarsWPdl/RTDiSV9z4zISz+sjNV3aMIIXpGlspwHqJWkl9wEjvQfYtNw5+RZieytFcWPa0baaOtBcKYsbAqsTFDVnTiBD17CoVVRxaWa1Dn5sCrtsltRJvGtRs6VxNMdloLHwNQM8pAqZbwAzGMMu0NLAuRfI9YOOYNHo1u3ZaVGxWEPlC0ISZS/+9ad5KEVhzBVmNZ4DJEmwJlV8wbwaStLg1348HmvVdr8ODUoOomfXdcGbwt9asWWaceZYyn+exf4Dk4lXX3RPHowDmpOs8y/P0xSmz3fl5GfHSh02E6ncBq/d9M5JmvzwNReKeB2ELqvKEtMbR33wUZe/NNKfD1Ax9aglnnxAtZom9iyESQs2c+LYl17mSURJqX9yqRFhqyJTuKhi/TZajmCkzx+ZniL7Ca7e/3Bq51mduh8nNep4fuNvltpa1vHug7LfrxtkA0lhNU5pdu0VGXAv6Sfbar/jw3RpUSmRQurst3V9Y8j1iw43OCeZvYV/619cCUcc5msWvZgirX+9m8UG/44lojT59Vby/wt52WnPTiLjGoXdeeaE9ZSR3wXrcG/4pTsVLhwp1iEyIgf1zdufI/ETDRSw+F6vGDpKE7O6VuDXBjuwKrCSXPc0gZEu8lNUx7pD5zDEwfG49cqGEhytYpSlhubhw10PNdZ5LWlaLG6/t+PMYSyn9BJRhvyLnuJ5Maqmnh0+TfTYEfkNOjzstTTTxukU2W+URUek43hVbe/43AmWVzpZoEuKysBQ+9XHe4alMvSglC/uexnFk8MRQirOzJwwNcT7bz3TqecYoL2LHbRb26n0/9WGhtF7jGZgkeXJto45XXD8WMmeovSKT7DTOGMAa7oPqICt8/b2ME+Fc2vrwpPCjm5ehY2CHhYC076WNc+ZfV6oxHZ9K7pBdhZcI07j5OXmTJWCkXxXzt9nN7RBe9/smfkz2hRKtZdpm7eLe0XlZyX/bAujU4gs1kJe8meHvPg0X4dU75OXkM74alOfqC/cbCfwVnyGd0C/dg3U3uj2nAqoxIQwfPeMrZrq5vKThMoKcCwuIqdm0/kpnDol4pg1hxQuVGkcd5KJ2AtyloiMJVISOEL/EiR80bCT6Q+vq3j7ypFlcs0q+YcRh0wtppA9r3h6T3/hi3/9PplmiJVSnUrPKKLcpUih/cxnbNYWaqa6hhUASrMENJmcPT85yANddJjfbqCnJSUBpyUFboAS8K2/WJ8R/Qf4IRJ4Q+fR6FA== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 666c707f-5821-4a6a-1f7c-08d9faf3c79b X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Feb 2022 19:51:58.3870 (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: Rt8OEP9zwluT9MXd+lOzZwK6CJw6rflJgZnsvtVuMTCMAsE9uvfkAwUbHh3ruaguqwlgUdRKrsDmZrsQJJ50OR88pLFeRIdYq4JryCL0RKA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR10MB1732 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10272 signatures=684655 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 bulkscore=0 malwarescore=0 mlxscore=0 phishscore=0 suspectscore=0 adultscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2202280097 X-Proofpoint-ORIG-GUID: gEsRGws4srB9oZEBtUQ6x8Sp4kc3b9VZ X-Proofpoint-GUID: gEsRGws4srB9oZEBtUQ6x8Sp4kc3b9VZ Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org This patch adds a helper function xfs_attr_leaf_addname. While this does help to break down xfs_attr_set_iter, it does also hoist out some of the state management. This patch has been moved to the end of the clean up series for further discussion. Suggested-by: Darrick J. Wong Signed-off-by: Allison Henderson Reviewed-by: Darrick J. Wong Reviewed-by: Chandan Babu R --- fs/xfs/libxfs/xfs_attr.c | 110 +++++++++++++++++++++------------------ fs/xfs/xfs_trace.h | 1 + 2 files changed, 61 insertions(+), 50 deletions(-) diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c index 1b1aa3079469..7d6ad1d0e10b 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -287,6 +287,65 @@ xfs_attr_sf_addname( return -EAGAIN; } +STATIC int +xfs_attr_leaf_addname( + struct xfs_attr_item *attr) +{ + struct xfs_da_args *args = attr->xattri_da_args; + struct xfs_inode *dp = args->dp; + int error; + + if (xfs_attr_is_leaf(dp)) { + error = xfs_attr_leaf_try_add(args, attr->xattri_leaf_bp); + if (error == -ENOSPC) { + error = xfs_attr3_leaf_to_node(args); + if (error) + return error; + + /* + * Finish any deferred work items and roll the + * transaction once more. The goal here is to call + * node_addname with the inode and transaction in the + * same state (inode locked and joined, transaction + * clean) no matter how we got to this step. + * + * At this point, we are still in XFS_DAS_UNINIT, but + * when we come back, we'll be a node, so we'll fall + * down into the node handling code below + */ + trace_xfs_attr_set_iter_return( + attr->xattri_dela_state, args->dp); + return -EAGAIN; + } + + if (error) + return error; + + attr->xattri_dela_state = XFS_DAS_FOUND_LBLK; + } else { + error = xfs_attr_node_addname_find_attr(attr); + if (error) + return error; + + error = xfs_attr_node_addname(attr); + if (error) + return error; + + /* + * If addname was successful, and we dont need to alloc or + * remove anymore blks, we're done. + */ + if (!args->rmtblkno && + !(args->op_flags & XFS_DA_OP_RENAME)) + return 0; + + attr->xattri_dela_state = XFS_DAS_FOUND_NBLK; + } + + trace_xfs_attr_leaf_addname_return(attr->xattri_dela_state, args->dp); + return -EAGAIN; +} + /* * Set the attribute specified in @args. * This routine is meant to function as a delayed operation, and may return @@ -322,57 +381,8 @@ xfs_attr_set_iter( attr->xattri_leaf_bp = NULL; } - if (xfs_attr_is_leaf(dp)) { - error = xfs_attr_leaf_try_add(args, - attr->xattri_leaf_bp); - if (error == -ENOSPC) { - error = xfs_attr3_leaf_to_node(args); - if (error) - return error; - - /* - * Finish any deferred work items and roll the - * transaction once more. The goal here is to - * call node_addname with the inode and - * transaction in the same state (inode locked - * and joined, transaction clean) no matter how - * we got to this step. - * - * At this point, we are still in - * XFS_DAS_UNINIT, but when we come back, we'll - * be a node, so we'll fall down into the node - * handling code below - */ - trace_xfs_attr_set_iter_return( - attr->xattri_dela_state, args->dp); - return -EAGAIN; - } else if (error) { - return error; - } - - attr->xattri_dela_state = XFS_DAS_FOUND_LBLK; - } else { - error = xfs_attr_node_addname_find_attr(attr); - if (error) - return error; + return xfs_attr_leaf_addname(attr); - error = xfs_attr_node_addname(attr); - if (error) - return error; - - /* - * If addname was successful, and we dont need to alloc - * or remove anymore blks, we're done. - */ - if (!args->rmtblkno && - !(args->op_flags & XFS_DA_OP_RENAME)) - return 0; - - attr->xattri_dela_state = XFS_DAS_FOUND_NBLK; - } - trace_xfs_attr_set_iter_return(attr->xattri_dela_state, - args->dp); - return -EAGAIN; case XFS_DAS_FOUND_LBLK: /* * If there was an out-of-line value, allocate the blocks we diff --git a/fs/xfs/xfs_trace.h b/fs/xfs/xfs_trace.h index 4a8076ef8cb4..aa80f02b4459 100644 --- a/fs/xfs/xfs_trace.h +++ b/fs/xfs/xfs_trace.h @@ -4132,6 +4132,7 @@ DEFINE_EVENT(xfs_das_state_class, name, \ TP_ARGS(das, ip)) DEFINE_DAS_STATE_EVENT(xfs_attr_sf_addname_return); DEFINE_DAS_STATE_EVENT(xfs_attr_set_iter_return); +DEFINE_DAS_STATE_EVENT(xfs_attr_leaf_addname_return); DEFINE_DAS_STATE_EVENT(xfs_attr_node_addname_return); DEFINE_DAS_STATE_EVENT(xfs_attr_remove_iter_return); DEFINE_DAS_STATE_EVENT(xfs_attr_rmtval_remove_return); From patchwork Mon Feb 28 19:51:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12763737 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1895AC433EF for ; Mon, 28 Feb 2022 19:52:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229705AbiB1TxI (ORCPT ); Mon, 28 Feb 2022 14:53:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44420 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229810AbiB1Twn (ORCPT ); Mon, 28 Feb 2022 14:52:43 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 27BDBCA736 for ; Mon, 28 Feb 2022 11:52:04 -0800 (PST) Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 21SIJIAw010136 for ; Mon, 28 Feb 2022 19:52:03 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=CbDiGC6d4rIMYPHF2GXl5716s0f2UZdG5o0FyWM2F0c=; b=o36a2MtdTv7X74kDMwJvvPXY1PA7aIsi2Mi30QyPASKxe4MMOkDSmcRPWI47mfh2Hfea 8V+AYaLd1bHtwBD1IGTLOYX49ihnTxZ0lCD7CX7AoZRFG/yysz5JjN+BYt+a8vQx+YyG 5FWkQocM7LceY1OuycNLOpBhn3MCKN8vBS/Nzw/EncBZ0zGj8n2RNbqv8H4MN2Yp0mqx jCBC28f6hYzWXCjZVxxMOF5FeRlGp9E0MFmxPVJ4AilqOOQbQmDLGLxJFUUs+Z4sjvuw g7ZovKMF5OHU59Fia6hN7aCfIC1t/YMlFBFc1Z9JIGOzwWlwa8tGdqrFS2KH77Ru5Q4a pQ== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by mx0b-00069f02.pphosted.com with ESMTP id 3eh1k40pqu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 28 Feb 2022 19:52:03 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 21SJjsZ7061244 for ; Mon, 28 Feb 2022 19:52:02 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2109.outbound.protection.outlook.com [104.47.58.109]) by userp3030.oracle.com with ESMTP id 3ef9aw0y4u-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 28 Feb 2022 19:52:01 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GtNQjVRRa/mq579FTDcjQ/OXT+fYpnAjeEUTiL2tXyq0EQ3eckp4PFuSdWu97x19oVUFif7qiyKUilKdwwkbEKWzPsUjFn4PjlLZuWysebUxbvU+u7mOgHuTK2gUjPoP5EYS6d4YyNga56zsS65DLZmRTLkJjH6L1CCuXVJ/IDJ03xChIOjMfriHRInDDZFNG1zrcQ2YHlEl69NLkMQc9pH/YbEmHTGPCfMLhFKN8AGWDmG/btV+DHAaqdtLrGkzrCpb32e5ydt472cMPWYyJIyH06R5z9TZ7ket5zRQCk0Bz/IV617xDySunFJhRG8h6++jMy+ynn9aI3Nz2ElhSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=CbDiGC6d4rIMYPHF2GXl5716s0f2UZdG5o0FyWM2F0c=; b=Rn/tEVM7QQk4rjxjuDt2HSY/YH7KWcDd9rS8ZTi9DejJCMR8WXD6HpRGXvAU6ZNcJEqdKpX5nQQ4jgezYoNmKexl1UzjiprqZXscBc4PpvMiZQbWT4NGfmS/BVhIdbRan72FBpbhk0tq/oMxyyyr3XW7IosrD+3ARUshAOOnftbyidiOc0zGvtfwSSKOwzeOfd84Skm2/J3HSxht2ievNF/TEKCgWyITVRtI4lPiDdxrQ9aShw1xW2vSzq9208/+aRJFLV3S/JKVm7AmKWeCBHCFmbX+FFZZYS+opLbstajmNeL1w4UJGdE6r2UXVwz1GIaa/ze0OLYNe1CDvl4Rxg== 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=CbDiGC6d4rIMYPHF2GXl5716s0f2UZdG5o0FyWM2F0c=; b=gy842GdWXcX4DewdkMv9EbR6eyv3zh4xLnBP68vam6yWxc84qN9+QcuP+sLLbaXemizhHwUly0foSVQZKAZ+LuTP2yi49CQrY5AstiZEGoToKny/oGdeX7GHDbAhZ75zP9DNT7Vlt/f0yVtUbQKZd4SepFLGfpTrpZZk+OMVvUY= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by BN6PR10MB1732.namprd10.prod.outlook.com (2603:10b6:405:9::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5017.21; Mon, 28 Feb 2022 19:51:59 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::a91b:c130:5e3f:119]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::a91b:c130:5e3f:119%7]) with mapi id 15.20.5017.027; Mon, 28 Feb 2022 19:51:59 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v28 13/15] xfs: Add helper function xfs_init_attr_trans Date: Mon, 28 Feb 2022 12:51:45 -0700 Message-Id: <20220228195147.1913281-14-allison.henderson@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220228195147.1913281-1-allison.henderson@oracle.com> References: <20220228195147.1913281-1-allison.henderson@oracle.com> X-ClientProxiedBy: BY5PR03CA0023.namprd03.prod.outlook.com (2603:10b6:a03:1e0::33) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 985f9090-03f0-426a-fd93-08d9faf3c7ca X-MS-TrafficTypeDiagnostic: BN6PR10MB1732:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: t4+qSiW3s9cFcl8xh+Qcvq76nkvFsF9R08BK0PX4DikNlX4tJyC2kPaj0TInN7JkKJyN+o0F1R4NRBMCXAIb0r3XU0FyZFs8K1MJNuHcJsBxPecfvQoegZwDxK2c9aG/N66IjzWbYBdIOoCG3Al1LFPQTEjQZ4osYH3MTjd8z3ejT7Rr4Gli2pnXhsistcosiik3StczsIgdgkbShGtfux4VsvJqAUIAApzjsfw5TDQA9SU1i43Bh0+iAzI8S2PXcWndIfNkta88rdYjTJa0H6gmdaxnhZQptvTHclakxjpQXaIXqqzk33b4NjA+vg9EhSILtmhO3+Zik/l2317Xh/3lJm0i2jC1wlASXA7ushWg5hqtPqbdzhKnEUF6Qx3gfG2HxDgZ/2qDmO2IbM+CUQaDv1UNjRYDBR57sl+Cdtbb3OUqA6fAI0UXt+BxsINq3ieUXtufgXMc/XtUNf7wd81U/cvd6RC33RYn6WQC8X6QfQ+mGjjD+aOPT8C0N1pi/DJw1HRMO2vLaO7IgERIWVfcjkrxzfTS1bU19PdSaEAtNzkgrDBbVr2swHzXGLRKN4gA0TT5nUF/gVBdNhmJfrOOJp8mOT8LSrc50YRzaRowQ/UcE9Vnpz9+vZrpLm6SYOVq3Keg30BvF0sBEgW8oq13Dgrk3FU8P2sQbSdwWkHNxArcdZtQwjWslq0rr7YqmOeG0h/zU8+IniYLnlUz3w== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(366004)(36756003)(6486002)(86362001)(6666004)(1076003)(52116002)(2616005)(6506007)(508600001)(26005)(186003)(83380400001)(6916009)(66556008)(66476007)(8676002)(66946007)(38100700002)(38350700002)(5660300002)(44832011)(8936002)(6512007)(316002)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: jT+r1f+rn3jGrwvQ23BGSUAjkNYLTNTNF5zLuknFnSfW0JWSGLcNtg+8mjx0vPVB8cPoLaNko77phIrWfaWVFhP7MpNUuyzfFcIVFt7+UB508ffeop5Zm8cetYFdICqoh9S0LpHjFkHbZGnxzRWeX+EBvduQstz65rHSSSjf6qW02/l7LtrqZUkFlKk4kU2c4RAl4Ysid6+AeOXLDcqFtpYC17KGleCt9FEZQoBPo0DSj/L9EuHyo2L2+kE2ZPSZeBNZrnsP6gCOBmCEUJtmp8Fi6I4ZpTMvqF5v80h4vYgpeesT2N/P/MyHUY3pFMk/smNh/DCGD5dLnKSELCsDaK8wq3ZQAr4dvVkO1LP3vx19/EVIl7MIREPl3RxIGbjNo01VY12mutUJFMkFwVojL9g0dL0o1KENnCF1Seg2QU8sE7TMZhuDNQPTqyzwly7zSiLKOAb+s+/AmNXz6Lmf1dIGVB2dxN+bHUZ0S8q6iLpJ1G0KJMaxYy01GCuil8HSptqCdhvoqy9+TO2V2qQ4aDbSnCyJ/ItjfcqVxESX7mBURk8SCRAh+HNwvJRQtZIRngPXlGFUs/CVelk6Io868Nm4OYLKEXJ2qXHNv2SNgcHReMRuv58vokdi/NhWESVcw04UGW/C8uPrX7HcWRJrrFMp4GmhMVGiTuvN9mL4+xb3om7XsGh7z9/l1PK/t+mqbCDeLC6gsKUciFuf798bl3ODzELAXeGn1C9SidT7RSTYX0gAHBQJC7ViRQx/vt7v7IBm20LDGZfrYHE8zvgM2SfKDDG26+DKHxRUV54fakUXWR+i890fOBy/7st8fwNcwoIABDQo/rzEFmnJn24p1mAwMe4UEsvvdFtY1Gbgi03c7aoZsAL8ktjBOjbFlpy0F14P6+8O275BrWvXkxdDSIHbI3Hw+MEuZaPja8cyahkuiMsm4exdMq9bEePKwRpytfnssGlGzlZgbEhZKFgeVbRArBgqBZ6XtJhnugApqRwq08JDpxkedwXARFr5bshOyOjEN85XDyngofzXAx+8LlheghNpPLak2RsHKZ3g6flk/1Plo3hHBu84/Rc9YlgKxTRAD0Ssj23c4jXwfZSM7VZLJrkObhYP12E1v/0KizkamnWw+Plk1SEhgNNcZZeuRibPCMDN2T3UQ8Ozth2tfa/II1xtzT+xDclg64KQS/l36KAbWWeqfi6b3QgxIvrH0Qr4XNaaY/b+hRy6NwrQCVgjqAjvJkZoBKBCBFsLkIVuguPIBAFG7irGxAzx0QFHpdlIu2pYTQ68xGPw5mVPehHEZbLaXfdMckBRDCprHe4pIPD5t32oe5OrCgq4EuJ4LtOCF7C8+75Lx7Dm3iFTH8WPerSMU3lHNBdKacDrPqFt0n3SG1DSQGgQzerOinKAKgcLG3pe58WdJ4Ee/i35ArsENr+1fzQtxL7d0RtoOtB1g62rcLi6zITtk2VEexLgqGL6KbgppJFHzuln8htl3ilkbXTDqWyQR2pU6i736rMwVqm13IVLR6s4OKgBNd8cKQme77VwfrFEejvf4qo9MAADGUvV+R6xT/zNPTB+07d2Y1mLe/vbqwESLrw+iG096QYn5a/izgwcEIPMSMsIV4HwiRoyfRrEPhpF1hkSO7zwQMrHKkMS1OUvP5jE7sPpaXPG67gx7QvxAPLW2fSCYg== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 985f9090-03f0-426a-fd93-08d9faf3c7ca X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Feb 2022 19:51:58.7476 (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: UuW1mDe6qyaNc99LslQBwUY01tBNmXyrJO0KLU42TTZ8edTsWtrKwIrsUMFKDwsaYN5j2o0jVnPE7q1NGB04qKwZGRJCIrGSz4vV/nu/Pzg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR10MB1732 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10272 signatures=684655 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 bulkscore=0 malwarescore=0 mlxscore=0 phishscore=0 suspectscore=0 adultscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2202280097 X-Proofpoint-ORIG-GUID: 55kthZMSWHcVvL07EszC9f8MMFdX_1i1 X-Proofpoint-GUID: 55kthZMSWHcVvL07EszC9f8MMFdX_1i1 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org Quick helper function to collapse duplicate code to initialize transactions for attributes Signed-off-by: Allison Henderson Suggested-by: Darrick J. Wong Reviewed-by: Darrick J. Wong Reviewed-by: Chandan Babu R --- fs/xfs/libxfs/xfs_attr.c | 33 +++++++++++++++++++++++---------- fs/xfs/libxfs/xfs_attr.h | 2 ++ fs/xfs/xfs_attr_item.c | 12 ++---------- 3 files changed, 27 insertions(+), 20 deletions(-) diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c index 7d6ad1d0e10b..41404d35c76c 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -202,6 +202,28 @@ xfs_attr_calc_size( return nblks; } +/* Initialize transaction reservation for attr operations */ +void +xfs_init_attr_trans( + struct xfs_da_args *args, + struct xfs_trans_res *tres, + unsigned int *total) +{ + struct xfs_mount *mp = args->dp->i_mount; + + if (args->value) { + tres->tr_logres = M_RES(mp)->tr_attrsetm.tr_logres + + M_RES(mp)->tr_attrsetrt.tr_logres * + args->total; + tres->tr_logcount = XFS_ATTRSET_LOG_COUNT; + tres->tr_logflags = XFS_TRANS_PERM_LOG_RES; + *total = args->total; + } else { + *tres = M_RES(mp)->tr_attrrm; + *total = XFS_ATTRRM_SPACE_RES(mp); + } +} + STATIC int xfs_attr_try_sf_addname( struct xfs_inode *dp, @@ -701,20 +723,10 @@ xfs_attr_set( return error; } - tres.tr_logres = M_RES(mp)->tr_attrsetm.tr_logres + - M_RES(mp)->tr_attrsetrt.tr_logres * - args->total; - tres.tr_logcount = XFS_ATTRSET_LOG_COUNT; - tres.tr_logflags = XFS_TRANS_PERM_LOG_RES; - total = args->total; - if (!local) rmt_blks = xfs_attr3_rmt_blocks(mp, args->valuelen); } else { XFS_STATS_INC(mp, xs_attr_remove); - - tres = M_RES(mp)->tr_attrrm; - total = XFS_ATTRRM_SPACE_RES(mp); rmt_blks = xfs_attr3_rmt_blocks(mp, XFS_XATTR_SIZE_MAX); } @@ -728,6 +740,7 @@ xfs_attr_set( * Root fork attributes can use reserved data blocks for this * operation if necessary */ + xfs_init_attr_trans(args, &tres, &total); error = xfs_trans_alloc_inode(dp, &tres, total, 0, rsvd, &args->trans); if (error) goto drop_incompat; diff --git a/fs/xfs/libxfs/xfs_attr.h b/fs/xfs/libxfs/xfs_attr.h index 1ef58d34eb59..f6c13d2bfbcd 100644 --- a/fs/xfs/libxfs/xfs_attr.h +++ b/fs/xfs/libxfs/xfs_attr.h @@ -519,6 +519,8 @@ int xfs_attr_set_iter(struct xfs_attr_item *attr); int xfs_attr_remove_iter(struct xfs_attr_item *attr); bool xfs_attr_namecheck(const void *name, size_t length); int xfs_attr_calc_size(struct xfs_da_args *args, int *local); +void xfs_init_attr_trans(struct xfs_da_args *args, struct xfs_trans_res *tres, + unsigned int *total); int xfs_attr_set_deferred(struct xfs_da_args *args); int xfs_attr_remove_deferred(struct xfs_da_args *args); diff --git a/fs/xfs/xfs_attr_item.c b/fs/xfs/xfs_attr_item.c index 878f50babb23..5aa7a764d95e 100644 --- a/fs/xfs/xfs_attr_item.c +++ b/fs/xfs/xfs_attr_item.c @@ -532,17 +532,9 @@ xfs_attri_item_recover( args->value = attrip->attri_value; args->valuelen = attrp->alfi_value_len; args->total = xfs_attr_calc_size(args, &local); - - tres.tr_logres = M_RES(mp)->tr_attrsetm.tr_logres + - M_RES(mp)->tr_attrsetrt.tr_logres * - args->total; - tres.tr_logcount = XFS_ATTRSET_LOG_COUNT; - tres.tr_logflags = XFS_TRANS_PERM_LOG_RES; - total = args->total; - } else { - tres = M_RES(mp)->tr_attrrm; - total = XFS_ATTRRM_SPACE_RES(mp); } + + xfs_init_attr_trans(args, &tres, &total); error = xfs_trans_alloc(mp, &tres, total, 0, XFS_TRANS_RESERVE, &tp); if (error) goto out; From patchwork Mon Feb 28 19:51:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12763736 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7B170C4332F for ; Mon, 28 Feb 2022 19:52:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229697AbiB1TxH (ORCPT ); Mon, 28 Feb 2022 14:53:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42396 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229803AbiB1Twn (ORCPT ); Mon, 28 Feb 2022 14:52:43 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 754A6CA331 for ; Mon, 28 Feb 2022 11:52:04 -0800 (PST) Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 21SIJHVA010129 for ; Mon, 28 Feb 2022 19:52:04 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2021-07-09; bh=h5DhRca4zryPXrcoZOXKCc0lz+98mokyw5DgOaFMES8=; b=pFuAFC8Py0zMqLBXfaTvGPWiOXKKpypUBsZnJbOGFARpTWtFkqmOTaN67OnMG5XO8JUp fxMq7fGg1nDYlCEa/cMM6VysHNaG9eJ+XoHNP2TZZWYTk8ZXYCaPOKBe6dLCSVyEBRpJ B3ZeAve+xKDqG018b8DbNLXW11a4SPLhxCKA/R+4+3Z44ppnDTjibSz+GFImAuOjILUb +JWpaAwTiEVUSACQD9Wy97az+7az32vi342b/RWqZhtkI3I8j2VPWFdNWZLhIMd4HM+0 Ri77xvWV42gb03GVDfZpC3kVTIL/5blqQC1iuzFY8n3C28qgUrxhsxTIHJx3kBVgUopB Pg== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by mx0b-00069f02.pphosted.com with ESMTP id 3eh1k40pqv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 28 Feb 2022 19:52:03 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 21SJjsZ8061244 for ; Mon, 28 Feb 2022 19:52:02 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2109.outbound.protection.outlook.com [104.47.58.109]) by userp3030.oracle.com with ESMTP id 3ef9aw0y4u-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 28 Feb 2022 19:52:02 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IGa21l87B3qv5kVftaJe7yPzj1hs05mL0jDknqzcWgEbluzM2etFu7p8QNfXLMDOK9X96s8nxlakX43R6oOjcsE+x2kzf+hisn6UTKECyr7M3HLeIzt5xqClSi8axI/+4Dupi5Z0TvBAHldPagiEM6at4gvzlB0MnoOytxrqFfgFLuXBI9bOIx4yMMkpyR0Mjx7soGasBLcnw5BsK2UrI4N7jzMwwErRVd6bWvoYvx1MVnYbAzJLzd/UFQCGoW903i1R1AvRlBbUHIF7mJEM9HqSyNI4h4KmLXQTOMnlhN7hb/ImEtjJHaDQ89DUbpLTzVCv45h7edFN5bo1BxPZsg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=h5DhRca4zryPXrcoZOXKCc0lz+98mokyw5DgOaFMES8=; b=MiHmqDaT3ca5HJvc4SoLVf3TXVReg7sHT2Ag+wzLSjqQkSfPepadRpeBBoMkDp4nE3/NqRj/pNXpcdFDzIobYagqdnwLY6bhCTGlSHW6Hv454PglvHLahoQEC0FyidkNhewxM/4iAAyIjAkoPfSs2WYp9tajAMughWHo8RZcffVNpiGhC459WwtPapt4YdrITrXwN/iH/3mkDhmIByTaDhLitpso0O/dwg0j9IvzVTf/gcsrrvh32Uvpfm86Y58tqoNqDc58W9Bywn/tK5RIrl3/3vM/2nk+4erlie/goJhsLO9fgoliifq5crB+YldYznktiouvxwwX6wFmkya3qQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=h5DhRca4zryPXrcoZOXKCc0lz+98mokyw5DgOaFMES8=; b=E1lLuL1jUCLYIkoPofsj+lwJ/9zEw/3RB+czuaSxzpFRmuAyFseHO2yZHu7DuWk28jFoxzE8PP7xHgIEU+6Izv7z72fmRaXduaQCupokKh1B+s2Oe0b5ncAAljX3CaT4nn4fsg4o8z9ZlF2BHvs12pT+IeWYvCaHLDphoqhnTYE= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by BN6PR10MB1732.namprd10.prod.outlook.com (2603:10b6:405:9::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5017.21; Mon, 28 Feb 2022 19:52:00 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::a91b:c130:5e3f:119]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::a91b:c130:5e3f:119%7]) with mapi id 15.20.5017.027; Mon, 28 Feb 2022 19:52:00 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v28 14/15] xfs: add leaf split error tag Date: Mon, 28 Feb 2022 12:51:46 -0700 Message-Id: <20220228195147.1913281-15-allison.henderson@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220228195147.1913281-1-allison.henderson@oracle.com> References: <20220228195147.1913281-1-allison.henderson@oracle.com> X-ClientProxiedBy: BY5PR03CA0023.namprd03.prod.outlook.com (2603:10b6:a03:1e0::33) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 44495aaf-a68b-47bf-f4ff-08d9faf3c827 X-MS-TrafficTypeDiagnostic: BN6PR10MB1732:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: aVAzk1gKuCbj1TOYESjOI9XkJyADq3d2cmOFdrCIL5cen4o9bsNRq1p6sRPEwAVIzMdbV3huV1CCyt0NDF8Brb89/NyYCdB1mfuny0JDRJ+qSTV+d/+nPFMBzA3m4Ccq96hrUCWbC+c2hGjd6AIdYUoT45SR4MMBTxLBtexNyGSjoiN/mcX0L65bSGhmDqphd4k6wP51C4sDEw9SJnv4LsbynRI20BPLELDb2kOOjP+uJGF3jbGP43mMINOJDNHQr4Fi5f/iogOJiMAqQn1/1LoUATh2DWmhAHWLzU37D0Cp/4Q5LzEHWGuhT0NU5nheuzvUvqEtVQZzk90P7DlxOpV570wFQXmIi7OkCBvLSViOAswCD4goiYvEYi8QELzBFlvL2GWQEMoAthfzyIAsJ+S7956G83rEf7ZhJr4gdeetc3o/m+UfhGB2Xdai5tiOnu8GRC9/P0jjOV46PgxNsOi5g2TVMKWNZzQxLYZvvrLsEcJb6ixp9AFEalgi8CJBaHevsCive+UcR18amvwBHT2DyEcawH6Ab4UYgU3525ooy+JkesrXnIM9f3q45dfc2YnMWqGRJqRo5quFwMhb9CswPUSouivPm5CMmDN0aA7I2u2WNJFea9VvWoQ9/jVDB5rz5T9pTY5TkIWCWmmxUFlSqy5hXByyKei9/Z6K0hERkLDyvkXwormQn7M6vaW+qLRQQMzG73Xt6NO4olmwhw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(366004)(36756003)(6486002)(86362001)(6666004)(1076003)(52116002)(2616005)(6506007)(508600001)(26005)(186003)(83380400001)(6916009)(66556008)(66476007)(8676002)(66946007)(38100700002)(38350700002)(5660300002)(44832011)(8936002)(6512007)(316002)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: yXTglkpD8hzgD7WofMbtXwJqWfEccRytU1h9Vr33En2Y+Qi58bhKJFFrVdd8jjPM9neKhwyAJakmTKMmq23HVhl4FmIRzbE65kdL+oESUX4lCS9IIXNXyWvBa52T2JNuEWmduJSMv5R4MDWOIlPM+3RkByrg4NJZTdK1CJNP7llic8jnBNdHEfjwJhhowY2lc2/2N3gb5bL2XEmFeeOJmkJ6/p3b+yDyrcRXv5k/rPwJuPBD8+GXk5JMSHlKMx05+dug178MYiahJ9MD5R85W+n/jm8FEGpHj13kkWZ/70yC1bf3FlyUVXm2/4IPOw3aya+HuTsXGGcsR2kjXgYY9GVCbGdr6MrY1XOc26JcpPpO7KvbK91JzoBqjGheXqDMlIcGHsusZA0Hi7PNJUw5pYM6dfevTRajV4vBsgj98JnB7hFv7DgomcKh+MFTqEPzdIoCp0OQkxok8LgUCb+MdM3hUdhG9I07jajChat7rMbN9a6gMe5piqiUs4GE/vRpY1gaE472CjMYkTJS9p9PIvQ3jn2dFKZgsrIbwAz3YlEGgHESmsf0sDGwopaK5G2NjbRbDacM1GY04xgJJAConIIq7ZPgDAzRcxBDWoOOc5437Xv+niI0hS8TDFNEp+tPnq+SuuTnY+uvBiQOfeLD3IAdRtsHTKV2SWXXwOLJUEDWiQFwcJfiY0Nf6VQylFITwkm3xOYulyxkN7SJDbP+kNUle7Fe6Esdw6aWMw38bGZrZ/C7vbv7Ww1S4zi0ACvB4PbjZTWBgMZBsmeFcV7ZLzQ7f921ithdW23Ypx9sV4CwXVvpYYg6oGQLGuFtf5RHIpBbQHeT9mjGgYyLs+NriOAZ3GwR+YQTN17OieHUfjhwvFH6zW4QdGwfKoDOJJDd0pPZdR39gCvDnAmc1mjiOuh3dyr+Oez7P4Jifv/2vswb8w/mmS7W/Vfcd8dpNOWaPQTYmQZng/mJaCKEV8vECx2RJsRZx5MLk7KN5r5cyEk3pJlmspiyefJr2VAG/3TLe5yBLqYFy3CKcqMYGOcIcd9IMf6wkkAS2dk0gu5iMnAFk3uaGMD7SADZY2i1BPTYnvuBXyAIBfN7pmPbE2oiQa30Hr57ES6bfbQH15ymHW+oUNga3Yz6BCPk2Mt57lWAaFzbQTqHL2F4WTsUvd1gQ3FjUUVlP+D4341SpQceK9AQ5eeK20zp2T2aKyh9HoCYyINP/VCiV5VaNIKN8IrvdeHEgA1Qh2S8bohHRTrrIXk10xbrvJ0oDKWe3382FlBxC+rWt2+wl8P1VnYAVy30rBca8nO0sMvGAmt1Cdn1RWmKJA918lKVDp1rXvA/UADWRjTLZ2/FfEIirbAIFUl9js5PCSEe+lX342PabRbYWlIYhR+ZxdyksPLclAE091B2KqLIomBqlzwBzhOa9ynfsR+wooGGTWUrIGMO8hDZpt92Me0AgtyZYQrNNQEwKqlnYURa9au8YlRRSukna2VY5nu9U0ILU1QLE+QdEbuf0Yuj1ciUM20IezS3/5fe3PkBPeaLzQ7/qpEXkIhR3HYAt7qupKeIuPyVsgvTsZ1OA+UGFWB3aegT56lDOyG+DU7hD9osq7S+plVxhniHrCLrKGKYcP5/lm0py+/SZg0uinPpCHpghrVQZTH1YQq454VRTyivpOBC+UQBYNmZyZrpcA== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 44495aaf-a68b-47bf-f4ff-08d9faf3c827 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Feb 2022 19:51:59.3256 (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: rUHMNoiwcYmo9NZgN22g+MgtS3/PXbqZOpaqWyr8FyNZgscbI0q/51qr0L5p4bfrVVdIvQNa35SF/MCXl6jAJnnoGNCZUczPgdcd7/XEdF4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR10MB1732 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10272 signatures=684655 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 bulkscore=0 malwarescore=0 mlxscore=0 phishscore=0 suspectscore=0 adultscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2202280097 X-Proofpoint-ORIG-GUID: _dxmF-_BasnBsg-aEJFSd107OTZhOewN X-Proofpoint-GUID: _dxmF-_BasnBsg-aEJFSd107OTZhOewN Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org Add an error tag on xfs_da3_split to test log attribute recovery and replay. Signed-off-by: Catherine Hoang Reviewed-by: Allison Henderson Reviewed-by: Darrick J. Wong Reviewed-by: Chandan Babu R Signed-off-by: Allison Henderson --- fs/xfs/libxfs/xfs_da_btree.c | 4 ++++ fs/xfs/libxfs/xfs_errortag.h | 4 +++- fs/xfs/xfs_error.c | 3 +++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/fs/xfs/libxfs/xfs_da_btree.c b/fs/xfs/libxfs/xfs_da_btree.c index 9dc1ecb9713d..aa74f3fdb571 100644 --- a/fs/xfs/libxfs/xfs_da_btree.c +++ b/fs/xfs/libxfs/xfs_da_btree.c @@ -22,6 +22,7 @@ #include "xfs_trace.h" #include "xfs_buf_item.h" #include "xfs_log.h" +#include "xfs_errortag.h" /* * xfs_da_btree.c @@ -482,6 +483,9 @@ xfs_da3_split( trace_xfs_da_split(state->args); + if (XFS_TEST_ERROR(false, state->mp, XFS_ERRTAG_DA_LEAF_SPLIT)) + return -EIO; + /* * Walk back up the tree splitting/inserting/adjusting as necessary. * If we need to insert and there isn't room, split the node, then diff --git a/fs/xfs/libxfs/xfs_errortag.h b/fs/xfs/libxfs/xfs_errortag.h index c15d2340220c..6d06a502bbdf 100644 --- a/fs/xfs/libxfs/xfs_errortag.h +++ b/fs/xfs/libxfs/xfs_errortag.h @@ -60,7 +60,8 @@ #define XFS_ERRTAG_BMAP_ALLOC_MINLEN_EXTENT 37 #define XFS_ERRTAG_AG_RESV_FAIL 38 #define XFS_ERRTAG_LARP 39 -#define XFS_ERRTAG_MAX 40 +#define XFS_ERRTAG_DA_LEAF_SPLIT 40 +#define XFS_ERRTAG_MAX 41 /* * Random factors for above tags, 1 means always, 2 means 1/2 time, etc. @@ -105,5 +106,6 @@ #define XFS_RANDOM_BMAP_ALLOC_MINLEN_EXTENT 1 #define XFS_RANDOM_AG_RESV_FAIL 1 #define XFS_RANDOM_LARP 1 +#define XFS_RANDOM_DA_LEAF_SPLIT 1 #endif /* __XFS_ERRORTAG_H_ */ diff --git a/fs/xfs/xfs_error.c b/fs/xfs/xfs_error.c index 666f4837b1e1..2aa5d4d2b30a 100644 --- a/fs/xfs/xfs_error.c +++ b/fs/xfs/xfs_error.c @@ -58,6 +58,7 @@ static unsigned int xfs_errortag_random_default[] = { XFS_RANDOM_BMAP_ALLOC_MINLEN_EXTENT, XFS_RANDOM_AG_RESV_FAIL, XFS_RANDOM_LARP, + XFS_RANDOM_DA_LEAF_SPLIT, }; struct xfs_errortag_attr { @@ -172,6 +173,7 @@ XFS_ERRORTAG_ATTR_RW(reduce_max_iextents, XFS_ERRTAG_REDUCE_MAX_IEXTENTS); XFS_ERRORTAG_ATTR_RW(bmap_alloc_minlen_extent, XFS_ERRTAG_BMAP_ALLOC_MINLEN_EXTENT); XFS_ERRORTAG_ATTR_RW(ag_resv_fail, XFS_ERRTAG_AG_RESV_FAIL); XFS_ERRORTAG_ATTR_RW(larp, XFS_ERRTAG_LARP); +XFS_ERRORTAG_ATTR_RW(da_leaf_split, XFS_ERRTAG_DA_LEAF_SPLIT); static struct attribute *xfs_errortag_attrs[] = { XFS_ERRORTAG_ATTR_LIST(noerror), @@ -214,6 +216,7 @@ static struct attribute *xfs_errortag_attrs[] = { XFS_ERRORTAG_ATTR_LIST(bmap_alloc_minlen_extent), XFS_ERRORTAG_ATTR_LIST(ag_resv_fail), XFS_ERRORTAG_ATTR_LIST(larp), + XFS_ERRORTAG_ATTR_LIST(da_leaf_split), NULL, }; ATTRIBUTE_GROUPS(xfs_errortag); From patchwork Mon Feb 28 19:51:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12763739 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 74BECC43217 for ; Mon, 28 Feb 2022 19:52:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229803AbiB1TxK (ORCPT ); Mon, 28 Feb 2022 14:53:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43518 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229811AbiB1Twn (ORCPT ); Mon, 28 Feb 2022 14:52:43 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C04A7C7E96 for ; Mon, 28 Feb 2022 11:52:04 -0800 (PST) Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 21SIJqlV009906 for ; Mon, 28 Feb 2022 19:52:04 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2021-07-09; bh=Af03T31u2y2ZuaGoP2kTHccW+Eg4gGdVpOz4egX7exA=; b=B5mKE5R+QjN5MMflcS/8bsCoFoIqshbL3b31wf8MYB3mVAZU454SqHVEGFwf45TdIXTC hedhj/nLD9UtjlTZ5g9i3UeirQ+tRKajgZcOU5dmFO7nBPne9ruUMh90Z4yBpaMhNw9P 8mVN3vA92Ea+gkHmcyMCaqYWm4gEXAcmvdvSs09eVPKIAIbD8wIncGusEAb4s4lJe3Qh kW0pYhCkNIcfkdRu4vFt9/gMUsTqqj/7QRaoG2aBb3CEJ3MjDSB9tnYY1VKcLXLNE5S+ HZePbFJytPseiapSfyCajJYgOcf+1YWNrYUedsYdGggsLymkuTd031poiLPru6GhPMvp MQ== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by mx0b-00069f02.pphosted.com with ESMTP id 3eh14brsje-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 28 Feb 2022 19:52:04 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 21SJjsZ9061244 for ; Mon, 28 Feb 2022 19:52:03 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2109.outbound.protection.outlook.com [104.47.58.109]) by userp3030.oracle.com with ESMTP id 3ef9aw0y4u-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 28 Feb 2022 19:52:02 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nRl90tQWwuMu23Zqza9PILKV8avD5kYlFwujniZBYwtFUFrA74OWEFuZ+T0CwhvzTRn4vzm5yoVTSZKmRus/I0v1lbBGwX/kpqrsGueOXt70a4knma6ha0fs2pXjwsgsPxorksXDNjH5flJq5q6TgTW/uvlReiE+9v5UB1nea2sD0TP6gexWSQLZrGvqrPbQWsV3Cc5s1+sKh/6aPNNEjCpZqXdhem3N1zcDue5rthzTmgJXi/Fhw9TxzlGo8zdpnExAoGjCBzIyOwT75uauT3dw9WpjnOCv1ml1MV/IQwKMYS6iSukzmS/GihxRRJr02rSK+wOaMDIsW+neWHFMLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Af03T31u2y2ZuaGoP2kTHccW+Eg4gGdVpOz4egX7exA=; b=W+x57tykz3VRTj3eKgZPH7x9mmxkQc4DzVfxkSm27Bpv3NR/0EGvWUVLy6vQ241+PqwXdqSQyNNpGYqTAuRN/TdBNNYuH2VfIu4DEtNFUFBFFjGXlkNLft9gSkj3RBstI321R3/rnlfEspNagnhPMj7ZDMTDCIF/OEkVfM2JJIPjK0rUifGyH/pS8VLgsk/GXKrb6APFlO5+yzwLyFKKooMapE5FV5wVPlgkF7Yl3obTphMmIH9IgfrNbhLE6VZeSy7US4LUK0rowOBDvj8O+ezz8iPh0ErvCIU+U3d0ChAFZFV8SicRH3/UC4sbuLJ2XYjC3V8UouFYfw1xl7mvyA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Af03T31u2y2ZuaGoP2kTHccW+Eg4gGdVpOz4egX7exA=; b=oBAcqBUx/IzyeR+sbuumoeXkaLYsXtuyC+JEhpZ9c6t8VLx6t6swTLezrgZSE6+JIj9pxAZMdczcXkgmztbdliOcbepRgiDaSdSsQiTv2cRwoemb9IIzjKQ8LGqR1lvHC1xUhrQ5JcmhvpYQ0TmAw6kAXR5dt/alc3LgPrYMh74= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by BN6PR10MB1732.namprd10.prod.outlook.com (2603:10b6:405:9::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5017.21; Mon, 28 Feb 2022 19:52:00 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::a91b:c130:5e3f:119]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::a91b:c130:5e3f:119%7]) with mapi id 15.20.5017.027; Mon, 28 Feb 2022 19:52:00 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v28 15/15] xfs: add leaf to node error tag Date: Mon, 28 Feb 2022 12:51:47 -0700 Message-Id: <20220228195147.1913281-16-allison.henderson@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220228195147.1913281-1-allison.henderson@oracle.com> References: <20220228195147.1913281-1-allison.henderson@oracle.com> X-ClientProxiedBy: BY5PR03CA0023.namprd03.prod.outlook.com (2603:10b6:a03:1e0::33) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9094865d-a6f7-4b30-c8a9-08d9faf3c85e X-MS-TrafficTypeDiagnostic: BN6PR10MB1732:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: tWvsHL6ObaVDbovn6uag+KqeGYr82qfkSaQEkwwqDAPIHq6OdVm3Z5G6KALUHBs3n3+cCK5kJAGJfhwW0u2NOO/YF8tE13TG6hNe6zAIifU/JN0lKn+vNOOaBqmQVFe30cXHyCNtKaqZ1pfYmN3Sp5FHBSrNY209updK4wmnoVubc/j06DsZJsAiMUIjD3S1e+M+1jNRWP0SKYivVCPL74tPULeUxFGwOobKoKuNF+o26dQ/TaePYOIrSTKcdH+oUZ9CmnX3VsbIQJKvfFdz41K9nO0V5Xaiw1f051FkjHKI7Enn2/bsfKMtlOxatLZUYsG9z86aNWV2J+GzOdZBuqFnE3ZJIxbANVIm3ln21KRWSMqNg0SBuiYOPN+FnAYTU8QIHlafXj12JxyAylzLGR/CZ8LWokL4H4ZAZhFpm8kUEBueV62A/tBYnaa4xC4+GpxkNLHtAdbouzYVczhSw6QQsNzSgwsfo+WnKDaPhwv4Qvt/gogE2HAgzbDmWwEwDZJbxdqG7XNFgbDgBnB73j48c5Zpuo7kzHJdP5jfP62tZ32aa5ChqaEIavPii9ecwowGpCz6LLGtVjPFytBkDozUvy1rSTGFfkjJZrUTPMJ54j1mXFZfdCwBrZwZ01UXMSdbiIytyRvbvg3b+yNZqu4cH0KbfozKxEiCmxyw/KLnSOdV0Sb4QDgbdYSxxsYbBtgF6Qi0NIxiyL6W3NVI9A== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(366004)(36756003)(6486002)(86362001)(6666004)(1076003)(52116002)(2616005)(6506007)(508600001)(26005)(186003)(83380400001)(6916009)(66556008)(66476007)(8676002)(66946007)(38100700002)(38350700002)(5660300002)(44832011)(8936002)(6512007)(316002)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: EtOUPj9m5ScCxCyEY7zGNjmHSmyl2oiZa0e35VRmZwN1ZMPa9S/1D8gWIm5aVKhK7Wdoi1l4bdkOhUFL5aI9rQf4cn3gA8M9xTgL/kS5BS57Brp1EX8hGunHWx7MW3j/dhpkX3n8WU8avBeuoQD1AEzLa8EACaRI7bvV/hHbbdtfXA8cQ7YP6xPZ/fxNw/o+tlRKFt+DdiaBpKW7g9hR2s0YYc5zhWD2jVCnHs+i9S0LBYe0saCulnKssWyh2rwyvono5zNCnq7tHMFDlzok9dFhTgj/WcAUR8isbLz38JB/jtbzoQ72/mqj/s9qwUUHFl+98a8hWltn8MZGII/QTwZrTLgUdvtAFZFkQa5D1kZBhmF3A9R/AXe4UbPa4wBIcwoM+1PlBmkLUiOhRjGGq1dni0NMhMnKIjCBRyE5LG2BQmpYpGsp6feUmrzEKuvcp3tq4QqT6t623XkVAlR0oYR6mXauue5AevqflWA/RuVsccJSLmp6IcmUG/nZ0UxOvzvVqTmI8WkrFk5Hmw9zfABm0zBTt3eD4zVWhqty4famBGl05AKKG+8e+ATFE/0sdgoQG9LEL1DEGOKJbzTA28SE370PgSvUDPtId2RoiCt7IJ1+9WFPHXFr6uHw4L7cH4Q2DDZlIMnzqvo52LHicP9ykF/mUZah0sAIXrHDi8SxNQng239Z6PzdGcA6xMKiv/4+QSwrHZufqJ0V/Y5fYkx4LAdCpNZYhPVv7jc4mSdUYpz8+JhEmdObiah+vwomM/aI04UQdw8PWvpHQR7JPdvEyjpPJrOTMOMYNuSnYylhbN/QvmLpv3TZwmPwgBDrvkFAk5AWxNAggi7rcORROdojLO8B68p5pD2lkQGNWwREYCzivYtGHj591Ek6Pm+JHpxE99rLmZW60su3V3Z1IWLvY1gSZx/m+wHUgLQUeqqYYlMcA/FcugidziYUTGsOiBgNhccoISNw5ictCd3sK+W6WjnSc2tOY95MpVaFBROocKESn/PEqusqXufnYDgikdObxcdfcWXLTGtXJGq2MyMvHj2QACQchyozm2QblJWsYj5QbPtjJ1k0zWkZ3jPmH+az/E0PFn+tHz35w79udxEQmSD8HPzCpCVcy6/smTLmLL+omE7UTtTRKfNsvmmq6Be+qNQajw0NZJ9sdS0iEdGxxaQSYyleO5okaZDN9vd152WJ12AdJzu0CdQ7qrCQ+s7vgNp4FmE48WBQDzQooMiTQnhh3nbmO+IkdhaeIpswhzby7NQs5NX6dLGJ3ALj9/zXOgcSk0dJcXgwG/OMMdhveYGClmEMr9IJyonAL1/e/dq7TgwHfZPXkV/zkfj0FFmYY7DkiA9xHmseRt95wANUgACN81GZKWqlT5453x2LVr1uZB1rwSd5jB4jGlrwH6hUfBPqTtlo2rO7a7CZezcUhKW+831BliAH9AaoRLUqhVahhe6gIDDKiaDmlNni1OXEXA5TDGh3fTNWW0KSCt2L9feM9wWZ0EaCuk0orig2SBM01lB8XC1RdebVyCyMuBiwWN/J3HuOUsHbfxrN7l02vshZHacjm6mvKcEqC/kseWLM/7UZhynxw8wSSUww+/yNNHHK4+J2msEYgGhjYbuSY4JZTAk41I9Gi1dZWbWNn0oS88JjW9mzkCGthswVbc0Pi3GVkIFlbAV5jAOHnQ== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9094865d-a6f7-4b30-c8a9-08d9faf3c85e X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Feb 2022 19:51:59.7006 (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: HPlz0aTkC7zfaG6K//AjEVu3RWMGshb1tvrv51ZVLAiKKa6As3hDWyARUZoFNVR2nP9z04InvWwi+WB/rSjTTs+2KeQl1xGTEDEimbzxvpU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR10MB1732 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10272 signatures=684655 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 bulkscore=0 malwarescore=0 mlxscore=0 phishscore=0 suspectscore=0 adultscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2202280097 X-Proofpoint-GUID: KcjqDEu-NPP_CKwmR90WFIA-574GrL6E X-Proofpoint-ORIG-GUID: KcjqDEu-NPP_CKwmR90WFIA-574GrL6E Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org Add an error tag on xfs_attr3_leaf_to_node to test log attribute recovery and replay. Signed-off-by: Catherine Hoang Reviewed-by: Allison Henderson Reviewed-by: Darrick J. Wong Reviewed-by: Chandan Babu R Signed-off-by: Allison Henderson --- fs/xfs/libxfs/xfs_attr_leaf.c | 6 ++++++ fs/xfs/libxfs/xfs_errortag.h | 4 +++- fs/xfs/xfs_error.c | 3 +++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/fs/xfs/libxfs/xfs_attr_leaf.c b/fs/xfs/libxfs/xfs_attr_leaf.c index 74b76b09509f..e90bfd9d7551 100644 --- a/fs/xfs/libxfs/xfs_attr_leaf.c +++ b/fs/xfs/libxfs/xfs_attr_leaf.c @@ -28,6 +28,7 @@ #include "xfs_dir2.h" #include "xfs_log.h" #include "xfs_ag.h" +#include "xfs_errortag.h" /* @@ -1189,6 +1190,11 @@ xfs_attr3_leaf_to_node( trace_xfs_attr_leaf_to_node(args); + if (XFS_TEST_ERROR(false, mp, XFS_ERRTAG_ATTR_LEAF_TO_NODE)) { + error = -EIO; + goto out; + } + error = xfs_da_grow_inode(args, &blkno); if (error) goto out; diff --git a/fs/xfs/libxfs/xfs_errortag.h b/fs/xfs/libxfs/xfs_errortag.h index 6d06a502bbdf..5362908164b0 100644 --- a/fs/xfs/libxfs/xfs_errortag.h +++ b/fs/xfs/libxfs/xfs_errortag.h @@ -61,7 +61,8 @@ #define XFS_ERRTAG_AG_RESV_FAIL 38 #define XFS_ERRTAG_LARP 39 #define XFS_ERRTAG_DA_LEAF_SPLIT 40 -#define XFS_ERRTAG_MAX 41 +#define XFS_ERRTAG_ATTR_LEAF_TO_NODE 41 +#define XFS_ERRTAG_MAX 42 /* * Random factors for above tags, 1 means always, 2 means 1/2 time, etc. @@ -107,5 +108,6 @@ #define XFS_RANDOM_AG_RESV_FAIL 1 #define XFS_RANDOM_LARP 1 #define XFS_RANDOM_DA_LEAF_SPLIT 1 +#define XFS_RANDOM_ATTR_LEAF_TO_NODE 1 #endif /* __XFS_ERRORTAG_H_ */ diff --git a/fs/xfs/xfs_error.c b/fs/xfs/xfs_error.c index 2aa5d4d2b30a..296faa41d81d 100644 --- a/fs/xfs/xfs_error.c +++ b/fs/xfs/xfs_error.c @@ -59,6 +59,7 @@ static unsigned int xfs_errortag_random_default[] = { XFS_RANDOM_AG_RESV_FAIL, XFS_RANDOM_LARP, XFS_RANDOM_DA_LEAF_SPLIT, + XFS_RANDOM_ATTR_LEAF_TO_NODE, }; struct xfs_errortag_attr { @@ -174,6 +175,7 @@ XFS_ERRORTAG_ATTR_RW(bmap_alloc_minlen_extent, XFS_ERRTAG_BMAP_ALLOC_MINLEN_EXTE XFS_ERRORTAG_ATTR_RW(ag_resv_fail, XFS_ERRTAG_AG_RESV_FAIL); XFS_ERRORTAG_ATTR_RW(larp, XFS_ERRTAG_LARP); XFS_ERRORTAG_ATTR_RW(da_leaf_split, XFS_ERRTAG_DA_LEAF_SPLIT); +XFS_ERRORTAG_ATTR_RW(attr_leaf_to_node, XFS_ERRTAG_ATTR_LEAF_TO_NODE); static struct attribute *xfs_errortag_attrs[] = { XFS_ERRORTAG_ATTR_LIST(noerror), @@ -217,6 +219,7 @@ static struct attribute *xfs_errortag_attrs[] = { XFS_ERRORTAG_ATTR_LIST(ag_resv_fail), XFS_ERRORTAG_ATTR_LIST(larp), XFS_ERRORTAG_ATTR_LIST(da_leaf_split), + XFS_ERRORTAG_ATTR_LIST(attr_leaf_to_node), NULL, }; ATTRIBUTE_GROUPS(xfs_errortag);