From patchwork Wed Nov 17 04:13:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12623619 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B49DDC433EF for ; Wed, 17 Nov 2021 04:13:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8DC66608FE for ; Wed, 17 Nov 2021 04:13:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232993AbhKQEQv (ORCPT ); Tue, 16 Nov 2021 23:16:51 -0500 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:44840 "EHLO mx0b-00069f02.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232453AbhKQEQv (ORCPT ); Tue, 16 Nov 2021 23:16:51 -0500 Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 1AH21H9V030389 for ; Wed, 17 Nov 2021 04:13:53 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2021-07-09; bh=i5ZjRRX0+Ag3k3QMER+6A3+XIPRF5VcX3CVx2dHGqEs=; b=G9TB70UXoJ8wxC18+3j+8D19N865yNHOn17ox95lRF/oyGUeLyRBi8MGM8HVdG8SrhJX mLUtHXv/7Gh238ad26JNxzOw/FyTtdKVa8qSGn8ewrgmqCf0rBb5zdsSxXe9egUSqWfO 9Z72bdt4gUNy5AI4PnnL59E0+b6XMn/l8S8tE4VE/b3Md4EnvoSSbihgx+KfxYFvpN3R GtMJTj5u6pmTmZUtHrqq4BqOuR9k+gxr9cLxcPqENesY4rJdU8PzZkIkOXVSN9KKPKVa EwdeTE0F/QFOkQ6o0DUrDxrlWz0ThkCeKO2kx6jO/VoP4jr3SY+M0cvH0STc/97IdDho 2w== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by mx0b-00069f02.pphosted.com with ESMTP id 3cbhmnwx0h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 17 Nov 2021 04:13:52 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 1AH4B6AP184801 for ; Wed, 17 Nov 2021 04:13:51 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2170.outbound.protection.outlook.com [104.47.55.170]) by userp3020.oracle.com with ESMTP id 3caq4tncu0-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 17 Nov 2021 04:13:51 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VdkJq/efOASjZ8WNcfU2UuCSaV7+4LnBwbR4A/SQdIzpwoKE1kOyQxMqrIrXyoLQ6h376c0/0NzBdqRFDey/FA6zYfzkRUfoIBUKceNOXUzhaXVXUy3I1fXyM8hxw+m99FLt3vowsIuikJHscLgStM7WiTDSJGkQMXncoQlCdhc+o6Hfo5RHDkYCdgWwP6qigGGBUAww1iOKY/t1ZIkoRi1Hg9F9r8/r10Z/85gWSEWDX8iVBxc+cta+2nQanBsuRQh4fS6qCvnNVKa64bj5X6Wfz8cxMurrpmgouAOqoSLMNoMo7eL44mQGpFv4qG5qB7FUSfo2y/hWqU4b+dRXcg== 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=i5ZjRRX0+Ag3k3QMER+6A3+XIPRF5VcX3CVx2dHGqEs=; b=akuKjAoDFpohO1u+JgSgwpPxoojkoUTtxTID+Xa23eRdK1yXKnMYcqCxWMr3p1amMFdUE8IrAL6nABvaAGfVjJa+2U9XxklguNX5coTCnUpM0d3OCBr3W75maQT9dh1dyiKVdjr5tsCqzxrgtiUMVvr6rvKeQacQFnq0r4VKxaN5V5Zs1HqZVo07dVeGyho5o2o0RY4fhqOAsBm8gcNYVKt53QSIgf6w9yJZGe7MKEK2Y8JyJd73RjWsGaduLxUbWdqHoRZy16mi6+R9t049CttSL9Vwlp+LpSYwyQMU2Ud1IgumhzZ1JkoJogaT/w6HwAoEyxTnaQoqrJ06psu5hQ== 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=i5ZjRRX0+Ag3k3QMER+6A3+XIPRF5VcX3CVx2dHGqEs=; b=giZ9W7BAemtjLEN+IedApmi3zRWQX8bWNlZ7aPljYkiIyBPVOJPj9Xu5HIydOMw71dpxaKyuHltqcULsEfgX8mqSuS0/0ZnTyEfwFdG1rUtiyI0vzMhzrT0h9vy9hwSX/MR4exwFIQBXBrFCZ6jPP0j+omolfYhRm3U9MPlryf8= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by BYAPR10MB4086.namprd10.prod.outlook.com (2603:10b6:a03:129::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.27; Wed, 17 Nov 2021 04:13:49 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::fdae:8a2c:bee4:9bb2]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::fdae:8a2c:bee4:9bb2%9]) with mapi id 15.20.4713.019; Wed, 17 Nov 2021 04:13:49 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v25 01/12] xfs: Fix double unlock in defer capture code Date: Tue, 16 Nov 2021 21:13:32 -0700 Message-Id: <20211117041343.3050202-2-allison.henderson@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211117041343.3050202-1-allison.henderson@oracle.com> References: <20211117041343.3050202-1-allison.henderson@oracle.com> X-ClientProxiedBy: BY5PR04CA0008.namprd04.prod.outlook.com (2603:10b6:a03:1d0::18) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 Received: from localhost.localdomain (67.1.243.157) by BY5PR04CA0008.namprd04.prod.outlook.com (2603:10b6:a03:1d0::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.27 via Frontend Transport; Wed, 17 Nov 2021 04:13:49 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 90e58bae-81b1-4d53-7b28-08d9a980a81d X-MS-TrafficTypeDiagnostic: BYAPR10MB4086: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:221; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +LO07qlLwEJSP7dWiYz5llnCbaap1MBEVeEJi5crUomu3orKmUrArw7eVhABAJ/ff0p8zj4QVEjLbKfG/Xl4tQp3afoROFz2cwzue4PU/n7ihcSf4QNntUZyusuZBrdxIei5oy5B65XGac7aCB5huDBneLHbmU8errMLnIMLdH8cfYMNrUIGX9SgUicNo0olVd4lw1ryQIPFQKM8AxtXgm7t/SYiXHXdvE1GRc+UZ6Vh7DTr2ugJsVk007ysJrmPI4RZjdEXeXziCHG4kKYrl8YqPjmRYzUnSnopjuZRmo5QaigZO2+pW0qE4Qw9fyLGjAycw4ZvTZhB1V6nxYvfedSZAziPf9UXe4D9svmWGfx7jxhfP1IY4Ab7GrstOhhXfLXIVHgYHXM3vceDNVtPqaIaFdvh6lEd4ks40SN//YILhd0S8rTWzL0jrQVWcA4ghRRSiYOtWUS3LQtDvbhbrl8rc7zZ7pQFe7jfX/lku1QNt79dBoEocmgxoU00NplHts+AQJGK97s6MITPzF6UmF36UW1e4rJMl3pYiQYgeKJ9dw+2hzw42Eoer+kAguiJMljpPgXB5vzpS/9O/dVHppX66kvpLagz9okXWfg4ybwGlPDZpW72EIW3iu0y2lCQDDWkd/wxmiFY3d4QGOGWGCxyFZQR9As9wvYia5IKP9tl6M2CbElQwteRXPhedNalIX22SC7jBJz97RbpE8Rw8w== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(36756003)(38350700002)(38100700002)(6486002)(44832011)(66556008)(8936002)(52116002)(2906002)(508600001)(5660300002)(8676002)(66476007)(6666004)(316002)(6512007)(66946007)(956004)(83380400001)(186003)(6916009)(6506007)(2616005)(26005)(86362001)(1076003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: HjVndrFjhu2fTIAOzqv3f6X9XwnbAAhkV7b2jwkPaURk0wCG0Elyv1reNhZqJkfuKfh3b9CA2IjWsHAOj451I+awtoaLn4GwVMr47WcAD94MsbTCdJlHRILX6RTNS4ZPxSrUBvchJ/qTyrWAlSMk+Ved2blUKNBaFXSq5uzppFjRCph+6UsDS6QgZpowO5+hzsZVztXRqXCevO6tLG7PCZoQ0RjiP9oENcC2K9ReXGMDhvX+OtJQoDvbVhYQKPkW+skkTIzAk8nmLA7f5orlK6N/Nqlg+QO0qtq12gTelGPcwM9hipoZNma/bfG98VacaurApydSHxeba6l/v0WDVLCAJ4xV8j84XtimOORrWFsQWcuOGKCkFRT+/fJCE2PMKmnR4VqrcrCIoqLbOaW6GwGWHPL1hHLOCRJ72DDT8/3CkYGhp+zUOM+DUTwo+sbaLXHwdEYNRYwHEG2frcmS0ZN9Epc4YhkjB+5A1KBT0F2enEdzvNI7/9rzuMCWpL7IxVcNGKBclcH6PzjURx1YXSQqBZn1Ovsa+GD3hWY7jnjgZtdXjOJMiZTHDLJ7mE91/52MVMsncS2cXrt6U0bsf9BF7Q80NJT3KLNkTV1BQTy5UGXz+KnKm+G4sPRwNC+qW37yLt17p7QsHeGDg+p85OF2iZKTqp2c3nNTHgjSGcJsB1mz0E/t4d9znhs15O+1d9rg5zJym2Lpwxwgj3Bky747IGLrNlXE3Qm70ejNnl5Sl/xvqZMov9LvhWXvGtbgKJh1v9AdLCvNeYMwaI2PsW86lJcwGAy/UUl0frUgykZ9ElNMkuM3ZgGuV92njv47+RDVdWeFUVWwnpCeWsEXA0mySfgUf/vuJKPoJ9azPUxpY8cv3yQN82mUhzv5QnCRXy/6mwKXz29Y0QlG+lEQ4JbPCBfRMgW2WWm4sDlquSojY3fyAC+QyFfbinHmoYgqSfkr6BtE6R0NQK5wgO4pHm0QRrFNrTdC2IBSLCYIQJOr16+veynm3y1T1pV4ryGVSIuCrg8XsMjIjzdoqxYefjnzzJP8XmVzias4U9k07HoboCez1h3cqbDtGCqKZLnGWaNkZTzRY+dYtvV2M5RyIRalXv0Iby1ttYYGWesLtOCtupDe9uscjM4wBhRjQhJ10ps9xAoNmNP7JjYajq7kCQcPftU1UZFtmseX36TNzuLNTFwT90Uu92BDEDYDHmY25CYLUtQgzxIU+b9VzD4Y5A8is0X8CxD9sa7pbZlAwiwjrxDEUloBYOcBxOfA3xL4kozuNfUvUZ3JyIWiDBPTzTMCAc+XhjqAg3XDNVPZtcfkFt6GxiXVNgpMFX16wGANnnS1v/TPW6B3BukrtuNQ0TfHWJC8l/yEiskUFWH9ttGo4iuuuGa7OmKCWJVW1VYKRjU0n6VxwTWyJaMd+oASyrJdUJ9RJKaZKWUZwYjYDE31kqpPtBCzrO3lqCnp6s0TcP/YgwaXjBv1LrwN3CVFEWgebKJH7c0COaQPXEnzLQsudH71+PEVDDZaSktZJsZGHuA9I1e167+35xnXxSkkkspPOk7JNlsGI16byiwUfZjq5uxYv7YYbwKmUDO6/6VXaXdKTW8xbkZDuowES36IE28ekyxrkQjq0vJpSJ3T/1UxgbltuAtHJuKm5RhMYoCgd/N1s+lGrCbOTPOQ1B2S2w== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 90e58bae-81b1-4d53-7b28-08d9a980a81d X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Nov 2021 04:13:49.2402 (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: Fr9nQv2R8BdYZLu1sCnApqVnmRhJIKbwSoADfZfTjazgg75sEpa5XDUNoSX3qGobWOuOmNSnDGdEn0zjEzJd+4ZlJ/egybKAAMJd0IWiiGs= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB4086 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10170 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 suspectscore=0 mlxscore=0 phishscore=0 bulkscore=0 mlxlogscore=999 adultscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2111170019 X-Proofpoint-ORIG-GUID: r1IqD55HttFpv1CGj4f_Rh9XOWMYKHiA X-Proofpoint-GUID: r1IqD55HttFpv1CGj4f_Rh9XOWMYKHiA 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 --- fs/xfs/libxfs/xfs_defer.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/fs/xfs/libxfs/xfs_defer.c b/fs/xfs/libxfs/xfs_defer.c index 0805ade2d300..6dac8d6b8c21 100644 --- a/fs/xfs/libxfs/xfs_defer.c +++ b/fs/xfs/libxfs/xfs_defer.c @@ -22,6 +22,7 @@ #include "xfs_refcount.h" #include "xfs_bmap.h" #include "xfs_alloc.h" +#include "xfs_buf.h" static struct kmem_cache *xfs_defer_pending_cache; @@ -774,17 +775,25 @@ xfs_defer_ops_continue( struct xfs_trans *tp, struct xfs_defer_resources *dres) { + unsigned int i; + ASSERT(tp->t_flags & XFS_TRANS_PERM_LOG_RES); ASSERT(!(tp->t_flags & XFS_TRANS_DIRTY)); - /* Lock and join the captured inode to the new transaction. */ + /* Lock the captured resources to the new transaction. */ if (dfc->dfc_held.dr_inos == 2) xfs_lock_two_inodes(dfc->dfc_held.dr_ip[0], XFS_ILOCK_EXCL, dfc->dfc_held.dr_ip[1], XFS_ILOCK_EXCL); else if (dfc->dfc_held.dr_inos == 1) xfs_ilock(dfc->dfc_held.dr_ip[0], XFS_ILOCK_EXCL); + + for (i = 0; i < dfc->dfc_held.dr_bufs; i++) + xfs_buf_lock(dfc->dfc_held.dr_bp[i]); + + /* Join the captured resources to the new transaction. */ xfs_defer_restore_resources(tp, &dfc->dfc_held); memcpy(dres, &dfc->dfc_held, sizeof(struct xfs_defer_resources)); + dres->dr_bufs = 0; /* Move captured dfops chain and state to the transaction. */ list_splice_init(&dfc->dfc_dfops, &tp->t_dfops); From patchwork Wed Nov 17 04:13:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12623623 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AD5E2C433FE for ; Wed, 17 Nov 2021 04:13:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 83CEA61A8D for ; Wed, 17 Nov 2021 04:13:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232996AbhKQEQw (ORCPT ); Tue, 16 Nov 2021 23:16:52 -0500 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:12602 "EHLO mx0a-00069f02.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232994AbhKQEQv (ORCPT ); Tue, 16 Nov 2021 23:16:51 -0500 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 1AH3CImM027666 for ; Wed, 17 Nov 2021 04:13:54 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2021-07-09; bh=ZpTsL0GDDNZIm9yYFGLwP/lj2vj5e9h1cr0Hp44p2Rk=; b=cWITsw52bmRiCnybszWP1moRarxuS2VFfmyoRzBW5d3WXTrO4IQIzHRXZz5VVRwkdJ49 G3v7yuT0RS2t+XF/2aOclF1kmKHeWrdPENwnIQ+XKA16Zgv/irgqEM8eeciN3a4Iw7Ny Y84ylOPW+HHKnYLlIsphOMtQ9wpjMdW2YP+g+TTV+78xLpa3jVa48UkVucWBrCMSQooa 7xE2DG3ycP2I4CmfIkRSo0iYX3ZmMxaT2H7pUZFJdtSt6YheQGQ/XOxzojLt4g6hsZJA sSRlPVuy7/NwrRwsH4hf6E+7hMVdwkdSGgGll9WR5aCh8okj+uQdD7ov1cSvIYerv9uE nw== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by mx0b-00069f02.pphosted.com with ESMTP id 3cbhtvvpby-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 17 Nov 2021 04:13:53 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 1AH4B6AQ184801 for ; Wed, 17 Nov 2021 04:13:52 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2170.outbound.protection.outlook.com [104.47.55.170]) by userp3020.oracle.com with ESMTP id 3caq4tncu0-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 17 Nov 2021 04:13:52 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=coO6gJlOYA+8+PbM7Q20sX0CoJpPp/7lawstmY/0M8/qOB5mbZxl+NVs9OGONFH2CPUraBiDeMbByNjKgA0gyN1uzJ0Mw7cfgMFG9trO+lXtIjQJ4ZQVZa5X+g9STNOOcVq/ahV3J9VvoZvzD7v1tnZJoNva2NsrItZ/LcpSiRvf5sqriMLmrvvyATo+larnUYASyn0x7lMoyq5PhuoT8ISBj7aVRuSga0l9Efi/VG4Ta3vur7XGD/1jk8ryrp1BifPrwUsjsaa1NtXv6dG96yO64j6mOebiujfYsYdlXZeHtdgJqnx3s/CtwTGMSILaIRFwntJ9JBW14S8po+Pz1A== 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=ZpTsL0GDDNZIm9yYFGLwP/lj2vj5e9h1cr0Hp44p2Rk=; b=kgbMI43+e+2cqQc4NgYlEw6nI7Cnl/oaJ3Z8c9y164HTAnLu0Jnevwgr6vkHcN1HMoAB+PKm6JzxdTvNdQyZTJg9dFrgAw6E5M14G/QH2Y+0FrQgAP/9jXe5Ae5b+DkjpYrkVAU50E+KBlHURoG7jn4pv/1zKsmhPsHR0Cu/1IJx1Psx9WQpUiB2v7ntGxQMt1sOLlrY/Vi2NtnNPpmNBtq+DXBf+MboPfiFhV1pZsgU+zi/Jm0qZE4vJkzs2hxbDFXP220HraZy3qzRetN2jwjkC+mrkTYIftwQu9WiCxBDpXsdu3gtJc02jkPq2Qd9gSwDNiBrfIytR6I1Ea/qhg== 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=ZpTsL0GDDNZIm9yYFGLwP/lj2vj5e9h1cr0Hp44p2Rk=; b=ePQyGxsLNE63KaKxrUPrMJbBob+ehBBZZ61MsyZXmJ9+qlSbjxePiil0z78jHWCRC21V0innyKE2D9dR1G9JLeGKoLEsFRnszTNTDOpB++5QzOcidSrPnSvYgi/ouTTb8YEn/CjZ6asrrSOWDvDi1tcCGB5elxp58On6+eFVnEA= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by BYAPR10MB4086.namprd10.prod.outlook.com (2603:10b6:a03:129::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.27; Wed, 17 Nov 2021 04:13:49 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::fdae:8a2c:bee4:9bb2]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::fdae:8a2c:bee4:9bb2%9]) with mapi id 15.20.4713.019; Wed, 17 Nov 2021 04:13:49 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v25 02/12] xfs: don't commit the first deferred transaction without intents Date: Tue, 16 Nov 2021 21:13:33 -0700 Message-Id: <20211117041343.3050202-3-allison.henderson@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211117041343.3050202-1-allison.henderson@oracle.com> References: <20211117041343.3050202-1-allison.henderson@oracle.com> X-ClientProxiedBy: BY5PR04CA0008.namprd04.prod.outlook.com (2603:10b6:a03:1d0::18) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 Received: from localhost.localdomain (67.1.243.157) by BY5PR04CA0008.namprd04.prod.outlook.com (2603:10b6:a03:1d0::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.27 via Frontend Transport; Wed, 17 Nov 2021 04:13:49 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 33af9f1f-2f35-46e0-7ce8-08d9a980a84d X-MS-TrafficTypeDiagnostic: BYAPR10MB4086: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1923; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: h5ud0s+VQVQrlZetnL0I9NsJmdOQj8uDyWKc9hU0Awts/8GDROWLz6f4yT2ykKsS31H1pXEGCFPUBW6HDR0F9SHzIxanBSF6kFn7LJUDv5YNxrl0ICfzC9FbKMPLnohikWfnc0ov0AGFA5IgD8j8a4kLBvGLUsyWkq8jtSS3RaJlKKqrh7/AwFPKlw0kFX6QTRgTb/wjnTGlWRx43zbm5akPRSWvIM3CAUOkNO/CNRjuOAbUxr1Z2pblXr8bXiZBlKpJUVlKkEubOBHTSfF8dkCJweHPa6B4W/T+HhP3i7RyLOI4HGFo21vmm0QcojGVYy52pATWzcsRZq3UDobXvT66Edr3IZcB824yvmdOZIv3Ca3LKpbgfXAaDnnaqtoKFtANJOLr8iCJjzkjze7zefQ6Ojif4W52UZlbeut/6A86TqUYcyXHMV0k3F9oszm6t79xgBUA/iKcdacJB2Yz6UIZ2qSl3IZ0VPOHSqihajfTCXrAJ2Gt2K7S9DB+Ip1KczhgIIcYejdYn4fBw10FwU+sZQuZqDenmGxX52xWqvV+JZoZNnHUPRWHXGkmqMPHup/X0ZPL7H5oyTnGJH/igPLnZ+96AFzUAlhZgI1MyA9io1ZT0PC5p8xTlzTmJNCtna8lxVPHVLsVtl/EzOcpr2q5guSGUXOLrcmJ+4mSpOr3KJKyVZn+2xl9tci5MRMAHExY+j1SFTrzSAiCt63o8g== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(36756003)(38350700002)(38100700002)(6486002)(44832011)(66556008)(8936002)(52116002)(2906002)(508600001)(5660300002)(8676002)(66476007)(6666004)(316002)(6512007)(66946007)(956004)(83380400001)(186003)(6916009)(6506007)(2616005)(26005)(86362001)(1076003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 18SPkStiwoWUqW5usm+ZOkI3kWfzaOg/CsLPXJTAn0PVALUHwDcdn4LNv4fdPK543GOgkFrDkr7F21bAhClo+MDKii98MNbTHCaQFL5gqReLHr18V4xUFlM7TR4eULZNLQrm1PYpDkS9tmBOBrBpKpCP0A5cFWjAcKKtL+g0tfcHThhKZHIt5RN+W0S3ZwVH4hi+m13iC1LYsuVuSUBw4oSo1wl8OMiJQNf3YPFNc/dDdQVlo99kmmcWHjfSTPmWO+MVuZWU+vjbXs35I+2SuuQPUeGoRsExk0122tLU1ozlg3RRDXDwN8hFnP9YXSq+TmyewZJ2bIkGiYhk5zAq70UiU1KknQMGdsteXDhiRmt2I4hbq63/d0dfNepk6cUyd5OUDVKxP2B4QxGqqFIcKuCI//EWMum8dP1xirEYPTdByLRka+tX+CgPbbtp7ILlw0GTnVuOonISbsx/i//YSGR/ZiOMU0OJEewTn6FPq/lZomTUP4D52cjrqTJkgZCRYqzbAWFhYRMJIRG6cQE3fzlvAb/3megw7n+jD4Mowl0Ye+XdcjXSXgqEWSMhqK2pbTCYHdIR7fQ3iHO1/keEGd7QYMxtK86TJbVtq6vfoNZHotq8cqX41VAA1NtE8jlOKognwEn2cqpiCu4uXB2yo3XuzeEDIqRwRyoYQNOOyg4Oi1X2buqxt37ZKFQaBr7Vv+rsompUemb8HJlCq1dFFz5IR116pnTFZbuKfKvDB9MVwpFV7lFVEoniNZaDYARwRKkoGvwfr7qv5Y5Wywz2XTc70NHgZAFILRzHklTDoLxA7fHgwQ/qBwWrWbH23b1zAjJhVeBNAuN6mTWtcGO4+lFp/qPX4ySMl/SfASSMRXzAunUNm4Tv2lknx2Ck4/KGaLJ2GC6h7KKLVE5vV3Xl+276cV5LCbjAOoUrvKB+J/wYUZ2rutl0Md88AfN5w5bJqSLj5/B/DMhI1d8ZvuzgoBcTtNRJJLQcfBIjgz/RlG5lFNFmkpI6Awfci0Ze8a2JbF0KGO8AerxXviDKGhKXiY6h6UWbdCdO2kZ9FRpIBKkE9GASemnAc3CTEFixMeuv8mOPRIjXTF8LzZ8y2BtG9ad0sAl8w0NyzFvSL4G+Hwo+YoPH65h2ABYRKO28u0JPJKvNIsxDLxIcSuz7nMuje7rLNGHb48FYVlInwz14PKE93T9X9zJGn6XNQ0XAUXjebqjmrd9BrL5sQZJqlHpUbTFSgUeJOWW04Tx/2E3hrAJHUSOjYaOSTi0yw0FAMRzSxdNy8eaQoNk8mGENoMIigLQXk5GVoP2BrcASDHP0FD+Of80o01uXr9LowSRhgmaW9rr5hcUtGi+RB0FBKTIkeuJWNHmZdnLfs1783nsL7PSghkgchecYeQbukqswnnjHZTednEfs9xlGngzZ5aysiW6iH9aM4/vxRRBr50pPbdEZZ44R77k38hW5sKVZyXAnE/z1M9K/r55fkEYHdlnaDCFiQq7hGNH82Uv+W0jsRrrlPlkPLb162OPe42buTFrFn/zpIYxGkmNTvbsUx3Zl6eory2dKYnUXxY6bWKi77DZT0BdjB2FPrPBRlIjUR0UYDdz8vMCqZ76fw9uSfyOFxwa8ObdLYBcnKYI1nLRFT6Lif3AkUkBGYFz4aOeglU+NG1C3gXEpJtIeF9gZB3lvow== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 33af9f1f-2f35-46e0-7ce8-08d9a980a84d X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Nov 2021 04:13:49.5389 (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: oYr2BCfiU4aGC3SaYVgmcXnQAc+SmE99YdUJ1sAA8TbQjkPv2FnguW0rgmhJwq92z24h+ORc2o7W7XHV6DbE6twLvwu1h+tk9b/ytrrRfOI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB4086 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10170 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 suspectscore=0 mlxscore=0 phishscore=0 bulkscore=0 mlxlogscore=999 adultscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2111170019 X-Proofpoint-GUID: TiS3DHwFmh-9xoXlL2Ib1kc0vzWR2Ug2 X-Proofpoint-ORIG-GUID: TiS3DHwFmh-9xoXlL2Ib1kc0vzWR2Ug2 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 --- fs/xfs/libxfs/xfs_defer.c | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/fs/xfs/libxfs/xfs_defer.c b/fs/xfs/libxfs/xfs_defer.c index 6dac8d6b8c21..51574f0371b5 100644 --- a/fs/xfs/libxfs/xfs_defer.c +++ b/fs/xfs/libxfs/xfs_defer.c @@ -187,7 +187,7 @@ static const struct xfs_defer_op_type *defer_op_types[] = { [XFS_DEFER_OPS_TYPE_AGFL_FREE] = &xfs_agfl_free_defer_type, }; -static void +static bool xfs_defer_create_intent( struct xfs_trans *tp, struct xfs_defer_pending *dfp, @@ -198,6 +198,7 @@ xfs_defer_create_intent( if (!dfp->dfp_intent) dfp->dfp_intent = ops->create_intent(tp, &dfp->dfp_work, dfp->dfp_count, sort); + return dfp->dfp_intent; } /* @@ -205,16 +206,18 @@ xfs_defer_create_intent( * associated extents, then add the entire intake list to the end of * the pending list. */ -STATIC void +STATIC bool xfs_defer_create_intents( struct xfs_trans *tp) { struct xfs_defer_pending *dfp; + bool ret = false; list_for_each_entry(dfp, &tp->t_dfops, dfp_list) { trace_xfs_defer_create_intent(tp->t_mountp, dfp); - xfs_defer_create_intent(tp, dfp, true); + ret |= xfs_defer_create_intent(tp, dfp, true); } + return ret; } /* Abort all the intents that were committed. */ @@ -488,7 +491,7 @@ int xfs_defer_finish_noroll( struct xfs_trans **tp) { - struct xfs_defer_pending *dfp; + struct xfs_defer_pending *dfp = NULL; int error = 0; LIST_HEAD(dop_pending); @@ -507,17 +510,19 @@ xfs_defer_finish_noroll( * of time that any one intent item can stick around in memory, * pinning the log tail. */ - xfs_defer_create_intents(*tp); + bool has_intents = xfs_defer_create_intents(*tp); list_splice_init(&(*tp)->t_dfops, &dop_pending); - error = xfs_defer_trans_roll(tp); - if (error) - goto out_shutdown; + if (has_intents || dfp) { + 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); - if (error) - goto out_shutdown; + /* Possibly relog intent items to keep the log moving. */ + error = xfs_defer_relog(tp, &dop_pending); + if (error) + goto out_shutdown; + } dfp = list_first_entry(&dop_pending, struct xfs_defer_pending, dfp_list); From patchwork Wed Nov 17 04:13:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12623625 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 903DBC433EF for ; Wed, 17 Nov 2021 04:13:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6C8D461501 for ; Wed, 17 Nov 2021 04:13:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233001AbhKQEQx (ORCPT ); Tue, 16 Nov 2021 23:16:53 -0500 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:13450 "EHLO mx0a-00069f02.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230088AbhKQEQw (ORCPT ); Tue, 16 Nov 2021 23:16:52 -0500 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 1AH3CImN027666 for ; Wed, 17 Nov 2021 04:13:54 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2021-07-09; bh=ncy9fIfoR8J9ug74+k59S/EA8Vjw7S1DvrQfkF0MIug=; b=vmRzpIUIbiykryk5azjGhyBEV4LBc6FH37/nQGfROKG0zcEomRnnEc7bGitjw7YFlWk/ Z+xSOf5U1PhWX5+Gnd5ikVS7ZpcjNaQ6T3OYQTaQVtuouMjrXxV+yUsQ4lmUU9606qxL zq7NLX4rktWTc4BnmpuVBaQ3XiYvbpWLLyVSuf/FJ9Mv7ufuBmO5AgYHnwPiy+HZhRiD 1iSiOsSI+f0vxTTll8kOtVNq3tPsdqECxQPAkpOWKYwwv03H1hQTXdouSlxQgopfXa3X 4owXGrhGJIo0RCSSzpmeZ2FkPQ+SIbUK6lKAf4mUHeRW8QwxFpAEAj3Psnmj385DGHf8 aA== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by mx0b-00069f02.pphosted.com with ESMTP id 3cbhtvvpc0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 17 Nov 2021 04:13:54 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 1AH4B6AR184801 for ; Wed, 17 Nov 2021 04:13:52 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2170.outbound.protection.outlook.com [104.47.55.170]) by userp3020.oracle.com with ESMTP id 3caq4tncu0-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 17 Nov 2021 04:13:52 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZOVNowdYqpGIR92bTPDKypnDJ3jXnM4dvKl2WceqYPMxAJa/ZUdYp20NfqNpUYHPYgGXkJcwZy2PiRltXglotlDgNWAJOXkLWhwYryfZi3YrGabjJa5m/4GGO/i8ohmwDSZq2TvdufLolqp5LrX8kh2CBdqslSNA8aENplJmwgUgPwJqAUMiejd5wFZEkl7D/Qak6mCW1IltuEdHCaTS2K287mo5y05Ki0vaABW/sB1WVuXA+HCJv9BlY8PU7FZdCH1a3IiQRmzbZsZEm/h3sQSEPtiSiFEY9XA1Bm4Qdc01HpQmnFLERVwtMtmcwJr6FSmBkEl4v9jgbItjoRPDhw== 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=ncy9fIfoR8J9ug74+k59S/EA8Vjw7S1DvrQfkF0MIug=; b=g4b02llnQgrgxXQa4/WSjk6F4/asU/0Zr57s27F4gX5i1BlFEkx+B18lPy0yVHeGClcLL6mAG+K3LH3nerdAx43GCMDf8Iz/zhu8mvVPEAaDJ4Qb8K6egTEMfUAAk/k7Qn3tDA9NzQ1K/aPG/u27RSK9MioPcPq8vSsHbQxHha7otl2D6tUWvWRe7kbFinveeAIB4115fi0MxCLvmKUsQXm2/RS1b92evwoettyQoyCMjwfcKGnPDbTIVIFpq4o22jpZlA5Ao2P7CTHINWLmYzJD2/MHdyTDOjRX+8vmSS6rZtYzkwGHxR/huPQJQuBCpPjIvURqklSItugjVbYDoQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ncy9fIfoR8J9ug74+k59S/EA8Vjw7S1DvrQfkF0MIug=; b=bQaEtQXgmNzC4yvIl9Bfj8GqocOI+zjvgN1+6pXjbdqDj5Ujt9XyWWHCsr5IQEVVnr6AuamB58NOZcOwPDSIQf5lp9/M5cqa+h+ExDNH0QqYesj5MFDCtO0TVoy89jlhVgoDQRY79G5dKJHMZmPGKTi5bGbMrG5HYS8oZcYTvXo= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by BYAPR10MB4086.namprd10.prod.outlook.com (2603:10b6:a03:129::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.27; Wed, 17 Nov 2021 04:13:49 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::fdae:8a2c:bee4:9bb2]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::fdae:8a2c:bee4:9bb2%9]) with mapi id 15.20.4713.019; Wed, 17 Nov 2021 04:13:49 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v25 03/12] xfs: Return from xfs_attr_set_iter if there are no more rmtblks to process Date: Tue, 16 Nov 2021 21:13:34 -0700 Message-Id: <20211117041343.3050202-4-allison.henderson@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211117041343.3050202-1-allison.henderson@oracle.com> References: <20211117041343.3050202-1-allison.henderson@oracle.com> X-ClientProxiedBy: BY5PR04CA0008.namprd04.prod.outlook.com (2603:10b6:a03:1d0::18) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 Received: from localhost.localdomain (67.1.243.157) by BY5PR04CA0008.namprd04.prod.outlook.com (2603:10b6:a03:1d0::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.27 via Frontend Transport; Wed, 17 Nov 2021 04:13:49 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ae8408a4-3057-4594-9bd3-08d9a980a87a X-MS-TrafficTypeDiagnostic: BYAPR10MB4086: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: WPKU/rfFmEmTHAR4JZ9yyz+MKjGuuSbGWvy/fGMmsu+Fhe9BhPTCQniiaynkQDH7DRQJm8jK3KoEcyLHQTt2uWACeGsBOd7bMizJaOMT9RXnfBcoK1g5Jnyn+dMO/Jndoguq3xFfgLGsZQzFO+jLWgTzMdyflzrNqRtZGF2b0tE5HBpTe3of/iHe6jnc0B0bUPiMNektdvdKAg4ounjVNzQRET2X9Zd0XlU9afSpMQ+LMdeHzG427+Uf+Q9HmNZcCs52O/SqFI/yK4JCuykXZ2fgbEhHhHxFQkAeeHx3V23s3MxXG06IgtUQOeyTN0dM2CjE4noCcpfckHpBYA9KnaxVaeDflS82n29Tv/68zID3IgjA50fWmVccq4qRS1hrmDPQ1M63I/javwMNJpdlZk2z4bn8PrhKwJb7ZOe01qIpDo7rN50i7/ii+CUHjMEju2hznpSDyfHTxwq4lk2CeF/jS5vKDuuFNzhc4jKUU/CcUOBJ+MZ1WIKoNoDQTwoDmkoS/feMF2NVLIUTmTxDKBGAp7OA8E/fUStn/YONM24f7JNfaOCgZ37DTwZVSTejU/rbaycN24v06RmZKizMWmEyn51ZwDj8tyxZ6soTgDQxYnMGFL8zlltyqjslJ+62+Go/IVzhjLn5mvuSlEOQRjhqJwWo/eBNryoOTW4r/FdEaTPeDvCDjlPurLj4la/AFjH0uvxhZW5m4NlaVLHgJmxTbj/22Afv0s7POR//wiwTcvrgU0fKVJWGJoOjtf6LLqk8COcCBi+snp0GbTnHemnkV85xduGvI+H+dS1pXTk= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(36756003)(38350700002)(38100700002)(6486002)(44832011)(66556008)(8936002)(52116002)(2906002)(508600001)(5660300002)(8676002)(66476007)(6666004)(316002)(6512007)(66946007)(956004)(83380400001)(186003)(6916009)(6506007)(2616005)(26005)(86362001)(1076003)(29513003)(40753002)(133343001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: uykQkhq3H7FZRD2HINOU4XfTCMRUjAIWCy32xkYjrUNXqNVDGoniY7H3e9S57nMPlmFAsJ9zwkjr06Vd+VM7YOK70nk2d3jh225hKKgmalrHNF1Sd9OUopRjUY/atHO3j7PRLMvYBXQA6ei560sQP4v8RuK4kdiQg0EDP1Vso9atGhbdqAYzHUWNkYI7B4S/Z6SOGuSoQocYEdHYN9NOBeJb/dvVPB934hYd3JrQMiUevaZKQ2K9Z8zhbMr/qIskyiw6MUlNzLZPrnTtSijhLDmbeDgK2ovMMlnOWMvIsTt+TUCNpJCvHkVpH7BqTjmKANaxh7PiL/wUkg1KZLUBvHN3Z6Fa+oFaMBPXfwJf2lFTIRnilQwF8LYDa+2b4oKzSI2tHa1Mg1/s4chTrZ6Q5mUmvTqoYg8stE2fvwtbx0wRpJxsbD9Xugtq1JBDIaJN6qlbr5rkoizQ9w0cic0v82NexHpWnYI91k9ssvAA5cqd+3iUP7zjOd0RQUKVmDg9oICRVAR1XUTOYMwqWJeuR1vBkal7QvHSHPAiv6fjv8ivzqiJFoaD7VnXiE64MdI4PnAyAIFxUZSs5lEdZR16UYk/1XaKAo0qjomXuMz47Advder43/S7pt7SLH9WZeOmQrTY0MH6hoKwaA4d9I6OusnvW3yXn+vkVK79JuYPIy3wLARd65nzpXpfKUigOJQgID1bw5T+jiZpQHVMVhlXAr3M/2xC5vu7lU4xFqF6WmeGFgif8RiJHpH0I2Ed7vL8my0sZCjcN07E+gJ4/mD52VarebZfr53di4wisihfMCmjpCm/fmmkDzGPbp2iXmAHfgePuys88+fLteAzlsiXXB5YszXF1XR2BzYKWRjLWZlJHpIrFI45OLIfVKPDPpZXRNrtGso3Aeev7QlfCcoO+UQH8y+kY0uvLiVSNyyYKkXGChhK1q7ImNszdcl2N3vCpOO3i4Ka510O3IMnUvVsj53jfEQZXtkS2mtMrbpy4BOlFFWH4KsQBFmhqGLCHrzU0jWWHYBPe/UuoRoH49GQ3FoaW9fGl48cz97JfrQH0ABk8677dlAmmGXEcdCMdepBggFK3BsMBF+k5JqGqEJfOA2eGMxDDhksJx7T1KGChj3C8PjpLH2NR+ItpiT2RvWKWzOOXSAlB1HmkWBpkAlOmwKHHRlbU6Z/h2c2mXbYgk8awWCgRw5iCZXihtN+y43HzRg2x0zljZXfcQfwl5aykCZxLO71TZF1/j0IsYBIr4z4hdlHEnxA08wOtAeIFHghtw+3VyEnMq7KYwRs4NQkJu6+X3smEC4YA0zca2bfCd7YPICpnzUO5btkODQTFezYxZE9nAZQvGTxEU49mnlbLHWY9k1Z+M99m8FvMkS8azJjMAEQ+fIwo6/oF4F88dRNbhVHqASzcJjRzMiWImB179A5/uBA3Q0+mec+bNw0DwJ/hqsrlhcLY+M9Z1/dJcBS5e/rsVDUv5k7iV827JZtO8knarxGVbvFTitXBvVrC0VliHK3JCuen7JIh44t13JFVSNDxbdRYyMJeT8c0oTBn5SJIQOb8CULjRGGkmVbj6Jx/6YuPGtSl6k+dqfCXiSMVY/+A6gcCvAVBIfTHjldvxxi73wUjjDNND435g0WYrjl7zcRcRYRcFbW8IVeynlVFF5iuXQ0dd9bjDH59O1hCg== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: ae8408a4-3057-4594-9bd3-08d9a980a87a X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Nov 2021 04:13:49.8246 (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: Kpv4xMTDsYqQGoj8BqsP/06Mu/fi9OLChz5W+G3iYo1CeVKW8qH+yCYYo5E+bvf3HEHu86S6UAf8p/MDkvvUJiWPD8s7sVxvTuOwp8MPom0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB4086 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10170 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 suspectscore=0 mlxscore=0 phishscore=0 bulkscore=0 mlxlogscore=999 adultscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2111170019 X-Proofpoint-GUID: k1deemM2DHaPmdbAqKUluD-C3kUfFcZF X-Proofpoint-ORIG-GUID: k1deemM2DHaPmdbAqKUluD-C3kUfFcZF Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org During an attr rename operation, blocks are saved for later removal as rmtblkno2. The rmtblkno is used in the case of needing to alloc more blocks if not enough were available. However, in the case that no further blocks need to be added or removed, we can return as soon as xfs_attr_node_addname completes, rather than rolling the transaction with an -EAGAIN return. This extra loop does not hurt anything right now, but it will be a problem later when we get into log items because we end up with an empty log transaction. So, add a simple check to cut out the unneeded iteration. Signed-off-by: Allison Henderson Reviewed-by: Chandan Babu R Reviewed-by: Darrick J. Wong --- fs/xfs/libxfs/xfs_attr.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c index fbc9d816882c..50b91b4461e7 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -412,6 +412,14 @@ xfs_attr_set_iter( if (error) return error; + /* + * If addname was successful, and we dont need to alloc + * or remove anymore blks, we're done. + */ + if (!args->rmtblkno && + !(args->op_flags & XFS_DA_OP_RENAME)) + return 0; + dac->dela_state = XFS_DAS_FOUND_NBLK; } trace_xfs_attr_set_iter_return(dac->dela_state, args->dp); From patchwork Wed Nov 17 04:13:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12623629 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C0A5EC433F5 for ; Wed, 17 Nov 2021 04:13:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A131161501 for ; Wed, 17 Nov 2021 04:13:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233003AbhKQEQz (ORCPT ); Tue, 16 Nov 2021 23:16:55 -0500 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:14266 "EHLO mx0a-00069f02.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233000AbhKQEQx (ORCPT ); Tue, 16 Nov 2021 23:16:53 -0500 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 1AH3Qt8F027682 for ; Wed, 17 Nov 2021 04:13:55 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2021-07-09; bh=nL+wZI8eQoeLloImocJsxRIqG/2uxmxJt4kO/MK692o=; b=JoDqEQe4oNB8cqcZZ9/CEdNbjusgOBncdRLUYvYUfFf9umzgU+mkkcVZT94Ncj5HdLs2 fU7zvyNw6fqwQAvCseJrhknKy2ziFnKGiYGw7NOKRQjYc8+IiPZ7d39UR6a+gaJMjJ9E y2MvTxBWgYALRs3MNPATE5wh2n4P0a0v/iFYMBfM8lasVvAmjn2/ba1SdUcHEHzRNN3W w5tJ9YFQ3gJMWEiyzUMEe+ZpLAUyeeO8JYOvJhtiH9GtNY8gFmtzdF11KXOUgEc9iXh/ 7iuMmWb+IRYOZK+CnEZQK4P8oLCfHjdjULKMWUbEvmoTGRB8zDROXlwAjsnXIfWBom9Q Ww== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by mx0b-00069f02.pphosted.com with ESMTP id 3cbhtvvpc1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 17 Nov 2021 04:13:54 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 1AH4B6AS184801 for ; Wed, 17 Nov 2021 04:13:53 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2170.outbound.protection.outlook.com [104.47.55.170]) by userp3020.oracle.com with ESMTP id 3caq4tncu0-5 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 17 Nov 2021 04:13:53 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=G6XRikqeRoLOdWWtB0CWOWKhzVKrWUBemS+088W2KyGDzdCmvTNiSRFEpTWnIBXEkh7CJoApq3bGwQptfDhZduChCVEzKNMSQebjYqDwl0tKoFRHWLNQ7I0xlL32DmxNISR5ofF51yRYDI8evZOy0thO20sjCvHmFpedaZVcZLMvwF+09YKGl8zRzGYX7Aqs8m3ORY6iDhBOkRr7JAV1+V8ulVyzySD1C8K+/pLuU3a2rNizAtl+RHpG40oHtcHXp3A4Wnc3UfRPmmzyg9050l3tYQ4Ow3PhZlGOxg43asEzZ8l8GpN4xKzWJewfWqVZdg1eezaIXPpMZ5WfQ9EXag== 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=nL+wZI8eQoeLloImocJsxRIqG/2uxmxJt4kO/MK692o=; b=GE02IpmgiUT4xooEPYX89KIleid4FPpE9wfsoJPujNC6x2xVBvwnssRi41G/tHkIvoarSgvQYBcR/0VPH6Cbigi+U/lrwT4la9GF2yrRjP/OYTjnwGDKvhd01XY1kL4ACoeFF+lD3hciVTup+EvHKVyBmskSQiAqMjrhTkpxJ9XI2q/UXD+aIBzU8//cO93bTDRweNclAFiRIx6L6kTM9rTsVtCu6+iJKwyyKqv7KhIPiPb/GhL2gj/K6F3Yfp8qxWgXE7SCHN4T39ee1k1GCf3aGjfBzMJTLvVvdcDRSZf7qeEHdRttfixyfq8vbsxwkes2RL2aHBsRfq8nInfCUw== 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=nL+wZI8eQoeLloImocJsxRIqG/2uxmxJt4kO/MK692o=; b=nbuM5lGczuSejB1uQi+podsBtej9rZvkhEtOFKvlCJvZTtTXBbM2GoKFEWzdu2wbfC1LoHMmvXWLBwIPQZMIrsjcAexIRrcPGkvXK7InHxCZBGZygWHUlfkbnFLN0czrpS4jlD01Ke7dBFIomnVSqqn8dQBUJOPB3Z8tapnnABo= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by BYAPR10MB4086.namprd10.prod.outlook.com (2603:10b6:a03:129::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.27; Wed, 17 Nov 2021 04:13:50 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::fdae:8a2c:bee4:9bb2]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::fdae:8a2c:bee4:9bb2%9]) with mapi id 15.20.4713.019; Wed, 17 Nov 2021 04:13:50 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v25 04/12] xfs: Set up infrastructure for log attribute replay Date: Tue, 16 Nov 2021 21:13:35 -0700 Message-Id: <20211117041343.3050202-5-allison.henderson@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211117041343.3050202-1-allison.henderson@oracle.com> References: <20211117041343.3050202-1-allison.henderson@oracle.com> X-ClientProxiedBy: BY5PR04CA0008.namprd04.prod.outlook.com (2603:10b6:a03:1d0::18) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 Received: from localhost.localdomain (67.1.243.157) by BY5PR04CA0008.namprd04.prod.outlook.com (2603:10b6:a03:1d0::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.27 via Frontend Transport; Wed, 17 Nov 2021 04:13:50 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f8b14858-c880-4389-8a77-08d9a980a8b0 X-MS-TrafficTypeDiagnostic: BYAPR10MB4086: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2hSGNdohBz57guLjE32t/jFvdP1195VkR2uUjmnVUYfG+Zrk3EM5FtmdR4z8b9EHSWfyWcxAbWSuXaEPp6gFSE++AtmZre9c5kgrY+cyvFLjSM366klp+eP3zCwtdE0GpnNzdrRC3dTXtgmuS/pdGTpwHRZDUFMtg9TQqDuBmsotAO7au2I/XEMJDCllTq5qNUcXPJFJdMIgSup1XzwVFIgCRMcaZVK1qTtOECQ54p7HjOE+a8uvyg1lXrMAGQeDcOXw6y/59Jd2YQVobsUfMrLbEOislcSvfRKjC5LrPzZhUP0k05jMDZtKPyrqMYnDLMSy0AZCWWgWM/fXT7RF2K2urqYUJs6dELGmwC6P2DrQkFLOPfRZSGlyizIhpduwjB/TdG4wbG8/rI7MZDo5gGBP07OpIh6s/3RdfQwgsCEQRPgXOULHV2kl88zVibYVI7LopMT4Q69d7JEwi349jdwq3iLCA4lpqfnmDS4sSWL4tz3nsZq7GcvSH7yvP7Xm4B/IklGvqwq8cGOJHw9pSI7g1IHdfiGFhY48pDBee5q66jRJYyU51JywsSqn0Fm6/ffuRbRfskYGxnWq+WB5lzht8Xs6uuW3jsaQkr1Wc586THBMorFybC6v5cXTPz7Ha9cIQtnQE5Lvt47N77XkTtE16knzpelXxRCb8QLsYv9C5YmZkx7s8qIVFMk0kE2Cxz/phr8VXTN7c1fS2OBuHg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(36756003)(38350700002)(38100700002)(6486002)(44832011)(66556008)(8936002)(52116002)(2906002)(508600001)(5660300002)(8676002)(66476007)(6666004)(316002)(6512007)(66946007)(956004)(83380400001)(186003)(6916009)(30864003)(6506007)(2616005)(26005)(86362001)(1076003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: MWIneyueBfzv8kJW5/+idiFO5aVe2TLLshUXBLBFIlP261pC0KZFdndm/DiNpojYsbQTxjpRsPpjr6TgDU+vcFwhF3rKJy47fygv8I5UXk4swfNU0hBKHKPoAvxSxU7qCAtLB/gW2F1KEJB/6a0kZ9uarN7uUQyzujvDmkashXkycmU4or72eBA0WmT6H3U3VBaz3tPTFbvq0GZFvrQ6mM1hxalvUEnyLU1EH1T0vrs9ZuQzTNQoKm8isUxAybOfCwUxf1rKtbJLrAll9fVTDIsMVzMQbASJ5eHi8osVhbUC5B5eVuZHk4hqL9PpfPxcEllRfhws+Y00HqRe49YFXkLOXZ2Vm46ryQ0bb2nfvRZxOTKwsUh4DYxJxfdK1MFOTJcxIa85TbAdf12bRydL5Q+IV4ZpmfaspnqqtvgLTqmjE/+hfAIlRacbXkrpzQXgrYJtSundorGVpAA5D2/XBwzcmeAwi4pfpgjnlJmf3TbBzNK4bE4LuynxLsL57XKGXeaP87EyVTE7F8Df1QomtamGHrTWChP+lyg2VABBsEHIcAeswFHI6950iMg8ZEiTWKGvRVQDBtGLSy+o6r+wDZ99qcCO6MFbHog76149u9+v9nMOiAo20tOSKCoD7MA3MgJzhtpZfCEfgQA3FnURuw7hu6gfuXmOjqvO88ivABoKBOTsNKtJlvvbtcEHdjs26Ep88YtcwCwRolgpuQDoT50ZifcJUDm5gmSZ5EFaApPiNdvDBE90UJYb0UBj3NPAVHhckSQIMKXRrKAx2Z5r/U4LfZdAUU808rfsPiHAbke4YDIFFLkxPDe8irxTtGm0Jn6HYk5I0HpfT6mGG2cBKpXPDS3y0ZagXQ3+vxndksEHfkMO1kbYqFgc0m2zbmFHHQGN4NdzUxkNriToSBuplpjyomn5QnIS+zmkkEb6MwLCJul6ItIdGiOHIej8J0q6AT1cpsS0yvSITmgs46s+8izDTie/z7CKZGgydM+jXLntXh0k1Ep5wzdCo+TdpR7A4n9L1fJ2T0iXNB1HfWPw0A3WJY8GsgK1IRJ2oV7DIq3eiWXW0PvwhwrQT9nSv1NeNvbKRcSFykDMzBucnyY5pcJSU5l7Upcpdb2VsDAvq7UVLrIdr/jfwUQJlB/6D6HG3S+ZcCAcYr24BWizLAQrWh55FaofuU5QOAqMteydRN7+HREO82cGSDfH4o6Gzu+ThpPCjAxz94kWiA443NUscP/PZrdDUu9RRVByYbkUAmHpKjWdR3UYQSYgyQvdbWM3GdIodHLgJjx0nP6W/4Mk2I71DoZT1ckuoTcMb/K4CESRDnIyfnl03hmr8lfKkvc9qzmHG1xQ8ka+tmswGpks7JsGi2JdUA5hb/PIFG3fIZj+1DsxrV5Bwma8lOFSATGZlmvaxX3GejInaME0xU6quSrxCbIHmXK8CPJK44gBwQM5FLgwXu7XcyLVCdQe7EVBp83HS+TiQYQtVXBkWVwvw4I3ZvJGb1hANGlMNZbQ0ZGtkgeuOK785TKLEi7/tjGueOlDgBjyh2CIv4Ca+zETesuLlVM17/gh0NDFmAAIs0BIijxkzT2pyf8F1EaBl0S3D4dCxM+k1C9XglxlOdraamWhTwlgm1TF47egWfeo5oBxvMfbVWYw4KlRAmcjDGG2mQtjiuGOiWuLi+7oShfDPg== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: f8b14858-c880-4389-8a77-08d9a980a8b0 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Nov 2021 04:13:50.2338 (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: a8jA/IqdZTcHO12jVI31CgXBt7X5l68mcUIlnfCx8D28PheyUH2qALWhvJzg2W9RQAidtyUCwV/EE95vllEd1qRrgA8MMNvx0ml0ijbRMLc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB4086 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10170 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 suspectscore=0 mlxscore=0 phishscore=0 bulkscore=0 mlxlogscore=999 adultscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2111170019 X-Proofpoint-GUID: _8tAPwbjOT96v38_pRD_Zpqv01lIlI-X X-Proofpoint-ORIG-GUID: _8tAPwbjOT96v38_pRD_Zpqv01lIlI-X Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org Currently attributes are modified directly across one or more transactions. But they are not logged or replayed in the event of an error. The goal of log attr replay is to enable logging and replaying of attribute operations using the existing delayed operations infrastructure. This will later enable the attributes to become part of larger multi part operations that also must first be recorded to the log. This is mostly of interest in the scheme of parent pointers which would need to maintain an attribute containing parent inode information any time an inode is moved, created, or removed. Parent pointers would then be of interest to any feature that would need to quickly derive an inode path from the mount point. Online scrub, nfs lookups and fs grow or shrink operations are all features that could take advantage of this. This patch adds two new log item types for setting or removing attributes as deferred operations. The xfs_attri_log_item will log an intent to set or remove an attribute. The corresponding xfs_attrd_log_item holds a reference to the xfs_attri_log_item and is freed once the transaction is done. Both log items use a generic xfs_attr_log_format structure that contains the attribute name, value, flags, inode, and an op_flag that indicates if the operations is a set or remove. Signed-off-by: Allison Henderson Reviewed-by: Chandan Babu R --- fs/xfs/Makefile | 1 + fs/xfs/libxfs/xfs_attr.c | 5 +- fs/xfs/libxfs/xfs_attr.h | 30 +++ 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 | 431 ++++++++++++++++++++++++++++++++ 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 + 16 files changed, 582 insertions(+), 5 deletions(-) diff --git a/fs/xfs/Makefile b/fs/xfs/Makefile index 04611a1068b4..b056cfc6398e 100644 --- a/fs/xfs/Makefile +++ b/fs/xfs/Makefile @@ -102,6 +102,7 @@ xfs-y += xfs_log.o \ xfs_buf_item_recover.o \ xfs_dquot_item_recover.o \ xfs_extfree_item.o \ + xfs_attr_item.o \ xfs_icreate_item.o \ xfs_inode_item.o \ xfs_inode_item_recover.o \ diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c index 50b91b4461e7..dfff81024e46 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -24,6 +24,7 @@ #include "xfs_quota.h" #include "xfs_trans_space.h" #include "xfs_trace.h" +#include "xfs_attr_item.h" /* * xfs_attr.c @@ -61,8 +62,6 @@ STATIC int xfs_attr_node_hasname(xfs_da_args_t *args, struct xfs_da_state **state); STATIC int xfs_attr_fillstate(xfs_da_state_t *state); STATIC int xfs_attr_refillstate(xfs_da_state_t *state); -STATIC int xfs_attr_set_iter(struct xfs_delattr_context *dac, - struct xfs_buf **leaf_bp); STATIC int xfs_attr_node_removename(struct xfs_da_args *args, struct xfs_da_state *state); @@ -166,7 +165,7 @@ xfs_attr_get( /* * Calculate how many blocks we need for the new attribute, */ -STATIC int +int xfs_attr_calc_size( struct xfs_da_args *args, int *local) diff --git a/fs/xfs/libxfs/xfs_attr.h b/fs/xfs/libxfs/xfs_attr.h index 5e71f719bdd5..b8897f0dd810 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,13 @@ int xfs_attr_get_ilocked(struct xfs_da_args *args); int xfs_attr_get(struct xfs_da_args *args); int xfs_attr_set(struct xfs_da_args *args); int xfs_attr_set_args(struct xfs_da_args *args); +int xfs_attr_set_iter(struct xfs_delattr_context *dac, + struct xfs_buf **leaf_bp); int xfs_attr_remove_args(struct xfs_da_args *args); int xfs_attr_remove_iter(struct xfs_delattr_context *dac); bool xfs_attr_namecheck(const void *name, size_t length); void xfs_delattr_context_init(struct xfs_delattr_context *dac, struct xfs_da_args *args); +int xfs_attr_calc_size(struct xfs_da_args *args, int *local); #endif /* __XFS_ATTR_H__ */ diff --git a/fs/xfs/libxfs/xfs_defer.h b/fs/xfs/libxfs/xfs_defer.h index 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..3c0dfb32f2eb --- /dev/null +++ b/fs/xfs/xfs_attr_item.c @@ -0,0 +1,431 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (C) 2021 Oracle. All Rights Reserved. + * Author: Allison Collins + */ + +#include "xfs.h" +#include "xfs_fs.h" +#include "xfs_format.h" +#include "xfs_trans_resv.h" +#include "xfs_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 "libxfs/xfs_da_format.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; + uint size; + + size = sizeof(struct xfs_attri_log_item) + buffer_size; + attrip = kvmalloc(size, GFP_KERNEL | __GFP_ZERO); + if (attrip == NULL) + return NULL; + + xfs_log_item_init(mp, &attrip->attri_item, XFS_LI_ATTRI, + &xfs_attri_item_ops); + attrip->attri_format.alfi_id = (uintptr_t)(void *)attrip; + atomic_set(&attrip->attri_refcount, 2); + + return attrip; +} + +/* + * Copy an attr format buffer from the given buf, and into the destination attr + * format structure. + */ +STATIC int +xfs_attri_copy_format( + struct xfs_log_iovec *buf, + struct xfs_attri_log_format *dst_attr_fmt) +{ + struct xfs_attri_log_format *src_attr_fmt = buf->i_addr; + uint len; + + len = sizeof(struct xfs_attri_log_format); + if (buf->i_len != len) { + XFS_ERROR_REPORT(__func__, XFS_ERRLEVEL_LOW, NULL); + return -EFSCORRUPTED; + } + + memcpy((char *)dst_attr_fmt, (char *)src_attr_fmt, len); + return 0; +} + +static inline struct xfs_attrd_log_item *ATTRD_ITEM(struct xfs_log_item *lip) +{ + return container_of(lip, struct xfs_attrd_log_item, attrd_item); +} + +STATIC void +xfs_attrd_item_free(struct xfs_attrd_log_item *attrdp) +{ + kmem_free(attrdp->attrd_item.li_lv_shadow); + kmem_free(attrdp); +} + +STATIC void +xfs_attrd_item_size( + struct xfs_log_item *lip, + int *nvecs, + int *nbytes) +{ + *nvecs += 1; + *nbytes += sizeof(struct xfs_attrd_log_format); +} + +/* + * This is called to fill in the log iovecs for the given attrd log item. We use + * only 1 iovec for the attrd_format, and we point that at the attr_log_format + * structure embedded in the attrd item. + */ +STATIC void +xfs_attrd_item_format( + struct xfs_log_item *lip, + struct xfs_log_vec *lv) +{ + struct xfs_attrd_log_item *attrdp = ATTRD_ITEM(lip); + struct xfs_log_iovec *vecp = NULL; + + attrdp->attrd_format.alfd_type = XFS_LI_ATTRD; + attrdp->attrd_format.alfd_size = 1; + + xlog_copy_iovec(lv, &vecp, XLOG_REG_TYPE_ATTRD_FORMAT, + &attrdp->attrd_format, + sizeof(struct xfs_attrd_log_format)); +} + +/* + * The ATTRD is either committed or aborted if the transaction is canceled. If + * the transaction is canceled, drop our reference to the ATTRI and free the + * ATTRD. + */ +STATIC void +xfs_attrd_item_release( + struct xfs_log_item *lip) +{ + struct xfs_attrd_log_item *attrdp = ATTRD_ITEM(lip); + + xfs_attri_release(attrdp->attrd_attrip); + xfs_attrd_item_free(attrdp); +} + +STATIC xfs_lsn_t +xfs_attri_item_committed( + struct xfs_log_item *lip, + xfs_lsn_t lsn) +{ + struct xfs_attri_log_item *attrip = ATTRI_ITEM(lip); + + /* + * The attrip refers to xfs_attr_item memory to log the name and value + * with the intent item. This already occurred when the intent was + * committed so these fields are no longer accessed. Clear them out of + * caution since we're about to free the xfs_attr_item. + */ + attrip->attri_name = NULL; + attrip->attri_value = NULL; + + /* + * The ATTRI is logged only once and cannot be moved in the log, so + * simply return the lsn at which it's been logged. + */ + return lsn; +} + +STATIC bool +xfs_attri_item_match( + struct xfs_log_item *lip, + uint64_t intent_id) +{ + return ATTRI_ITEM(lip)->attri_format.alfi_id == intent_id; +} + +/* 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) { + xfs_attri_item_free(attrip); + return error; + } + + attrip->attri_name_len = attri_formatp->alfi_name_len; + attrip->attri_value_len = attri_formatp->alfi_value_len; + region++; + name = ((char *)attrip) + sizeof(struct xfs_attri_log_item); + memcpy(name, item->ri_buf[region].i_addr, attrip->attri_name_len); + attrip->attri_name = name; + + if (attrip->attri_value_len > 0) { + region++; + value = ((char *)attrip) + sizeof(struct xfs_attri_log_item) + + attrip->attri_name_len; + memcpy(value, item->ri_buf[region].i_addr, + attrip->attri_value_len); + attrip->attri_value = value; + } + + /* + * The ATTRI has two references. One for the ATTRD and one for ATTRI to + * ensure it makes it into the AIL. Insert the ATTRI into the AIL + * directly and drop the ATTRI reference. Note that + * xfs_trans_ail_update() drops the AIL lock. + */ + xfs_trans_ail_insert(log->l_ailp, &attrip->attri_item, lsn); + xfs_attri_release(attrip); + return 0; +} + +/* + * 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..057cea27b657 --- /dev/null +++ b/fs/xfs/xfs_attr_item.h @@ -0,0 +1,46 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later + * + * Copyright (C) 2021 Oracle. All Rights Reserved. + * Author: Allison Collins + */ +#ifndef __XFS_ATTR_ITEM_H__ +#define __XFS_ATTR_ITEM_H__ + +/* kernel only ATTRI/ATTRD definitions */ + +struct xfs_mount; +struct kmem_zone; + +/* + * This is the "attr intention" log item. It is used to log the fact that some + * attribute operations need to be processed. An operation is currently either + * a set or remove. Set or remove operations are described by the xfs_attr_item + * which may be logged to this intent. + * + * During a normal attr operation, name and value point to the name and value + * fields of the calling functions xfs_da_args. During a recovery, the name + * and value buffers are copied from the log, and stored in a trailing buffer + * attached to the xfs_attr_item until they are committed. They are freed when + * the xfs_attr_item itself is freed when the work is done. + */ +struct xfs_attri_log_item { + struct xfs_log_item attri_item; + atomic_t attri_refcount; + int attri_name_len; + int attri_value_len; + void *attri_name; + void *attri_value; + struct xfs_attri_log_format attri_format; +}; + +/* + * This is the "attr done" log item. It is used to log the fact that some attrs + * earlier mentioned in an attri item have been freed. + */ +struct xfs_attrd_log_item { + struct xfs_attri_log_item *attrd_attrip; + struct xfs_log_item attrd_item; + struct xfs_attrd_log_format attrd_format; +}; + +#endif /* __XFS_ATTR_ITEM_H__ */ diff --git a/fs/xfs/xfs_attr_list.c b/fs/xfs/xfs_attr_list.c index 2d1e5134cebe..90a14e85e76d 100644 --- a/fs/xfs/xfs_attr_list.c +++ b/fs/xfs/xfs_attr_list.c @@ -15,6 +15,7 @@ #include "xfs_inode.h" #include "xfs_trans.h" #include "xfs_bmap.h" +#include "xfs_da_btree.h" #include "xfs_attr.h" #include "xfs_attr_sf.h" #include "xfs_attr_leaf.h" diff --git a/fs/xfs/xfs_ioctl32.c b/fs/xfs/xfs_ioctl32.c index 8783af203cfc..ab543c5b1371 100644 --- a/fs/xfs/xfs_ioctl32.c +++ b/fs/xfs/xfs_ioctl32.c @@ -17,6 +17,8 @@ #include "xfs_itable.h" #include "xfs_fsops.h" #include "xfs_rtalloc.h" +#include "xfs_da_format.h" +#include "xfs_da_btree.h" #include "xfs_attr.h" #include "xfs_ioctl.h" #include "xfs_ioctl32.h" diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c index a607d6aca5c4..4f1310328b6d 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 53366cc0bc9e..f653a3701f89 100644 --- a/fs/xfs/xfs_log_recover.c +++ b/fs/xfs/xfs_log_recover.c @@ -1800,6 +1800,8 @@ static const struct xlog_recover_item_ops *xlog_recover_item_ops[] = { &xlog_cud_item_ops, &xlog_bui_item_ops, &xlog_bud_item_ops, + &xlog_attri_item_ops, + &xlog_attrd_item_ops, }; static const struct xlog_recover_item_ops * diff --git a/fs/xfs/xfs_ondisk.h b/fs/xfs/xfs_ondisk.h index 25991923c1a8..758702b9495f 100644 --- a/fs/xfs/xfs_ondisk.h +++ b/fs/xfs/xfs_ondisk.h @@ -132,6 +132,8 @@ xfs_check_ondisk_structs(void) XFS_CHECK_STRUCT_SIZE(struct xfs_inode_log_format, 56); XFS_CHECK_STRUCT_SIZE(struct xfs_qoff_logformat, 20); XFS_CHECK_STRUCT_SIZE(struct xfs_trans_header, 16); + XFS_CHECK_STRUCT_SIZE(struct xfs_attri_log_format, 40); + XFS_CHECK_STRUCT_SIZE(struct xfs_attrd_log_format, 16); /* * The v5 superblock format extended several v4 header structures with From patchwork Wed Nov 17 04:13:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12623627 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 93B9BC43217 for ; Wed, 17 Nov 2021 04:13:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 79A7061501 for ; Wed, 17 Nov 2021 04:13:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233002AbhKQEQy (ORCPT ); Tue, 16 Nov 2021 23:16:54 -0500 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:13966 "EHLO mx0a-00069f02.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232994AbhKQEQw (ORCPT ); Tue, 16 Nov 2021 23:16:52 -0500 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 1AH2u8c9023615 for ; Wed, 17 Nov 2021 04:13:55 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2021-07-09; bh=M0SKSKIVUUYTRkm4IwhPl96C1U4GypGEsUqHKPCm3Gs=; b=NR6sTHo5j/6wR7tBze/DtIueJN11kumHh8w8bEQQkVTHPGOfcJBHtgp+ImEial2ktb5B 1J1E9obDxaBgGwD3GYWgDC00V/qDjqBx78UuEXn5gO/dEx/isIXj7mnjDl23m65dv2Kh gWtCnUoEKoU3X7fPlxcKKhK3Z9O1pS51ydFX/9YksTJNNAMpjFHIm+hI3d6H0IQVjxrj UHE2e+NE2ZJCzecf+JYM3AFbo6on5TTqtDxVoczMdk9dKZFVcXeCUJyrBMf26C5NBhNj FMigUhK9yx7PcmuYBUqwFZe/I/V7QINs/eHHlRujg/2nKZxR+4UvZzKsT2AhtpvuH6MK 8Q== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by mx0b-00069f02.pphosted.com with ESMTP id 3cbfjxwwm8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 17 Nov 2021 04:13:54 +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 1AH4AEJW180636 for ; Wed, 17 Nov 2021 04:13:53 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2176.outbound.protection.outlook.com [104.47.56.176]) by userp3030.oracle.com with ESMTP id 3ca2fx68vt-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 17 Nov 2021 04:13:53 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KXPfglgOx7Esw8bLzb1CVf3MNVnImymk4dtyTGTZDEdJ6+F/GPQ86GkTeO6tFAP0b9KKWOewisY+J3lm1eaPPwRWPWAcN3k31I3Si1KHHflLTbJUoJcuRW5SgNy+ola3q1cs9+c6asQdTJOTHWz7Zv5Jrq28S7SxB1u4IlxFcXPdrm3A4bsHRVTXn/qreUUpjFol7coRO79BzjjMUXaD9vIA6B+Kb9WSSjJ79Ob7OMFmhuQPcokhpA/xJNxTK3xDo+WDFJVE1qKTaViZvjf+Ldb4BDRsRk4IRt9FyY1zHweOa7Gw64zaxXvX8PHMUBAHVS0m/SqdIy/txqSBElz4Kg== 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=M0SKSKIVUUYTRkm4IwhPl96C1U4GypGEsUqHKPCm3Gs=; b=I9eZggu7TgSB7ji/6MHS/XZMW5fgWM/bIMqW1/cKxURDOQF+3wGkwUdpy63ksThhtpJ7nMNcXLk9rBrS48tZZgjVnA1p7b/ke/Ci4rfiRyMMQmJ0Ybn26rCUuau7WPjEyrkd5IsYQqqGr0lARsHXg0/RBYD+VNsKXATNgI+wayC+l6Aueg3kdHb/euwooA3o2Elq1eKye3kBZSCRZbc6PKHiPrS17aarKCQpFd6TmX8K+Jp2xxk4Cq+tKYX4UkgrN3nF9Cum19o+l2s4vO4PFR0mqH3EFajIw0Yhlq3Vtx7PCQG/aR4xSTAZ2GIMTXnH3FZ82ceRBcd8X6PqeHGf/Q== 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=M0SKSKIVUUYTRkm4IwhPl96C1U4GypGEsUqHKPCm3Gs=; b=Co9glSQtImSnQrEWSGrcQrtyYnTmoOb3qJPChhxk316TJWDE4OrA0zXwts22IjoizlnTY9PxWEm4bHuoiHFkXIcXuqcqB1jHV66H2PtXrcB2Yh9RfpcBVUkYOF//PTnGYCzcMma1Hy/oKzoMUjF7Kd95lLqqyoAUXzToTIe+3b4= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by BY5PR10MB3921.namprd10.prod.outlook.com (2603:10b6:a03:1ff::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4713.19; Wed, 17 Nov 2021 04:13:50 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::fdae:8a2c:bee4:9bb2]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::fdae:8a2c:bee4:9bb2%9]) with mapi id 15.20.4713.019; Wed, 17 Nov 2021 04:13:50 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v25 05/12] xfs: Implement attr logging and replay Date: Tue, 16 Nov 2021 21:13:36 -0700 Message-Id: <20211117041343.3050202-6-allison.henderson@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211117041343.3050202-1-allison.henderson@oracle.com> References: <20211117041343.3050202-1-allison.henderson@oracle.com> X-ClientProxiedBy: BY5PR04CA0008.namprd04.prod.outlook.com (2603:10b6:a03:1d0::18) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 Received: from localhost.localdomain (67.1.243.157) by BY5PR04CA0008.namprd04.prod.outlook.com (2603:10b6:a03:1d0::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.27 via Frontend Transport; Wed, 17 Nov 2021 04:13:50 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 73711fb0-0df3-43cd-acb2-08d9a980a8e2 X-MS-TrafficTypeDiagnostic: BY5PR10MB3921: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:231; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xqmsNl7dTulBVNIIy8h56GN5HNchgCcbO8avNCq6pMjQeeGmNVJvDhtA3TOqIdKpDlZ2P8QRMQfysKDU0bJ8dqkwcAQhudobzW85HLdDc5YISPo/JhbDkKpqT9rXyjCigflddv7Z86NpixAEvZuinPLkNbjToi4kxW6BTYiAKLeHOgoA9D7gLbD5hv3qvB154UVwMb2Pg+ujoVoqEjd77/qGUlmaZNUG99omo6INexL6f9RF/4hCHQMcxwOPIFZOmRXzLCCjvTiC9IrU8+nOLeu39RMF/FQSFwubKfrkGxMNGweS/lgD9s7+sI7jJL0DOng8e2//gfRgMXTU1s3k02Rl7+J0hM2B6/jzIDT5zrLsLnhXSrE0mgAl/xU5aaf1beTr7XV67FSuo82vn0gSOOfQcnnLTwSGboXtL69/mfMXYjSdkW9IFFspIc6khYBKbMk1ZPp+9QKVgmXUTCxMGgDODC7RRcrLEJbw4WFGeVtFjiT1Vp3HU7XxOnGV2gAdylBzOoDya+8VxhYuy5ttKRStgNCllBb+rd+g/Yb5Fjs32gvrwZNdtg+gUXgik7LvhoRaFP5I/ht2BEyiYrlJweMEuIwdfWAJGZAYi/fDgRXsNsaHBoAq5j07Zx+Fp0NwyVnVYbMNRAfM/BqZaWjBnnFbZK2RasooR3adoE470VkqsgPG3oDqxP3b75+XzEzsEAKemSU44jBDHeAcUGPuig== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(8936002)(38350700002)(6506007)(2616005)(86362001)(30864003)(6512007)(5660300002)(8676002)(2906002)(36756003)(83380400001)(508600001)(52116002)(186003)(66946007)(38100700002)(6486002)(316002)(6666004)(44832011)(66556008)(1076003)(66476007)(6916009)(956004)(26005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ExvlJJT01x6EU0iPFkAL41lksZmgWriu0erjfPtoPvL9e6VB55en7w6fB/dzza748XOC/FjJ74PYGzUQOQfWn47A1Dh0olwzs7nps+HvqI3nSAdWSNZyEcPHF+uhkKwlWyudzDmSVNy7wHUd58kuS7ItuvBGneD5geL3YpDbaYl1s5/UTb0RWdumPyZVlmBvrgw3FvAKneoGZDTWXP5U50fENnxaF2kZcSVvsvotyTZ5pCWWpktN80UvO3kWD4igSvPHQcC+F9ZYF6xA1hO2SsWp4Lkd9YsL/GOsEuZ8sJxIikaydIvQS1V6xnfWyV7FhmxzT7WGdZ9cHcwDby2hV+4CgpPzZywPulgi9ozKbYvK7N6SuIRkwX6RKsVTKhP4rI0EV3l11+/aNBP+E5qQvIzkfmQu2cKtCgxTB9x/CT3gO+Ox7ZuS9F4z4fGof1xjZVBYDDse1MoybBW29ZqteXYnNd4pVtm//gfVNmZ471VtffVV5nUYgnSvauE7WVHYTd2Yt8qMIx6w+x5GHqR29v4fjGmevg70ge1cBu+nQRSbpkoxOKDjWHzxk6QvAcOEdz3XlZKYO8+ngmbg6r/if+lBiGJba1Xgeyt6kzoBHWg8zOhjnYW+mH9AA/OB2Wjw1dV8+xg+UNwxA9zG5qdHGKKNijneKe99xJrMNqHafmNeXy0lsSU7kdkD7HaMwemn+X8G+OqULMkdsPEkh/JGF8Kd3kJEi3o0tS3RkzrpZyfXfGw103MnuTdo/j0OGFLswZYxVF46173DtECDvP4V32FoRlyCeUFvht9yGbnZ+FKhpfvHAj2jeqRhSXlfVfVL2x51LDq+5bwlaeq0b+qIUW2PpdadpSFBC12rFOdNhln+b1qo4nRYDuCn4Eybadk9zJMudxW657WA0EBd4f1MO6eUUixHMJUoOCY6NvcdwtOIK9E7ltsO/1J9/8J05qmqkRov177jruwx1YFJdyBrES1YPA6a8f/MSGwYb3PL6i+lhnfW+cOOjcrUuCKwMQxOv5Ec+9gtW3GXkiMbtzQl4R3KKm8klpEcTRL0yfOvkJZE8G4Zm4yvEb1FrwmX2iajfYt9GzrqHZ8PHi5VnYprDT/9n9lx6ejyNLErHqC5wG1AC6yBtku7okj80CGKwJ564egdkmpt2an/VdhEyyxq/nVI38N3AWiw18hDRhONh/zFRyb8yb3hxgFvJ9lv3sJtTSu24BuEj+dwuktcInGQ57IUnX8DY8bNRC6DKBh8WpHZ1PvRabfhQb9jcRlBeAav4+cSJJJ2vRAMKD4COyAzxT3Qs6Nf36tqdSYLoeVF68xfwxv0XJI80/zPMqWS7QZK7xvQQiunw402d+pnvzeU2bILB3I8J6W78VpTPfkdasqfH4wRuUAlAgp4bLOgo9RPPBUbjARQ6uBdXan/wwGrzi6f6EgRDlkvfwacCdp4zXcDDNYMUSRDWLhlCOFY46Q5/gOnGLHZOk5CFeFuU/1ll7sjpBnC8X8fYCu8TSsTUlweoN8kGitHCAnWlz5hypecwl05zoL53xXdMGNJVhnxsY4j1vKYGhPHzHES0REQxoNeTVfbPxlBVv37yPG8E1Q+R1K8PHZSHDtjSBaG0Bg94p9nKKi7CtZmhbVTe5suuzs7d4KjMWN9Vs4qd+yeFj5nGf6CQtaiznPtIH0QN2XFYQ== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 73711fb0-0df3-43cd-acb2-08d9a980a8e2 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Nov 2021 04:13:50.5156 (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: VuTqqhs5UeCzgDh+M6UMNk7aVyvAwudAUTBOZmOEdeLQ9hsS36V9qgec1GA8g6/cDXLznWgrSKLlNGzJKA6hELOlPJdmaRtGnBOo4Nf/Jb4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR10MB3921 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10170 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 phishscore=0 bulkscore=0 adultscore=0 mlxlogscore=999 malwarescore=0 mlxscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2111170019 X-Proofpoint-ORIG-GUID: 1E7xAhaJ1r-GIS92wF49DGrn0DviymU4 X-Proofpoint-GUID: 1E7xAhaJ1r-GIS92wF49DGrn0DviymU4 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org This patch adds the needed routines to create, log and recover logged extended attribute intents. Signed-off-by: Allison Henderson Reviewed-by: Chandan Babu R --- fs/xfs/libxfs/xfs_defer.c | 1 + fs/xfs/libxfs/xfs_defer.h | 1 + fs/xfs/libxfs/xfs_format.h | 9 +- fs/xfs/xfs_attr_item.c | 362 +++++++++++++++++++++++++++++++++++++ 4 files changed, 372 insertions(+), 1 deletion(-) diff --git a/fs/xfs/libxfs/xfs_defer.c b/fs/xfs/libxfs/xfs_defer.c index 51574f0371b5..877c0f7ee557 100644 --- a/fs/xfs/libxfs/xfs_defer.c +++ b/fs/xfs/libxfs/xfs_defer.c @@ -185,6 +185,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 bool 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 3c0dfb32f2eb..5d0ab9a8504e 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" @@ -30,6 +31,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) { @@ -254,6 +257,163 @@ xfs_attrd_item_release( xfs_attrd_item_free(attrdp); } +/* + * Performs one step of an attribute update intent and marks the attrd item + * dirty.. An attr operation may be a set or a remove. Note that the + * transaction is marked dirty regardless of whether the operation succeeds or + * fails to support the ATTRI/ATTRD lifecycle rules. + */ +STATIC int +xfs_trans_attr_finish_update( + struct xfs_delattr_context *dac, + struct xfs_attrd_log_item *attrdp, + struct xfs_buf **leaf_bp, + uint32_t op_flags) +{ + struct xfs_da_args *args = dac->da_args; + unsigned int op = op_flags & + XFS_ATTR_OP_FLAGS_TYPE_MASK; + int error; + + switch (op) { + case XFS_ATTR_OP_FLAGS_SET: + error = xfs_attr_set_iter(dac, leaf_bp); + break; + case XFS_ATTR_OP_FLAGS_REMOVE: + ASSERT(XFS_IFORK_Q(args->dp)); + error = xfs_attr_remove_iter(dac); + break; + default: + error = -EFSCORRUPTED; + break; + } + + /* + * Mark the transaction dirty, even on error. This ensures the + * transaction is aborted, which: + * + * 1.) releases the ATTRI and frees the ATTRD + * 2.) shuts down the filesystem + */ + args->trans->t_flags |= XFS_TRANS_DIRTY; + + /* + * attr intent/done items are null when delayed attributes are disabled + */ + if (attrdp) + set_bit(XFS_LI_DIRTY, &attrdp->attrd_item.li_flags); + + return error; +} + +/* Log an attr to the intent item. */ +STATIC void +xfs_attr_log_item( + struct xfs_trans *tp, + struct xfs_attri_log_item *attrip, + struct xfs_attr_item *attr) +{ + struct xfs_attri_log_format *attrp; + + tp->t_flags |= XFS_TRANS_DIRTY; + set_bit(XFS_LI_DIRTY, &attrip->attri_item.li_flags); + + /* + * At this point the xfs_attr_item has been constructed, and we've + * created the log intent. Fill in the attri log item and log format + * structure with fields from this xfs_attr_item + */ + attrp = &attrip->attri_format; + attrp->alfi_ino = attr->xattri_dac.da_args->dp->i_ino; + attrp->alfi_op_flags = attr->xattri_op_flags; + attrp->alfi_value_len = attr->xattri_dac.da_args->valuelen; + attrp->alfi_name_len = attr->xattri_dac.da_args->namelen; + attrp->alfi_attr_flags = attr->xattri_dac.da_args->attr_filter; + + attrip->attri_name = (void *)attr->xattri_dac.da_args->name; + attrip->attri_value = attr->xattri_dac.da_args->value; + attrip->attri_name_len = attr->xattri_dac.da_args->namelen; + attrip->attri_value_len = attr->xattri_dac.da_args->valuelen; +} + +/* Get an ATTRI. */ +static struct xfs_log_item * +xfs_attr_create_intent( + struct xfs_trans *tp, + struct list_head *items, + unsigned int count, + bool sort) +{ + struct xfs_mount *mp = tp->t_mountp; + struct xfs_attri_log_item *attrip; + struct xfs_attr_item *attr; + + ASSERT(count == 1); + + if (!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_trans_attr_finish_update(dac, done_item, &dac->leaf_bp, + attr->xattri_op_flags); + if (error != -EAGAIN) + kmem_free(attr); + + return error; +} + +/* Abort all pending ATTRs. */ +STATIC void +xfs_attr_abort_intent( + struct xfs_log_item *intent) +{ + xfs_attri_release(ATTRI_ITEM(intent)); +} + +/* Cancel an attr */ +STATIC void +xfs_attr_cancel_item( + struct list_head *item) +{ + struct xfs_attr_item *attr; + + attr = container_of(item, struct xfs_attr_item, xattri_list); + kmem_free(attr); +} + STATIC xfs_lsn_t xfs_attri_item_committed( struct xfs_log_item *lip, @@ -311,6 +471,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)) + return -EFSCORRUPTED; + + error = xlog_recover_iget(mp, attrp->alfi_ino, &ip); + if (error) + return error; + + attr = kmem_zalloc(sizeof(struct xfs_attr_item) + + sizeof(struct xfs_da_args), KM_NOFS); + args = (struct xfs_da_args *)(attr + 1); + + attr->xattri_dac.da_args = args; + attr->xattri_op_flags = attrp->alfi_op_flags; + + args->dp = ip; + args->geo = mp->m_attr_geo; + args->op_flags = attrp->alfi_op_flags; + args->whichfork = XFS_ATTR_FORK; + args->name = attrip->attri_name; + args->namelen = attrp->alfi_name_len; + args->hashval = xfs_da_hashname(args->name, args->namelen); + args->attr_filter = attrp->alfi_attr_flags; + + if (attrp->alfi_op_flags == XFS_ATTR_OP_FLAGS_SET) { + args->value = attrip->attri_value; + args->valuelen = attrp->alfi_value_len; + args->total = xfs_attr_calc_size(args, &local); + + tres.tr_logres = M_RES(mp)->tr_attrsetm.tr_logres + + M_RES(mp)->tr_attrsetrt.tr_logres * + args->total; + tres.tr_logcount = XFS_ATTRSET_LOG_COUNT; + tres.tr_logflags = XFS_TRANS_PERM_LOG_RES; + total = args->total; + } else { + tres = M_RES(mp)->tr_attrrm; + total = XFS_ATTRRM_SPACE_RES(mp); + } + error = xfs_trans_alloc(mp, &tres, total, 0, XFS_TRANS_RESERVE, &tp); + if (error) + goto out; + + args->trans = tp; + done_item = xfs_trans_get_attrd(tp, attrip); + + xfs_ilock(ip, XFS_ILOCK_EXCL); + xfs_trans_ijoin(tp, ip, 0); + + ret = xfs_trans_attr_finish_update(&attr->xattri_dac, done_item, + &attr->xattri_dac.leaf_bp, + attrp->alfi_op_flags); + if (ret == -EAGAIN) { + /* There's more work to do, so add it to this transaction */ + xfs_defer_add(tp, XFS_DEFER_OPS_TYPE_ATTR, &attr->xattri_list); + } else + error = ret; + + if (error) { + xfs_trans_cancel(tp); + goto out_unlock; + } + + error = xfs_defer_ops_capture_and_commit(tp, 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, @@ -377,6 +691,52 @@ xlog_recover_attri_commit_pass2( return 0; } +/* + * This routine is called to allocate an "attr free done" log item. + */ +static struct xfs_attrd_log_item * +xfs_trans_get_attrd(struct xfs_trans *tp, + struct xfs_attri_log_item *attrip) +{ + struct xfs_attrd_log_item *attrdp; + uint size; + + ASSERT(tp != NULL); + + size = sizeof(struct xfs_attrd_log_item); + attrdp = kmem_zalloc(size, 0); + + xfs_log_item_init(tp->t_mountp, &attrdp->attrd_item, XFS_LI_ATTRD, + &xfs_attrd_item_ops); + attrdp->attrd_attrip = attrip; + attrdp->attrd_format.alfd_alf_id = attrip->attri_format.alfi_id; + + xfs_trans_add_item(tp, &attrdp->attrd_item); + return attrdp; +} + +/* 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 @@ -410,7 +770,9 @@ static const struct xfs_item_ops xfs_attri_item_ops = { .iop_unpin = xfs_attri_item_unpin, .iop_committed = xfs_attri_item_committed, .iop_release = xfs_attri_item_release, + .iop_recover = xfs_attri_item_recover, .iop_match = xfs_attri_item_match, + .iop_relog = xfs_attri_item_relog, }; const struct xlog_recover_item_ops xlog_attri_item_ops = { From patchwork Wed Nov 17 04:13:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12623621 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 060A5C4332F for ; Wed, 17 Nov 2021 04:13:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DD1B661266 for ; Wed, 17 Nov 2021 04:13:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232999AbhKQEQw (ORCPT ); Tue, 16 Nov 2021 23:16:52 -0500 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:13178 "EHLO mx0a-00069f02.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232453AbhKQEQw (ORCPT ); Tue, 16 Nov 2021 23:16:52 -0500 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 1AH44w6e031988 for ; Wed, 17 Nov 2021 04:13:54 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2021-07-09; bh=tr9lV82/etMnh3Aq+R/e5z6QTjGuvUzQskuWAxyAy9I=; b=rdDhWpuqZcMSONEbtZGcXLCkoJCvdtp6HcVd5D56R1IrMA/K873jembKVErVIbpNwWgh CAms+m21JAkOcJ8lJV75L72dz+5fSpnnsMFnb7yf9nahpugn3E3Fwq9JRsWf+GLcqJSB J3m9PtJep8LXIhpxLNXVHctnfYivA4SR6xbPNB34vY8DFO5pZ/vvYNSq1k3XtY5H3qXf 6y353Xc7C6EXQ/eETcUC38idZ5PVa65xegWRqEAM0lgquh8RJlZf3f5nS51oebPIufaO Uz25uuix7VfN1g1wrpnPWA1qO0G2+4gwEs+oPWBQTvnAGj3jb9q5VkMLqjGmM0AjPVVS Kg== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by mx0b-00069f02.pphosted.com with ESMTP id 3cbhv86ekt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 17 Nov 2021 04:13:54 +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 1AH4AEJV180636 for ; Wed, 17 Nov 2021 04:13:52 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2176.outbound.protection.outlook.com [104.47.56.176]) by userp3030.oracle.com with ESMTP id 3ca2fx68vt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 17 Nov 2021 04:13:52 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TqPG96lWzT/OeUACrmrLpjylRo5qTlmJl8RTNVIDPSQ63XXF9fOwnnh9DAF2/bQQlvlUr5LSTXMpjQiUt6uc9ZchEqnHrysfROgbiZwcPTmSAEq3kZFE21ELL66gX510GYJqxWg2Phu1oLjqI4QGu0HjChQdgxny5cbonJlsIZIGCRLPsidIKCZ4wVjYWhuvhUMm2C0f3P2Z2wH/4VBqj4HgPk+w6MXOuUMo6i9oId8X91xX5lKyxZmjc7/4L481kXzJqDM43KICDyZf1Y3hDYaSUAzLRGvG/PdT7jLvRCkjoZhnS73txdvW7YKgc4zwGYxb96F8Tb3YCd6+8ojSkg== 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=tr9lV82/etMnh3Aq+R/e5z6QTjGuvUzQskuWAxyAy9I=; b=Qr75SB3I/12qPy/e02jBp3ObUBFXEScRNay+x1mOiQRWtDeB9RNSFBi9IQNL9jsmOrasqn79YTvQs/7BMuE6foADGSs+nXWAbIRkBjDpNFAD43nUz+0cW3uYPWMcx2C985GfxSz8GxudYAqiWJv6ovlQIvzPKshSa5t/amPurkVbpBWSovUmmmBkhMh0MOogHjpwJqCBrjHGccAm92+ONNiPj9fYMvqvYIFKlJu4vRcX61WOkT8SGzyJFVihSI2MBTF8iQNoSHIV0zebTPwcHAAYLjU6Jy6GBk8gXEaLzMLI3fWknvCZL8zh+gwRQuyPd11w5eo1vZBPL40DF7L2RA== 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=tr9lV82/etMnh3Aq+R/e5z6QTjGuvUzQskuWAxyAy9I=; b=tHsdRy3NDJ63qSWmyF+hNhTRZlpTTdWIg9/h5NS61pH6qITufLrsRqvgNf9LY3gvpER4q8snR9hVRzrFhMwUq/3FiFvFOR3mmvFtfvWeI09tf4sN4Ei2CPrlaH29oC8Gfo3ai6XON1oO0hZ6Ng4/nxe/MQsfbmFfiMjzzt7rsQA= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by BY5PR10MB3921.namprd10.prod.outlook.com (2603:10b6:a03:1ff::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4713.19; Wed, 17 Nov 2021 04:13:50 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::fdae:8a2c:bee4:9bb2]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::fdae:8a2c:bee4:9bb2%9]) with mapi id 15.20.4713.019; Wed, 17 Nov 2021 04:13:50 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v25 06/12] xfs: Skip flip flags for delayed attrs Date: Tue, 16 Nov 2021 21:13:37 -0700 Message-Id: <20211117041343.3050202-7-allison.henderson@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211117041343.3050202-1-allison.henderson@oracle.com> References: <20211117041343.3050202-1-allison.henderson@oracle.com> X-ClientProxiedBy: BY5PR04CA0008.namprd04.prod.outlook.com (2603:10b6:a03:1d0::18) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 Received: from localhost.localdomain (67.1.243.157) by BY5PR04CA0008.namprd04.prod.outlook.com (2603:10b6:a03:1d0::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.27 via Frontend Transport; Wed, 17 Nov 2021 04:13:50 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4f3a1e14-0e89-4b66-5083-08d9a980a911 X-MS-TrafficTypeDiagnostic: BY5PR10MB3921: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6790; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: JVEm8cjH/13CdcWvji1AjBbxkYpZfa0+g/ikOrRUbh5W8U8CgSEe/xkRZhR1jzAYkipZRLSqPW03VSnerCuu/0U9AfjlU25hQZFbHzbK6UDkJXwz2lBNguosWJeKOAskKN1YNS2eyVupmLdc2+F188nvJJ4z+VZ6vYlqmvILMRFqmhddIo5KGIP5ZuCXfGE0hUpC7gIN1hkLXXLb8D1z81NILtAImYJ/f/efA/cnepX1a4SmdLqOVejLcJ23RmcTU4TKf6LQdUggxepDGYhN1xUJiel6NsohreM5JF1WukEf2WxKi/ctmJI1w3ubVMvgrTzsWlX5qRm521nDzNifDuYZ6nyN/BUU0oKTT3wXxv7qgt+oTxcgUUJbbZUB5g4CD4YC+P+4NLSiHxggnrL96GNNsxFGm008uf4P1tbSiPWKvCmLEd+90tJ/9Q0u6N0jjElPyCRD0hcbLLGvYl7JBkSomwSOp5cpOR2RcFVrDetKpfeODfEZTcaUIqnCfkQPevzg6KZVcMhVx8TMjBJusSXxLN8T7/cPOQmpAIUsboSLUe+uoIds1tFJAyxBNVNrBIe2fZRGChAvWAaX2zyj9yZ2hyzAtXZcludeTCSpjwTqgbUjzFaDEFpbiL8QLaugOeGOc5e1cmx62stWNV4m2BdvsWP/PzSUHakFlkX6qqhMSkuEB51Dxk3MvTftV6SS6h9w1WG57N+q7DE+PyIxYg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(8936002)(38350700002)(6506007)(2616005)(86362001)(6512007)(5660300002)(8676002)(2906002)(36756003)(83380400001)(508600001)(52116002)(186003)(66946007)(38100700002)(6486002)(316002)(6666004)(44832011)(66556008)(1076003)(66476007)(6916009)(956004)(26005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 1OteQKshLpw8r31hu3A1Fo+8ibm9NN5vQu+KHuFdUDkNBPwEU0K8GQCo3VitJN07pRAwqh239msBDiwYhj7bnJMK0wQPa4W8uKCo+OmsimbDjTiAyUdXo6V2yXpP7m+u3wA7OmcBhflVPa4Q2ooo9JUjTGGK/MEoRM3Jr8rfnUdglcyNfdSwel63r0WYTGu+d8Kx77Q/Hr0/T9UuyMev6QHsZstsKKOCRhhYOQzGTypyvKCtu/YTLq/GNWMsnrLgUcspJsPBEyVasPfwiMC4vO3vSKTVBQ4pMqUJ+vUVMVDnJgyKp2UgX94UQG+zSRYqi2z0f1L6p19vCGBcDjz3JxBhJv5NQZEzjVJuti/pkHm9L4wcWjIenKgSzOAPetwl7RoPmX/7MLLG7xhghw4KeqB6ie6IEkLhdYcxWw/rNrdZM9PKYfOLllQgnOk+CQLUjifmt6b/5VHgST0C9Vt5S73QKqUgLCAkYBxq1q2R7gUj3M4PmbmbQJPKXtBZpisVTv+qlRiFFg0kSu580o3wO9Kk6orn0AYsZkAQKLFVLZv+cr05+CdmPWdplOpyGOaz8zMCCTAOVUm90H7UvTjJJg7d/qlYw1QOeGXZo//8IrLOosXCPFtREJxhkRc0nGV9F5SXoG7b/7SVfePM3uKPWAISNA8g8L14fJnu6NNpc8X2xoNlYrCGqVeukMuvUZGrUKakiLyjkkkxcQzcagDtYKbxYvf7taE5ynnU3jTn4tufu70GXtXvV0OBQXipBX03yELtWUCTc5PFniO3ApzvRd1in/DFvOGDjYxER4XQPcbL2z2YB8lA5UBpTgCg1oyXLgZc1DeZRuJB++8awP0dp6tfLkPVaqkwMXYLv+9Co74VSS46B0cuVERcPiU6YNeZffsqB6wFRQatodr9iD7k5NHIEjrtmNzUvUtLmEmqM8i73RlNjYjYpHaVgBr0c8i8IxZ221IKQ8fv0Z6PkiqMHeBHDvkp9gyaflt4UMmkJ9Y5lQRomN2zgFnuzxUqyU4PUW8D6XVLqCK3hHU9c1K/9YIEe0DlqwqOO83hlHDRElJT35PYbXp3IkqrJTLuBchhIw80b7PQ2pbtLsvnofo7GSjhex7sXICZg2CWxfeeT7Vi3R60bDLiKfEaTL5NNFPmlNoV8YevvW+IQIdzMiFM2bHLTfZLtdDgGnJ0Dcb77ydaMNVkBr/1E7QhmuTEvWa61BLR0+zxpyTrggMomhn0Zm30Eu6DbRidr0yHroolRhO5sRxtFeLYe+VOhvD/ADWHecY/grMtpVWH7smnUSzR64fXjRu7cMghMkQ0THlQO4cFRSjDtGu/goFJrbriafxC/JmCn2Y3Wy8NjFQhVx9YwxkS1C295pt/9xQ9ZT9KQVug41bF7uh6lrkPOE2pcIyaLj4qbOc/4rYtR4zOFxUWS3rEom0A3Z33LxKMPO5tqbtWT/ahmpd5QmjEjGq9oQx7snG1dxKB+KmD8Ob56N2f1JLRvuJAHuh868PI5dx20NZq6zG4jjU8Nk6lwJosVHItAfUYJQ57SBgHfxovYe/AKszKixSs1WutZIpB0bJd7dtlogBOfKnxqCgCPtjpqVYOb1EBgHsw0vRIvoWjMHr2+PbOHsAXJKQ7RgU8gOy910NgMQLQXj3N95Agql9waO9K57X3WGZgmfnPEdujergk/g== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4f3a1e14-0e89-4b66-5083-08d9a980a911 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Nov 2021 04:13:50.8103 (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: DknsUgExAn3jENN8gIezDgYtvf2NeYfKFZTmvfddJ54PG9WJ3g0GIfheYROHwEiR+7vK6RkaDw99Qm5h1gpPiirwjJ0Z3ga17dgiRAOlsb4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR10MB3921 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10170 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 phishscore=0 bulkscore=0 adultscore=0 mlxlogscore=999 malwarescore=0 mlxscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2111170019 X-Proofpoint-GUID: OZYWfw9iPWIhtMuAhG188HFS7B4agqy7 X-Proofpoint-ORIG-GUID: OZYWfw9iPWIhtMuAhG188HFS7B4agqy7 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 dfff81024e46..2ae5b3176253 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -355,6 +355,7 @@ xfs_attr_set_iter( struct xfs_inode *dp = args->dp; struct xfs_buf *bp = NULL; int forkoff, error = 0; + struct xfs_mount *mp = args->dp->i_mount; /* State machine switch */ switch (dac->dela_state) { @@ -477,16 +478,21 @@ xfs_attr_set_iter( * In a separate transaction, set the incomplete flag on the * "old" attr and clear the incomplete flag on the "new" attr. */ - error = xfs_attr3_leaf_flipflags(args); - if (error) - return error; - /* - * Commit the flag value change and start the next trans in - * series. - */ - dac->dela_state = XFS_DAS_FLIP_LFLAG; - trace_xfs_attr_set_iter_return(dac->dela_state, args->dp); - return -EAGAIN; + if (!xfs_has_larp(mp)) { + error = xfs_attr3_leaf_flipflags(args); + if (error) + return error; + /* + * Commit the flag value change and start the next trans + * in series. + */ + dac->dela_state = XFS_DAS_FLIP_LFLAG; + trace_xfs_attr_set_iter_return(dac->dela_state, + args->dp); + return -EAGAIN; + } + + fallthrough; case XFS_DAS_FLIP_LFLAG: /* * Dismantle the "old" attribute/value pair by removing a @@ -589,17 +595,21 @@ xfs_attr_set_iter( * In a separate transaction, set the incomplete flag on the * "old" attr and clear the incomplete flag on the "new" attr. */ - error = xfs_attr3_leaf_flipflags(args); - if (error) - goto out; - /* - * Commit the flag value change and start the next trans in - * series - */ - dac->dela_state = XFS_DAS_FLIP_NFLAG; - trace_xfs_attr_set_iter_return(dac->dela_state, args->dp); - return -EAGAIN; + if (!xfs_has_larp(mp)) { + error = xfs_attr3_leaf_flipflags(args); + if (error) + goto out; + /* + * Commit the flag value change and start the next trans + * in series + */ + dac->dela_state = XFS_DAS_FLIP_NFLAG; + trace_xfs_attr_set_iter_return(dac->dela_state, + args->dp); + return -EAGAIN; + } + fallthrough; case XFS_DAS_FLIP_NFLAG: /* * Dismantle the "old" attribute/value pair by removing a @@ -1236,6 +1246,7 @@ xfs_attr_node_addname_clear_incomplete( { struct xfs_da_args *args = dac->da_args; struct xfs_da_state *state = NULL; + struct xfs_mount *mp = args->dp->i_mount; int retval = 0; int error = 0; @@ -1243,7 +1254,8 @@ xfs_attr_node_addname_clear_incomplete( * Re-find the "old" attribute entry after any split ops. The INCOMPLETE * flag means that we will find the "old" attr, not the "new" one. */ - args->attr_filter |= XFS_ATTR_INCOMPLETE; + if (!xfs_has_larp(mp)) + args->attr_filter |= XFS_ATTR_INCOMPLETE; state = xfs_da_state_alloc(args); state->inleaf = 0; error = xfs_da3_node_lookup_int(state, &retval); diff --git a/fs/xfs/libxfs/xfs_attr_leaf.c b/fs/xfs/libxfs/xfs_attr_leaf.c index 014daa8c542d..74b76b09509f 100644 --- a/fs/xfs/libxfs/xfs_attr_leaf.c +++ b/fs/xfs/libxfs/xfs_attr_leaf.c @@ -1487,7 +1487,8 @@ xfs_attr3_leaf_add_work( if (tmp) entry->flags |= XFS_ATTR_LOCAL; if (args->op_flags & XFS_DA_OP_RENAME) { - entry->flags |= XFS_ATTR_INCOMPLETE; + if (!xfs_has_larp(mp)) + entry->flags |= XFS_ATTR_INCOMPLETE; if ((args->blkno2 == args->blkno) && (args->index2 <= args->index)) { args->index2++; From patchwork Wed Nov 17 04:13:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12623631 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EA454C433FE for ; Wed, 17 Nov 2021 04:13:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D26E861A8D for ; Wed, 17 Nov 2021 04:13:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232994AbhKQEQz (ORCPT ); Tue, 16 Nov 2021 23:16:55 -0500 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:14436 "EHLO mx0a-00069f02.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232453AbhKQEQx (ORCPT ); Tue, 16 Nov 2021 23:16:53 -0500 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 1AH3CImO027666 for ; Wed, 17 Nov 2021 04:13:55 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2021-07-09; bh=55SiZo+Yck2WaHEQ9E43/KKORSy2FgCUXVYYoi2lsWY=; b=Wqfl6YEG6B+jexRKDrwC0xhucOqhoTf8aIeX+ZmiCCwNiapFvzfsVFA92Tu62vklfCTu 64mCdh+pWc3dGiBa6PMOeLYSqRMWGnUwQH04ESczzbg0OH9XCXnHrWso2MZ23D9zPuH/ oZ/TizCf4ABB64/cknahRGvp7R6wLcyenpAfzb+rF6wLRVMp/hhplhB7BZ8NO3Y+PdoY asGHzY9PfXHIbmiYdNBqk73ADb3E6XZz0xSOS2UzpnLKa7xWFqmQKYkECgcVAYvoa4v3 oD5ULFlHd5K4ICUEGCmiseyPhMMcZwnbnPgzdUESUF5K+pDdY72VKow2qowManBkCf6p kQ== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by mx0b-00069f02.pphosted.com with ESMTP id 3cbhtvvpc2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 17 Nov 2021 04:13:55 +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 1AH4AEJX180636 for ; Wed, 17 Nov 2021 04:13:54 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2176.outbound.protection.outlook.com [104.47.56.176]) by userp3030.oracle.com with ESMTP id 3ca2fx68vt-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 17 Nov 2021 04:13:53 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nE6+qpswWzoUOUxNxAt6CqwiVs4qba5kbX7KVotr7Xcnibk+jecNRx0FF8/xuVaOFmnl0iTI+wkNnLSTRe+jGK4ewe3U75iahvttgSYYcEjRnQjHJ2mnuRSfmBUkftoBeWhEdsBDuAQiXfNDbaEIuHGZaSLLsGaNnJfDnLWUuAY0/eEFjOPldXdgA1DNkeHbZIxgpBzFrs4bn4LUQcbM4gg8E0HDNE9XY/24q9ObMNnh90j5qCGfeXEIj+mRVrmTHcMqDhlVBYGY23SGUZxyfOUiJ7Cryk380/IqZ0Z8eV7XRn7XHcXcyoKNLR+Pxfy890BTJ9KzfS2uMrjv4n+JjQ== 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=55SiZo+Yck2WaHEQ9E43/KKORSy2FgCUXVYYoi2lsWY=; b=Rx7TA85nwfjJrWaXgrSkRETYd2jxFoRvCna1N1WA/yhSuuanB4s4mqa+ThUa84Llig8M7gdAxiDLAvh3phnU8qcf6jXSpEjWFk2FeTch/+kSYv8N1FnwnPXvvv+2wsPN/iVrpZUo3VU7gwKw1xoBMBqWDrqk55kTH/VGzrnjcHkyx9Z18eGy16+wlvNPGomfjorixBXxR4/8jNf7EhqaGmei2Vao2j57Wkge+4KnBr6nRYYgM3x7kKsonIO76KOZYxPHBdgWfbcwAWFkh+mAFIr5W8DoUR15uV0LFhroS3Dr0BFccJF7eosESOIjhGOdCWV7HiCtWBwTT4UIhgLW/Q== 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=55SiZo+Yck2WaHEQ9E43/KKORSy2FgCUXVYYoi2lsWY=; b=bcvjY9a06nNDFTK0ehzG/tVaQ5G2lA2baBo5i1fMU5ChNthM2JoJUorYtHqOqrzGzn456o3If27icXmoKeFUpUZy5AMNw5XYvw/mS8m8PU1ZNtrZ2VU/Vd8PWWW0GmHmR6oTubYdnRCf7R5mfIHH493xalIk2aXNj0eNZxYY8Bo= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by BY5PR10MB3921.namprd10.prod.outlook.com (2603:10b6:a03:1ff::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4713.19; Wed, 17 Nov 2021 04:13:51 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::fdae:8a2c:bee4:9bb2]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::fdae:8a2c:bee4:9bb2%9]) with mapi id 15.20.4713.019; Wed, 17 Nov 2021 04:13:51 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v25 07/12] xfs: Add xfs_attr_set_deferred and xfs_attr_remove_deferred Date: Tue, 16 Nov 2021 21:13:38 -0700 Message-Id: <20211117041343.3050202-8-allison.henderson@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211117041343.3050202-1-allison.henderson@oracle.com> References: <20211117041343.3050202-1-allison.henderson@oracle.com> X-ClientProxiedBy: BY5PR04CA0008.namprd04.prod.outlook.com (2603:10b6:a03:1d0::18) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 Received: from localhost.localdomain (67.1.243.157) by BY5PR04CA0008.namprd04.prod.outlook.com (2603:10b6:a03:1d0::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.27 via Frontend Transport; Wed, 17 Nov 2021 04:13:50 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c124f31d-f2e5-49bb-115a-08d9a980a93d X-MS-TrafficTypeDiagnostic: BY5PR10MB3921: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:494; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: D/Pws+TvQIg7bWdHGHtm8YBNvfgxvY9cfJWL4eCyFVj70leNArz8tA+W6wF6LnuxntUTXGBdIFSqZj6UfkH1Hi1533yuOfNYNxO2ztXAKMHVAG4npFAZL+hPC7s8XRoMzy/lbEAPI1gB+nDZpHrvmUMK1mZMaNLQsnEnfi2d944RLrLFzrfnjdPgLNudcgXNB0mPc/k+xkhCCGU6V9VvQxbDNv6Ii9dZViALWSK57C+WSbegGvd/v8bro8NAHaJmWQq2uH9AXER14bVfWZehej99OhISvTpHeTXKe8s6GHuAXz6a83xCebckXFZ2jyGNXcz4Tvwh5OMALdzQE0I02KKu/Pljb6shmA2/lJ+xglqfuqRnQWhCY9orWXUg1/63dKqjCy5ltNbNB2jwfMiPWoy16g4gIdwPCbaOHkTyQp9jKBMqLrJ2h46M9ibzesX3fov8KKurTGgzZGOCPPL04qZE7SNtRU6WvdUKe2vKbiqcjHRImarIMqDQcuwsW6OYSqot2IhEgCzqx2aX8rXw/trEmFX300izaFA4SremEvEnQmNEkiXcAiF/hRP6xn/Bea5jEYLHsTdJtjzZkkMo2+6AtNWWOl7e2P72icA3gtpjNKO2GHA8s1556dW8khYMxVEL7hRBcNmPt8tFr8kJE7C5Bt3rxq4tm3cxZ/UB1Uugptk7D2SbS0Q1PvqI+ymVkCr1KUFkpsf/wniNsFtwDw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(8936002)(38350700002)(6506007)(2616005)(86362001)(6512007)(5660300002)(8676002)(2906002)(36756003)(83380400001)(508600001)(52116002)(186003)(66946007)(38100700002)(6486002)(316002)(6666004)(44832011)(66556008)(1076003)(66476007)(6916009)(956004)(26005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: POj+FZuL8E0eYSG87SWIMr9r2NmlPpfVDucyx2yX1mMALO/8LyKxalMQ51I6wLk19dYKkF4w1aLOquX4O9LELWCQug8+lpw4SV1TzbAPTGOKMmw32nbiZopNmquCoEXFzFB7RwA/2uf3oDGk7Uw+2xR06va196DyWzhwM9M0MhKbfmKBC2rJhNO997FMFN/12c6LnG6kA6AkKEkB1NviQNxfy22o9TJozc6F1V9ybb6RBOzgkCwXguAwP77oxwX87bvhb469wPLJZFch2QV2vUV9a6j4iBl5UbzasC6sDX9BECLJvj3lPoCflQD6DkThwbs3IInT7j6z5FaMssBInBuW8HFiVOk40HcJ2zKC8UWAMHFY4omblDAVjjWwrhfKK567ozVIgjKI8kiCuKvVbDofSHuA0ctsNJbeY2IMdUjvxk2iUZC1sFLd4ALxb83vbPr9Lu3YnwsyHRmLqZqIgsAiEVi9rNcN2X2Z1m6Gn01n6uYSW/OIXMAoXn1i13moE6w68bZYkL03Nxkn6LTzJJKpLD6E5CKAJA9r/eZZh1ayjdKh6POf4ixLkOWZtFGCzIFwIPH7/WOUXWRPBLrxiH0mywdLqYHAlWkQRUojzkCUrfSvMo2n1BGBXtUi/Nk82kN9sNRY4N43NXbZ/N9AJjOerXCM6jVsqZerfhlHS1YeSnEy6ESZDFOTGsyLpxBnp8P5JmBXCYFfDXcP2qiwJRMr/XZ6MfUzoc9Qrj1iGGh0kwKBOoI0cE2x+UBllY8F7RiUjZhVc3gF03eAlZvxPgLYKBFVktVEuy9P/DQkskPrqRizvdkYzdBOYV9GY6Z9LBk9sNHQRAWMRATRgtV4NmK/Q/VvCezrfDUWcHRKs3aYt2pBz3ydPqdhplYtQp0ZDi+A/Kuyo9tCzkp61XJCNuNYgR7YzNbtKzudMHl5QFmOGAE4O/xUdikOEduXgQ4Uf/CksbRKBcGEOEVU6VO4z3c4KhQBLHSWb2jcYotLYHwTQzFuesFnDDkJ+gcYDzejU46KtC1vDpofe01GsM6cuFjfTvp44QoyMR48rH1W+UD3jzhmdrKNvXF+w2AVfYaVtUOar1tk20HZCsnzCXJ7kIH7vLOxg744mtiZb7FkLLR33O5KedV3/VFbkeRl84j9xGeJrgmCRhRw7nIyHAiiZKFQtxNhlt3Xty2AoeoH4M2jVVRSwS2Fw2gOiUSeXYCrviRnKQC6J7ojJO5C5HyOZflHS21efJX6GrQ6NLir1ibkI6RzReRO6kcFW7/tp8SXzIqzv43HM0rU8ttWVsbQXoRifev1KWlk+bcTiSmKD/897UisHyY+dmHMlSz7ZUTKd9ymg3+VULM92E/3rGBBzfdKktvzlTT1S/kFuz7D3zUE44VSa+KQe20DSU6i25YaDY2xtc1AsJ0CcCBRzeGRIu7U9W2/EtnMwiZfYBG/S3UswhgcXJMPptkGvWz9lkyKo8WB5o/nd8p7zNdhm4AuxK3qUwto0U+l4ks5ML5rW+2qtgZb+JqOYiWnDK28+n51A8/oritnEdSb0DS+oWX5+7psLctQZwpUxu3qOyEX7dkcX6XekG6uwDP9ZeRT6OUyxcaNDKwV9MJiksEPcV/w5Nhd7sF8YsWz1dk9iH1NyX1htPif1WwKNIWTDHN4QQvuQE7YzcnObDOMO/8IAix8VQ== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: c124f31d-f2e5-49bb-115a-08d9a980a93d X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Nov 2021 04:13:51.1050 (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: 406aivzQ+wD6ps8W4m+WfJtoleWoX6eFr1bFcPabXEj9TRPzdtyYImiHqOqOABSdf3lJCOyMwpT6znKE3KToa3jB4AzUdJXK/4b3IpO9yf0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR10MB3921 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10170 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 phishscore=0 bulkscore=0 adultscore=0 mlxlogscore=999 malwarescore=0 mlxscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2111170019 X-Proofpoint-GUID: FQbADWm3GlKMpO6vKSDrh7fBRr-GkKCa X-Proofpoint-ORIG-GUID: FQbADWm3GlKMpO6vKSDrh7fBRr-GkKCa Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Allison Collins These routines set up and queue a new deferred attribute operations. These functions are meant to be called by any routine needing to initiate a deferred attribute operation as opposed to the existing inline operations. New helper function xfs_attr_item_init also added. Finally enable delayed attributes in xfs_attr_set and xfs_attr_remove. Signed-off-by: Allison Henderson Reviewed-by: Darrick J. Wong Reviewed-by: Chandan Babu R --- fs/xfs/libxfs/xfs_attr.c | 71 ++++++++++++++++++++++++++++++++++++++-- fs/xfs/libxfs/xfs_attr.h | 2 ++ fs/xfs/xfs_log.c | 41 +++++++++++++++++++++++ fs/xfs/xfs_log.h | 1 + 4 files changed, 112 insertions(+), 3 deletions(-) diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c index 2ae5b3176253..2bdd1517e417 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -25,6 +25,8 @@ #include "xfs_trans_space.h" #include "xfs_trace.h" #include "xfs_attr_item.h" +#include "xfs_attr.h" +#include "xfs_log.h" /* * xfs_attr.c @@ -726,6 +728,7 @@ xfs_attr_set( int error, local; int rmt_blks = 0; unsigned int total; + int delayed = xfs_has_larp(mp); if (xfs_is_shutdown(dp->i_mount)) return -EIO; @@ -782,13 +785,19 @@ xfs_attr_set( rmt_blks = xfs_attr3_rmt_blocks(mp, XFS_XATTR_SIZE_MAX); } + if (delayed) { + error = xfs_attr_use_log_assist(mp); + if (error) + return error; + } + /* * Root fork attributes can use reserved data blocks for this * operation if necessary */ error = xfs_trans_alloc_inode(dp, &tres, total, 0, rsvd, &args->trans); if (error) - return error; + goto drop_incompat; if (args->value || xfs_inode_hasattr(dp)) { error = xfs_iext_count_may_overflow(dp, XFS_ATTR_FORK, @@ -806,9 +815,10 @@ xfs_attr_set( if (error != -ENOATTR && error != -EEXIST) goto out_trans_cancel; - error = xfs_attr_set_args(args); + error = xfs_attr_set_deferred(args); if (error) goto out_trans_cancel; + /* shortform attribute has already been committed */ if (!args->trans) goto out_unlock; @@ -816,7 +826,7 @@ xfs_attr_set( if (error != -EEXIST) goto out_trans_cancel; - error = xfs_attr_remove_args(args); + error = xfs_attr_remove_deferred(args); if (error) goto out_trans_cancel; } @@ -838,6 +848,9 @@ xfs_attr_set( error = xfs_trans_commit(args->trans); out_unlock: xfs_iunlock(dp, XFS_ILOCK_EXCL); +drop_incompat: + if (delayed) + xlog_drop_incompat_feat(mp->m_log); return error; out_trans_cancel: @@ -846,6 +859,58 @@ xfs_attr_set( goto out_unlock; } +STATIC int +xfs_attr_item_init( + struct xfs_da_args *args, + unsigned int op_flags, /* op flag (set or remove) */ + struct xfs_attr_item **attr) /* new xfs_attr_item */ +{ + + struct xfs_attr_item *new; + + new = kmem_zalloc(sizeof(struct xfs_attr_item), KM_NOFS); + new->xattri_op_flags = op_flags; + new->xattri_dac.da_args = args; + + *attr = new; + return 0; +} + +/* Sets an attribute for an inode as a deferred operation */ +int +xfs_attr_set_deferred( + struct xfs_da_args *args) +{ + struct xfs_attr_item *new; + int error = 0; + + error = xfs_attr_item_init(args, XFS_ATTR_OP_FLAGS_SET, &new); + if (error) + return error; + + xfs_defer_add(args->trans, XFS_DEFER_OPS_TYPE_ATTR, &new->xattri_list); + + return 0; +} + +/* Removes an attribute for an inode as a deferred operation */ +int +xfs_attr_remove_deferred( + struct xfs_da_args *args) +{ + + struct xfs_attr_item *new; + int error; + + error = xfs_attr_item_init(args, XFS_ATTR_OP_FLAGS_REMOVE, &new); + if (error) + return error; + + xfs_defer_add(args->trans, XFS_DEFER_OPS_TYPE_ATTR, &new->xattri_list); + + return 0; +} + /*======================================================================== * External routines when attribute list is inside the inode *========================================================================*/ diff --git a/fs/xfs/libxfs/xfs_attr.h b/fs/xfs/libxfs/xfs_attr.h index b8897f0dd810..8eb1da085a13 100644 --- a/fs/xfs/libxfs/xfs_attr.h +++ b/fs/xfs/libxfs/xfs_attr.h @@ -525,5 +525,7 @@ bool xfs_attr_namecheck(const void *name, size_t length); void xfs_delattr_context_init(struct xfs_delattr_context *dac, struct xfs_da_args *args); int xfs_attr_calc_size(struct xfs_da_args *args, int *local); +int xfs_attr_set_deferred(struct xfs_da_args *args); +int xfs_attr_remove_deferred(struct xfs_da_args *args); #endif /* __XFS_ATTR_H__ */ diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c index 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 Wed Nov 17 04:13:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12623633 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CFE2AC433EF for ; Wed, 17 Nov 2021 04:13:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BC69F61A3A for ; Wed, 17 Nov 2021 04:13:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232453AbhKQEQ4 (ORCPT ); Tue, 16 Nov 2021 23:16:56 -0500 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:15058 "EHLO mx0a-00069f02.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230088AbhKQEQx (ORCPT ); Tue, 16 Nov 2021 23:16:53 -0500 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 1AH2u8cB023615 for ; Wed, 17 Nov 2021 04:13:56 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=lyZr8ZR7meKQDVJuLCfKJ1Kibo8kO8sJWO78Vpq11HQ=; b=GzEXwinUB9lBn0mL+0dmM2g3ywFJhVzqRoExbvW8UZaZrgpT52J8Ws3DvA5d/TVZ2T0x ycSCmUErhUV6i7Su7Ft6PXmpGBgs2B7Hszjo5mVJld58BOBo7sZKVZtpFNBH95Vy+ZkM 4KBEzcK1/qru9CWV7hsMt+w2RfhkLUiqznkZ2PjEV+b6AikRSAVKge0o3P0UDW2sa+Hc qAd+M8S6WMKz99mZCiR4iLT5ESjrlv0ACfDwPMnI0h9YQAWB+t8svonDh1GvNsa9WTG1 LEBgBTaq1KRTKNpeEo0rlj2YEWcmHTi653PuHim7jXJ9BE7a9k+kiknfekFuLgm0xu2C jg== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by mx0b-00069f02.pphosted.com with ESMTP id 3cbfjxwwma-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 17 Nov 2021 04:13:55 +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 1AH4AEJY180636 for ; Wed, 17 Nov 2021 04:13:54 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2176.outbound.protection.outlook.com [104.47.56.176]) by userp3030.oracle.com with ESMTP id 3ca2fx68vt-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 17 Nov 2021 04:13:54 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YqgUG2xgdu1vuBBFL/+cclk5FMvz17tutU9q8M/9Jynd454Qu29a3fvu8wmywBXNhhbc//nbB4ewZtzXwn11k/1VGbo5N+4yQz2bjUCMHkdhCtvXhrdzHAbIqK3qNBr2O07RVa1kFyUc4wShhi9j3umYu0ztXArjhjBhDOiXeYHYG66gvwg3AQznUFqsHdM14DN+i0mYDmDzasdZgw9dB/4RYIl6n4XKhKvRHUZ3YNyan6PmyFMR7ns5VdVd2+S3wc2Jg6UkMUXbokH684pzNZh/DSu3NSE6FC5PimLBhap9TnzbxTmrzM6crpoy4JyTgeUUU3R0sSADDX7oUmQiMw== 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=lyZr8ZR7meKQDVJuLCfKJ1Kibo8kO8sJWO78Vpq11HQ=; b=IoZj3PTrtoB2CM+2W9/pZnyVU6V1U6LuQ/cn7OlE+VwY79Uuv1sca2QBHtYpjFFD95Lks+SRfcj3Su8PPuKt4vFYmuOB/Gs2GwTk5RdnWn44WjcSQGThUogsulbnkAUTPG6aC1ZCKPZ8ezOJe7IgqaXZD+Uj3P3Kw1SVNUiDwFPJbJ7hBryxpYsCKa15U5O0M5yw8R0brBCJYZP0kjv0RhhZWTUD6tg9vIGXTP2gX4DjKSH9f0XLxObq6OALCWFjODnjvqmHQcApj0aRQYZD1rve0rWuBiizu7+1/h962g8Xo7fK9fkSmHKoNUUaZgiLaRViaxaJ7m4fAnf8I7i4aQ== 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=lyZr8ZR7meKQDVJuLCfKJ1Kibo8kO8sJWO78Vpq11HQ=; b=mlVdDJVdoR5AwXGVWjYdgHTrng+i7jstZ/+po+Ci9eLzSF2cQPQrq5g8Ckbglwb1wevFRr3wGWrf0bHpQke9ILYgFfAy97K1Pw5Y/fv99oJyuGd6SlihSRNTlNVe4hMGerKquoOpBuTraxM+0xUx3ZDTVqH/7jG436uBfheK6dM= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by BY5PR10MB3921.namprd10.prod.outlook.com (2603:10b6:a03:1ff::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4713.19; Wed, 17 Nov 2021 04:13:51 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::fdae:8a2c:bee4:9bb2]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::fdae:8a2c:bee4:9bb2%9]) with mapi id 15.20.4713.019; Wed, 17 Nov 2021 04:13:51 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v25 08/12] xfs: Remove unused xfs_attr_*_args Date: Tue, 16 Nov 2021 21:13:39 -0700 Message-Id: <20211117041343.3050202-9-allison.henderson@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211117041343.3050202-1-allison.henderson@oracle.com> References: <20211117041343.3050202-1-allison.henderson@oracle.com> X-ClientProxiedBy: BY5PR04CA0008.namprd04.prod.outlook.com (2603:10b6:a03:1d0::18) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 Received: from localhost.localdomain (67.1.243.157) by BY5PR04CA0008.namprd04.prod.outlook.com (2603:10b6:a03:1d0::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.27 via Frontend Transport; Wed, 17 Nov 2021 04:13:51 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: eb33d6a2-ebe3-4436-6757-08d9a980a96b X-MS-TrafficTypeDiagnostic: BY5PR10MB3921: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7219; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: n7QmJX8oms5CXhvza5sFx7YBnPxiRTSRnELa2tq4hZGbB9moPOIFnv0uOc8lBX8U434lbb9Up9EtyYA+Erz3XsSOKOwGVf8UY3itbknC9hDu31LYENRWRI6RXYHd5JvzZEUuOfz4mXnwGHnv5nJQh9U6mpJTz9RIO/j9cS7glTV5Audr0nNrdt7CzvdR43OHmvoG0VJ6WiJTSvSUYDASFprV0v8Jjzi+twyfK5wJ9eWi64IbgOiYCYPOnkblKj1uni8uiPayMLMbesWFZixl+sBMxi5VJsNaV5lFAlxpMTNqhnmggFtSmcJoBBRkvmEoIndXbempPbWJ2MeakTtxfd2J1+9vLdmnJQCeA43xROHanutSVNzGufBlZF/Gz2sP782AwjjhLVTVuE8YPj5q++6SdG3Ta+zmbqU8ZmoA6/UL9C30odmgT2f4ouCV4a5p6fdMdbvSHdHHAaajsW+h62CKMTiPWAUey4rmh0KSlil/XiWQezmbTWhF42ETgTdCCoCZMeHSlAEWYStBl9ntYP0bma5fbjDbdZFqUVrkzVsOm0Dw95x84f1KDiiK8vARrBWR/moiRnEsB3ac60keyOBv4gK0+wCZ4up/JOTonNEzsnEFLOC6rMlMYvQBXKKuugYMIUQGb0eRtLw0dh3khpOKYBrbAmV9jXFHeZWDozMYPm7I6IJuvq09sGB0mGqETWZ0I4rpWqsgoQEhg5CKyw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(8936002)(38350700002)(6506007)(2616005)(86362001)(6512007)(5660300002)(8676002)(2906002)(36756003)(83380400001)(508600001)(52116002)(186003)(66946007)(38100700002)(6486002)(316002)(6666004)(44832011)(66556008)(1076003)(66476007)(6916009)(956004)(26005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: te5g8cb0tIE2A5vMdtrJ4jt//wJ/PwprpySLEVcQYsfsBAs9STD1T7i8wl8bmqK9THHcyICmHL2yKleyE0X7NT6xjeD0YC6v70+ochcFRdGQy1mddWyEOAEIYdis4aYPk+IjbC3fxJAXh0gyoWlsVUBLYYnulN4+jIJXd+4iK0NaCjy5T4w6wZRhlvLD7Y3AKmKOi/3ds3rUWq5iggE099PJZ1relzJpd1LGBP7QVZCBeS0tYa7vh7IkeJ+e2ScCfVQeVA8cU9hy5FaHGOTVfZzbP9GqYOQzRxy6radScbToBKrd8+RxK9AnJI06Uh89y1JxSZfHr5fH6t10w+cGJ57iGcFfbHe5Z7j630cgrNlEvw35ptUw0eUhfLky/y6WZfbSuV8kLPC6x8B2Y5ts7c6yLr9nJTFwsv0/5floJ6VG0EJQ96wXZKDAhKOtOE2NxhplJ+elQMI34W6EoHjbndgUffKa9PxlKacu2MZFnrIFdT2Fravn7Wmwuxo1z916/wvTP58jxV4uqFcFvAwuVSkCSefmORXFzMlRxRFaqlqwBSOnVzzKJ/r+OhlyLIobcsjtUz00TCZ82Pkszo5c/u8MmULd2Wvk82vRWihl9lpgMtfeNJghAVtO1Jcw93rxhz9VNOik9Nid+IJ+GBy9235TnokbwwIY0NJ9+FEzuyfLdXNn0F0q8d/99WDepxRg4vNNg+/hZO53Hm5kvTPIhIbWlVqY4NIqrmub+z7jTpthdxR/cvaAYJRGDu7uLMT+4TU3YV1dnhdvkUbupuPdUduCQc4EXPzJsaA8lb+KnzAWJs76pMhUgQwOnvrryQtRnm9wfwqI/py2tIERAJkzFbSIt55JR6hHStbnI6HExLBWEYCwRCwG8znIG2WCcVZl477/m4lkvJEpptfYzxhPFCxVY0s+GLNKP+jIeYtasW82GVaO1hvO8W75kpHw6Wt9OpihbSPbsn/dosdqtalvvvD9qEP27hRMV4aL3JziFmRdm9xSnqHxXO6Rrpllq//JvW3g+hkMyGv1CBAYZoKlUIamtI9G3XVU3DIn2Wx4tel5RMxphtYoHLNn/sdQ1UQV5aMYpwFlM9QhFcjgdoEQbnXC51Mlea+SusN3He4Ks8voRdfGcTf54FBCm9MXr+Gg4AowXw7GCbi4++d745OxRCMzndjuEzDWDdWyrTj+N9wcnBIzVU3Lz8py/knh33a1TACzULnvvtlqmFUotEKwpNb1CgSJwv80J0fyNLDvuTMwrZ16A7NLFSLb2pVutDQ00cijEgp/X/sBD3z12o6MCicEgdA/CLysjWK3VFD4sHWc2t06nITWhgmKmrp+EQALQeeNIKFtbm5RAQ/oLm+bHxLbR/ewaapWWneGNJHSSyHnuJ1whE61fRQoh5nRY+CGCzqXKbHBWVOx+T4RX1mJlcZzQY9cQ6lgCxR5+fO++RNNf14eTPGcLntKYnR4UwbUz0Tc31hrWtoSbqLiXvSYEthK/NXeloi40uw8uGS/ZKBPKJJXxWgMW4xXO+6/h/lnRJrx/H3Q/6VcherVW9hUAetF1n/zBIV0WjBjqUMzKZ5XzzIS8p/6hGLPV7pxKttXuFBlYthmcbT6ST1ol+vlk31YCuj8KDb8Jdnb/Q0zPpERUTI7uZU7uTa/jjT3wQLlluQZBn4tWeB5dzpC3rbvLA== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: eb33d6a2-ebe3-4436-6757-08d9a980a96b X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Nov 2021 04:13:51.4057 (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: HI2jzYqU7GGwDdpKtMX2GaphaXfbbcnImoAnFeQ0ZCiGzPZusNjJZE1sD97bjpPUGyNmrlOOG11b+ppUmyNdP1QKiU8o6JFxp4FgHnUwl/Y= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR10MB3921 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10170 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 phishscore=0 bulkscore=0 adultscore=0 mlxlogscore=999 malwarescore=0 mlxscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2111170019 X-Proofpoint-ORIG-GUID: AEgM_MLgLdnPyrrxnbqQJxZaYuiAQBNS X-Proofpoint-GUID: AEgM_MLgLdnPyrrxnbqQJxZaYuiAQBNS 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 | 6 +- 4 files changed, 13 insertions(+), 108 deletions(-) diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c index 2bdd1517e417..1186c0702a0f 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -244,64 +244,9 @@ xfs_attr_is_shortform( ip->i_afp->if_nextents == 0); } -/* - * Checks to see if a delayed attribute transaction should be rolled. If so, - * transaction is finished or rolled as needed. - */ -STATIC int -xfs_attr_trans_roll( - struct xfs_delattr_context *dac) -{ - struct xfs_da_args *args = dac->da_args; - int error; - - if (dac->flags & XFS_DAC_DEFER_FINISH) { - /* - * The caller wants us to finish all the deferred ops so that we - * avoid pinning the log tail with a large number of deferred - * ops. - */ - dac->flags &= ~XFS_DAC_DEFER_FINISH; - error = xfs_defer_finish(&args->trans); - } else - error = xfs_trans_roll_inode(&args->trans, args->dp); - - return error; -} - -/* - * Set the attribute specified in @args. - */ -int -xfs_attr_set_args( - struct xfs_da_args *args) -{ - struct xfs_buf *leaf_bp = NULL; - int error = 0; - struct xfs_delattr_context dac = { - .da_args = args, - }; - - do { - error = xfs_attr_set_iter(&dac, &leaf_bp); - if (error != -EAGAIN) - break; - - error = xfs_attr_trans_roll(&dac); - if (error) { - if (leaf_bp) - xfs_trans_brelse(args->trans, leaf_bp); - return error; - } - } while (true); - - return error; -} - STATIC int xfs_attr_sf_addname( - struct xfs_delattr_context *dac, - struct xfs_buf **leaf_bp) + struct xfs_delattr_context *dac) { struct xfs_da_args *args = dac->da_args; struct xfs_inode *dp = args->dp; @@ -320,7 +265,7 @@ xfs_attr_sf_addname( * It won't fit in the shortform, transform to a leaf block. GROT: * another possible req'mt for a double-split btree op. */ - error = xfs_attr_shortform_to_leaf(args, leaf_bp); + error = xfs_attr_shortform_to_leaf(args, &dac->leaf_bp); if (error) return error; @@ -329,7 +274,7 @@ xfs_attr_sf_addname( * push cannot grab the half-baked leaf buffer and run into problems * with the write verifier. */ - xfs_trans_bhold(args->trans, *leaf_bp); + xfs_trans_bhold(args->trans, dac->leaf_bp); /* * We're still in XFS_DAS_UNINIT state here. We've converted @@ -337,7 +282,6 @@ xfs_attr_sf_addname( * add. */ trace_xfs_attr_sf_addname_return(XFS_DAS_UNINIT, args->dp); - dac->flags |= XFS_DAC_DEFER_FINISH; return -EAGAIN; } @@ -350,8 +294,7 @@ xfs_attr_sf_addname( */ int xfs_attr_set_iter( - struct xfs_delattr_context *dac, - struct xfs_buf **leaf_bp) + struct xfs_delattr_context *dac) { struct xfs_da_args *args = dac->da_args; struct xfs_inode *dp = args->dp; @@ -370,14 +313,14 @@ xfs_attr_set_iter( * release the hold once we return with a clean transaction. */ if (xfs_attr_is_shortform(dp)) - return xfs_attr_sf_addname(dac, leaf_bp); - if (*leaf_bp != NULL) { - xfs_trans_bhold_release(args->trans, *leaf_bp); - *leaf_bp = NULL; + return xfs_attr_sf_addname(dac); + if (dac->leaf_bp != NULL) { + xfs_trans_bhold_release(args->trans, dac->leaf_bp); + dac->leaf_bp = NULL; } if (xfs_attr_is_leaf(dp)) { - error = xfs_attr_leaf_try_add(args, *leaf_bp); + error = xfs_attr_leaf_try_add(args, dac->leaf_bp); if (error == -ENOSPC) { error = xfs_attr3_leaf_to_node(args); if (error) @@ -396,7 +339,6 @@ xfs_attr_set_iter( * be a node, so we'll fall down into the node * handling code below */ - dac->flags |= XFS_DAC_DEFER_FINISH; trace_xfs_attr_set_iter_return( dac->dela_state, args->dp); return -EAGAIN; @@ -687,32 +629,6 @@ xfs_attr_lookup( return xfs_attr_node_hasname(args, NULL); } -/* - * Remove the attribute specified in @args. - */ -int -xfs_attr_remove_args( - struct xfs_da_args *args) -{ - int error; - struct xfs_delattr_context dac = { - .da_args = args, - }; - - do { - error = xfs_attr_remove_iter(&dac); - if (error != -EAGAIN) - break; - - error = xfs_attr_trans_roll(&dac); - if (error) - return error; - - } while (true); - - return error; -} - /* * Note: If args->value is NULL the attribute will be removed, just like the * Linux ->setattr API. @@ -1275,7 +1191,6 @@ xfs_attr_node_addname( * this. dela_state is still unset by this function at * this point. */ - dac->flags |= XFS_DAC_DEFER_FINISH; trace_xfs_attr_node_addname_return( dac->dela_state, args->dp); return -EAGAIN; @@ -1290,7 +1205,6 @@ xfs_attr_node_addname( error = xfs_da3_split(state); if (error) goto out; - dac->flags |= XFS_DAC_DEFER_FINISH; } else { /* * Addition succeeded, update Btree hashvals. @@ -1544,7 +1458,6 @@ xfs_attr_remove_iter( if (error) goto out; dac->dela_state = XFS_DAS_RM_NAME; - dac->flags |= XFS_DAC_DEFER_FINISH; trace_xfs_attr_remove_iter_return(dac->dela_state, args->dp); return -EAGAIN; } @@ -1572,7 +1485,6 @@ xfs_attr_remove_iter( if (error) goto out; - dac->flags |= XFS_DAC_DEFER_FINISH; dac->dela_state = XFS_DAS_RM_SHRINK; trace_xfs_attr_remove_iter_return( dac->dela_state, args->dp); diff --git a/fs/xfs/libxfs/xfs_attr.h b/fs/xfs/libxfs/xfs_attr.h index 8eb1da085a13..977434f343a1 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 5d0ab9a8504e..950ccbc9918a 100644 --- a/fs/xfs/xfs_attr_item.c +++ b/fs/xfs/xfs_attr_item.c @@ -267,7 +267,6 @@ STATIC int xfs_trans_attr_finish_update( struct xfs_delattr_context *dac, struct xfs_attrd_log_item *attrdp, - struct xfs_buf **leaf_bp, uint32_t op_flags) { struct xfs_da_args *args = dac->da_args; @@ -277,7 +276,7 @@ xfs_trans_attr_finish_update( switch (op) { case XFS_ATTR_OP_FLAGS_SET: - error = xfs_attr_set_iter(dac, leaf_bp); + error = xfs_attr_set_iter(dac); break; case XFS_ATTR_OP_FLAGS_REMOVE: ASSERT(XFS_IFORK_Q(args->dp)); @@ -387,7 +386,7 @@ xfs_attr_finish_item( */ dac->da_args->trans = tp; - error = xfs_trans_attr_finish_update(dac, done_item, &dac->leaf_bp, + error = xfs_trans_attr_finish_update(dac, done_item, attr->xattri_op_flags); if (error != -EAGAIN) kmem_free(attr); @@ -547,7 +546,6 @@ xfs_attri_item_recover( xfs_trans_ijoin(tp, ip, 0); ret = xfs_trans_attr_finish_update(&attr->xattri_dac, done_item, - &attr->xattri_dac.leaf_bp, attrp->alfi_op_flags); if (ret == -EAGAIN) { /* There's more work to do, so add it to this transaction */ From patchwork Wed Nov 17 04:13:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12623635 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6BB30C4332F for ; Wed, 17 Nov 2021 04:14:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 52A5E608FE for ; Wed, 17 Nov 2021 04:14:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230088AbhKQEQ5 (ORCPT ); Tue, 16 Nov 2021 23:16:57 -0500 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:48318 "EHLO mx0b-00069f02.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233004AbhKQEQy (ORCPT ); Tue, 16 Nov 2021 23:16:54 -0500 Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 1AH253b8003491 for ; Wed, 17 Nov 2021 04:13:56 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=zNBnGl/0UjqgqDWRsjbwCAzkslDA2qAE3hnn1uxjLwE=; b=KrwoIbkGfPOx0l8+t3QRk6nqunYuxV0NQdzAVV+4WFMjAjvzENIY8vIlDrKkDg1/6lBB UpqGVpLEHYgYFACFVqTXIrbwZth90freiSBYxJLkHS9esgSPbW76DCkoU0MQTZJRb3EK AvKN5A24cG5U0B4QcVUvrbhS/IU3hDkhWf5Pcjh6Ilx6sDEhWMbNaBdYl3y6prMojCMj a46WrTeC/IcWXTjzh8P/Qz9ItOU0x7c030J1RQSa7tjADkzawQ45XDU2j86ZnE5y7UUA aYxv790F4TouHt169e0Kc0080GwHbFRYF7YL1pmkqwhxmlxdYloP3URqmkJCciHlWCe+ HA== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by mx0b-00069f02.pphosted.com with ESMTP id 3cbhv5drkt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 17 Nov 2021 04:13:56 +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 1AH4AEJZ180636 for ; Wed, 17 Nov 2021 04:13:55 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2176.outbound.protection.outlook.com [104.47.56.176]) by userp3030.oracle.com with ESMTP id 3ca2fx68vt-5 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 17 Nov 2021 04:13:54 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=l6y5+w+rZrG947kyY7XjDfNOxHoKCsDMNYphaO6CQZgC2k8wJrCgQFyNIVvRFuDAg9quifkRXSYJGTp+cHBVlL6dw+l3V32CNoMk/j1qASUtB48iNJAtE4yJ10paLC4bBRh2WBbO3g7D86TBw9CwjW+MpXSK82R4Y41B7r24ngCws+TKil3I+Uh0n9glb79d4I/VdDt6ToK1pxRCfejE7oFoKR5MNyUaL/TxDaXgVPEmRIH0Wn1kNx1E68iQeOmXmZLzavKy+PVYbJ9GgTpLl4abVOBc8ujrJEanuN5ANW6FrO4CN++tPFwLqBzVhbQtIwRf2bls+66bY1bwmFVV5Q== 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=zNBnGl/0UjqgqDWRsjbwCAzkslDA2qAE3hnn1uxjLwE=; b=jlcYS/5uHFGDW/pU9Ldg2RRGf4i6WvdzwmYpY5atmGwFkz1AuDnpLcxVDxsvZdxtUVsuY7SvBmyw5YBSWiMSacXQOCk220XE3WUqqrpC9QiFxnGXCxFYx7w7TSlhHNhU38dMY8Im+jRrTRtDuQs+aLuw5ylRe3LwxRXjR/lur9nezNZ+Ha/TkZscxfhPApxGqTVlVLBGjYUd+zZ9PA7W2PkUFhERhILzyd7gN4Jh48evHAujtKiKTKgoHvzBSNtUtnTanUdLrLZ/zE5UBL1UoppnaHuhGn+diH42aW2hT1R1ASa3j7ZoKQwcr20Ar9OmwkqoJndJgrQJcfmxgG+YuA== 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=zNBnGl/0UjqgqDWRsjbwCAzkslDA2qAE3hnn1uxjLwE=; b=vOMFKs+flpnG5tNz3yPN9yrBM3o0a3Ts8ZXw1lg46hPRS3zwXzVqXYRiCIRbnKBRzjMwpoRRFUTEpLTWeLToYeH9AEjKMPfaCEEJglLOrbBwlN4vUqiblCD68jq7JOJj51s/N8YwyHDKV+Z+VwPaXgewDbN1oWiqv2h4z0+YLLc= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by BY5PR10MB3921.namprd10.prod.outlook.com (2603:10b6:a03:1ff::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4713.19; Wed, 17 Nov 2021 04:13:51 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::fdae:8a2c:bee4:9bb2]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::fdae:8a2c:bee4:9bb2%9]) with mapi id 15.20.4713.019; Wed, 17 Nov 2021 04:13:51 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v25 09/12] xfs: Add log attribute error tag Date: Tue, 16 Nov 2021 21:13:40 -0700 Message-Id: <20211117041343.3050202-10-allison.henderson@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211117041343.3050202-1-allison.henderson@oracle.com> References: <20211117041343.3050202-1-allison.henderson@oracle.com> X-ClientProxiedBy: BY5PR04CA0008.namprd04.prod.outlook.com (2603:10b6:a03:1d0::18) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 Received: from localhost.localdomain (67.1.243.157) by BY5PR04CA0008.namprd04.prod.outlook.com (2603:10b6:a03:1d0::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.27 via Frontend Transport; Wed, 17 Nov 2021 04:13:51 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b1e471bb-cf74-42a1-4f1b-08d9a980a997 X-MS-TrafficTypeDiagnostic: BY5PR10MB3921: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2150; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: tvQsF4jIpGQ5pVN2jkwsE/vcLNc5V0OwKbFUngDINPrGU4eye1/NOT6vDpn+8wXp5aJ0HsMTMWZk6qbYXLetHHIMesdkN+EoAgO2zZSx6GKyqwoOh5EFNNK7j55SAVs/Va9Zg4zddkZiLNhEDBDEgOuABONzS/DABq/vpf7LMaGU8VV96dVDmmogtmH+IWugyNcStEHE+XQtIR9VAkKMObmkqM7GNpg2KBXoIHzLDiQOBFHhp6O8mOs2Z1wElnUxWKrfuC3s+Kp6FWfyDVXlvabYPdALi7q9pVeTy1XdzYFpykpXkkdSvKFKgqI0j1ThuWAdXhMyTTLzf5Ti+VN5Qu6s7i+8P3TegurWsQWT0Gd1hhGaK26jkgKhOxSjb7VAknrG+DR53rkTvtfc2SlyFVwGgbP3anns1ZucPl0OacCDA+RVgRSkMZ86X2FbFPYHKlXA/X+P2jbWvITHjBLm1JhEDZKReSBnxR84W1Fc1XkfzrWSrjcWpECtshMFFqPY2Ybq0krmTGjW6YAXRq53RkMAEeXK92JwM23a83KCPgHG8YEg7BRglzmjihpl/9naYYSg9etb877m1CwK8Ahnzxaa+tPYctyYeDZ6b0WCvByi2KbKeJGNbPCiakxyTDrNEQBWBG5iw1aJQA3LebVEo8rdMa9jKfjP+c961Eo03NFyvGx96GqdkqBDdQ8/1awhPRcDpJtzIEaReP04lwLNyA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(8936002)(38350700002)(6506007)(2616005)(86362001)(6512007)(5660300002)(8676002)(2906002)(36756003)(83380400001)(508600001)(52116002)(186003)(66946007)(38100700002)(6486002)(316002)(6666004)(44832011)(66556008)(1076003)(66476007)(6916009)(956004)(26005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 1Z6Bnb518ZsklvTjXAV9y8brRqjSTs8Jaedoqw8spDeQKt3ujoW2Jipyw0w6bphaKs+WbxvO2Ho8NKQwMjvuvPDd6E0qM1nLdiM5l4GA65Bd4NePlLIr/L/RlGZR+Nuhryq7XtKIbfTUMETCxt/fvMNVs51v7EVDRIEmD4sstEMlZnkFZO6TW5KHxvUlrCDAnrabYqPPuVfheVDZK5OWzm4FYnrbBU/nB15S7SNxdavM+c8N8z7k52woJoM1GTAU63A0iMUnE146n/B2W2m7KGeCJZdAj5G7o5jUlAez0LrqtBAYRSDiMoRGo8Hi2pCnr2SVbUnb0reV9bEBzkIBuEj+78TMW4qdqpajnq/FDf8cUGaTB5HKUVqW+H1v3mJj4dTM3DVbiWgggSLuwbgereD8BQi0tH1brJUI+bFSuj3Dxpx+4KEpra8ElhfyQsgLXFiijDA3TUCLrtEZID9AT9yfZIZ2ead9tlVSEnNTPoMKnfGq2X70vbXWjn0gnLuiRTTx6lXmLpJMhXt7z6RZ64EAsEqBNB8yCOcm7bV37rhhIb5eLcGIdrH7OH011XlxX+1JzBr5QzWtSnP2cT97ppT92o3ky2S513aBqI9/yAO+I5XiB8l6imRIgWVD3cca6sVERWTEcjk5dhwkHTXCrvD53OnedoTSNIlaEHbe+/lU8M/PvFj2Onp+gFN2mTANbrk237oK80+XjPJCqz5DDLqANuOZMU4hwphAO1x/JuNZTwfehdqEKKpxU2AUlaOD3/5MpCbP+9tXHsyRBOY25m+obJ++2gPSGoilfyQ8Mja6tw+YqzeaLgtKkAj47D9Ql8CEke5qWJPYjxGQBWd4rTAUdYD9uDaLgpUaXpCW0Ag5bOzlCF4LVbkn4jDaQ5iVF4VYkuT2dYcFlR4EDvGrCRxy/n07DSvs5E8QiLtxp5ALqhr20b2H80EJiojEBLn66Lcb5cGdSiQIS4jX3JUD/YvAn1bPkQql6bCvn02Yzz8ceqAxn6Ip7YU8tsYJs9UaQfSicqkAljxMsWS88oZzk0z6pF0vKR8wbUnxiOOvhuo9P3GzyrtRPV5jww98ttZ2qC3h2gl4/n7yc5PY+2xHbjBwV3MZYxwcD3uQdqO/Y8N0OQWZn7jIa/VMGEH0ai+pR1lmSzLjhYiyWIdXKejc3d3P+RfwZLvujiQ6e1XoC3m17aMA1xfvjfNteVu+qD+Nx98SSN6LJw9sorSZlelAkyoLRBeNKwfpTY6NPrP7ebrxMJaC/dMgPPqNprt6py7YGAxEcC6mdKD8GSRDB79jS5wcZOyuwy9bgp/ztTSRQmYQAmQsCDKbQEpg5Gn+/Op2yJK/rRR5q2OBomdhHSEYV359V/AdXg6TEyZ6tEzEcLKDWLZigRPrK7C1+KyRcVd67C5n3oadQkXM7kVY1hiz04shoQZntNdw9xf1fW+kFQyrT1yjTTSO7jhw5tv3LcID/wyA9b630Tu/MsIAEX/Ll4faZ8kGTkm22MsP1d/oBMHs2Xj14TkoaXo52a8ijcEFpJyCLFgyKbtb9JcO5IZ9D20RZyA6k5v6vhYyMXugcsTEeU8llcD97btNGKReBfbHbqAKZ2alQ+sa8VQoCBY/0ChCNNlMm+na4KbKu/fs/3184GJWFOxR6DdGZfwEfr5N3Gv5dTlZytmInlKZn3YhCg== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: b1e471bb-cf74-42a1-4f1b-08d9a980a997 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Nov 2021 04:13:51.6695 (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: R9xcCGkQgPh4aSeyDJsxJSbf4hDQkH1HMkWtrQlm+sL7/5y83ojhuzYIHQwUvHRoMFKIEgNkMV8JDWQe9ys4nhvdxzH3y4qLPV46rjvwfVw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR10MB3921 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10170 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 phishscore=0 bulkscore=0 adultscore=0 mlxlogscore=999 malwarescore=0 mlxscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2111170019 X-Proofpoint-ORIG-GUID: XnlcG480QeoK9Ns4lzTOyx0p6hP7x4YK X-Proofpoint-GUID: XnlcG480QeoK9Ns4lzTOyx0p6hP7x4YK 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 950ccbc9918a..6c5a59c87526 100644 --- a/fs/xfs/xfs_attr_item.c +++ b/fs/xfs/xfs_attr_item.c @@ -25,6 +25,7 @@ #include "libxfs/xfs_da_format.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" @@ -274,6 +275,11 @@ xfs_trans_attr_finish_update( XFS_ATTR_OP_FLAGS_TYPE_MASK; int error; + if (XFS_TEST_ERROR(false, args->dp->i_mount, XFS_ERRTAG_LARP)) { + error = -EIO; + goto out; + } + switch (op) { case XFS_ATTR_OP_FLAGS_SET: error = xfs_attr_set_iter(dac); @@ -287,6 +293,7 @@ xfs_trans_attr_finish_update( break; } +out: /* * Mark the transaction dirty, even on error. This ensures the * transaction is aborted, which: diff --git a/fs/xfs/xfs_error.c b/fs/xfs/xfs_error.c index 81c445e9489b..d4b2256ba00b 100644 --- a/fs/xfs/xfs_error.c +++ b/fs/xfs/xfs_error.c @@ -57,6 +57,7 @@ static unsigned int xfs_errortag_random_default[] = { XFS_RANDOM_REDUCE_MAX_IEXTENTS, XFS_RANDOM_BMAP_ALLOC_MINLEN_EXTENT, XFS_RANDOM_AG_RESV_FAIL, + XFS_RANDOM_LARP, }; struct xfs_errortag_attr { @@ -170,6 +171,7 @@ XFS_ERRORTAG_ATTR_RW(buf_ioerror, XFS_ERRTAG_BUF_IOERROR); XFS_ERRORTAG_ATTR_RW(reduce_max_iextents, XFS_ERRTAG_REDUCE_MAX_IEXTENTS); XFS_ERRORTAG_ATTR_RW(bmap_alloc_minlen_extent, XFS_ERRTAG_BMAP_ALLOC_MINLEN_EXTENT); XFS_ERRORTAG_ATTR_RW(ag_resv_fail, XFS_ERRTAG_AG_RESV_FAIL); +XFS_ERRORTAG_ATTR_RW(larp, XFS_ERRTAG_LARP); static struct attribute *xfs_errortag_attrs[] = { XFS_ERRORTAG_ATTR_LIST(noerror), @@ -211,6 +213,7 @@ static struct attribute *xfs_errortag_attrs[] = { XFS_ERRORTAG_ATTR_LIST(reduce_max_iextents), XFS_ERRORTAG_ATTR_LIST(bmap_alloc_minlen_extent), XFS_ERRORTAG_ATTR_LIST(ag_resv_fail), + XFS_ERRORTAG_ATTR_LIST(larp), NULL, }; From patchwork Wed Nov 17 04:13:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12623637 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 345FFC43219 for ; Wed, 17 Nov 2021 04:14:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1C706608FE for ; Wed, 17 Nov 2021 04:14:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233011AbhKQEQ5 (ORCPT ); Tue, 16 Nov 2021 23:16:57 -0500 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:48914 "EHLO mx0b-00069f02.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233006AbhKQEQz (ORCPT ); Tue, 16 Nov 2021 23:16:55 -0500 Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 1AH2dGuA030703 for ; Wed, 17 Nov 2021 04:13:56 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=m+pWZv4dcmPUXPWxtyt+HDdPKvQ2PCfFk9aZFr/hUvc=; b=LCdQS3jIUyW6EvgDUxT+HgYyFo/TAUofrOE4hlBcsrmmSyOUop4GnveY0yh3EIyU5C30 tNte4+jkyHHcXc0JvGyrYrvOcbNfNO89VPqBbJ+JM4MGTjd1bg+YqSepUr5NwqPAWN5U xJSdJnRChECdhdWq34YKVAQZrKLR+Y52BzsoGcyycRAGnmhfS/CYIgZWF0lIl2kO2sdk AXfea1psNwD9mgcLhrBfXl54bHQE6aLENmxIdOcT8nOnlDK3J73JhtFxiniyziKBQUyN 0eLbMpPK9+XpZdPa1fDNj9ZaqBz9LQJP+SeAHZz/ywdNfM6wJ8W5okCG2fO+60vnPJJE wg== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by mx0b-00069f02.pphosted.com with ESMTP id 3cbh3e5ba1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 17 Nov 2021 04:13:56 +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 1AH4AEJa180636 for ; Wed, 17 Nov 2021 04:13:55 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2176.outbound.protection.outlook.com [104.47.56.176]) by userp3030.oracle.com with ESMTP id 3ca2fx68vt-6 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 17 Nov 2021 04:13:55 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jTtc7DeDOeiKU/Pm2vN3k1gDgtM8HoqyWNjruPcpiQaesqElYJpv0h3+mAlyWrgziPyOR2alc2T73ezRD0qMDb3G67CSvyMURMJHNZ+lUM/uvb/uRkfDyCQgYy2nnKc7B9IYc4G7pc8i51GIwZXLZnjGGe9yMfxSva+97HhnsFdRsjKkXTPjZp+UB3CCkV4wOkVE0pOnAurQsvkNv+BmuIJbl2eONpRMXfu4h6Fr2bny0gETEEEdcUge4nmP1D3odLWi7Kw94FfbVG6NbKYNv5tsOmDdCkZs5w38R0V87a0mA+fcZwxuILVyA7ObAOwrOmZv+sWgmEg28X2VYuXUWA== 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=m+pWZv4dcmPUXPWxtyt+HDdPKvQ2PCfFk9aZFr/hUvc=; b=nHGHVJSOHCv4wa9xPTxhLxizQyMNBfgHRhoAv+8wq5UonFZ0qhhtb0wb4RpuUfLw0Hje4x8fMlss24KA3SzjQdgUpmXYZ2PzQ4Eds24QzRGsARhz2XHki+FrXld6BpGj77jkymuGyT3pb4YQN3pwz0AydAcjuMgsd+Wh7pXi+LRrvt60pr+iSPSFMbcqZSqShBqBzSJSflOuyWIVqy5dxuYCjJALtoH6KoO8IL8ckA36IEXeRGwXpM0koDQ2zWiWGzjiB1FotUKy/sQzdsJavwQf4wKTWmA1yc/i/zQZoHq0xlWTKT+vsjM6Z5KBhKzRtkQq64slcrLdlJniuEsb0Q== 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=m+pWZv4dcmPUXPWxtyt+HDdPKvQ2PCfFk9aZFr/hUvc=; b=gOXQtB/sUlH40ITchwi6LcLEG6vWJXaqAyixQ3cBpO0TxpgFBv3QhwhJAOhRgsIO5BBi2Ahzd4yIrH1DaHNxmKBgw9/X9nHGJFi2gVg192z2le6V1RhL+lsDeE6dvtxcE1cPttppuhPziv/P8YHr1/ZJZJvX45PHS+ZCBBeDGaA= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by BY5PR10MB3921.namprd10.prod.outlook.com (2603:10b6:a03:1ff::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4713.19; Wed, 17 Nov 2021 04:13:52 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::fdae:8a2c:bee4:9bb2]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::fdae:8a2c:bee4:9bb2%9]) with mapi id 15.20.4713.019; Wed, 17 Nov 2021 04:13:52 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v25 10/12] xfs: Add larp debug option Date: Tue, 16 Nov 2021 21:13:41 -0700 Message-Id: <20211117041343.3050202-11-allison.henderson@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211117041343.3050202-1-allison.henderson@oracle.com> References: <20211117041343.3050202-1-allison.henderson@oracle.com> X-ClientProxiedBy: BY5PR04CA0008.namprd04.prod.outlook.com (2603:10b6:a03:1d0::18) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 Received: from localhost.localdomain (67.1.243.157) by BY5PR04CA0008.namprd04.prod.outlook.com (2603:10b6:a03:1d0::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.27 via Frontend Transport; Wed, 17 Nov 2021 04:13:51 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 463e122b-8ba5-49a0-8127-08d9a980a9be X-MS-TrafficTypeDiagnostic: BY5PR10MB3921: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:644; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: OIo1K1lv4YGp0X8cexhcScguKA8wdpv6+Hr3khRI45kyRtu6QsFIlTT8cNWQ6yeMQvF1LHl3+NxNDk/r8Gn7gd0vHUnFnCpjuimmMkLhRd2ItCO5ElhuN6XAdd0cn+iF5DqyVwLNNwOH6hy3M8gU/IrCTfHX0Q42YG+G06HVBIoMEdkilB5JGYTF4DL+oe01lKMLyBhf4jU1wQd0cKzH6y5bIFzgJeqNtK7FYsGFU1hpCgCMvRLW1CEzQLXHRnakaGleqf6aYg0j3MUYnyb1RdhwkrMrouYWFdt7LwgQ5LoqlGPAB88HjR/67+o99tajXcsibAy45FtITvpq5aBcxeVw0kPa9nxU3HM2gILH/2y61fjGwQcSrD2vSoKh9yFwYXyyZOC4s/t9dR3JhVSkz1c4FzLkpIz6J0qlOz3aEWNbKRJMNUCD/jQqwp8WSqpPznwTWLKRL1YnQEy0KjT39XDoUyiZjSez3NgtK5SD2xAxHKrRvrEAjwMrNPyUTvgWK8HeFrwkF1Shm9XToZBb4pNJf71OMImHrkGsD4k0rKtNQgv2stcpeA2doQGUE4Mtpt6KGAgKvTkcKCYvPM/vDHk3x2L7eqq2qXPv6qU8NNlgpN4L4JHHlUDtakiCzeLcyXu2+wzpaPWRP0q5bPyMN+0Se0NyLiOTFl94gz7TbmDAufgd1ySAMiX3jVanfjlJ0GP71XG2Igy4FiOZQM6zOA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(8936002)(38350700002)(6506007)(2616005)(86362001)(6512007)(5660300002)(8676002)(2906002)(36756003)(83380400001)(508600001)(52116002)(186003)(66946007)(38100700002)(6486002)(316002)(6666004)(44832011)(66556008)(1076003)(66476007)(6916009)(956004)(26005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: R1fbCmopiBT0W61q++FMjAZ7ZNhgLL1uy1pczjAuhKJtrIpZ6CY7EPEXyb5aEkVZlcuiKNPeqkZwXorkZJRCkR05tFr6a1ilr9fd1w4CaOd+l5m4k+VlICRzsAS3AC/Sx9Y8zQe4PTsyGnPMSHL0sUkaC4Ae9k6DGqa7qZIbg19Q/c9xeaSH31D27F6UF7PbEaQOEZ0I1IKVicCmTcHHGDMFqcpLyocCaTqsCwn5rafHmtsqjpVpBnjaF7S3/YrsydFah5MZvwuzcfW8AkI8cmApNL7H6tm0G2ymhcQ1rFg6RMBZ3eRQwBOOi/brvoLDPAHfpVocfBNbiLKvyGLFawQyO1rNnfqgkzddIbphz7ED8sueDbcmo6m4ZDVFSh5YfOpROOJRKTxgAD2On44ZevjVFKRLspeLZdN0MD0rthOq5nmvTUe9/CM7O3AlW35Z9hFNI9pRUdo8ijGwNmC8L76wXnHgcYa3CMUWDp4XByCUqYDGupjpXFJ9k8jK5zx13PglbQ3a2rTidvibk9srxaLtUMnto256mak/iBOEGDA7VCYCVqgSVyVEr9M+bSmvsYZVB/wbgq1A1G2o6nGz2SicM9iTMq+0RNhJwEBH9kzUQ2/Up7CtWodWL/3kizaBn7BN3n4hU7xJamm7r8h2JHq6MuzFsNAkOWiR/LMASEXBSL+4DFwBTtxNepVvCLmdKQFux2uJdyGasE6/C0ETSDMWhAMVz0NQBI3jf/idL4sBbKJpjVr1uiTvEmemTAVxwa9rSN4Tp42W4btFt5i1fYQ/yisE/i8P2jJBhs/niGqURQgeCNgcVVEaIHLzwzJN7xcTrZkuBmvPP5gdiMgH35WVHe65eaXAoL56HCWFVXu+XbPtzbgEvXuy8eTuvJje36k5LHLUkdYrwTz7fPsdbd9K5xoklArPKRsM4Vl4epIBbCYXRtfIpQToYovnnnU1wxLFbxs9WA/OL6TljGhIY+HluR9IXdFn3HVtm61ya/m1fBCYvyz1W2Y6+AGSCoub4vijM9fvfbsk8UY2L+Zz7nilke/4388CB5LKNV63GGPW5hFTY/n2jfGFBwHBOpWxxIlfEKyzJpAjXGNFiYjXq9I3UIO98T3mED2MSTzS/yZU71ppuwyW2ENI/YUBkkTNfM3/seoV3jodc9rb5OjBbFfGvrbEpVUGcTZZf5h5Yc6CJQwVREhjk9V9YJMDEfEfdzuCu8aOttxtgVwUtJr76nh99plazWaF6r+QRrAAE6VWBYvrD4ETwPRkZY0goMdK6jvwGux9yLZWy7C2OGi+GzfXoEMtNJKEzQDjosenwDiLpnSI5e4a/eehbqKg9RclnN6QpJhdloSp3ImxAsRSGRE7IMdGrtQJYmwQevwrfSZsSaaRrJBtnNVxXEqVjUIy4UfFJ9LsSAG6aF2MXytaDTWHNuOhACjpbf3655S0/jdcGWvZFUbeBJ8+TKBBRv9g7ZVVx66NS4dsRXH7Br3HgWEuNcqjgzq3i05hjKe/Clq4y+HMVnLO1B41TZy250q3j1jVh4biYFKYpqKWdod4Kyw2h7VLgXO+reqYHEAkM5R9XmpQzXFFa3dClIptjfCGh1oG+SR36u5e/gb7RTntIRx83Ul5PCTBgr3v75nLrlCERbjMZLaZzMps1y4RArFVSkoRexDIYx3XT73lDVCx7Q== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 463e122b-8ba5-49a0-8127-08d9a980a9be X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Nov 2021 04:13:52.0001 (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: /PW+2Z8SZiUa5Npq0lHG2OXFajoxV6o2YM+SfNxDNPeVUZ4fPMI1l31ToVdhPvtBk1IX0ZoUqMt5pwoTqTW1qcuJbxrLwSYKXDQgZ+4bKpU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR10MB3921 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10170 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 phishscore=0 bulkscore=0 adultscore=0 mlxlogscore=999 malwarescore=0 mlxscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2111170019 X-Proofpoint-GUID: TiUXiZL3Ai4brOOTEEMYc23mvLG-OukG X-Proofpoint-ORIG-GUID: TiUXiZL3Ai4brOOTEEMYc23mvLG-OukG 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 977434f343a1..6f5a150565c7 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 8608f804388f..02a0b55e26b3 100644 --- a/fs/xfs/xfs_sysfs.c +++ b/fs/xfs/xfs_sysfs.c @@ -227,6 +227,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[] = { @@ -236,6 +259,7 @@ static struct attribute *xfs_dbg_attrs[] = { ATTR_LIST(always_cow), #ifdef DEBUG ATTR_LIST(pwork_threads), + ATTR_LIST(larp), #endif NULL, }; From patchwork Wed Nov 17 04:13:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12623641 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EFA4AC433FE for ; Wed, 17 Nov 2021 04:14:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D50D261266 for ; Wed, 17 Nov 2021 04:14:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233000AbhKQEQ7 (ORCPT ); Tue, 16 Nov 2021 23:16:59 -0500 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:17346 "EHLO mx0a-00069f02.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233008AbhKQEQ4 (ORCPT ); Tue, 16 Nov 2021 23:16:56 -0500 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 1AH44w6h031988 for ; Wed, 17 Nov 2021 04:13: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=Mb9n37Weayy5SBC/BVLjLcAimIOaLWkk8jmusVtdRfs=; b=trIu2GzAIRTBxyzhTLy6VDQuGvRD4cmu4hfvxy+Zx3oWXMdWxDOOz7ePCKj6nlHihvpw yCqXHUCUSwKByS6Q5FwoSgWGHb4SYQjQpnBakIHmfSSEpKvoMbXvY8SsG5CqIw7O4sCq sEDis9eMz8MzbBcHMnVlhZh9a8h1utvQ5upUNZflqNT2D1HGIVoO0UijIh94gs5Wpn1Y LemwR5Uu3jp2oESsnwu2Y9clwnkJP2/ZutV7FesRkNh7J0H04DSA5hpBQp0FBXJkw8gV bndqVJXu5x8GJaquctCfK98W56L9xNa8ErMoLA2Ji59YKwIMMiC+nPjfoEkFoP7dQv+K yg== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by mx0b-00069f02.pphosted.com with ESMTP id 3cbhv86em1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 17 Nov 2021 04:13:57 +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 1AH4AEJc180636 for ; Wed, 17 Nov 2021 04:13:56 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2176.outbound.protection.outlook.com [104.47.56.176]) by userp3030.oracle.com with ESMTP id 3ca2fx68vt-8 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 17 Nov 2021 04:13:56 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kXVOYWmtgdcFd5UljJq7Jc2bxJ6SFCXulD+tFdCEqlwRos+CwDFJKA1YeqfIYWewltCJhDDNUm7dsedwsATSgcr025Ihwabp2Dy2UFoEMBADz7sLmf0ajXp+gTqvaUJ+BrVQeEaGFZoiGvPAhsnU5Gyf01iGm/YtebgckHeCUWTEbGdfmYFNSKH/dQzJkXsZrKMr2cIq1a0DnqNCAJ2SIK1ssi49JymSnfCfBuyiZqEILTqPKTsqMa1ximwjbOQLGRxh5LfF499u8GX/+mDsuX8RQyRvsj13QCgauFIaT0MpzI4c5ODCG727CIJt6gcDHg5nD20DB4kHCbytegKKtw== 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=Mb9n37Weayy5SBC/BVLjLcAimIOaLWkk8jmusVtdRfs=; b=JwJBOiPluDVwx8ze9k8zt5B/W7cj+L2WY7LlVN5Se0KmC+V+3NXBa5+ED8gWaK9fZA0TlCDPPZOflpHUUfyLRjvYp0rV2mQ53Kdp/UKt8IC14oJ1DcrUnm4JBKA+5Rj0a3S7ki9kQgfMyo2PuNcN3OcyfQmsosrkTrImTuhxFRy+C6ChgrlM7xbOjsLOCE8t0rXPMPs876Auo1b1lE4A+FNYNijRZ0GZLXFA6+5T8JPlf+nbIIFwK1/YIu1hjLspUjDW2CIjBpUsAJtQgebydX5cEl8aAukVoi9UPqJo0ixiLsD7ey1mGIaS9CP2Yy0egVY5pOds9A3wWlolX5dXQA== 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=Mb9n37Weayy5SBC/BVLjLcAimIOaLWkk8jmusVtdRfs=; b=a+1HOI4Vx+NJJikmfyZxQySWbx+r2oO6rDCxOSfczCNfuaRI8Z8+J7NgWz+VLIc9tGckDlRqXM3XMvxKHkEjKYzDrySGTsEZ2URjJ719GyEwWX13wl0mfD6NxcCmXkmtwHkXZrIi1TLLYMO+VFc6dbFPJFG5BfonvDH4Jzo8W3U= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by BY5PR10MB3921.namprd10.prod.outlook.com (2603:10b6:a03:1ff::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4713.19; Wed, 17 Nov 2021 04:13:52 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::fdae:8a2c:bee4:9bb2]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::fdae:8a2c:bee4:9bb2%9]) with mapi id 15.20.4713.019; Wed, 17 Nov 2021 04:13:52 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v25 11/12] xfs: Merge xfs_delattr_context into xfs_attr_item Date: Tue, 16 Nov 2021 21:13:42 -0700 Message-Id: <20211117041343.3050202-12-allison.henderson@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211117041343.3050202-1-allison.henderson@oracle.com> References: <20211117041343.3050202-1-allison.henderson@oracle.com> X-ClientProxiedBy: BY5PR04CA0008.namprd04.prod.outlook.com (2603:10b6:a03:1d0::18) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 Received: from localhost.localdomain (67.1.243.157) by BY5PR04CA0008.namprd04.prod.outlook.com (2603:10b6:a03:1d0::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.27 via Frontend Transport; Wed, 17 Nov 2021 04:13:52 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: fdc59d05-132c-46cb-d43b-08d9a980a9f3 X-MS-TrafficTypeDiagnostic: BY5PR10MB3921: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:250; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Ki+Hk8xbnGNXec50q+YTkaen7S41Ng9qYPCGy8ykzP4h1UiPvvZ6UJbyYd+oxICQ1LnqE2yqCNyCSKNQMoKCJl65KTi4Yh6fqDKZUpxVoZn9cQOqk1D1wXzoy46wd19saSGKSSuIvf3rB9GggeAtuuAfSryJo3o3QFUWBGrjY2aZyi2XepA9GS6eYiYP4DWxSmz/jOtsseGGqNDq+Bcg43zxBatEWh50OhhDVUi+pTHzIsphb+cCVvA4A/eX2ZWZun4oc4xyG22UkSPk6xwWRJEe7hH64oI0LFp+Vj2we6IFEyvOumE6Qp335cBrWslBn7L0TyT8KIvAFd9gslbWYG4SKQYxnsS4TCEwmvenyek4gbxcCfjJBRZGMAkfwMaCfNmZp7DfqpM8op/I+TZSUcq62MtoZGYZjWk+66GIVMBxY46QdzKcfHbEJgDKwdWhuXNhHUIpRY3PeC+VHY5I31bk9IgtkdpvvdNnzaGsTG3Fw2LirSkWPm3pWA+hTy1LLcd1VubS2nSzvPtHOPzfXOPOhzfvG76tjgGIIJFvtfy235onyUS+KA4/J7FrhOklk4YhvZ+jmvykzuwiVM61NHxc+YFFXz+DG+fQPzf6Y0mD+9yguJhoFaTneFIiUqUROkYDyn8LKqlGJv0MHdvz2NZ0HDP4eV28j7ZIHWqXz41kh06or0qdcMwR/Y4nRV94aEcBDYnOE4kEbWEbg96UXw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(8936002)(38350700002)(6506007)(2616005)(86362001)(30864003)(6512007)(5660300002)(8676002)(2906002)(36756003)(83380400001)(508600001)(52116002)(186003)(66946007)(38100700002)(6486002)(316002)(6666004)(44832011)(66556008)(1076003)(66476007)(6916009)(956004)(26005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: fge0NUbQI6jGj3CX9ce6wjXe6D+l+bWKYenchf9i++CcB4a0iSxoqxWguRVPYTs/ltVaW4ctyCSshhYGBYv4F4QAu7pYla7XaAgmPwOiRSZsF+rGbXuS8B79mp75q3FWxC0SXdtw2joJe609gDwTOoPgUrJ4nVhk6VC0rfmsBasJhOHZpm1MOghBE1dPWZaYwvxjOc3csTFoSSZHmQ9Vytrd3O7YHKrSvtHruax3lmFzURlyt9lzJs33N9B94T0VDCDZH8ZjOoDDf8/HYIU2Ti5xu+jNpDWJdZIqKRZiiPPtaokv9dBPWTArfFgeyxdo1re4h3kLD3nQZYmBj3JeHzSDPC2KkUImgK6WIaSs33teIj0IZzg1X4N/G+ZWP6KherPwr2BPDi/2au5t1xxuin8FQ9cjgseECnTZJvM2DPpoXGeelnmjXuGZCy6xO2ONL+NRQKMPXRo5GRN8pJqYY2EEzbiGN6GdxI7rOVHvWK6Wb2HfDUr9uzJxb41drokDriktt7qQ9hK2gE53KYEjfsBEKF/nzHbUfGFy+VUJ5l9MpaKdGpA0OZspdNpxIOfURNOjRBCobNFhzkOxr6RI1dj5yw26YlCBiLghAlXFIuvjIRmHIP+yzJw/i00qgi9DfRNU6Hgp4MIra+clJtCTcSEC1vYQ1mFddLzolsscPPXYhR9Sssv2LSnaCpOlG8L0ZsMBOmfXsaY2EvAhtAMavmIpI/+eyW3AEcyKBnr50JaXlRr6Q+6lvrtBrCR3/f9id86BvC/MaDwZZd8c2RbRfHMv8EBVKg9L9XujuB/yVdI9CkGi44O533TudwD6ySXdOCkDV1uDGx1QTLDt4cbSiUWS4y2lgdEzrIkLNpk7lO3sos5BMBvoqPiOO/wvyEwKiX1OyS0ReHv+HWs5KEVlWoBMfMuUKmFcJx3B3zNUd1Ylkv9ZXh7VtWQ7+VoD+19dTi8dULjrvj75JlEZq0QkgDuy7dEzh1wzTWcuva4/21/U7qJJtJRWretPQbsvnxIo2sdObtb8jtvN9Fi4mzjbKgD5gABSyknZrZhje9o909nwKaPx7TpguuJuo0LSVfx37kDwDCEV4EYsKMzJH8v/n26yPMFD9AgFQ89Qi2F8NlamY9uO2Rec54c33IUUiYHefmFuTnhVPVG4xGUd+tLq8Je6kPeAC6qC5mleLcJTrFOnpEE0bHPaWoC+Q6ng1G/LPQOmXka4vpChO5zE877QmanyYscMKnIcetaQ97IkXApBhs+VPH/DcdMuSX6UQ/RsN43IQAYEkCn/CUFekD/t58wBmEGW3vb+kuMonXQSYvme23wGip0wPjmoEzEZmtVFtJXC6pe+26yJKdWVfKAAb9cWsW/eZmLmgxP/yMy0hXeNQSkHvCGchcnMXO0xr9IY90KlBtizFcDwU2fR/FhtUizVhb42ysuxKlgrYDMQ/Gh6m13yaG04lEOur7ws98jxVDV/RgtpMm/HH5+TRztqERvOP8F7jZwooKJmrRE/EYIK17hSzxh9ObYs0Tpg9YHbygGN9o/9W1ioiUQfo9kHtFz/n2MFFkVl+tvKEWb90cLVpgi7TkZF8gAjVvswTb7RsDCu5XSaYxNeKid2LQbw1cWaMKKo/hH4URWBq9xT61QQ4vEweI6OYbKnlzk9CbhpuPWPwHNkhKPKPsNJFDwSBA== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: fdc59d05-132c-46cb-d43b-08d9a980a9f3 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Nov 2021 04:13:52.3645 (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: 3oxjNu/YGyfOXDVmxVAkbIPGUC38uCQsTlAaaaBJrkIF16oqt2ZH81zBMcderQeSoUOcBjLjo/byWirq5Y6ZBAuZKMn9UBy2oPDk5CE0ppE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR10MB3921 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10170 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 phishscore=0 bulkscore=0 adultscore=0 mlxlogscore=999 malwarescore=0 mlxscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2111170019 X-Proofpoint-GUID: _ymAnLOMjAgjtc5EM3UhXnckzt5ElcIe X-Proofpoint-ORIG-GUID: _ymAnLOMjAgjtc5EM3UhXnckzt5ElcIe 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 | 40 ++++---- 5 files changed, 142 insertions(+), 142 deletions(-) diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c index 1186c0702a0f..6a04c7e5933d 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -56,10 +56,9 @@ STATIC int xfs_attr_leaf_try_add(struct xfs_da_args *args, struct xfs_buf *bp); */ STATIC int xfs_attr_node_get(xfs_da_args_t *args); STATIC void xfs_attr_restore_rmt_blk(struct xfs_da_args *args); -STATIC int xfs_attr_node_addname(struct xfs_delattr_context *dac); -STATIC int xfs_attr_node_addname_find_attr(struct xfs_delattr_context *dac); -STATIC int xfs_attr_node_addname_clear_incomplete( - struct xfs_delattr_context *dac); +STATIC int xfs_attr_node_addname(struct xfs_attr_item *attr); +STATIC int xfs_attr_node_addname_find_attr(struct xfs_attr_item *attr); +STATIC int xfs_attr_node_addname_clear_incomplete(struct xfs_attr_item *attr); STATIC int xfs_attr_node_hasname(xfs_da_args_t *args, struct xfs_da_state **state); STATIC int xfs_attr_fillstate(xfs_da_state_t *state); @@ -246,9 +245,9 @@ xfs_attr_is_shortform( STATIC int xfs_attr_sf_addname( - struct xfs_delattr_context *dac) + struct xfs_attr_item *attr) { - struct xfs_da_args *args = dac->da_args; + struct xfs_da_args *args = attr->xattri_da_args; struct xfs_inode *dp = args->dp; int error = 0; @@ -265,7 +264,7 @@ xfs_attr_sf_addname( * It won't fit in the shortform, transform to a leaf block. GROT: * another possible req'mt for a double-split btree op. */ - error = xfs_attr_shortform_to_leaf(args, &dac->leaf_bp); + error = xfs_attr_shortform_to_leaf(args, &attr->xattri_leaf_bp); if (error) return error; @@ -274,7 +273,7 @@ xfs_attr_sf_addname( * push cannot grab the half-baked leaf buffer and run into problems * with the write verifier. */ - xfs_trans_bhold(args->trans, dac->leaf_bp); + xfs_trans_bhold(args->trans, attr->xattri_leaf_bp); /* * We're still in XFS_DAS_UNINIT state here. We've converted @@ -294,16 +293,16 @@ xfs_attr_sf_addname( */ int xfs_attr_set_iter( - struct xfs_delattr_context *dac) + struct xfs_attr_item *attr) { - struct xfs_da_args *args = dac->da_args; + struct xfs_da_args *args = attr->xattri_da_args; struct xfs_inode *dp = args->dp; struct xfs_buf *bp = NULL; int forkoff, error = 0; struct xfs_mount *mp = args->dp->i_mount; /* State machine switch */ - switch (dac->dela_state) { + switch (attr->xattri_dela_state) { case XFS_DAS_UNINIT: /* * If the fork is shortform, attempt to add the attr. If there @@ -313,14 +312,16 @@ xfs_attr_set_iter( * release the hold once we return with a clean transaction. */ if (xfs_attr_is_shortform(dp)) - return xfs_attr_sf_addname(dac); - if (dac->leaf_bp != NULL) { - xfs_trans_bhold_release(args->trans, dac->leaf_bp); - dac->leaf_bp = NULL; + return xfs_attr_sf_addname(attr); + if (attr->xattri_leaf_bp != NULL) { + xfs_trans_bhold_release(args->trans, + attr->xattri_leaf_bp); + attr->xattri_leaf_bp = NULL; } if (xfs_attr_is_leaf(dp)) { - error = xfs_attr_leaf_try_add(args, dac->leaf_bp); + error = xfs_attr_leaf_try_add(args, + attr->xattri_leaf_bp); if (error == -ENOSPC) { error = xfs_attr3_leaf_to_node(args); if (error) @@ -340,19 +341,19 @@ xfs_attr_set_iter( * handling code below */ trace_xfs_attr_set_iter_return( - dac->dela_state, args->dp); + attr->xattri_dela_state, args->dp); return -EAGAIN; } else if (error) { return error; } - dac->dela_state = XFS_DAS_FOUND_LBLK; + attr->xattri_dela_state = XFS_DAS_FOUND_LBLK; } else { - error = xfs_attr_node_addname_find_attr(dac); + error = xfs_attr_node_addname_find_attr(attr); if (error) return error; - error = xfs_attr_node_addname(dac); + error = xfs_attr_node_addname(attr); if (error) return error; @@ -364,9 +365,10 @@ xfs_attr_set_iter( !(args->op_flags & XFS_DA_OP_RENAME)) return 0; - dac->dela_state = XFS_DAS_FOUND_NBLK; + attr->xattri_dela_state = XFS_DAS_FOUND_NBLK; } - trace_xfs_attr_set_iter_return(dac->dela_state, args->dp); + trace_xfs_attr_set_iter_return(attr->xattri_dela_state, + args->dp); return -EAGAIN; case XFS_DAS_FOUND_LBLK: /* @@ -377,10 +379,10 @@ xfs_attr_set_iter( */ /* Open coded xfs_attr_rmtval_set without trans handling */ - if ((dac->flags & XFS_DAC_LEAF_ADDNAME_INIT) == 0) { - dac->flags |= XFS_DAC_LEAF_ADDNAME_INIT; + if ((attr->xattri_flags & XFS_DAC_LEAF_ADDNAME_INIT) == 0) { + attr->xattri_flags |= XFS_DAC_LEAF_ADDNAME_INIT; if (args->rmtblkno > 0) { - error = xfs_attr_rmtval_find_space(dac); + error = xfs_attr_rmtval_find_space(attr); if (error) return error; } @@ -390,11 +392,11 @@ xfs_attr_set_iter( * Repeat allocating remote blocks for the attr value until * blkcnt drops to zero. */ - if (dac->blkcnt > 0) { - error = xfs_attr_rmtval_set_blk(dac); + if (attr->xattri_blkcnt > 0) { + error = xfs_attr_rmtval_set_blk(attr); if (error) return error; - trace_xfs_attr_set_iter_return(dac->dela_state, + trace_xfs_attr_set_iter_return(attr->xattri_dela_state, args->dp); return -EAGAIN; } @@ -430,8 +432,8 @@ xfs_attr_set_iter( * Commit the flag value change and start the next trans * in series. */ - dac->dela_state = XFS_DAS_FLIP_LFLAG; - trace_xfs_attr_set_iter_return(dac->dela_state, + attr->xattri_dela_state = XFS_DAS_FLIP_LFLAG; + trace_xfs_attr_set_iter_return(attr->xattri_dela_state, args->dp); return -EAGAIN; } @@ -450,17 +452,18 @@ xfs_attr_set_iter( fallthrough; case XFS_DAS_RM_LBLK: /* Set state in case xfs_attr_rmtval_remove returns -EAGAIN */ - dac->dela_state = XFS_DAS_RM_LBLK; + attr->xattri_dela_state = XFS_DAS_RM_LBLK; if (args->rmtblkno) { - error = xfs_attr_rmtval_remove(dac); + error = xfs_attr_rmtval_remove(attr); if (error == -EAGAIN) trace_xfs_attr_set_iter_return( - dac->dela_state, args->dp); + attr->xattri_dela_state, args->dp); if (error) return error; - dac->dela_state = XFS_DAS_RD_LEAF; - trace_xfs_attr_set_iter_return(dac->dela_state, args->dp); + attr->xattri_dela_state = XFS_DAS_RD_LEAF; + trace_xfs_attr_set_iter_return(attr->xattri_dela_state, + args->dp); return -EAGAIN; } @@ -491,7 +494,7 @@ xfs_attr_set_iter( * state. */ if (args->rmtblkno > 0) { - error = xfs_attr_rmtval_find_space(dac); + error = xfs_attr_rmtval_find_space(attr); if (error) return error; } @@ -504,14 +507,14 @@ xfs_attr_set_iter( * after we create the attribute so that we don't overflow the * maximum size of a transaction and/or hit a deadlock. */ - dac->dela_state = XFS_DAS_ALLOC_NODE; + attr->xattri_dela_state = XFS_DAS_ALLOC_NODE; if (args->rmtblkno > 0) { - if (dac->blkcnt > 0) { - error = xfs_attr_rmtval_set_blk(dac); + if (attr->xattri_blkcnt > 0) { + error = xfs_attr_rmtval_set_blk(attr); if (error) return error; trace_xfs_attr_set_iter_return( - dac->dela_state, args->dp); + attr->xattri_dela_state, args->dp); return -EAGAIN; } @@ -547,8 +550,8 @@ xfs_attr_set_iter( * Commit the flag value change and start the next trans * in series */ - dac->dela_state = XFS_DAS_FLIP_NFLAG; - trace_xfs_attr_set_iter_return(dac->dela_state, + attr->xattri_dela_state = XFS_DAS_FLIP_NFLAG; + trace_xfs_attr_set_iter_return(attr->xattri_dela_state, args->dp); return -EAGAIN; } @@ -568,18 +571,19 @@ xfs_attr_set_iter( fallthrough; case XFS_DAS_RM_NBLK: /* Set state in case xfs_attr_rmtval_remove returns -EAGAIN */ - dac->dela_state = XFS_DAS_RM_NBLK; + attr->xattri_dela_state = XFS_DAS_RM_NBLK; if (args->rmtblkno) { - error = xfs_attr_rmtval_remove(dac); + error = xfs_attr_rmtval_remove(attr); if (error == -EAGAIN) trace_xfs_attr_set_iter_return( - dac->dela_state, args->dp); + attr->xattri_dela_state, args->dp); if (error) return error; - dac->dela_state = XFS_DAS_CLR_FLAG; - trace_xfs_attr_set_iter_return(dac->dela_state, args->dp); + attr->xattri_dela_state = XFS_DAS_CLR_FLAG; + trace_xfs_attr_set_iter_return(attr->xattri_dela_state, + args->dp); return -EAGAIN; } @@ -589,7 +593,7 @@ xfs_attr_set_iter( * The last state for node format. Look up the old attr and * remove it. */ - error = xfs_attr_node_addname_clear_incomplete(dac); + error = xfs_attr_node_addname_clear_incomplete(attr); break; default: ASSERT(0); @@ -786,7 +790,7 @@ xfs_attr_item_init( new = kmem_zalloc(sizeof(struct xfs_attr_item), KM_NOFS); new->xattri_op_flags = op_flags; - new->xattri_dac.da_args = args; + new->xattri_da_args = args; *attr = new; return 0; @@ -1099,16 +1103,16 @@ xfs_attr_node_hasname( STATIC int xfs_attr_node_addname_find_attr( - struct xfs_delattr_context *dac) + struct xfs_attr_item *attr) { - struct xfs_da_args *args = dac->da_args; + struct xfs_da_args *args = attr->xattri_da_args; int retval; /* * Search to see if name already exists, and get back a pointer * to where it should go. */ - retval = xfs_attr_node_hasname(args, &dac->da_state); + retval = xfs_attr_node_hasname(args, &attr->xattri_da_state); if (retval != -ENOATTR && retval != -EEXIST) return retval; @@ -1136,8 +1140,8 @@ xfs_attr_node_addname_find_attr( return 0; error: - if (dac->da_state) - xfs_da_state_free(dac->da_state); + if (attr->xattri_da_state) + xfs_da_state_free(attr->xattri_da_state); return retval; } @@ -1158,10 +1162,10 @@ xfs_attr_node_addname_find_attr( */ STATIC int xfs_attr_node_addname( - struct xfs_delattr_context *dac) + struct xfs_attr_item *attr) { - struct xfs_da_args *args = dac->da_args; - struct xfs_da_state *state = dac->da_state; + struct xfs_da_args *args = attr->xattri_da_args; + struct xfs_da_state *state = attr->xattri_da_state; struct xfs_da_state_blk *blk; int error; @@ -1192,7 +1196,7 @@ xfs_attr_node_addname( * this point. */ trace_xfs_attr_node_addname_return( - dac->dela_state, args->dp); + attr->xattri_dela_state, args->dp); return -EAGAIN; } @@ -1221,9 +1225,9 @@ xfs_attr_node_addname( STATIC int xfs_attr_node_addname_clear_incomplete( - struct xfs_delattr_context *dac) + struct xfs_attr_item *attr) { - struct xfs_da_args *args = dac->da_args; + struct xfs_da_args *args = attr->xattri_da_args; struct xfs_da_state *state = NULL; struct xfs_mount *mp = args->dp->i_mount; int retval = 0; @@ -1327,10 +1331,10 @@ xfs_attr_leaf_mark_incomplete( */ STATIC int xfs_attr_node_removename_setup( - struct xfs_delattr_context *dac) + struct xfs_attr_item *attr) { - struct xfs_da_args *args = dac->da_args; - struct xfs_da_state **state = &dac->da_state; + struct xfs_da_args *args = attr->xattri_da_args; + struct xfs_da_state **state = &attr->xattri_da_state; int error; error = xfs_attr_node_hasname(args, state); @@ -1389,16 +1393,16 @@ xfs_attr_node_removename( */ int xfs_attr_remove_iter( - struct xfs_delattr_context *dac) + struct xfs_attr_item *attr) { - struct xfs_da_args *args = dac->da_args; - struct xfs_da_state *state = dac->da_state; + struct xfs_da_args *args = attr->xattri_da_args; + struct xfs_da_state *state = attr->xattri_da_state; int retval, error = 0; struct xfs_inode *dp = args->dp; trace_xfs_attr_node_removename(args); - switch (dac->dela_state) { + switch (attr->xattri_dela_state) { case XFS_DAS_UNINIT: if (!xfs_inode_hasattr(dp)) return -ENOATTR; @@ -1417,16 +1421,16 @@ xfs_attr_remove_iter( * Node format may require transaction rolls. Set up the * state context and fall into the state machine. */ - if (!dac->da_state) { - error = xfs_attr_node_removename_setup(dac); + if (!attr->xattri_da_state) { + error = xfs_attr_node_removename_setup(attr); if (error) return error; - state = dac->da_state; + state = attr->xattri_da_state; } fallthrough; case XFS_DAS_RMTBLK: - dac->dela_state = XFS_DAS_RMTBLK; + attr->xattri_dela_state = XFS_DAS_RMTBLK; /* * If there is an out-of-line value, de-allocate the blocks. @@ -1439,10 +1443,10 @@ xfs_attr_remove_iter( * May return -EAGAIN. Roll and repeat until all remote * blocks are removed. */ - error = xfs_attr_rmtval_remove(dac); + error = xfs_attr_rmtval_remove(attr); if (error == -EAGAIN) { trace_xfs_attr_remove_iter_return( - dac->dela_state, args->dp); + attr->xattri_dela_state, args->dp); return error; } else if (error) { goto out; @@ -1457,8 +1461,10 @@ xfs_attr_remove_iter( error = xfs_attr_refillstate(state); if (error) goto out; - dac->dela_state = XFS_DAS_RM_NAME; - trace_xfs_attr_remove_iter_return(dac->dela_state, args->dp); + + attr->xattri_dela_state = XFS_DAS_RM_NAME; + trace_xfs_attr_remove_iter_return( + attr->xattri_dela_state, args->dp); return -EAGAIN; } @@ -1468,7 +1474,7 @@ xfs_attr_remove_iter( * If we came here fresh from a transaction roll, reattach all * the buffers to the current transaction. */ - if (dac->dela_state == XFS_DAS_RM_NAME) { + if (attr->xattri_dela_state == XFS_DAS_RM_NAME) { error = xfs_attr_refillstate(state); if (error) goto out; @@ -1485,9 +1491,9 @@ xfs_attr_remove_iter( if (error) goto out; - dac->dela_state = XFS_DAS_RM_SHRINK; + attr->xattri_dela_state = XFS_DAS_RM_SHRINK; trace_xfs_attr_remove_iter_return( - dac->dela_state, args->dp); + attr->xattri_dela_state, args->dp); return -EAGAIN; } diff --git a/fs/xfs/libxfs/xfs_attr.h b/fs/xfs/libxfs/xfs_attr.h index 6f5a150565c7..6e4c8e763690 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 6c5a59c87526..02bc2d8d468b 100644 --- a/fs/xfs/xfs_attr_item.c +++ b/fs/xfs/xfs_attr_item.c @@ -266,11 +266,11 @@ xfs_attrd_item_release( */ STATIC int xfs_trans_attr_finish_update( - struct xfs_delattr_context *dac, + struct xfs_attr_item *attr, struct xfs_attrd_log_item *attrdp, uint32_t op_flags) { - struct xfs_da_args *args = dac->da_args; + struct xfs_da_args *args = attr->xattri_da_args; unsigned int op = op_flags & XFS_ATTR_OP_FLAGS_TYPE_MASK; int error; @@ -282,11 +282,11 @@ xfs_trans_attr_finish_update( switch (op) { case XFS_ATTR_OP_FLAGS_SET: - error = xfs_attr_set_iter(dac); + error = xfs_attr_set_iter(attr); break; case XFS_ATTR_OP_FLAGS_REMOVE: ASSERT(XFS_IFORK_Q(args->dp)); - error = xfs_attr_remove_iter(dac); + error = xfs_attr_remove_iter(attr); break; default: error = -EFSCORRUPTED; @@ -330,16 +330,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. */ @@ -380,10 +380,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); @@ -391,9 +389,9 @@ xfs_attr_finish_item( * Always reset trans after EAGAIN cycle * since the transaction is new */ - dac->da_args->trans = tp; + attr->xattri_da_args->trans = tp; - error = xfs_trans_attr_finish_update(dac, done_item, + error = xfs_trans_attr_finish_update(attr, done_item, attr->xattri_op_flags); if (error != -EAGAIN) kmem_free(attr); @@ -515,7 +513,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; @@ -552,7 +550,7 @@ xfs_attri_item_recover( xfs_ilock(ip, XFS_ILOCK_EXCL); xfs_trans_ijoin(tp, ip, 0); - ret = xfs_trans_attr_finish_update(&attr->xattri_dac, done_item, + ret = xfs_trans_attr_finish_update(attr, done_item, attrp->alfi_op_flags); if (ret == -EAGAIN) { /* There's more work to do, so add it to this transaction */ @@ -568,8 +566,8 @@ xfs_attri_item_recover( error = xfs_defer_ops_capture_and_commit(tp, capture_list); out_unlock: - if (attr->xattri_dac.leaf_bp) - xfs_buf_relse(attr->xattri_dac.leaf_bp); + if (attr->xattri_leaf_bp) + xfs_buf_relse(attr->xattri_leaf_bp); xfs_iunlock(ip, XFS_ILOCK_EXCL); xfs_irele(ip); From patchwork Wed Nov 17 04:13:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12623639 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 87E4CC433F5 for ; Wed, 17 Nov 2021 04:14:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7493661501 for ; Wed, 17 Nov 2021 04:14:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233004AbhKQEQ6 (ORCPT ); Tue, 16 Nov 2021 23:16:58 -0500 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:17210 "EHLO mx0a-00069f02.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233000AbhKQEQ4 (ORCPT ); Tue, 16 Nov 2021 23:16:56 -0500 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 1AH48UCN032014 for ; Wed, 17 Nov 2021 04:13: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=IjPCCIe3uLXXNy4Lw8Jv2YglFcF7EEtek0sXCKNYw/U=; b=0QlH/rLM3pvW1wdkrhmMPTtEa3/PTa7uq3kYWAv/0gmkr1wpzDzYBO4otoOZhOtVGUUg 8spl8TEZ1D6XKIzUdoh3ssu92/gVdKRY5KYQz3LbabCnOFavNc5IusRxZtZFXw8myZHP dXeOGZEuNbf0UODEG8zL9i8BNIajFK3VxukqVOOADisSVnrZXD7OHLZtpfuS5FY1WzPk MPMNYY0cTNCNnaUrl6JSZjPA68fXMPvX463uoDFVk2zSQJrXyHWR8dymcL8hKahsDm4s wLUr/dqmJ4miZoRJNlY7kxNdv8i/hVTGwpiYSV/aHFl7Loh5/VFZWcMLNckshTivnBcV Dg== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by mx0b-00069f02.pphosted.com with ESMTP id 3cbhv86em0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 17 Nov 2021 04:13:57 +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 1AH4AEJb180636 for ; Wed, 17 Nov 2021 04:13:56 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2176.outbound.protection.outlook.com [104.47.56.176]) by userp3030.oracle.com with ESMTP id 3ca2fx68vt-7 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 17 Nov 2021 04:13:55 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VrjGT02bb/aP8XmMpb4k0lKVAwLcIyG/1+vHIVfBbiHYSoi0nR2OsGvxKhPdHdye8rd39bqho1mwU4LShYtFpoIzB2/N5YNUHMY3JSnwa167w7M5fhB7qal/BKi2EARbcJje5MnLms7eQ4Bzq1i1CEu7VDSh2N3LQpgbe83uDHd3PnviNFJQHTfgFj5FemAWRUDAbTSHH9bedEH8Km0XxN1odkoFK3pnKbF3V5026i4G6wVZsIUNb7m59e1ZtPgv5lYmvZlvoY3FCheY/u6UokgQOHANKftu+nWzMhLTNpa07zV4KHujmmsT1CdSgBOV7dh+G1dfnMTendqzZKvQLw== 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=IjPCCIe3uLXXNy4Lw8Jv2YglFcF7EEtek0sXCKNYw/U=; b=lN6i8vxhcDcTHmdKHdgYzniIpxs5H4exRZQi383puc7L1ZqOBBKWty6hl9m9xqfKS6muxwKovdeyEgSHO/oyQ/BWSwjxGUhiCYA2C7nm+vL1qtYm5j4rerotH5g/rGf40u8zf3cpTXjmxUwR9fpVomnHwuw+XJ4p0oBNxoAtEOuLfC/JsA/RQTUqAkkJbEH9uswzEnUa9rVPrgFXlVPzhtPW6EuVjTagBH4snADIidsT4tcYl6IyYfQFljH654l6DHaV9TvvwBGVJnW/dC3TIls93ZCTkrjtWn+JkObIXUEKLHrq7tWQdM4AytvZKciReGOMWe/3rxiAWklYCAREsQ== 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=IjPCCIe3uLXXNy4Lw8Jv2YglFcF7EEtek0sXCKNYw/U=; b=Q7yHqtoLU2F6lJTWk0hOTgiql8DZjN3vC/D5bbbbfHbsPHlBZSL2AC4OuiGtImrd4pFylwjEH+6MZ0kf9JWpjCQn9M2HTu0oA3HOvQ4i2jaogsCJS4ETLAkmzPQVIawD2HIxCL3hd5Psk+h45mSPfzvGy9nIALhPV+fom60YQPM= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by BY5PR10MB3921.namprd10.prod.outlook.com (2603:10b6:a03:1ff::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4713.19; Wed, 17 Nov 2021 04:13:52 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::fdae:8a2c:bee4:9bb2]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::fdae:8a2c:bee4:9bb2%9]) with mapi id 15.20.4713.019; Wed, 17 Nov 2021 04:13:52 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v25 12/12] xfs: Add helper function xfs_attr_leaf_addname Date: Tue, 16 Nov 2021 21:13:43 -0700 Message-Id: <20211117041343.3050202-13-allison.henderson@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211117041343.3050202-1-allison.henderson@oracle.com> References: <20211117041343.3050202-1-allison.henderson@oracle.com> X-ClientProxiedBy: BY5PR04CA0008.namprd04.prod.outlook.com (2603:10b6:a03:1d0::18) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 Received: from localhost.localdomain (67.1.243.157) by BY5PR04CA0008.namprd04.prod.outlook.com (2603:10b6:a03:1d0::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.27 via Frontend Transport; Wed, 17 Nov 2021 04:13:52 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1d4b8675-160b-41fc-1700-08d9a980aa28 X-MS-TrafficTypeDiagnostic: BY5PR10MB3921: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:10000; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: gFedu3n483nhyaxynjwRIC3KH0NQXr2B753p/+ZTP1yNLHGpqVUS4uHS+44Vo9dBzawNc+kcqiCDgHyRpdInZUEdzC7DfdAmgfwi8k1TrgcoDb2CQpWAFcuwwQLb3W6u90r4Zhii7USwB/5Th8AlP2mqmJVpWk9WtgPt+0FIkstZV6rCMbeVKG8iQi0rLlNga0m+0lnmiuiv+CREYokSVAAg8yTcxIm0xU2CSR1Nwg/zm1L8/UdZ5YN9NfikFgETIp1TpzdyaEeKtd/btxMre+6r94yEdbs4uORuSPOIuZx5Bb0Qh2YDnDIy12gGczMdZHpz30ia74cyy3+CgB3skHt6pzHjQgvpCtT5gKHxBAdRpUCBYQVnKiOHBMuWnTgJPexjJbhUUgr8p7nXVwFsFRRCCQdJupedjnJ3Is7alJtyCEweLRyhOAMXBeHIoq49Ri4ISJdPjxh9oUBS18qVXeMEX4RYglpMykENsA117h76xr0a9RNyPsTdjvrwwvBAHF/Gf7l8Usuxu0UwRgLPvRt570h3HyDYs1Lf1By1PUYCKYaVTI+Q8mknwvuo7A3CDkNL54OKwXaI84FtSWcMBJfoPBTP7kk7BTXqN3W9WDmJQz+xOLWaCiDi+APmrTgIMlbiyTYbMYUBCork0rTi19CvAo5OxIluZMQ27UdVYNgi8yrijzCHh5O3jF6eLO7PlGudPuD/iipTsEjesfYLjw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(8936002)(38350700002)(6506007)(2616005)(86362001)(6512007)(5660300002)(8676002)(2906002)(36756003)(83380400001)(508600001)(52116002)(186003)(66946007)(38100700002)(6486002)(316002)(6666004)(44832011)(66556008)(1076003)(66476007)(6916009)(956004)(26005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: fuP7ELRK3LbACIfujbTcTaEf2Uxt6omWzOm+6F1ixrPi0i7q0EKM5teJIXpqj5zdvVReb+XQUeEul/FQaLqJhPlqqZJ6RZuOA/afbrx+MqDYbF86WS5R6BEEkfY4OUP0JBB07PKgUhVeAJCN+D/uberWdeJC46xmIAVUqPRdYrur+SXKrBU+buRm5JqWCVJAae6P41qJQaHxBuYtE3M/o69pzyWPdaGr8H1Xp2Yhq2jborVQmpvsFenoGCoh1JCSwTlSBBFIG+wM4myJmjRsQhRWaYkX1ecK398XghrmKIpwstC7dSjnjT2pU9iJvkK1NW1gijvxE0WRuVGqcjT+7xNoZJ7qk4oGWeEc+LTZnSs2C5ATsZ8Fd4Reu0UaoTSU4frEEWK2qH0YpkEJicJqM4toC1/g0mTzH88BQp5/MtPSWG700UgBn8DMBJcpsvsBrbf6bGP7k4UpXUQYHMLRsou1dpbOmL57WUWlPbScJXOabjw1Uj3OVbYLngHeCBBrZWq5ptTCXikhPjQtCTdWsqRiNjEDfNh9vTIeePe36KYTfwb9lQrKbErymV6H+bgSbDJSQ2vBes0TMsc1GN9FRWwfPwE7zwTz68/le+VpEIWn3l+P/jmw2Bx2Dj1ZzkYwf4uNd+1mRPrxs53dxze+ujg7LPnXz0zVDORZfiSy5kWIGnNndbgFrZ2wQQv1FQe/l6HLdrtII8HYco2RUqDig/uyaNLx818bPKPt01r+4kMskfaeAZ0Qqmi9kJ7fkq6iFj4ql8vE7uLM/M2w4gLazQcNNyDHgDrZBMnG5qPmmur0aL0YAQTrKg6E5caMfW+kcElsDXxiykGsEark7ypL3rSx2aTj4gMAI39jk9qB+LKqAif6LQesavWMxueNRzebquJqkVgJ6v7VVYbqjbWQQ82G0CIs/H2CAGEaC24ciIPG1it4iQlCkiYxuMhwr627PJfNAhENi8xh/XCmhoNJKl/nYetquqn8c2mvrf2rYsE4bvIvZk1BTsS8PeaLwiOcgzs+lpwktG9tNHej3x7hPGfotu39aUowkQvZaI+B4wV5b4DF92pmxg4cllrLw7UM7/ILXRinrTlii2FcllUCROElT4NqpEy3WzhunCUacwwrp+/wpJSgmOm1qhQB2Rtf2pLCIzdrLn+6lR8niccWnrkd2Cuio6pkTTMWP1xnuWRvaOCmMs3xzBaGEqFv9+pILMacJHI7JTrEJJ+/WGZmB3yDSlLQOnRmkTKZIr5bmYlPPnZg0UDwlCG1zfv6GVpEd1IXEn/LdQuOv7wYLiGz7kCNirZlLmPO19NkXezUqzuW8V5pYBwG5V9sZOH4B1mTDJHRay1pS0pVkDbksEf62OKc9RG/IV0geEIBmeoKwV+ECMrNzWZhx1I5qSslemIs9wQCnDFTWzQKOWiGlWh33t77x2BeTwqmdKR1AsqGx5dB4B0cjr5/OBQ3pPyMgXbJ6dfCmU42XslL8w+MQsjtWpChzG3mlvjGN2LZ+Vted7nemHoksNKiuiRVw3dbeMZ3szBmIAsIkxznMIwz2AW0k7Euzjdrx6LF+5tekH2yCrfAf/K8lbJt/hXnReiOv842muHgC7Nrxo1T7ERN4WpEKJcSXYc99jBJhGOByjdTIlmF16ZYLDsQVhHtgbZqCfOCJPmATyhZ683KR5ScRXSdNg== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1d4b8675-160b-41fc-1700-08d9a980aa28 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Nov 2021 04:13:52.6413 (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: 6gLUoGHoNiznlmGhyWyKZFpUatehPSkOQTXWo5e4rdkB3hs4Ivkhxs0JTMBNQ+9sFZOthnGMYsHJPLZkKtNKn2Ca2kERngy52GSwMU4EVmU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR10MB3921 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10170 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 phishscore=0 bulkscore=0 adultscore=0 mlxlogscore=999 malwarescore=0 mlxscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2111170019 X-Proofpoint-GUID: 5MpfiuHRlEOaxRnjgxGxYUp-hywWZVrO X-Proofpoint-ORIG-GUID: 5MpfiuHRlEOaxRnjgxGxYUp-hywWZVrO 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 6a04c7e5933d..e49284325d04 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -284,6 +284,65 @@ xfs_attr_sf_addname( return -EAGAIN; } +STATIC int +xfs_attr_leaf_addname( + struct xfs_attr_item *attr) +{ + struct xfs_da_args *args = attr->xattri_da_args; + struct xfs_inode *dp = args->dp; + int error; + + if (xfs_attr_is_leaf(dp)) { + error = xfs_attr_leaf_try_add(args, attr->xattri_leaf_bp); + if (error == -ENOSPC) { + error = xfs_attr3_leaf_to_node(args); + if (error) + return error; + + /* + * Finish any deferred work items and roll the + * transaction once more. The goal here is to call + * node_addname with the inode and transaction in the + * same state (inode locked and joined, transaction + * clean) no matter how we got to this step. + * + * At this point, we are still in XFS_DAS_UNINIT, but + * when we come back, we'll be a node, so we'll fall + * down into the node handling code below + */ + trace_xfs_attr_set_iter_return( + attr->xattri_dela_state, args->dp); + return -EAGAIN; + } + + if (error) + return error; + + attr->xattri_dela_state = XFS_DAS_FOUND_LBLK; + } else { + error = xfs_attr_node_addname_find_attr(attr); + if (error) + return error; + + error = xfs_attr_node_addname(attr); + if (error) + return error; + + /* + * If addname was successful, and we dont need to alloc or + * remove anymore blks, we're done. + */ + if (!args->rmtblkno && + !(args->op_flags & XFS_DA_OP_RENAME)) + return 0; + + attr->xattri_dela_state = XFS_DAS_FOUND_NBLK; + } + + trace_xfs_attr_leaf_addname_return(attr->xattri_dela_state, args->dp); + return -EAGAIN; +} + /* * Set the attribute specified in @args. * This routine is meant to function as a delayed operation, and may return @@ -319,57 +378,8 @@ xfs_attr_set_iter( attr->xattri_leaf_bp = NULL; } - if (xfs_attr_is_leaf(dp)) { - error = xfs_attr_leaf_try_add(args, - attr->xattri_leaf_bp); - if (error == -ENOSPC) { - error = xfs_attr3_leaf_to_node(args); - if (error) - return error; - - /* - * Finish any deferred work items and roll the - * transaction once more. The goal here is to - * call node_addname with the inode and - * transaction in the same state (inode locked - * and joined, transaction clean) no matter how - * we got to this step. - * - * At this point, we are still in - * XFS_DAS_UNINIT, but when we come back, we'll - * be a node, so we'll fall down into the node - * handling code below - */ - trace_xfs_attr_set_iter_return( - attr->xattri_dela_state, args->dp); - return -EAGAIN; - } else if (error) { - return error; - } - - attr->xattri_dela_state = XFS_DAS_FOUND_LBLK; - } else { - error = xfs_attr_node_addname_find_attr(attr); - if (error) - return error; + return xfs_attr_leaf_addname(attr); - error = xfs_attr_node_addname(attr); - if (error) - return error; - - /* - * If addname was successful, and we dont need to alloc - * or remove anymore blks, we're done. - */ - if (!args->rmtblkno && - !(args->op_flags & XFS_DA_OP_RENAME)) - return 0; - - attr->xattri_dela_state = XFS_DAS_FOUND_NBLK; - } - trace_xfs_attr_set_iter_return(attr->xattri_dela_state, - args->dp); - return -EAGAIN; case XFS_DAS_FOUND_LBLK: /* * If there was an out-of-line value, allocate the blocks we diff --git a/fs/xfs/xfs_trace.h b/fs/xfs/xfs_trace.h index 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);