From patchwork Wed Mar 8 22:37:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 13166517 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 29B0FC74A44 for ; Wed, 8 Mar 2023 22:38:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229708AbjCHWiR (ORCPT ); Wed, 8 Mar 2023 17:38:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33794 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229801AbjCHWiN (ORCPT ); Wed, 8 Mar 2023 17:38:13 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8BF9F34F78 for ; Wed, 8 Mar 2023 14:38:12 -0800 (PST) Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 328Jxuqe026675 for ; Wed, 8 Mar 2023 22:38:12 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-2022-7-12; bh=c2vpJvOtq9qJvLcor06pWWGrAIAYm1ZeINLc4MN6fEA=; b=Do/y7YHQCrADpuM27+PmcdDfvyhKWbsQ5G9Fq/OPsDRYGaL5DtdEYfxbM4I92E7voFWY gsgejYqIjevTUo0UQ5a25me0LSA7uDzfPmBELjWmN4G0/b/q9AnMFkHepdnWrcld3tVh OLWhYq9naliVE8MUbaZt1OrPtdi1yMpYpErP/y2BB4sxUf5Ke2Tif6gjq9leIpS4XKCR oEDeEm33sTWPjDOfCD4JsfZXZgt+q+UIWz+zwppbdjoGWvce4uEI6JUJHjAY9JFLp1A4 hMr+voE+xMGiM3cKJ4DSHQOjFeq8lkPpPk2we3fupKGl1bYJYDxEv5cz967GolSPX6Bx PA== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3p5nn95qe7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 08 Mar 2023 22:38:12 +0000 Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 328MAF4o036499 for ; Wed, 8 Mar 2023 22:38:10 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2106.outbound.protection.outlook.com [104.47.70.106]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3p6g464w1m-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 08 Mar 2023 22:38:10 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=acvvAXNdoamshUGv5sLgLYOrylmadzqh0xh6IMsv3ZPM5I37Uhlv8pUy0UMtaJrxO89vA1lZBmkjRQ5nJaL4s2DZOvGUR9gfcEYNfpOxOb9Ctww+bO+9C9vJo/v6EgGXf5wegQi7XKkXxZfG8oSSCMTThhUiDF2z1PBHLZd4HR6+AyEampVDRLto9kg9kCLuS8JrasvTC4+O8qAON5iMqYgw7ZvuoIBIPKLfupXBwX/MizxI6UifodykgIreCF2TmX/QTEwljtLsgZpVSEC4khlboh5H0o7JTs5XupfXda8X3nJPl0gevEsRcYm+G6wNs8s1Wcv/3Geux1HKynfe/Q== 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=c2vpJvOtq9qJvLcor06pWWGrAIAYm1ZeINLc4MN6fEA=; b=ReGYP+CrLl2zvazmR4QhXCVAp7FbiCtdyksGTI2aR+fhXmC4hYD/5Doa4CJbIMGGX+CQ1QL9otSBmCSabS8WDJBijpq2I+Op7WGzxgJri8arAe+AGfT3NH0qV5OgHjIJfQdZNRUOmMlRxHRhAws+xmlkLmmmGYhspcny9kLoWDnhguhglvmYMqr/8x9ERSP29mUNnjaxzaJevy9VMmLlnmnZrOufpmgeLu0XvriKmexT4EqWUcvYh29et+byF+byiFMP4ckuLKRfF1jI+XqktqeBKthW0BN1SkFs+nYakq0kWBLnzFLt+P7edV4/Qvo6jEmHY2uKYXhXwrD6xeToIw== 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=c2vpJvOtq9qJvLcor06pWWGrAIAYm1ZeINLc4MN6fEA=; b=qUtQu//pnZvs3r5xXZEEpQNrI9IYc9kQXRVbG8oSlo7N6ZSXodAUWeglWg9q3TBbZ/PsbjoxpAt7vLtVE2jo62//+lazfQ3w9i+K4T9mHNkW30o5cGigte9ni++9+fPynKN4+K0J1513Kr4U5p9WHoqEB/nDjg6+g43pF3j1qDc= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by SN7PR10MB7102.namprd10.prod.outlook.com (2603:10b6:806:348::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.29; Wed, 8 Mar 2023 22:38:02 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::2a7c:497e:b785:dc06]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::2a7c:497e:b785:dc06%8]) with mapi id 15.20.6178.017; Wed, 8 Mar 2023 22:38:02 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v10 03/32] xfs: Hold inode locks in xfs_trans_alloc_dir Date: Wed, 8 Mar 2023 15:37:25 -0700 Message-Id: <20230308223754.1455051-4-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230308223754.1455051-1-allison.henderson@oracle.com> References: <20230308223754.1455051-1-allison.henderson@oracle.com> X-ClientProxiedBy: BYAPR04CA0004.namprd04.prod.outlook.com (2603:10b6:a03:40::17) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY5PR10MB4306:EE_|SN7PR10MB7102:EE_ X-MS-Office365-Filtering-Correlation-Id: 66a6ccf2-ede7-4bf5-99e6-08db2025c6a1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: EDUlBDicFDoBdA0DrfjxEs9mCslwwHwg75tH0qete1JgS2kbwlH9gOuMcGPpqL7uD1OHklhXNSUNnW4U87ClD1t9KP7XQ99AJbhnud/StvHvjicRA+rklwgiDlAuJjmSbhk2vLrouBDbjwpVmcwbW6FdBHYjsJrx+wfQ3FYmPrt/3GKDYmXLsKhPqK8Aayvj16P0q4mrPYE4nwMAkeBIpu18oSGhf21UTuzcFmx1E3Mqb39AJ/ufJe6Ptd4v2j1gFh72bPGipueXfzLix3iY9VUOWqV8LGekUQ/tli59dQp8RnADSaaZZlYigXSPOzTZOclOr+1ktB63bY55acFSESovdIG5kLCwQgfgvw49EaF+xYB2hr6v3M6MZn6l3sUJmW9mbPGX3b8weZSk9DCz2jnHNTZ6M1ksrU90WosqGO4lZc0EBMrBpSdijaGGtzL+txxDifO4jgTbtqnAgn2I4Ti8okdZ/Y+VB3Or/YveDOY7ZB4iqSKa6pJ5yM/lRvlsv+7QndiBQcj3HKRTyvTPtzAv7ngAvrUuOrQwcXRXJOlGTnbngAjH8GWpHwU9CY4m2JUMMLy779U8DeZf3WzXH50mfNecN0OHoB3lEM1eS/3yQ8dB6XPcT6XkSLcVkdhOiRvOdszYHsZujrLzuZYNVQ== 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:(13230025)(376002)(39860400002)(366004)(346002)(136003)(396003)(451199018)(36756003)(6666004)(8936002)(6916009)(41300700001)(8676002)(66476007)(66946007)(5660300002)(66556008)(6506007)(2906002)(38100700002)(86362001)(6486002)(1076003)(6512007)(316002)(478600001)(83380400001)(9686003)(186003)(26005)(2616005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: VJxBhiUCZMZcmXG0NIWxtwt9aGwUpJ/XcU5UTY6VUpbEXWSPicOA+mVezU7WExXF1u5J4dCXEGgexTthr0HHzGJ5/T5UmvroTUEdSwH0RT5Af+70jNbJ7RohG9PtWO7OlMhXT6eDNtvP8TIYo7s9ZP4rr0O5nIiKqPdQat5m0BTE3Qm8dNlTls+0oEvHxqjD2Zcpt/AV6T1lJET9sloIWvQwxwLX7S8fCOSx7933pqlOEjvnllpn/wX5Rfi9jBXm5bVWP0pzrT7l87uIJuB29+IQIhrJA4n0k1oTD6nteBbek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nlD29l4Xf5lrnMC5jbTMda+lo7Gx3YkrZEw== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 66a6ccf2-ede7-4bf5-99e6-08db2025c6a1 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Mar 2023 22:38:02.2991 (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: mO370knk0nFr1AMFwfUSU/g/AdhWsAz9R7JwANykE0Y60HuAhZl1uM41yVrHRtRffovQtiBdTgNJc4N5zOmKUsB5IfbHVOwM58TxT4ctGjE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR10MB7102 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-08_15,2023-03-08_03,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 malwarescore=0 mlxscore=0 mlxlogscore=999 adultscore=0 suspectscore=0 phishscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2303080190 X-Proofpoint-GUID: q_uBHbDzXl-OF2JHVkruDh5GELO11THB X-Proofpoint-ORIG-GUID: q_uBHbDzXl-OF2JHVkruDh5GELO11THB Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Allison Henderson Modify xfs_trans_alloc_dir to hold locks after return. Caller will be responsible for manual unlock. We will need this later to hold locks across parent pointer operations Signed-off-by: Allison Henderson Reviewed-by: Darrick J. Wong Reviewed-by: Catherine Hoang --- fs/xfs/xfs_inode.c | 14 ++++++++++++-- fs/xfs/xfs_trans.c | 9 +++++++-- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index 16ebe144687c..fc730c573eca 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -1279,10 +1279,15 @@ xfs_link( if (xfs_has_wsync(mp) || xfs_has_dirsync(mp)) xfs_trans_set_sync(tp); - return xfs_trans_commit(tp); + error = xfs_trans_commit(tp); + xfs_iunlock(tdp, XFS_ILOCK_EXCL); + xfs_iunlock(sip, XFS_ILOCK_EXCL); + return error; error_return: xfs_trans_cancel(tp); + xfs_iunlock(tdp, XFS_ILOCK_EXCL); + xfs_iunlock(sip, XFS_ILOCK_EXCL); std_return: if (error == -ENOSPC && nospace_error) error = nospace_error; @@ -2518,15 +2523,20 @@ xfs_remove( error = xfs_trans_commit(tp); if (error) - goto std_return; + goto out_unlock; if (is_dir && xfs_inode_is_filestream(ip)) xfs_filestream_deassociate(ip); + xfs_iunlock(ip, XFS_ILOCK_EXCL); + xfs_iunlock(dp, XFS_ILOCK_EXCL); return 0; out_trans_cancel: xfs_trans_cancel(tp); + out_unlock: + xfs_iunlock(ip, XFS_ILOCK_EXCL); + xfs_iunlock(dp, XFS_ILOCK_EXCL); std_return: return error; } diff --git a/fs/xfs/xfs_trans.c b/fs/xfs/xfs_trans.c index 8afc0c080861..7e656dd42362 100644 --- a/fs/xfs/xfs_trans.c +++ b/fs/xfs/xfs_trans.c @@ -1356,6 +1356,8 @@ xfs_trans_alloc_ichange( * The caller must ensure that the on-disk dquots attached to this inode have * already been allocated and initialized. The ILOCKs will be dropped when the * transaction is committed or cancelled. + * + * Caller is responsible for unlocking the inodes manually upon return */ int xfs_trans_alloc_dir( @@ -1386,8 +1388,8 @@ xfs_trans_alloc_dir( xfs_lock_two_inodes(dp, XFS_ILOCK_EXCL, ip, XFS_ILOCK_EXCL); - xfs_trans_ijoin(tp, dp, XFS_ILOCK_EXCL); - xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL); + xfs_trans_ijoin(tp, dp, 0); + xfs_trans_ijoin(tp, ip, 0); error = xfs_qm_dqattach_locked(dp, false); if (error) { @@ -1410,6 +1412,9 @@ xfs_trans_alloc_dir( if (error == -EDQUOT || error == -ENOSPC) { if (!retried) { xfs_trans_cancel(tp); + xfs_iunlock(dp, XFS_ILOCK_EXCL); + if (dp != ip) + xfs_iunlock(ip, XFS_ILOCK_EXCL); xfs_blockgc_free_quota(dp, 0); retried = true; goto retry;