From patchwork Sun Dec 18 10:02:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 13075994 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 0A204C4332F for ; Sun, 18 Dec 2022 10:03:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229509AbiLRKDV (ORCPT ); Sun, 18 Dec 2022 05:03:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59780 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230244AbiLRKDR (ORCPT ); Sun, 18 Dec 2022 05:03:17 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9A35665E4 for ; Sun, 18 Dec 2022 02:03:13 -0800 (PST) Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2BI5RW4w005645 for ; Sun, 18 Dec 2022 10:03:13 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=p+Mj2o48KZIU06tjOsGJKlU3MX9+qMBJYtvtML+DC1k=; b=Mk6/e9WWSa8D4Rm7mJF2exnh4tyfMKrl2jwtW/w2zkmbognyBELfZq8GARBpLQOwZNP8 4v8MAKDuof9lW95mh2xcUr5PNxE2JKC+Cp2RtkW8xrFX8+JTLkPbP8/Wi4DEsztTq1UN 4OQJATTV89UUuyuGn8xzNjqTJg9HdDsIiXYei7/x3JQwunfJoyz0OgA2h9ndwuAaxnok wOtx7ULEHouJgrhyKHNfZWkz5w6k4YtCHqekwvEwK6HxVRcM/pSUsFG2XUKugjt1XBGc HHCMnek2doaCCkw6VtjX3yNTg8FkNOSqfpgvo5eRIF0kFoWUTG2Kpre+QuwEkSDgaK8G QA== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3mh6tph91u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sun, 18 Dec 2022 10:03:13 +0000 Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 2BI7axvR007083 for ; Sun, 18 Dec 2022 10:03:11 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2173.outbound.protection.outlook.com [104.47.55.173]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3mh479cbhv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sun, 18 Dec 2022 10:03:11 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=J4L4ciukJRLqKU8PgXERSzDUGFLNvN4ZD5yx85Jqgg2KEAMppnlZp+5GG2jhgbGDFzSQiJ3vdp0C+MUQIx3AtdZHMKXMuith8rtTn/NNL6bPZ09feeElpNmVqPmV+aysMmqvgnG5B0JKel9g0OxWei7zVuXXDS/wkFP/B7i2B7fPFRRyfr6tjcrQoik9oeVl8lvhahOJ+VYTyAsIkOlqEEvWV+XYP9HvvjFve5CsKY65xSWJs2WUYstyuaZ1wT7OzAXwb//XR38C8kZt/7Tv6SlbLvQVsipYKz56ObbYMVqV3xK/eHhHD7yPiBTHbOcZ0IpwuGwbuPy6eAivGhO2Wg== 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=p+Mj2o48KZIU06tjOsGJKlU3MX9+qMBJYtvtML+DC1k=; b=jQkq7Q35sWa54ihdCag/ORCRhal/MMNr8hlUFbUU3ak7P96QLMjSB5owWCl0VdpVh/Ts88i494nr3NJEcfok1d+1vuTEq9k/xFsfrif5rsKIltHucYv4sIJAnz3/SQOQP+2uDxu5tF/sfV6se2oyyx6PeEAUmR4lPvKau2ob0jbzlOV+VT8hf8LEGEtcxsc3odiFMqHlc25AW8TFaZdR1kUYAfkh7wJNUTuTY51oA+QlvdJNFfJiq/mFyThzKwW4+Ksddq26N7bEo6E+ekdXT+qQn1BHxxuacnVf+T7AbzMlkZ+kR0SVU9WcPpIrc1ftoqgOiq3s85wgy9lbqua/VA== 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=p+Mj2o48KZIU06tjOsGJKlU3MX9+qMBJYtvtML+DC1k=; b=t70zaGUpeqPYdmLCE9NELJ4Wh1nCChPsEgfpxcLQq66/g+7HspkW4ZUttk3UMWI/s45WxRKviQ5UWpVxJ9rxnI7jUPhZy+37uFyto9G/e0fThOpRH09BLnBZvfFxAfJ/XfzB/cM3hgnU8Dtpm2ggTDA0LNUB2nB1rAdnZPOPnO4= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by PH0PR10MB4536.namprd10.prod.outlook.com (2603:10b6:510:40::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5924.16; Sun, 18 Dec 2022 10:03:10 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::3cab:6ff7:cb4d:b57c]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::3cab:6ff7:cb4d:b57c%4]) with mapi id 15.20.5924.016; Sun, 18 Dec 2022 10:03:10 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v7 01/27] xfs: Add new name to attri/d Date: Sun, 18 Dec 2022 03:02:40 -0700 Message-Id: <20221218100306.76408-2-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221218100306.76408-1-allison.henderson@oracle.com> References: <20221218100306.76408-1-allison.henderson@oracle.com> X-ClientProxiedBy: BYAPR11CA0071.namprd11.prod.outlook.com (2603:10b6:a03:80::48) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY5PR10MB4306:EE_|PH0PR10MB4536:EE_ X-MS-Office365-Filtering-Correlation-Id: 172bc518-4dc8-4a0f-141f-08dae0df1158 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: y9idT2krZDezl18AMfke3M3M2qZhNanjqY1XJNsSGpNaVnMo9U9TNyDxvW0Uk9cy0PLkc8bQxEoytXKvDu7dGNT6DXK3YLzNnVg+rrVKGnNujwvvidqL3ilf+3RtIULv4hKvnKv1lkxhk/m/ZJbigAcjYzwVj8LZxi7bCcUCOg4bGohpdNElp+0zzbo6HTWKkzTeCjP78/QBkewU+78kXaq2COqCL6CTKNYT2A6FSwDH3ICqMU5ZTew+xpMEUto5XZX8c9Vq/m/M3TlzWYmupyI6x/EWg1M0t04s8ndPzj9yTqXZDhU6f5upea2pa5HzKHwzQuHinnwYzRWLtkEDM28O9agcnaseyWeqduAc9Wc3pY9OCwFBcJItuus1yARgKw7/tIPWsmdz/wJc9l5gYVh8wZw/A2KAqyrFr0aX8FVjOy1MWwELcXhuY/3ssd/q8nU1eXa8CwFPXd7FEd7l8iypNYBmGmXeZmVR78Qi80c91rBQAt8a4TBCNaxPRlqj36aN2KBZcNFV+8DNnRIG6s0ZQPTW/KBtGR28bUk2IXKYc3D6iL4bTBr6kFeGqZlP/1kGbRNyW8r458te68lpMA+16PEnYGeqOyvpT8ZOChtDvFkEnLT9hJQukMJHtb/07XzE/akYUrH1EfVmoL/mCg== 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:(13230022)(396003)(39860400002)(136003)(346002)(366004)(376002)(451199015)(83380400001)(38100700002)(86362001)(30864003)(66476007)(2906002)(8676002)(66556008)(5660300002)(66946007)(8936002)(41300700001)(1076003)(9686003)(26005)(186003)(6512007)(6506007)(6666004)(2616005)(6916009)(316002)(478600001)(6486002)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Babv3GNuzyx6ySY4ad5G1iPqLTaxjTU/cbyF/nc1MI68DuguFfRG7gT/oFoPYuSbRuscbU0ufuoxvB/vc7fXXsEk1RhfbiYr6zJvaI7IddtAShfuuivr2zQRqPQ7kgkdYxI6OkoIAzE1HgqKJ8eiYT64Vqxq1vYln/fpRZ4L4TS71/4RVQVXObzan0L9R5QxQ6TQTw17MnW/7wpcuvYNQzBManBolre+uM5h6rbvS0CBdFHRgR6luxhfp2WJWW71OXVmXTHMaZqIZ1c5X5o5FmgYYO1pVsjhibzUjG5T9mROrjARgrev4kcv6ItMjlyjUVpgrKzS8n/F9zFxeVq+8rR+PKJB7nZeqBjAtQp9HLM5Mv4ILG4OC4QSGmoOo6lePWkVNRxaeKFKPKLrzarteADOHZFWbhOeMF5OFdo/4zHBv/iZuifaztV8bGu9nr06DeJqknJXmj5aBZ346Yj2kOLdeKFmYcvETgrBE7vIT6XNLROl5rmjQCEiQ2vaHTss9oPU9u8pb2ijA/MHa7i0rFTLbMr1q/4cwe9jBQftCBd5PpDVjHpZQ8Ll8vf4v94N7TUf0RwKhBeiua7ZtHO580RYVKprIlNxoztqkDavee68w9GVXp7i8Rj4ks6AnW3AggWVhtxaT9sMd2rDFz9UxIdPdBx+Apme1yg6198rJ+wJK6HuZz/OTOcJboOIbxIb2wnl+C8gIDiLZFsarmnr6MYdTcxIzBNcSoWsqJYGb1SceXoE4cIeLovjj9ITtrjWkNeQXfdfdvWPLfonY9hovB0w+sGIBQ34CcBfyuSeTbYnJO+l7hrICS2S/1nkI/ley8eSGUKiRWztgvcIJ5kv9yC6z9AbtljTV/iBRloOIAyriwcTBKATRheedtUxgpjz9VVjAG3N8UIfDOUnj0Acv50Gs0WjaqYgpQ477PqBsirEVraMFYH1gYfl9oBWpcMI60CepLz8BMBYRh6LSCypPBlRW5jilFzZnBBSZZaams00vg2I+4wT2wOXy+arxh4JZ9/M/VG6uPGk9bWcpJ7Hw/9ljgtoYJ9hsEKI0xKPM7IYDgk4AmwY7q2whtTuSLR9VqBKRnkdGJGyhuyYFzHgnB+RUVubr0YYsdqwAAxIWDzLdFB1j0kaNZLhZ7660ZNmB0y8WaJgzm53yWi56QEPqmRGS2T980LqiF1EG7fVrv6jfsd+lnj70LKf+N9+ahKjTkyI4y95DaoeN1eyGjhYXnMmA/1pHgwP9rIJ/+rK0vG/CzKMTFI/ARaPwb94pHgrQOHUsfh3cG7+ZjEVyUZxCQLX5FAMBem8d+p38kHvCMj4cQuoadtzv/ujE5cARgoGO2dU0i0sm4VHtA88SIhJmAi9oHSUDNWNseE4XI4yGdlWpGpx7dl2hw8QjBqfXp6J9fmo6tKKq1JifgnPis0Y25v+GFkthHsDvo2O9LHgFms60uavJ/ltNKDvmG/PeXN5dxExm2+RRqaPtSOrBbcmg4YvS0YJCR0MeOzS2usWZBfR3RldLGYXEaLsXI7SAAR0fQQcog274ycThFHP6gEZtrUSJg94+Q8qlTBJ1ADhcTZ4j3a2+L2k3ycmTgvZpOTf4H/L+EpcmqvkgDCB+U7nEw== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 172bc518-4dc8-4a0f-141f-08dae0df1158 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Dec 2022 10:03:10.0753 (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: pZrlOu308w3TOSk+u93Y9N3kpww+QBXtFx2deUBKdRmmaDxWc5M5vQwy84RRz1kkHjaNfN95Kh0zEdejh8S5yzJiY0HF2gtOsIjoRe8jQ50= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4536 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-12-18_02,2022-12-15_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 malwarescore=0 phishscore=0 suspectscore=0 spamscore=0 bulkscore=0 mlxscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2212180095 X-Proofpoint-ORIG-GUID: 2WPub9hSeYBbfZiXp6_h7AM28xOicLUh X-Proofpoint-GUID: 2WPub9hSeYBbfZiXp6_h7AM28xOicLUh Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Allison Henderson This patch adds two new fields to the atti/d. They are nname and nnamelen. This will be used for parent pointer updates since a rename operation may cause the parent pointer to update both the name and value. So we need to carry both the new name as well as the target name in the attri/d. Signed-off-by: Allison Henderson --- fs/xfs/libxfs/xfs_attr.c | 12 ++- fs/xfs/libxfs/xfs_attr.h | 4 +- fs/xfs/libxfs/xfs_da_btree.h | 2 + fs/xfs/libxfs/xfs_log_format.h | 6 +- fs/xfs/xfs_attr_item.c | 135 +++++++++++++++++++++++++++------ fs/xfs/xfs_attr_item.h | 1 + 6 files changed, 133 insertions(+), 27 deletions(-) diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c index e28d93d232de..b1dbed7655e8 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -423,6 +423,12 @@ xfs_attr_complete_op( args->op_flags &= ~XFS_DA_OP_REPLACE; if (do_replace) { args->attr_filter &= ~XFS_ATTR_INCOMPLETE; + if (args->new_namelen > 0) { + args->name = args->new_name; + args->namelen = args->new_namelen; + args->hashval = xfs_da_hashname(args->name, + args->namelen); + } return replace_state; } return XFS_DAS_DONE; @@ -922,9 +928,13 @@ xfs_attr_defer_replace( struct xfs_da_args *args) { struct xfs_attr_intent *new; + int op_flag; int error = 0; - error = xfs_attr_intent_init(args, XFS_ATTRI_OP_FLAGS_REPLACE, &new); + op_flag = args->new_namelen == 0 ? XFS_ATTRI_OP_FLAGS_REPLACE : + XFS_ATTRI_OP_FLAGS_NVREPLACE; + + error = xfs_attr_intent_init(args, op_flag, &new); if (error) return error; diff --git a/fs/xfs/libxfs/xfs_attr.h b/fs/xfs/libxfs/xfs_attr.h index 81be9b3e4004..3e81f3f48560 100644 --- a/fs/xfs/libxfs/xfs_attr.h +++ b/fs/xfs/libxfs/xfs_attr.h @@ -510,8 +510,8 @@ struct xfs_attr_intent { struct xfs_da_args *xattri_da_args; /* - * Shared buffer containing the attr name and value so that the logging - * code can share large memory buffers between log items. + * Shared buffer containing the attr name, new name, and value so that + * the logging code can share large memory buffers between log items. */ struct xfs_attri_log_nameval *xattri_nameval; diff --git a/fs/xfs/libxfs/xfs_da_btree.h b/fs/xfs/libxfs/xfs_da_btree.h index ffa3df5b2893..a4b29827603f 100644 --- a/fs/xfs/libxfs/xfs_da_btree.h +++ b/fs/xfs/libxfs/xfs_da_btree.h @@ -55,7 +55,9 @@ enum xfs_dacmp { typedef struct xfs_da_args { struct xfs_da_geometry *geo; /* da block geometry */ const uint8_t *name; /* string (maybe not NULL terminated) */ + const uint8_t *new_name; /* new attr name */ int namelen; /* length of string (maybe no NULL) */ + int new_namelen; /* new attr name len */ uint8_t filetype; /* filetype of inode for directories */ void *value; /* set of bytes (maybe contain NULLs) */ int valuelen; /* length of value */ diff --git a/fs/xfs/libxfs/xfs_log_format.h b/fs/xfs/libxfs/xfs_log_format.h index f13e0809dc63..ae9c99762a24 100644 --- a/fs/xfs/libxfs/xfs_log_format.h +++ b/fs/xfs/libxfs/xfs_log_format.h @@ -117,7 +117,8 @@ struct xfs_unmount_log_format { #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 +#define XLOG_REG_TYPE_ATTR_NNAME 31 +#define XLOG_REG_TYPE_MAX 31 /* @@ -957,6 +958,7 @@ struct xfs_icreate_log { #define XFS_ATTRI_OP_FLAGS_SET 1 /* Set the attribute */ #define XFS_ATTRI_OP_FLAGS_REMOVE 2 /* Remove the attribute */ #define XFS_ATTRI_OP_FLAGS_REPLACE 3 /* Replace the attribute */ +#define XFS_ATTRI_OP_FLAGS_NVREPLACE 4 /* Replace attr name and val */ #define XFS_ATTRI_OP_FLAGS_TYPE_MASK 0xFF /* Flags type mask */ /* @@ -974,7 +976,7 @@ struct xfs_icreate_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 */ + uint32_t alfi_nname_len; /* attr new name length */ 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 */ diff --git a/fs/xfs/xfs_attr_item.c b/fs/xfs/xfs_attr_item.c index 2788a6f2edcd..95e9ecbb4a67 100644 --- a/fs/xfs/xfs_attr_item.c +++ b/fs/xfs/xfs_attr_item.c @@ -75,6 +75,8 @@ static inline struct xfs_attri_log_nameval * xfs_attri_log_nameval_alloc( const void *name, unsigned int name_len, + const void *nname, + unsigned int nname_len, const void *value, unsigned int value_len) { @@ -85,15 +87,25 @@ xfs_attri_log_nameval_alloc( * this. But kvmalloc() utterly sucks, so we use our own version. */ nv = xlog_kvmalloc(sizeof(struct xfs_attri_log_nameval) + - name_len + value_len); + name_len + nname_len + value_len); nv->name.i_addr = nv + 1; nv->name.i_len = name_len; nv->name.i_type = XLOG_REG_TYPE_ATTR_NAME; memcpy(nv->name.i_addr, name, name_len); + if (nname_len) { + nv->nname.i_addr = nv->name.i_addr + name_len; + nv->nname.i_len = nname_len; + memcpy(nv->nname.i_addr, nname, nname_len); + } else { + nv->nname.i_addr = NULL; + nv->nname.i_len = 0; + } + nv->nname.i_type = XLOG_REG_TYPE_ATTR_NNAME; + if (value_len) { - nv->value.i_addr = nv->name.i_addr + name_len; + nv->value.i_addr = nv->name.i_addr + nname_len + name_len; nv->value.i_len = value_len; memcpy(nv->value.i_addr, value, value_len); } else { @@ -147,11 +159,15 @@ xfs_attri_item_size( *nbytes += sizeof(struct xfs_attri_log_format) + xlog_calc_iovec_len(nv->name.i_len); - if (!nv->value.i_len) - return; + if (nv->nname.i_len) { + *nvecs += 1; + *nbytes += xlog_calc_iovec_len(nv->nname.i_len); + } - *nvecs += 1; - *nbytes += xlog_calc_iovec_len(nv->value.i_len); + if (nv->value.i_len) { + *nvecs += 1; + *nbytes += xlog_calc_iovec_len(nv->value.i_len); + } } /* @@ -181,6 +197,9 @@ xfs_attri_item_format( ASSERT(nv->name.i_len > 0); attrip->attri_format.alfi_size++; + if (nv->nname.i_len > 0) + attrip->attri_format.alfi_size++; + if (nv->value.i_len > 0) attrip->attri_format.alfi_size++; @@ -188,6 +207,10 @@ xfs_attri_item_format( &attrip->attri_format, sizeof(struct xfs_attri_log_format)); xlog_copy_from_iovec(lv, &vecp, &nv->name); + + if (nv->nname.i_len > 0) + xlog_copy_from_iovec(lv, &vecp, &nv->nname); + if (nv->value.i_len > 0) xlog_copy_from_iovec(lv, &vecp, &nv->value); } @@ -374,6 +397,7 @@ xfs_attr_log_item( attrp->alfi_op_flags = attr->xattri_op_flags; attrp->alfi_value_len = attr->xattri_nameval->value.i_len; attrp->alfi_name_len = attr->xattri_nameval->name.i_len; + attrp->alfi_nname_len = attr->xattri_nameval->nname.i_len; ASSERT(!(attr->xattri_da_args->attr_filter & ~XFS_ATTRI_FILTER_MASK)); attrp->alfi_attr_filter = attr->xattri_da_args->attr_filter; } @@ -415,7 +439,8 @@ xfs_attr_create_intent( * deferred work state structure. */ attr->xattri_nameval = xfs_attri_log_nameval_alloc(args->name, - args->namelen, args->value, args->valuelen); + args->namelen, args->new_name, + args->new_namelen, args->value, args->valuelen); } attrip = xfs_attri_init(mp, attr->xattri_nameval); @@ -503,7 +528,8 @@ xfs_attri_validate( unsigned int op = attrp->alfi_op_flags & XFS_ATTRI_OP_FLAGS_TYPE_MASK; - if (attrp->__pad != 0) + if (attrp->alfi_op_flags != XFS_ATTRI_OP_FLAGS_NVREPLACE && + attrp->alfi_nname_len != 0) return false; if (attrp->alfi_op_flags & ~XFS_ATTRI_OP_FLAGS_TYPE_MASK) @@ -517,6 +543,7 @@ xfs_attri_validate( case XFS_ATTRI_OP_FLAGS_SET: case XFS_ATTRI_OP_FLAGS_REPLACE: case XFS_ATTRI_OP_FLAGS_REMOVE: + case XFS_ATTRI_OP_FLAGS_NVREPLACE: break; default: return false; @@ -526,9 +553,14 @@ xfs_attri_validate( return false; if ((attrp->alfi_name_len > XATTR_NAME_MAX) || + (attrp->alfi_nname_len > XATTR_NAME_MAX) || (attrp->alfi_name_len == 0)) return false; + if (op == XFS_ATTRI_OP_FLAGS_REMOVE && + attrp->alfi_value_len != 0) + return false; + return xfs_verify_ino(mp, attrp->alfi_ino); } @@ -589,6 +621,8 @@ xfs_attri_item_recover( args->whichfork = XFS_ATTR_FORK; args->name = nv->name.i_addr; args->namelen = nv->name.i_len; + args->new_name = nv->nname.i_addr; + args->new_namelen = nv->nname.i_len; args->hashval = xfs_da_hashname(args->name, args->namelen); args->attr_filter = attrp->alfi_attr_filter & XFS_ATTRI_FILTER_MASK; args->op_flags = XFS_DA_OP_RECOVERY | XFS_DA_OP_OKNOENT | @@ -599,6 +633,7 @@ xfs_attri_item_recover( switch (attr->xattri_op_flags) { case XFS_ATTRI_OP_FLAGS_SET: case XFS_ATTRI_OP_FLAGS_REPLACE: + case XFS_ATTRI_OP_FLAGS_NVREPLACE: args->value = nv->value.i_addr; args->valuelen = nv->value.i_len; args->total = xfs_attr_calc_size(args, &local); @@ -688,6 +723,7 @@ xfs_attri_item_relog( 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_nname_len = old_attrp->alfi_nname_len; new_attrp->alfi_attr_filter = old_attrp->alfi_attr_filter; xfs_trans_add_item(tp, &new_attrip->attri_item); @@ -710,48 +746,102 @@ xlog_recover_attri_commit_pass2( const void *attr_value = NULL; const void *attr_name; size_t len; - - attri_formatp = item->ri_buf[0].i_addr; - attr_name = item->ri_buf[1].i_addr; + const void *attr_nname = NULL; + int op, i = 0; /* Validate xfs_attri_log_format before the large memory allocation */ len = sizeof(struct xfs_attri_log_format); - if (item->ri_buf[0].i_len != len) { + if (item->ri_buf[i].i_len != len) { XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, - item->ri_buf[0].i_addr, item->ri_buf[0].i_len); + item->ri_buf[i].i_addr, item->ri_buf[i].i_len); return -EFSCORRUPTED; } + attri_formatp = item->ri_buf[i].i_addr; if (!xfs_attri_validate(mp, attri_formatp)) { XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, - item->ri_buf[0].i_addr, item->ri_buf[0].i_len); + item->ri_buf[i].i_addr, item->ri_buf[i].i_len); + return -EFSCORRUPTED; + } + + op = attri_formatp->alfi_op_flags & XFS_ATTRI_OP_FLAGS_TYPE_MASK; + switch (op) { + case XFS_ATTRI_OP_FLAGS_SET: + case XFS_ATTRI_OP_FLAGS_REPLACE: + if (item->ri_total != 3) { + XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, + attri_formatp, len); + return -EFSCORRUPTED; + } + break; + case XFS_ATTRI_OP_FLAGS_REMOVE: + if (item->ri_total != 2) { + XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, + attri_formatp, len); + return -EFSCORRUPTED; + } + break; + case XFS_ATTRI_OP_FLAGS_NVREPLACE: + if (item->ri_total != 4) { + XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, + attri_formatp, len); + return -EFSCORRUPTED; + } + break; + default: + XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, + attri_formatp, len); return -EFSCORRUPTED; } + i++; /* Validate the attr name */ - if (item->ri_buf[1].i_len != + if (item->ri_buf[i].i_len != xlog_calc_iovec_len(attri_formatp->alfi_name_len)) { XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, - item->ri_buf[0].i_addr, item->ri_buf[0].i_len); + attri_formatp, len); return -EFSCORRUPTED; } + attr_name = item->ri_buf[i].i_addr; if (!xfs_attr_namecheck(attr_name, attri_formatp->alfi_name_len)) { XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, - item->ri_buf[1].i_addr, item->ri_buf[1].i_len); + item->ri_buf[i].i_addr, item->ri_buf[i].i_len); return -EFSCORRUPTED; } + i++; + if (attri_formatp->alfi_nname_len) { + /* Validate the attr nname */ + if (item->ri_buf[i].i_len != + xlog_calc_iovec_len(attri_formatp->alfi_nname_len)) { + XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, + item->ri_buf[i].i_addr, + item->ri_buf[i].i_len); + return -EFSCORRUPTED; + } + + attr_nname = item->ri_buf[i].i_addr; + if (!xfs_attr_namecheck(attr_nname, + attri_formatp->alfi_nname_len)) { + XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, + item->ri_buf[i].i_addr, + item->ri_buf[i].i_len); + return -EFSCORRUPTED; + } + i++; + } + + /* Validate the attr value, if present */ if (attri_formatp->alfi_value_len != 0) { - if (item->ri_buf[2].i_len != xlog_calc_iovec_len(attri_formatp->alfi_value_len)) { + if (item->ri_buf[i].i_len != xlog_calc_iovec_len(attri_formatp->alfi_value_len)) { XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, - item->ri_buf[0].i_addr, - item->ri_buf[0].i_len); + attri_formatp, len); return -EFSCORRUPTED; } - attr_value = item->ri_buf[2].i_addr; + attr_value = item->ri_buf[i].i_addr; } /* @@ -760,7 +850,8 @@ xlog_recover_attri_commit_pass2( * reference. */ nv = xfs_attri_log_nameval_alloc(attr_name, - attri_formatp->alfi_name_len, attr_value, + attri_formatp->alfi_name_len, attr_nname, + attri_formatp->alfi_nname_len, attr_value, attri_formatp->alfi_value_len); attrip = xfs_attri_init(mp, nv); diff --git a/fs/xfs/xfs_attr_item.h b/fs/xfs/xfs_attr_item.h index 3280a7930287..24d4968dd6cc 100644 --- a/fs/xfs/xfs_attr_item.h +++ b/fs/xfs/xfs_attr_item.h @@ -13,6 +13,7 @@ struct kmem_zone; struct xfs_attri_log_nameval { struct xfs_log_iovec name; + struct xfs_log_iovec nname; struct xfs_log_iovec value; refcount_t refcount; From patchwork Sun Dec 18 10:02:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 13075996 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 52911C4332F for ; Sun, 18 Dec 2022 10:03:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230247AbiLRKDY (ORCPT ); Sun, 18 Dec 2022 05:03:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59930 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230255AbiLRKDR (ORCPT ); Sun, 18 Dec 2022 05:03:17 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CBDE665F3 for ; Sun, 18 Dec 2022 02:03:15 -0800 (PST) Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2BI7gqoW016629 for ; Sun, 18 Dec 2022 10:03:15 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=kjnJXb4QLTI/gC6onLA0jkmfXuy0GCZXIVbvceEUfO0=; b=BKIVDS279WOWisAknbfiFDMV/nhRWcmoWlfK4NKu+KF7SAfQGt/8KNj0UUdi0HSb0cOo Gxf2eVMmcm6GfhSNZZRXlkcOSoGvl6hFMyZAehsFOzncocvtP1eTVP9mhIk95RiA9YY8 ej4nIe2GUSETbOP1TPJ9OEo6GYPTyxO0ama9x956gx0EtkVteNo1qGXamzvkyLs4REpR 69H8BDctQgpG+UOeS1WQIWfE7k75cqvjhH4QLDS+MDNN68yUwgn/zkA6fWpYjc4UDQ9B e0tCKXO4ZpfbXyrqtYT+W6wlPOgtMyQpESvo51vJv6ROedenKMn4OWunz+98jLVWP7qU mA== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3mh6tms9b4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sun, 18 Dec 2022 10:03:14 +0000 Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 2BI5lGwu022376 for ; Sun, 18 Dec 2022 10:03:13 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2170.outbound.protection.outlook.com [104.47.55.170]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3mh472brp3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sun, 18 Dec 2022 10:03:13 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cOweR+sTXLf7sfUk+7utRZtPimJzE3aUcdZy2dPoji3KBi9/ANF0HPbhLLDofieCygqSjdznf9pdzfaqg4xqdguDrD/ZRTIH/FIC6w9HLxGgOcgxU17VCxncKX+r/oyjbdNjHJubm8hECB0O+/UaGDsE3uZWd53YAjFzg+usSq9yKyEdLrtkH9RkXmnWYmhf9WtSfro9UhErHTkdE6ld8Rj18LBmF95OtsbBqLEFg47kEKL4fIeDXxpLP7kleroMkTLsk3yfkAinOQbeXZ2vl4S5PEK+kiGbw+k2joIlksX6fqOWDT6BagPGZemmUS8iaS3SNintpXvb/YRXnurJpA== 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=kjnJXb4QLTI/gC6onLA0jkmfXuy0GCZXIVbvceEUfO0=; b=c7f4TiAb/KEYgK/YXhZuM0FASnZu1M6oORSE4/6s8j2Cz1NUWhdZYB70sMrFKfgOXslXUvGsaANYKzeVZGDibozdOdxOmIVK1Wpo+TvwJltEgjgBfBYXqW7WNmeOg9iyvnEJpKujuJuu3Y2zBLcXNqEJctGkFA7rAo98/gFS0MGYogQ3F3hPTzgkyUzRM13YDVN8tyIeSdwu/FfM0bI7oinEEak13ZD796Z6jGCAGXypkI1b9psk9dZ5XRmLlpyYx5SkrNPunOTJOoqwaCTINk9SeKrdcDhOCL00GcGfFlz8673AYd3u9pSsfa0+nVPtM2KKIgldOogQwDdi1LSCoQ== 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=kjnJXb4QLTI/gC6onLA0jkmfXuy0GCZXIVbvceEUfO0=; b=VhcDBJnnsyOb/iKXo9ha0ULebP0QV0XWKZtDoHe5qyMiSfng0NCflS4qycSWQtOiwMO7tkM3UYlo7Cv3jUMD8TXYhVgkbmQNSXTRCkngXaHzwpRyTIrsqmcNxnEEJHGX7z00LJDP4PdfDcCPYo30qBzeVjM/njBn2UWwnC4dKM4= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by PH0PR10MB4536.namprd10.prod.outlook.com (2603:10b6:510:40::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5924.16; Sun, 18 Dec 2022 10:03:11 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::3cab:6ff7:cb4d:b57c]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::3cab:6ff7:cb4d:b57c%4]) with mapi id 15.20.5924.016; Sun, 18 Dec 2022 10:03:11 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v7 02/27] xfs: Increase XFS_DEFER_OPS_NR_INODES to 5 Date: Sun, 18 Dec 2022 03:02:41 -0700 Message-Id: <20221218100306.76408-3-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221218100306.76408-1-allison.henderson@oracle.com> References: <20221218100306.76408-1-allison.henderson@oracle.com> X-ClientProxiedBy: BYAPR11CA0058.namprd11.prod.outlook.com (2603:10b6:a03:80::35) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY5PR10MB4306:EE_|PH0PR10MB4536:EE_ X-MS-Office365-Filtering-Correlation-Id: abc99f68-105e-4aad-e120-08dae0df1260 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +mzUGiGx2uP4hq2ueWLejH1l+6jxuLsLp+5R+XLzwbWmbXo5jB3xo4NPvS/RZMLerTMo7IKKMeKJr6ItHFOw1Xr0WBT5K4zRy1UrN6tP6U7Ia2sNFmk/qyT4uQmCPTLR8MgbundHz9vzRYa1kijFNcsMuuOk/Cnut8tUj/f+l1GvX3yx1eKkrME8QHAVyvGO/JiLXukdVtx8gC5cvxSexffY6FiMWUiNExjUuPzMbd2aiSq4/h6JxbaT+XAWNWbC4zRXOx1nSvSlkqgiQoZXgNW0oe/nre3Ubd3H/VJHzqp7NGjp4QEf3fsRnPPTZCUrXVmVZeWoGwIjHdRluA703FwNvgicKm52mFK5wpxlQG2aPfjQvKPLet2Gcnf8gz8RoCrkfoulOuw7i8BZUI9REoUbGyiMJedzrDu2eoWp0j6iGEl5GB899IxACt0iEp4FXDsoJsCPb3I9cQTFEcPMTDpZfnmCdsq6ZE9hXeEIuhHkl74C2U+VeACaF01JbnW+FmadZNvegkYQONySNxTSyC8maANo7FGb6Bc7OLxU3a/XhFjmmtrYUUId8KP+XZ3eKyH5LVvN1oN8aENPkRuDNq8mZffkxYGJbAy76wlaEFPstm3HBOvPD/wIOWQSqcEs 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:(13230022)(396003)(39860400002)(136003)(346002)(366004)(376002)(451199015)(83380400001)(38100700002)(86362001)(66476007)(2906002)(8676002)(66556008)(5660300002)(66946007)(8936002)(41300700001)(1076003)(9686003)(26005)(186003)(6512007)(6506007)(6666004)(2616005)(6916009)(316002)(478600001)(6486002)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Qay4kOkCLL7y5DZ0apKsfwDkWAWEhjS2p6qpUJha6VET0udT9fXtZ+cg8UddTlROiDkjQ2oLM3xFO6woix/ZQtPeaLEoybGLVuHktZqkO+Yb/FMs+O8UQBNV+u/HwnRysweqjHHvFTa+mRgkLzGG51ucIfJ93b4sDM6nSdjxGmpzR/C2aqw4e1V/uWMX6qgVC1Vwb9pccpsGq0e09r4ns2+Re65d6Szd+IQ5ilX4iTqXU+HiUIkEMiOqSSaPf8ZYdDef7rJAjDXAYhMWtBW6WuZE6pv1EJPP9ffn/CNzk4FBmXN8p5AYf3raK3r1k2JtqEUqkor+BoCVmDshFik8g4x3zppMJqff+J/glFArhkIBBJzCRRD14ZpgQe5X/PlToGLoWsSP7huT5eDq+tV0ZIZqrWZ/tnz3uggHFdW6sGZy6a/cK/JVZhmjTQskQDGA9fRnAxRVOYmHiTp3lVtBEuMmAJEdhH/ohrhcEC4Ul0TAjuVCOrfHV4M3rnc1gW9F3XZ7HTK8HHOsyNC8uLMPIZ7BHOgx/gGTaXQP3DnLgaHnFMDNBKNq4v0eIAiwokrTPFS+GoIgwOzAl0VuDgiEPIaVMA14aYxF3r3z9orzkDhGLd9Zcr7EgWBpUcG0F46q++6V6/CizixBY1QWMu3UUsx4BZQWMNeN2L/VQDBURWLCsLX0QVMQkjw+7Grl2/VRiIlschPfxvCduQimZILa1JZWU6ic2pdXj9zNfITvz4jne2jAe+e2Au+FYbMoXSJGTAsXnW9YaePVX5h7p5lKuVRgrZclorar+OzqhHfUpk70xg3t1O65r7jo+xDWiPJRdtTteh/7MnCUkHagTGp6cFRKUC18FyQnG/bnHjG5Ymb7K3EDXLyf2cVU2ItOhnNl+b9nOAgq9Wb0SMlggDIcAKGGQOqETi1XnNq8+T6sCRWB8uVdc4gUMIQOq8204WsYQvEtqQ2hfcDtc8JSTq0wv/UgKuT2NBlTrQ/ZprZdiOfLgKdO2pCwAofmlSQxjZcNxX/3DKAMZbaRRuz+USp6Xo9H6v/mzUOcXRWtc7zDvE1oaytkya8uOxz4jnXgHW9EP2t1PAKs7c2Pv08jBJLG/HwlW86eH6qqPS8gnlo1pdbF2vlWpJ0URO83ntqUf6AhpB59X3oEkTqSFZ1kiMhsvLW8iyte+tGtDxSBla8F/c8B5nBMAGJUD3RMxZ4wrzP0hIdCXqWFLmgNjt7LJfqfukjMAx/PjGOf/zW2ltIYpXmduiLqVw3JIcnilMmI1TSx4ThH+gyCuSWxocK7cY5ltvT5b6a9K2FnRyNVgywd5ykR5szUBFl5WW8ohKd0zDdsmSmNWSNRRCMR/uUtGOASRztSbrgK0MeeyvS4GoINITNKM5ynHakf9WrqrDdpX55TF9bEmYNvgiUQsSCQdxYF/v54zgg9UpYG37zJSdfoGivSRnL++pAxRWcVz+Gdjtsd7Ryxvwk5zDJAE8SWyP0uBABrc3Xiym+fC1BUhZCJNW8kWWJm0NILbmQ/16C0Mwo3BrVQjqIXG80rTA/Xj1q/4SLopvi5CFrIEY5Ef6Uxn/l3Sp2KY94fY4IiEnYm1NeMeTuZpxdFg/eYOH0WI2u/tA== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: abc99f68-105e-4aad-e120-08dae0df1260 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Dec 2022 10:03:11.7951 (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: sun/Wb84AVzwzCayIxX+yMFbulQ1F8kz0uY4pc4WdpQ3lJiibrQB2RAM9tYhd8q3wARGfGBYuQw96XXAQpN+vlSz/gQChWfyMg5lAhUCXnw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4536 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-12-18_02,2022-12-15_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 mlxlogscore=999 spamscore=0 phishscore=0 adultscore=0 bulkscore=0 mlxscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2212180095 X-Proofpoint-ORIG-GUID: WPg1NKfxxb992pXZkRACijSa9GGl8_DX X-Proofpoint-GUID: WPg1NKfxxb992pXZkRACijSa9GGl8_DX Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Allison Henderson Renames that generate parent pointer updates can join up to 5 inodes locked in sorted order. So we need to increase the number of defer ops inodes and relock them in the same way. Signed-off-by: Allison Henderson Reviewed-by: Darrick J. Wong Reviewed-by: Catherine Hoang --- fs/xfs/libxfs/xfs_defer.c | 28 ++++++++++++++++++++++++++-- fs/xfs/libxfs/xfs_defer.h | 8 +++++++- fs/xfs/xfs_inode.c | 2 +- fs/xfs/xfs_inode.h | 1 + 4 files changed, 35 insertions(+), 4 deletions(-) diff --git a/fs/xfs/libxfs/xfs_defer.c b/fs/xfs/libxfs/xfs_defer.c index 5a321b783398..c0279b57e51d 100644 --- a/fs/xfs/libxfs/xfs_defer.c +++ b/fs/xfs/libxfs/xfs_defer.c @@ -820,13 +820,37 @@ xfs_defer_ops_continue( struct xfs_trans *tp, struct xfs_defer_resources *dres) { - unsigned int i; + unsigned int i, j; + struct xfs_inode *sips[XFS_DEFER_OPS_NR_INODES]; + struct xfs_inode *temp; ASSERT(tp->t_flags & XFS_TRANS_PERM_LOG_RES); ASSERT(!(tp->t_flags & XFS_TRANS_DIRTY)); /* Lock the captured resources to the new transaction. */ - if (dfc->dfc_held.dr_inos == 2) + if (dfc->dfc_held.dr_inos > 2) { + /* + * Renames with parent pointer updates can lock up to 5 inodes, + * sorted by their inode number. So we need to make sure they + * are relocked in the same way. + */ + memset(sips, 0, sizeof(sips)); + for (i = 0; i < dfc->dfc_held.dr_inos; i++) + sips[i] = dfc->dfc_held.dr_ip[i]; + + /* Bubble sort of at most 5 inodes */ + for (i = 0; i < dfc->dfc_held.dr_inos; i++) { + for (j = 1; j < dfc->dfc_held.dr_inos; j++) { + if (sips[j]->i_ino < sips[j-1]->i_ino) { + temp = sips[j]; + sips[j] = sips[j-1]; + sips[j-1] = temp; + } + } + } + + xfs_lock_inodes(sips, dfc->dfc_held.dr_inos, XFS_ILOCK_EXCL); + } else 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) diff --git a/fs/xfs/libxfs/xfs_defer.h b/fs/xfs/libxfs/xfs_defer.h index 114a3a4930a3..fdf6941f8f4d 100644 --- a/fs/xfs/libxfs/xfs_defer.h +++ b/fs/xfs/libxfs/xfs_defer.h @@ -70,7 +70,13 @@ extern const struct xfs_defer_op_type xfs_attr_defer_type; /* * Deferred operation item relogging limits. */ -#define XFS_DEFER_OPS_NR_INODES 2 /* join up to two inodes */ + +/* + * Rename w/ parent pointers can require up to 5 inodes with deferred ops to + * be joined to the transaction: src_dp, target_dp, src_ip, target_ip, and wip. + * These inodes are locked in sorted order by their inode numbers + */ +#define XFS_DEFER_OPS_NR_INODES 5 #define XFS_DEFER_OPS_NR_BUFS 2 /* join up to two buffers */ /* Resources that must be held across a transaction roll. */ diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index d354ea2b74f9..27532053a67b 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -447,7 +447,7 @@ xfs_lock_inumorder( * lock more than one at a time, lockdep will report false positives saying we * have violated locking orders. */ -static void +void xfs_lock_inodes( struct xfs_inode **ips, int inodes, diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h index fa780f08dc89..2eaed98af814 100644 --- a/fs/xfs/xfs_inode.h +++ b/fs/xfs/xfs_inode.h @@ -574,5 +574,6 @@ void xfs_end_io(struct work_struct *work); int xfs_ilock2_io_mmap(struct xfs_inode *ip1, struct xfs_inode *ip2); void xfs_iunlock2_io_mmap(struct xfs_inode *ip1, struct xfs_inode *ip2); +void xfs_lock_inodes(struct xfs_inode **ips, int inodes, uint lock_mode); #endif /* __XFS_INODE_H__ */ From patchwork Sun Dec 18 10:02:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 13075997 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 3EE4CC4167B for ; Sun, 18 Dec 2022 10:03:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230251AbiLRKD0 (ORCPT ); Sun, 18 Dec 2022 05:03:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60000 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230287AbiLRKDT (ORCPT ); Sun, 18 Dec 2022 05:03:19 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4E6FA65FD for ; Sun, 18 Dec 2022 02:03:16 -0800 (PST) Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2BI5weh4028846 for ; Sun, 18 Dec 2022 10:03:15 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=8hCopp/nA2uT3LddAeVVvUGVEsFmCIiF3XYQIYuJc8E=; b=T3k9lUvyOLbH8GKonMpX47sgqVTAPGLSAzk3Mv5o41QDcI9JbrLeZz+V6XbShRZATvYT L5w0MwCTJeFIpRlVN4Pyl2ippoTH0ehAcEJaF2Em5G4TJW7kyKIZQsBjMTplcFSNVqLK c7vzZsbHDr1lFMfn6AFTLZunJnz0Yq+DtBX8AHHCydE8kObGuEKib5UxRf/MqYLNtynj QS+Wwh1Wapmp+iUNLaMYExrYKMa3Nxk7ynwCmZxWR51o7lsC9eGPFXnj3r+0ObY8hr6/ M7AxRDUm07EPA1jtv0k8j3vF7bOuHCyp8c2yZSnSVE+nVCwkriCQ8p5vniuGzQg8+Kzn 0w== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3mh6tm19a0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sun, 18 Dec 2022 10:03:15 +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 2BI8AaIK006861 for ; Sun, 18 Dec 2022 10:03:14 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2172.outbound.protection.outlook.com [104.47.55.172]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3mh478n3n1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sun, 18 Dec 2022 10:03:14 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VernPWd5g89v8nEbUhYIYMUovNO5H9FCH5NTAhwWZ6FsBGrzGtzifG8UKZ0tJrTYcSfG+qnoClJJLc6exdfk8Q3bCSxCAHGge48a1dyb2hi/QGEDih6FM9vb4ggVG8kY8UJ0HcnhTYhaeFo5VLLGPxMIFtxaBbdlCGorGUXWmCM9aWVCtLziUFqiyQOC4ymuZOvUYpKIyRM8e4/+eBRLTTjq/pm00DaTsT97Bp1L/VlQXxzG9F5l0jmv9x3pShHkXKHmZAlMj5CwGSfKwR8seOmuKCtAW47wNXRcOs5uQNfnAL3S9FEom1DRdaFrT7+HLUuNRTkMDTiV9sGsU7rhEQ== 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=8hCopp/nA2uT3LddAeVVvUGVEsFmCIiF3XYQIYuJc8E=; b=ju92i8mw1ii2wj7Bnntr6wkusBCyK1Gwr3M3fhrU0wLxGii5yVaDdTJ2qbf37K8iBXAFYQ7yjYdCQ/w/eeEkLLRTP3sjqyI5YcDWyTNsTfoviz0HLup2wWBaRH2gJ/YeIC9HlQaq+2g+NkuWROhwjymHFZdwKi3RIiEpB5a/pDTbTr3INLn3qybrRhXde80pefFQ4mY042qlwt5RAxAuvSzxNjbdmhjxBbL77AacQo8V3iU9SJUpsNWfeHxgKyC0AFHtCLfd676sFKIopgCJXg6+YSeiONRLXvH030ivaseXrbfWBQtZqftAL4ST7efwaPgSVe3yvgZgLJDvCm6Giw== 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=8hCopp/nA2uT3LddAeVVvUGVEsFmCIiF3XYQIYuJc8E=; b=wzE7WVn/shTL72GWSXhaU9JQoroa8+oQ736uOSdJYCDMUoTk2MAYayPcUOiS6JjGj9J4NoVRaGrbg2DUrRaZFKWu0bX9QOqWAVjnvHC1eRuKTTlQct/06PlAOMG4gCEDrPOGyL0BsEI2ZofObGnF39n6jB1kiLVZYAX7Fy3MUaY= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by PH0PR10MB4536.namprd10.prod.outlook.com (2603:10b6:510:40::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5924.16; Sun, 18 Dec 2022 10:03:13 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::3cab:6ff7:cb4d:b57c]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::3cab:6ff7:cb4d:b57c%4]) with mapi id 15.20.5924.016; Sun, 18 Dec 2022 10:03:13 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v7 03/27] xfs: Increase XFS_QM_TRANS_MAXDQS to 5 Date: Sun, 18 Dec 2022 03:02:42 -0700 Message-Id: <20221218100306.76408-4-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221218100306.76408-1-allison.henderson@oracle.com> References: <20221218100306.76408-1-allison.henderson@oracle.com> X-ClientProxiedBy: BY5PR16CA0020.namprd16.prod.outlook.com (2603:10b6:a03:1a0::33) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY5PR10MB4306:EE_|PH0PR10MB4536:EE_ X-MS-Office365-Filtering-Correlation-Id: 7a1b12e1-af77-4d12-ab0b-08dae0df134b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9/1oLt9kQ5/I2N29WolI0i4E3kJ5y4fzJk5cvE0dEZuNkTppbO5fZsZpcxbP5lVDhMh0qYxxEmInjeIT+rITpKfou9zohSacoHzKUDY88wa7k7nnNB4gdyTLuWa4b0HH1H1dOxGaaBoNcAi76VFlItpgS6w1Ubik456yjkjE2RW9FfDFmWFMHDhtVSVSvzICNy9MrmqjnwivrqojlE3mRpYKsQQme0AhZS9D1H9DNhwYZnvkSV20HwjtrEda+Wwr+qBCT0RhzO+WmJFin7Qy3IXL5yh/PTOBMOhxMXVmNLH8Umb3/Wqi0PhRpoRTKT1kHI2kXqLHkamySLXhEsMB7mjLY29Mu+wnVKUVMQQ+pduiHBRUGfSaK+9vYlL0sWIcV8jE7mvgPdVcQLg6ihMjkuSrLsXiG4A7/P1pCA+avz7JNTMyzTsieHoAokBafQHobpnIFwbcGNava4P4GTkZB4tEhJY71pdOGwf4EidzLAA6u04fQfLNRqgkSA+DxE3/LsV7TX1JlXfOrJ+h+stUu+dwV7xanSpybiafv6d6knEkDl2qyH9Hqu7/qVxLbO3kASw9PLUnKm3Oeh8hOWZW1f23y4CT4S696RkAngB0TPIbXv80Aem3Ja9iVOAwxsGj 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:(13230022)(396003)(39860400002)(136003)(346002)(366004)(376002)(451199015)(83380400001)(38100700002)(86362001)(66476007)(2906002)(8676002)(66556008)(5660300002)(66946007)(8936002)(41300700001)(1076003)(9686003)(26005)(186003)(6512007)(6506007)(6666004)(2616005)(6916009)(316002)(478600001)(6486002)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: qWuKqv6gdwF8mZj7+M4wf6PkOF4XOB+B6wI8OskN3HBuhsn3Qm9GIWfQxbxv1szFP0bqyi0R1E5QFlvluq05r8MamsM/u0LB4T5YAX24qYKZIElRABj2l8DBVvOccmF0kdHh4JZ6Sa23uAuDXCRdBhL4sdy6cxxeQ0rq25x019IKpUiE3O816UabuMBusz+nXtV0m18kDgjnlKBUn7tjqo9rWjzrCEcOs4kHqNrA/AV5Mt0SOmMAOMAQNKJa4VS1Mf6WpTPXeaFHjTvowaOgI6PClSAshWWDV4AaHMLoc6v5HhfAy0mO4k53cFLmtTBtSziu49fbrUiDbxGJCY1/siIFwyiVZa2la4FT/Xj0MqV+trsuvcVN01oXfr7TrXgsT1VVr3NZNQSovBmo3RzLBYGY/60VwUVBaqSp4giJBoVvOyuT8pkIZVhEET3J9/sIlj3O3pJJcYkyIEdhrVhqBnQRj2zzDVm8bAbOoG6dMKFoE+fihc234ggXzy9Zch3gGUnBr1OWciQnAFR5ElepvsYi8zmlw7faJ0QhQQyVJAlqPq+N5R3a5T81JPUWD/izwtDItH0J/HkhGcYV6WnAKGekVDXLfjUUFgZnze3L6nN/8gI7ZSxNZFMb7aogZF8fWzrWUxYFQFujaOo4bZKogFn9dDYf9O52rVgkrYcSqkp6tXP47RzyLvC0d8Jx3Ffz5j+TW7jcNBWf55VcK7ddNyTVnakaN6Xt/QnzcyJbWEmq3fBdnHlC03hCMY9djvTR+LhED9GvyzOedNWJEWSu8LXteAyZoZ9vNIpVy2fMuJz4myIfcwLexu3s42Fc2gZ8uk+F9MF6LrSwsW1etMn2BzGo/PyJu+1kiZogNIPxYcWxoOYFojNOEl3TPsf8rXLpGHkya1qxKhc2Hyyc6RXqNLo6lWCTnvbFpuIxXnnOaqqSGl1bgRHGpV9hWAs+Tsx+/vsWWvVPre+Gmw3iBP7O/eoLobe6r7vnYLxxx9EKLWSWdIqoJCBJGXZevYrgcm1cGlcuQLP7URTpeqyA9+reR4B26OqckIjzzQl/qAShlmkVWD2DMo7F8k1TrAUfT8wR4yBQw4P0ccrgVHRJZruXadmN2ZEMPGusLJIJ7sRcuuup1vs5XKmAY7IHt7db8i8mYXNYXW9IgnpWKtQ+FCOrnVV2Q4kVu92hSb1L/JXpwAlzb1XhwOWnAqZ7al99kqS8U1IwbetT9Ch4Pms5Dq8/Ab3HJ8LRCqDEc4Xh/biKWRrjKlIMXW1ypD5bcYgT7CUXvyHbXr9BRAm0cW2Vf/tjnR1W252GIBcTmoaiCnAtr+psT4Zajjfu7QgIFzQ7ebJ/0AlOFLT2YfHhWnYE4aZPWoup4qpWkc+jaId0xiZfOvyIrL1qpk5iynUSLDyMa29jrKkT68VI/wHBtCIV6auypaSwyRQHeOmjWhBdwiX6r83o0c5LrFjBXGZ7IktiJjaSLsFXYuuur16qR6MyJC6fFWSqUN/CAYX26nvEVB1jN2eTrYrZu67e82mScGp2tWvE+owMp7JDoBSU6ZZWwtk3OvX0harQPESLfbk826CHRixd/31nhKLnajG0FRbkt//LkZCOt38+AS8hxqenEVSO5A== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7a1b12e1-af77-4d12-ab0b-08dae0df134b X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Dec 2022 10:03:13.3495 (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: gCpUtsVAjFdJRxS6PHYlEdn+t8I/Cp7++Q3wPJeGjfzS0FwOqHq9jK0t7Ugc3kUDYwK1Yhku8CtyKB6LeociFpBffAsOGSEdM9rHq6ROZUM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4536 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-12-18_02,2022-12-15_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 adultscore=0 phishscore=0 mlxlogscore=999 bulkscore=0 malwarescore=0 suspectscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2212180095 X-Proofpoint-GUID: V36JtkkAjkEgjyRrQaRtZ0lOJ6avamkd X-Proofpoint-ORIG-GUID: V36JtkkAjkEgjyRrQaRtZ0lOJ6avamkd Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Allison Henderson With parent pointers enabled, a rename operation can update up to 5 inodes: src_dp, target_dp, src_ip, target_ip and wip. This causes their dquots to a be attached to the transaction chain, so we need to increase XFS_QM_TRANS_MAXDQS. This patch also add a helper function xfs_dqlockn to lock an arbitrary number of dquots. Signed-off-by: Allison Henderson --- fs/xfs/xfs_dquot.c | 25 +++++++++++++++++++++++++ fs/xfs/xfs_dquot.h | 1 + fs/xfs/xfs_qm.h | 2 +- fs/xfs/xfs_trans_dquot.c | 15 ++++++++++----- 4 files changed, 37 insertions(+), 6 deletions(-) diff --git a/fs/xfs/xfs_dquot.c b/fs/xfs/xfs_dquot.c index 8fb90da89787..1a602d22bcbc 100644 --- a/fs/xfs/xfs_dquot.c +++ b/fs/xfs/xfs_dquot.c @@ -1333,6 +1333,31 @@ xfs_dqlock2( } } +void +xfs_dqlockn( + struct xfs_dqtrx *q) +{ + struct xfs_dquot *d; + unsigned int i, j; + + for (i = 0; i < XFS_QM_TRANS_MAXDQS; i++) { + d = q[i].qt_dquot; + + if (d == NULL) + break; + + for (j = 0; j < i; j++) { + ASSERT(d != q[j].qt_dquot); + ASSERT(q[j].qt_dquot->q_id > d->q_id); + } + + if (i == 0) + mutex_lock(&d->q_qlock); + else + mutex_lock_nested(&d->q_qlock, XFS_QLOCK_NESTED); + } +} + int __init xfs_qm_init(void) { diff --git a/fs/xfs/xfs_dquot.h b/fs/xfs/xfs_dquot.h index 80c8f851a2f3..dc7d0226242b 100644 --- a/fs/xfs/xfs_dquot.h +++ b/fs/xfs/xfs_dquot.h @@ -223,6 +223,7 @@ int xfs_qm_dqget_uncached(struct xfs_mount *mp, void xfs_qm_dqput(struct xfs_dquot *dqp); void xfs_dqlock2(struct xfs_dquot *, struct xfs_dquot *); +void xfs_dqlockn(struct xfs_dqtrx *q); void xfs_dquot_set_prealloc_limits(struct xfs_dquot *); diff --git a/fs/xfs/xfs_qm.h b/fs/xfs/xfs_qm.h index 9683f0457d19..c6ec88779356 100644 --- a/fs/xfs/xfs_qm.h +++ b/fs/xfs/xfs_qm.h @@ -120,7 +120,7 @@ enum { XFS_QM_TRANS_PRJ, XFS_QM_TRANS_DQTYPES }; -#define XFS_QM_TRANS_MAXDQS 2 +#define XFS_QM_TRANS_MAXDQS 5 struct xfs_dquot_acct { struct xfs_dqtrx dqs[XFS_QM_TRANS_DQTYPES][XFS_QM_TRANS_MAXDQS]; }; diff --git a/fs/xfs/xfs_trans_dquot.c b/fs/xfs/xfs_trans_dquot.c index aa00cf67ad72..8a48175ea3a7 100644 --- a/fs/xfs/xfs_trans_dquot.c +++ b/fs/xfs/xfs_trans_dquot.c @@ -268,24 +268,29 @@ xfs_trans_mod_dquot( /* * Given an array of dqtrx structures, lock all the dquots associated and join - * them to the transaction, provided they have been modified. We know that the - * highest number of dquots of one type - usr, grp and prj - involved in a - * transaction is 3 so we don't need to make this very generic. + * them to the transaction, provided they have been modified. */ STATIC void xfs_trans_dqlockedjoin( struct xfs_trans *tp, struct xfs_dqtrx *q) { + unsigned int i; ASSERT(q[0].qt_dquot != NULL); if (q[1].qt_dquot == NULL) { xfs_dqlock(q[0].qt_dquot); xfs_trans_dqjoin(tp, q[0].qt_dquot); - } else { - ASSERT(XFS_QM_TRANS_MAXDQS == 2); + } else if (q[2].qt_dquot == NULL) { xfs_dqlock2(q[0].qt_dquot, q[1].qt_dquot); xfs_trans_dqjoin(tp, q[0].qt_dquot); xfs_trans_dqjoin(tp, q[1].qt_dquot); + } else { + xfs_dqlockn(q); + for (i = 0; i < XFS_QM_TRANS_MAXDQS; i++) { + if (q[i].qt_dquot == NULL) + break; + xfs_trans_dqjoin(tp, q[i].qt_dquot); + } } } From patchwork Sun Dec 18 10:02:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 13075998 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 D7F0DC4332F for ; Sun, 18 Dec 2022 10:03:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230259AbiLRKD2 (ORCPT ); Sun, 18 Dec 2022 05:03:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60004 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230294AbiLRKDT (ORCPT ); Sun, 18 Dec 2022 05:03:19 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 784EE6333 for ; Sun, 18 Dec 2022 02:03:18 -0800 (PST) Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2BI2xPk1023317 for ; Sun, 18 Dec 2022 10:03:18 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=I8sRiT8HegoLo3XD+Hnm8N4HbjY6M5kTI37zdnr8ZWA=; b=18YqxdSC4o9axrLhyk+trjPP74Ub20f2CIZNmeHLY01BaXnbbVTuh2+6MvJXG+rcsVW4 oHonUoihpf5x9B2NY5SIU9/3tDsq1qk7PJAae519Dk10xppskIO6fijZQT9Xx8k5QBkY 8bRmy81KhPjBmnfmragYrOZsPa1eopwieRILTEqyga6SIU5NrVNxpF8WCGRnkR/VVXk/ 3WPX/OeUYRluH6ttM1cSkS1uaSOaT5FuJBm/R7mBbZn4BoP74itEpUm5E9hjJ+YqR4S9 m7Qo+m/4fAS+3UByO0Vk/cFl+y/GxdI8XmS5OaBOAmwx+fAC4AXMWT9Y+66K2Hirtjym 7A== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3mh6tp1911-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sun, 18 Dec 2022 10:03:18 +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 2BI8PpxY006839 for ; Sun, 18 Dec 2022 10:03:16 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2176.outbound.protection.outlook.com [104.47.55.176]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3mh478n3nj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sun, 18 Dec 2022 10:03:16 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PtX23P2rm4Qx4HoXCWGVgWXXJ5nlgFUMq3VRJ2pFa+BinUaJ1QqmA9XqAiPWhprHMeIQwbuintuRsKDjihq4xwtCRscvIJKI1s/TT7rGb2iVwJU2vxzbta8YVynZ0DVGFne3/y9SyawsSMnP6lm82bjVcr4ARTJFpDK8jFLtMB78qvdpsh3vJll9geReHVgcNajVZWtlf2fEXWWbK1BOhniH8QcXImzD/FoONtaF2t1TczMAPCmAI6y4BWdIUcPeBLNroUVjAbJhP5IskXf6GpVAoBT3sQvOiNivo/3P4OAQXvGEPR/bBPL1ljbUZioUhMWDtgtpaGy4bHC/z43zcw== 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=I8sRiT8HegoLo3XD+Hnm8N4HbjY6M5kTI37zdnr8ZWA=; b=dVO7yUvy8MTiCZRvNpybW9GPFUEQft+4e4xDK0jzFjaUSeZpdHNQETeUCkdLxMJ0dN5sauvHxSIGq85woDzMetiVyy9i3NpRa0M0iOr/7jnj6ZnKtLdy07EXP9XTBlQ0rRSrCODsUkw4bwBcEgY7hIK2bVeKn1QL1n2HwO7bZgnf8NrgSyhpPSegQIbRLAGmd1/cmabvu4n3DS2jxkMpySWT8NyeM6el9v3ACfRvHD58dWQdfDMKO/HbhfpPsR5WURkTRcRS0+5Cu6fSgpt5FAHxgfEl5KgskPz8XhB885MicVad59WNrzjLQcB6+wFrQZcNkCpM1wFhEPU8SH5ZQg== 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=I8sRiT8HegoLo3XD+Hnm8N4HbjY6M5kTI37zdnr8ZWA=; b=O1RD9BUcowd7Lp2DbYXyiSE7E0SWxBern4sjKM4HduBIcbVi0BNDA2nEky8aOV98Usezx9trb0gz6QQ2MkmwDM4FKwKL+KHH3zlJYF1qWzj2UyUbpBT3/O68jMWNLThbnhFhwD6Tlaf1R7Ii5iZMNWJY8Akh/CDQDLB87Cb2DO8= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by PH0PR10MB4536.namprd10.prod.outlook.com (2603:10b6:510:40::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5924.16; Sun, 18 Dec 2022 10:03:15 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::3cab:6ff7:cb4d:b57c]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::3cab:6ff7:cb4d:b57c%4]) with mapi id 15.20.5924.016; Sun, 18 Dec 2022 10:03:15 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v7 04/27] xfs: Hold inode locks in xfs_ialloc Date: Sun, 18 Dec 2022 03:02:43 -0700 Message-Id: <20221218100306.76408-5-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221218100306.76408-1-allison.henderson@oracle.com> References: <20221218100306.76408-1-allison.henderson@oracle.com> X-ClientProxiedBy: BYAPR11CA0057.namprd11.prod.outlook.com (2603:10b6:a03:80::34) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY5PR10MB4306:EE_|PH0PR10MB4536:EE_ X-MS-Office365-Filtering-Correlation-Id: f73f55ea-b3f8-41d8-f45e-08dae0df147c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: v6Ll9/bQGUvVm2GjUL9mGvrTTPnP9Fd13/nALPwXLIakmdlfJAylxgNkiPdrMObTcxL7C15Rvr+A+CrvCqmbbSejEkPJpX0PkXXj3vxvaVUKh9jhUmWkqLK8k/ENAfUGD5eqH7taWHk9oZPctMJTfCF/QaB9znRBKplHB9jEobfToQMgoqmbBVUaOfWzZaOjACSPNu/Lng93BkblXdUqLrdEdCDxSdvnlya980LA2Og7ojq8cqVKSXg0dAuMOWiIAh9p+QM/TEA+spzzEHldrVgOwozDbElc41+oZ7ETQ6X294T1IwRJ/HnQnCt3YDPzzKW/lGrZl40Cevt44jnCP/ak/CitJpT1JiizyOWXOly4ofOgjVunKoLseVfdmx2IZI3a2JABYO26y8lJdHz6Pd4+L0fSr6B9ORKL9JbuS0UDe57hA1BdTEF0QG0V/IS9hHWQzk9p1/LW3cOYhLJngIS2hvr4W90JnOIBdrU5tlljoGPQmaADSPlW+UM/10LxWZL3TCBrZCskmKnT4dGXsn/DF3aEzfMocAx9iL0CJ0mEYV5V7zGVpBxUoGQx7X0q4YWwpKd8uagVrLRg52H1biD9s2ppC9snd6KjJJQSF0BDrHTz5vSuAWXyvj0SwNUe9oQMC4fO2vs9jAGAPwzK9Q== 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:(13230022)(396003)(39860400002)(136003)(346002)(366004)(376002)(451199015)(83380400001)(38100700002)(86362001)(66476007)(2906002)(8676002)(66556008)(5660300002)(66946007)(8936002)(41300700001)(1076003)(9686003)(26005)(186003)(6512007)(6506007)(6666004)(2616005)(6916009)(316002)(478600001)(6486002)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Zuoh13qnwtVuWJIBR+/pNPWva5W3IgZdRIthg3N+PjoVxDl+zK7nOYWjoQjlN8fvbbBzJyH5Yx0D6T74fz4ggQ5+N3RQr4zu70SdXeFwGmoEBnp1di02MWyKPmrE6+e7xDDSNoSbM1Rp1s/5jzyx2xuepRVAgMG0OsN7UqX9Z6jQcC/JCPFDU2bLzIPIbgJ8aaCZOD8btk/X/cDn5MROP/R5yQHZ2Q6Fjp8zQ+Lno110CHGjxyiIizCzpALhJksDhaDTSSLGtT/gjsLSv2DQuajCpA+6JouzkVpLzGEhqSfsD/r4UhHSkm39OzQxfLPv/acL1fNuF1y5N6Ft7ypVWq9iubDqZWALVB6u7s8nYcSh/JOiuuNXVrxpcKrB1ZtnGxAQh/BvOBPkjdFtjecruVohyYvHL020EaEbBkcAnmH2fQiJ9iHqVZDEa2Wz+O42+dJTHb5D1DEHDMCUYMoP9ERkLI2GzON3M3lJIc966TIzOcCJu5yFZ7TbTlt797D49Sf3fka8bA/xeTARc66YqIv9jmwVJA+nV9eDkWgWF/x2u7Z8sKrnSSHyXCkxW34oTyep/5F23f3/p5kz0LqzYfoXJ2sKyRVpezXw6+DArTnmU94XbkogSqkva6rUp41x8kXTv8c5y7wU9xsssJZxRbLl5YtXHynTwTfV+LHRiMmtIAj1wmNBqLufBtElMXFCQmIu+hOpqURSbBjfT+c12+4Vlf36tkX/Xm5Vg3F9wVn3fzowTHIauM0Kyqo41e7bGZ3RYtCD8E6L/oVote+2KG1TJI8V+ThDReAMjp0icn/TcVI2yJPiMBh34v7votrPySbwVhVAXrHTVlRp1IMOvcjlNkNwTcTOt2JhMF12XI81FtbEPdHB4WrZIzjEQItMO4CbWrqCK4IbG2dTJ6RG04V1W+/iAjVZ8ndDaVoP9EyIIFOPv2Li3sh+//kDJPSWYoYsifd0hNOOpleoc4tGDB5ZYcUeDRaNmGXfW0uiTxFFU2ghQJilG4MqmKfL2i0cBkcahR2rdagiROIRB1byq/AmYNzC8A530WuM0jGoPgjyeXyg+cPnt7gHUzEfieYdHUVxnrDW4Kw/RBt9Q78PQUAJ7BhONGR2/cnKlogPVIFRU28sWoDfgYoyNC5ffBhl02tcF1aYlbg6lbv4RNYEde6mK0CaR4y3SOux5G4yRFAkSzJvsBGL6JwXZwuZBVw0AA4jWAHXNZNAULaf/vHAvkXNbOEF4sWAHWFYz2Z8x4kqJWhlW1+++MzXJzSRcELcfMb8oFXYgKIbUaqS/3CVDWwvfN+Zg+rQhicyBcJ73U1O8fqrq3WbyoirdMTfJdSGGYc9DiN8RbBoJ/zrbcLUe1waaPgPNvrAmUtR+5TlHw6yXSbMDTK9F7Hq2tRYrT1DVfO6DM/7/cYg4F5LwPwiQzW9qmxDus7DF2j9F7z9uny3qzQx6kimfmUDut/XQNo1M68/0M+matcrCCsMKFSFoJugu2bNLQHPrEDFWSr8Yw0H8k0U7L7dycrQldtnBEwsNHvxGmemV+TaMPewuHFfbxTGNu4NSDXo2M2U0tjfpvHuI5ij8EHRVcOvbJwLkuoInoZR+5AClSRjmGN84iF+mg== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: f73f55ea-b3f8-41d8-f45e-08dae0df147c X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Dec 2022 10:03:15.3189 (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: uRobulx3c7i0xCjBh78Kk7R4ssKMFnF9+K/5QLD/5SdowNbZLemgZrOaA/kl8t9qcs2+JgqVRIEbF8oiVjsM65RPvorRt1kKR5ivzEjJS+0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4536 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-12-18_02,2022-12-15_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 adultscore=0 phishscore=0 mlxlogscore=999 bulkscore=0 malwarescore=0 suspectscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2212180095 X-Proofpoint-GUID: tZpTsHYn-XhqgdMNVPuc148TUCtFymZq X-Proofpoint-ORIG-GUID: tZpTsHYn-XhqgdMNVPuc148TUCtFymZq Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Allison Henderson Modify xfs_ialloc 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 | 8 +++++++- fs/xfs/xfs_qm.c | 4 +++- fs/xfs/xfs_symlink.c | 3 +++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index 27532053a67b..772e3f105b7b 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -774,6 +774,8 @@ xfs_inode_inherit_flags2( /* * Initialise a newly allocated inode and return the in-core inode to the * caller locked exclusively. + * + * Caller is responsible for unlocking the inode manually upon return */ int xfs_init_new_inode( @@ -899,7 +901,7 @@ xfs_init_new_inode( /* * Log the new values stuffed into the inode. */ - xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL); + xfs_trans_ijoin(tp, ip, 0); xfs_trans_log_inode(tp, ip, flags); /* now that we have an i_mode we can setup the inode structure */ @@ -1076,6 +1078,7 @@ xfs_create( xfs_qm_dqrele(pdqp); *ipp = ip; + xfs_iunlock(ip, XFS_ILOCK_EXCL); return 0; out_trans_cancel: @@ -1089,6 +1092,7 @@ xfs_create( if (ip) { xfs_finish_inode_setup(ip); xfs_irele(ip); + xfs_iunlock(ip, XFS_ILOCK_EXCL); } out_release_dquots: xfs_qm_dqrele(udqp); @@ -1172,6 +1176,7 @@ xfs_create_tmpfile( xfs_qm_dqrele(pdqp); *ipp = ip; + xfs_iunlock(ip, XFS_ILOCK_EXCL); return 0; out_trans_cancel: @@ -1185,6 +1190,7 @@ xfs_create_tmpfile( if (ip) { xfs_finish_inode_setup(ip); xfs_irele(ip); + xfs_iunlock(ip, XFS_ILOCK_EXCL); } out_release_dquots: xfs_qm_dqrele(udqp); diff --git a/fs/xfs/xfs_qm.c b/fs/xfs/xfs_qm.c index ff53d40a2dae..319a263d09e7 100644 --- a/fs/xfs/xfs_qm.c +++ b/fs/xfs/xfs_qm.c @@ -826,8 +826,10 @@ xfs_qm_qino_alloc( ASSERT(xfs_is_shutdown(mp)); xfs_alert(mp, "%s failed (error %d)!", __func__, error); } - if (need_alloc) + if (need_alloc) { xfs_finish_inode_setup(*ipp); + xfs_iunlock(*ipp, XFS_ILOCK_EXCL); + } return error; } diff --git a/fs/xfs/xfs_symlink.c b/fs/xfs/xfs_symlink.c index 8389f3ef88ef..d8e120913036 100644 --- a/fs/xfs/xfs_symlink.c +++ b/fs/xfs/xfs_symlink.c @@ -337,6 +337,7 @@ xfs_symlink( xfs_qm_dqrele(pdqp); *ipp = ip; + xfs_iunlock(ip, XFS_ILOCK_EXCL); return 0; out_trans_cancel: @@ -358,6 +359,8 @@ xfs_symlink( if (unlock_dp_on_error) xfs_iunlock(dp, XFS_ILOCK_EXCL); + if (ip) + xfs_iunlock(ip, XFS_ILOCK_EXCL); return error; } From patchwork Sun Dec 18 10:02:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 13075999 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 A7722C4167B for ; Sun, 18 Dec 2022 10:03:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230250AbiLRKD3 (ORCPT ); Sun, 18 Dec 2022 05:03:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59804 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230244AbiLRKDW (ORCPT ); Sun, 18 Dec 2022 05:03:22 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 861CE6352 for ; Sun, 18 Dec 2022 02:03:19 -0800 (PST) Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2BHNmi7G019280 for ; Sun, 18 Dec 2022 10:03:18 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=p+ajdmAuPHTwwdKb6mU8U+6ouxowBIzJiTCTb8Z9cOE=; b=2Ao3SECmG1oFPO6yQSoeHgs59i5/24E5peyzri9Jp1MMt2hZlGOY4Ol91TFAaHiuuZ2d P0DgVO8smVjTFzDI+RCZwGN9NUISFyrYwrPN/MFF6J2mmZa5S+5xZwqKxPuKeMttpVVp ONAgxtFKjUMfFFebCAqYp8p9rYJTZOLAd7oOu5jS3UeTECyZSzD5JJ0ep3hfQh65/N2M zqjA36+D9L1nupMMv+hL5zJTLg7Zdf8sGwghlLAYuIvVZlKiBF+cvQJ+CShdoK2InCAh 4kXUFSIT1KIdIGB27h7qX5OeFMsZZ4IIThEWpRcqAB98SU+U45F1SNng/pZ4jOcfshMR Tg== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3mh6tn196q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sun, 18 Dec 2022 10:03:18 +0000 Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 2BI7ween024738 for ; Sun, 18 Dec 2022 10:03:18 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2169.outbound.protection.outlook.com [104.47.55.169]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3mh478mxj2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sun, 18 Dec 2022 10:03:17 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XA/U7EQPaFFMh6wurqxmawsNXJGcUder+6rYLB2cadOZ09a+0HSMt2tRe03HiCkmilb20tyXguPvlS7zYG9mQnmU68/Yy3s6+lVxKLvtZC30Q1g2we2gWivu29xlhPzVB7ZonOa7jUdGZOLZWvwWqfyxQqpPvSMd/C0dK6TX9s7sqn0GYXZyavqvkcelVp8N89BUwYhRvsvEtOOJuO86ndLTWg3Czs7TZU1fKAWFjCZWg/oZdZ3XmRzA51ycKk0COqb0cZzcaZr+TmZ5yCrRonAndYmSceCzByfGEIHw8hMmnJ7SOX6ZlT5XJdo8l77d7MnTahjRG/StZtR3HylB+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=p+ajdmAuPHTwwdKb6mU8U+6ouxowBIzJiTCTb8Z9cOE=; b=Wska4W1y7ak73aQB2gOecV325zNYUMs5f1qJL2ZdEYLart96KdU03rB/88RkJofOjnCR4pAh6mN85oj4vjx69wQ0k6akvmlLe5HcNdiKlC2POLc7xIL3YSPKP2irXxvVWYREmjESoOYwNK1cLTCs32eVSzyyfqk+OKy3hIX/OBjknTdkd+LfU+s/Rm3IDrhqFaSpJBWs9SG1w9AX/2kj68BHbOBc/JbzhNBVGSrkjJEQOruUpOyAtvnhu+10abRb+UklWmeI/s+CJHC+3GGq3a7I94z4zbERzkNybFjKF8e3LA/7/Lp8yZmj9j6ymuf3lRtrvzGARbAYNAbzbcjkzg== 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=p+ajdmAuPHTwwdKb6mU8U+6ouxowBIzJiTCTb8Z9cOE=; b=YbGWKa73EkMVNtvc+SdDsC2EeWbfRLaUv+pq+vJser5ypifryxBz0Sn2YAprDaGRT9KJ3hQ4wkSmM56sAIBNVtgaYaLuqXpTrfieSPrT4PhgwigbocD1JMgebvNVDW9MSz9cbGXcRZdAI53IJcafHB/mr3VSobBcDWxgFSRKk9g= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by PH0PR10MB4536.namprd10.prod.outlook.com (2603:10b6:510:40::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5924.16; Sun, 18 Dec 2022 10:03:16 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::3cab:6ff7:cb4d:b57c]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::3cab:6ff7:cb4d:b57c%4]) with mapi id 15.20.5924.016; Sun, 18 Dec 2022 10:03:16 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v7 05/27] xfs: Hold inode locks in xfs_trans_alloc_dir Date: Sun, 18 Dec 2022 03:02:44 -0700 Message-Id: <20221218100306.76408-6-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221218100306.76408-1-allison.henderson@oracle.com> References: <20221218100306.76408-1-allison.henderson@oracle.com> X-ClientProxiedBy: SJ0PR03CA0081.namprd03.prod.outlook.com (2603:10b6:a03:331::26) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY5PR10MB4306:EE_|PH0PR10MB4536:EE_ X-MS-Office365-Filtering-Correlation-Id: dd3ac7ca-3c89-4db3-ce3a-08dae0df1542 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: WzsDmtHlAx3zxTcHlvMMbcyo/BbGB90PFU/KAm4rhiMLfKHdTAXL/uPFDk9UIgDHpswm5CTaB8jWmB5484FLjZTFO5Z+pbCGNXdL6s4Q4ORXCdxsYWFt6A00y51Dzl3rbC2Vm7cEZCwhF3JdURFEr7LcfKSu8vV14Uj+n8bbVgaWWfz7sKMVf7wTq58hmL7yt2DH+Xh5ukOAixHLf1b/iK8hHmb2QTVd6F28joGZJ7vBo4oCgyrHoUA3lIT/PnqLAxK46rRQ90bFAF7qBS4gGfTWf9kH+LfEVZ2vBx31i7pT8p7E8vTShcCm1717qSejJj+oC+DUwvFoQSYHny++pDcTeMRMV5/aME7moJXN9xErCBxw11NxkSAXLKOp2FMXYZiwEpwkQzTUx5Bi10VwZtIUwCSG5sLzAQlurPRl8ixQXWZJOIlwXkZIHn2S4wfebxqPk/EDdDdyzbJ0cUofUluqaaI5Ng9fok287YZsfTBl2R/YTD+fKPVrZpX63rJAL5YM3paTk5urLq5hTwDb5py1OG0tskRem1LRlspYBeOsbWFqixyv3Tyyb/NBbztDu081UbP+s5eGRSHuSx4PduwYmJP8TMoY0NdmBy5+pSEO79wdZ+6rRBznFmKN6QUePxYozn1nqBSzXabbMv1C+Q== 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:(13230022)(396003)(39860400002)(136003)(346002)(366004)(376002)(451199015)(83380400001)(38100700002)(86362001)(66476007)(2906002)(8676002)(66556008)(5660300002)(66946007)(8936002)(41300700001)(1076003)(9686003)(26005)(186003)(6512007)(6506007)(6666004)(2616005)(6916009)(316002)(478600001)(6486002)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: FQ0WYD3snetU1QN/WHVRH3j/k8uqEsfMaMu6KY2bhvS8Oev33SMPsb9mrpdhJnsNG3W49ytLz+8uMT0PlrTYi/pKfYWOi20gAwh/1qIVsV0uBgzz3Gb0bzlLh7kX/AMxDi3EG46euZm/yVHf5UrJDzocScnxyI9c7sc+rICyvr1c8yhuUJH6G9o5Ql5xAoZDpKQx0Tht6PwNvYtMliVgDYSQmeAVwzzGU7VeVQQW9q+LEkWQXG0eHUa/PBDQO041ZSCFJryBPgaKBoD8E8rTAXE1ukQIKPeCBqd3N0/P6aeDuW+X8qw1OwDL5O893CeS3u9Zb4OmsRLsj3w8K88SK/H/ZoSUWFtPfoS6VJUS/XUY6GhCzEGi+/eY9gByD+TJhh2s3Qrn7IdcJ0EqnjPJGuXp3hiAgBgJs7VHxXrKWnIZQ3qeverDaPmL0c4W57fTrCxPNDgquo30DrAvbU3Oy+v6fWetUqhbafqwI3jc+fcTUSqsEeSktAP0mSW97ZfsyK6aSpFu1DcLca0uLQNp3YE5IdmkzINwef6APSF0cXBBJXA/A6muagWnYHbPmTPkBhFhaHq5SjPCPLpQhjKwW7RmcknT2zCbMo+rl4Sj9MitnV1kK+0zAfvMXXbsd4dIXsLkJcqTQSIwY1VJr8Z3tc/lMZKt/s4pD3AgAeeZcNzj+1zh81jHtiIOYIqK6FwXaZP6UblFeagfKN1qzf3kMd+Tnvi1AW31hQhO4orD+tOmFYcZgqYDCKtked8R+G3DR5mAD4T1HJU/WLKyIIkq87mER+HmxcoHMdwIVFGSGqdtWXdjwj45napsdJSxL7kPkJKoS0yqSS9m8ESg9i5hyAljxbQomg9ShxD5E5dL1nIdaq5Kn/aLsivFBaLrz0Jn0W0I3yHVBUlUcHNvrjodMkVWS3GTJj/R6Qt+5D/LUSHuhPc0hpz7cb8ZGmx1iemSx36GEv8OyhHGj/N0Ob+qaqZO0300+gV/fpdeJgN1pAtjjRHkAP4wOffhfXOUhB1BUyEINfFSPGpynd9IwkwSGFda11//A7JJHHpF/vdzTzm9dNf9FAMUIY+rM+qXWSBHrpjMW/ZUzalem4Eq0RH7gsb8TVuzHtayBbvdkCqvsZd1lmuKTWjWo80f2BcVz2lGBP+n5hP0WqB9c66u/kWCL2gtiWlLXLyb8SH287iGeBZ/rPEAlGoLsp80VrvJChXiQ4syO2UJ3VcUTovDY1oDVNYay4b1XTt29HH9nffecF69q0Z00u1/8wjwzsSHMwd8zCwnSV+2cZp9BREBuTHO/cPSGFHk4IRhFm1lQzlDI+3vw0y6Ln0CZRoh29S3YYn/TpJ/DQEiENLSlxXOTLyMU4QwnQJX1sQU6H3NOlNCwVeGENvTNFAWdHTrLeQefVNw3Gn64sj0fyUo5WDNygoiR6D7tfp9/3AdfWNVJeMbiNC1AaNLRT6PXL9/juXeQLmtYAMjLV/SSs/QDQmhk75HHv9WVbFqM5FqMRFjGWppjVpe8Dvn27pOfgwOoifnJOshN+IuWlu9iqLHyholGdtNkIHwibyl1F/QwoH6a7QALjzVaNOwxGZKuyuFxLcCN6j7aYl6k5vM3bJlFa/IjUWvZA== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: dd3ac7ca-3c89-4db3-ce3a-08dae0df1542 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Dec 2022 10:03:16.6000 (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: PrRZwd+3mm2aOVwsmax6VkMxTKtg26DXM+W9LVmm/WdJB59PdSApvFcWI3TONlVjmGyvHaE0LNy+SpuxvjWJsnzuSgKgOUkQBMiqrgJEBN4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4536 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-12-18_02,2022-12-15_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 mlxlogscore=999 phishscore=0 bulkscore=0 malwarescore=0 spamscore=0 adultscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2212180095 X-Proofpoint-ORIG-GUID: Yw6nxHoAV8gNq3_9npuQFo1k_eBLD5r0 X-Proofpoint-GUID: Yw6nxHoAV8gNq3_9npuQFo1k_eBLD5r0 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 | 6 ++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index 772e3f105b7b..e292688ee608 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 7bd16fbff534..ac98ff416e54 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) { From patchwork Sun Dec 18 10:02:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 13076000 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 4434CC10F1E for ; Sun, 18 Dec 2022 10:03:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230254AbiLRKDa (ORCPT ); Sun, 18 Dec 2022 05:03:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60038 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230245AbiLRKDY (ORCPT ); Sun, 18 Dec 2022 05:03:24 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 401C155B2 for ; Sun, 18 Dec 2022 02:03:22 -0800 (PST) Received: from pps.filterd (m0333521.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2BI1wOWE029115 for ; Sun, 18 Dec 2022 10:03:20 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=geWvvCvoKwcsR4SdXeW16FAlpfW3zsKn6xVsjg6OarA=; b=2+tUEL7/WIT76gVIhcakF03uXItUcb7WkiZUg4/zjfx8NkjOoSro4WuNOwCVS0s2qI2d V0uactHYX7nU4Jj5wQMZL7m6fd9EdxG/S0SuKikXyzmdg1CsY2MZ+J6ZNJQMcLjy8if2 wmYaca92CuqQ4FmirUST5an5QTncNQFlVoBnYpxU5m5iwK4WWjImqZxEpiZEdYsbWv+w l8W8Qh5rQpMNe3xnDhIIra/TGbPpKGX16OdEym+sxGVupOybP1xbr6m4MIkYosU4c4rt DLgAVJqY4tE0lg37dtfFZwNVnR9+jDK70bGHIJxZceHn9xrC0ePMbzcXu9l5x8LKTvgZ ow== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3mh6tn99gd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sun, 18 Dec 2022 10:03:20 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 2BI6oEpL006541 for ; Sun, 18 Dec 2022 10:03:20 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2176.outbound.protection.outlook.com [104.47.55.176]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3mh472m2yf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sun, 18 Dec 2022 10:03:19 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PvsBpppHXLME0NA7B2DksGwO+SxmBqKei7rJDj9mfWmTuBD2XQFRV/x19RIO2o6pymVooq7G6x6HyNIeHZ5pxlTrlGekJ9fAlNFsn72Oz6h4GuiCW+ywWWReql0Gb0ZXokEOe4OETmDFjAWRJphcenheSiEx9JzhBXJPO7n+uMs9AnpDRhs7hog6u27uX+U191E5LD/m9ROu0sawyBby1N8v811V9cly0L2MqWacqBN0bBOr9UuREfsp1kMx0T0oyYO3RrzgGG7rgNtGsCozShW6cCylohPQBSsylOhK9dNxZHIc3AhPQMNje2n67601TQk4WXj+gPaHT8bXwVkoJw== 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=geWvvCvoKwcsR4SdXeW16FAlpfW3zsKn6xVsjg6OarA=; b=RfahmQQ0EhhQ2ruzN4HMSoQxHDQQGN2Sz4m6uIaxP7himNi8E0KxChLyFpTpbVzEuWUlJhJ1INOnU4kcF3lwhcP3/O9S3pThz1BS0VOWRX9XrmkU7PGRJOd6rcQjAgJqrPKL/h2xX38ntRPpmdzePZtcfzwHqM8FIeu0YAmv1ksDfTm60x3wCzv1li4YIraD9UtyeETpN2FHREpHr4oBfuCaeBkOaRvNyuWiZQTpLlfhBd8Y/ZK93pHb0ZgkkBWaavEiV1BhBUwN5B5m2yR0p+v2JPJdCok4WktYgt5av0gHM2PwzTTd7qeR1v7p7Z041w51pHyONiZfAPWC/VyB3w== 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=geWvvCvoKwcsR4SdXeW16FAlpfW3zsKn6xVsjg6OarA=; b=z8BxAELRdsdYswr9AWTblCCdqNQ6S1A2xvrGA8bYKYxVQte9F4GkDPjrqdFODiCjVHhc18MALDApAItVpKzVWkrz/1WuSvE8xanboTaNM1m5QWnnExXzmFet/rIPxv5/JdItGz1A3JCKJeP3wALWotrNYW538WAMe7lNNhkIu08= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by PH0PR10MB4536.namprd10.prod.outlook.com (2603:10b6:510:40::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5924.16; Sun, 18 Dec 2022 10:03:18 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::3cab:6ff7:cb4d:b57c]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::3cab:6ff7:cb4d:b57c%4]) with mapi id 15.20.5924.016; Sun, 18 Dec 2022 10:03:18 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v7 06/27] xfs: Hold inode locks in xfs_rename Date: Sun, 18 Dec 2022 03:02:45 -0700 Message-Id: <20221218100306.76408-7-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221218100306.76408-1-allison.henderson@oracle.com> References: <20221218100306.76408-1-allison.henderson@oracle.com> X-ClientProxiedBy: BYAPR02CA0016.namprd02.prod.outlook.com (2603:10b6:a02:ee::29) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY5PR10MB4306:EE_|PH0PR10MB4536:EE_ X-MS-Office365-Filtering-Correlation-Id: 893d7058-2236-4244-0858-08dae0df161e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: YOV6ZVfDpGqHQvu2e9LOfKsuTJTLP5ZOgTv4jN00MZbZpPeENGCmSFHg2+9Q2KaKhwghm5vOY1J9SS+aO3TjK1SJSaJAmwHd8kqNfkJPbGqTMv3ZHbRuANU9OlbkGZbBSfEvdGOL/mUDuCcZNITkqDFqxjS+5YJaI+Ip71jAekBSNFoc8ztWyjUBVvHuzdzJGf0CLcxl69MbtKB525llX4m73AAzp5fh0eDTSpA4CvpNdHce12ZHviwk7McIhO1xIeVfd+xoNZ71I1fd/Q5kT0aXULGe4yOdGObyXu0yMsmzKpq4eLF9XA6+GIgtE3Q4/Tu0sxwSpeO6iywLjcqP26L7tlN+DwuRrLauo+CLEktHGqQTPJX5lUkxmKnXYjIPtaDDyhQIsbGXZb4gXRIMGFPfIhNe3TdWi5v6zQomf4Uq7oXZ2WyawEAmrV9/e8QmPVHe2fBAVhxpYBmDnhTlaIr1+e6GxAXVDGQL1GYvF5jczSRkED4H/AXD0GIhqtP10Q3ZUV6zeBnHdXvglgS0T3TXLrUpkLtpknZNft2pzYtToq5ukz2SQD57SKIDZxHWy77DSL6Jo32+HklRnspsj6C63O4zbYgtTmAOMLRqGe55c6Z/94WXmauS9P6U0z3sr4i26Bj6QpqHjubeZNuNaQ== 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:(13230022)(396003)(39860400002)(136003)(346002)(366004)(376002)(451199015)(83380400001)(38100700002)(86362001)(66476007)(2906002)(8676002)(66556008)(5660300002)(66946007)(8936002)(41300700001)(1076003)(9686003)(26005)(186003)(6512007)(6506007)(6666004)(2616005)(6916009)(316002)(478600001)(6486002)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: mfV5O1kbEPXedZu6owWvv7mzJCbvBOO67MnGBmJoLZB4hdDYjfi+begeFs6FCqKHqFy+z41+IXUBUSc4PcAPCKX0To3coueEomJGa5ooawbzKqD1f+qfB6uAjfziclI8ybfJ6iu41iZgbi9CjtODK1yc506rjEq7mljBvmugo0TiSNKP8nJXKiwX0QnVqRM8CQv5gVrj9GTZBZ+sl8bbMfMY/8zEzE2fCSWY4uORLZySL2lLPxqQydWN/Zjd3xNn9ICf7EfvX7YeZDRriT2qPvgOfaHQUlCJWRUMH/r/7EjsbazIEYzSpaAdE5ihqysOg2WcwW6hjD/hCgZj3Jq532rYHKh7tEom/VKPldTH0ixhfQ1TAwghikLIWt/hFuo0NvB6eMpAt2F4Zr+06wYz0gvisctoW/2JFChF+hEFZhQirv7R6l1gcMzRJj0uEER+pO9A8edlVBbbuvNXVdxtls4WEtZnibcHiPTJxcXZQaVqZhVQJXYrmM9E3Qa+CGdb/2luCDeyrAAiz7ILusRDBo5rdXW3DWP+eviCJh6SvXmPcBmzjCvaITPJbFp7oUkIL+x33LPSW922X7MfUiMiTfS776gr0CxgZkQoTGazVWrUqPBcyDBT6Wko9EHnT0zVvP0/dhosVkHibBWW+dT7zEXTAmgsG1FAbKEKAr0yaLqvFv8fcUjlEEqz8RhwPB42HMpRh+SbxfF7My/rkSLIKaZ/pIKfmY6YS5yie75P983n5NGv/PTsUODxtavCrnhSTFAPsPImCtcSXKEv3NYrNnTsrD5el4T5zpkmLWVQDxYn2KBgp3i61MZQ+qAaggxw9qZtzyUYF5QGpsCtfmGqg5rRvulbI7b6QGvMDUU/SyGV+vYKFeNRfSe7k2G9+3Nrpx3lu5ThEdipmzItqf//0ThWJyvJxx1N2E8FmET6/YzcwCNHfPjM+bkJumeDdM9shXnSDsFu2NbA2mrX+p1waMc6EB0rov1K8I/xm5Mty0qV6dK1FqXBN74XC7PeFNTh4jveMiZJdljwbf2AvOfdpi01g+ubRqdKJd1uxYt2BRPkau3utqUmTcZPbSvwBQTSHFy8wklCv2725hXZwekpFfKMf40/LfFit5mHNFhhfjP/UQ4wzzJpgx90FIvBFPYw1L3InnaFvI4naHI8cyT1pDQOyzjjRjIjQhAejWgJPQ9A/KvmctjdlghmpxgPUcBpjsRMewYdHMuqVbtcEW7poSFkgISV5qtXBOtAZ3g4n6Uq9ECCv2a/OGNwNbB/EO6ehk3T1oCSzppSi13m0tBYw+3O9CDEeaurEKl7BFDNJx+yyFJ175Gdo5lFJuDP3h+PXvrHV/QxS5q/Bz7IVigBVqPy4M9KTSq7/TQzNVvclw2KfqjnHT6lZ5lp/8CSmav9aAkbl5gTGJ2Oy2okc/ucWkSrTS90T4ywDC5wb5bM4PtR+n4wS5DpXn/rf/Q/uBNqXGSzc6vrMVZ9VfIx37CzUmQLBlYAkatjAEI33RMLIARWiLxmKUWyyHHFJd5cm1nDAWWrz5MdneG/X31jLBEAwmuOG8ZFg+/2Mn/RU/K/lhj7/elPtdvv1/i/mPnPKX2ksbpNGZOFq/Sko6lbFdRyNg== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 893d7058-2236-4244-0858-08dae0df161e X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Dec 2022 10:03:18.0209 (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: lt+Y9qaYeoIQoYaAYgEOJZx/BTqUTcSQf6SQ6iSPEqVzVHV1zLNmAJRrGXP2sTnHDXr0RbbL5VXKGu0lIfB59Fb7OwyasMtlHBxqb0dyrXA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4536 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-12-18_02,2022-12-15_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 bulkscore=0 mlxscore=0 adultscore=0 phishscore=0 suspectscore=0 spamscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2212180095 X-Proofpoint-ORIG-GUID: D04P1qfG0pDQDzNVWeRx4hP_hJLn1rs1 X-Proofpoint-GUID: D04P1qfG0pDQDzNVWeRx4hP_hJLn1rs1 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Allison Henderson Modify xfs_rename to hold all inode locks across a rename operation We will need this later when we add parent pointers Signed-off-by: Allison Henderson Reviewed-by: Darrick J. Wong Reviewed-by: Catherine Hoang --- fs/xfs/xfs_inode.c | 42 +++++++++++++++++++++++++++++------------- 1 file changed, 29 insertions(+), 13 deletions(-) diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index e292688ee608..4b39ec7fa5f0 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -2541,6 +2541,21 @@ xfs_remove( return error; } +static inline void +xfs_iunlock_after_rename( + struct xfs_inode **i_tab, + int num_inodes) +{ + int i; + + for (i = num_inodes - 1; i >= 0; i--) { + /* Skip duplicate inodes if src and target dps are the same */ + if (!i_tab[i] || (i > 0 && i_tab[i] == i_tab[i - 1])) + continue; + xfs_iunlock(i_tab[i], XFS_ILOCK_EXCL); + } +} + /* * Enter all inodes for a rename transaction into a sorted array. */ @@ -2839,18 +2854,16 @@ xfs_rename( xfs_lock_inodes(inodes, num_inodes, XFS_ILOCK_EXCL); /* - * Join all the inodes to the transaction. From this point on, - * we can rely on either trans_commit or trans_cancel to unlock - * them. + * Join all the inodes to the transaction. */ - xfs_trans_ijoin(tp, src_dp, XFS_ILOCK_EXCL); + xfs_trans_ijoin(tp, src_dp, 0); if (new_parent) - xfs_trans_ijoin(tp, target_dp, XFS_ILOCK_EXCL); - xfs_trans_ijoin(tp, src_ip, XFS_ILOCK_EXCL); + xfs_trans_ijoin(tp, target_dp, 0); + xfs_trans_ijoin(tp, src_ip, 0); if (target_ip) - xfs_trans_ijoin(tp, target_ip, XFS_ILOCK_EXCL); + xfs_trans_ijoin(tp, target_ip, 0); if (wip) - xfs_trans_ijoin(tp, wip, XFS_ILOCK_EXCL); + xfs_trans_ijoin(tp, wip, 0); /* * If we are using project inheritance, we only allow renames @@ -2864,10 +2877,12 @@ xfs_rename( } /* RENAME_EXCHANGE is unique from here on. */ - if (flags & RENAME_EXCHANGE) - return xfs_cross_rename(tp, src_dp, src_name, src_ip, + if (flags & RENAME_EXCHANGE) { + error = xfs_cross_rename(tp, src_dp, src_name, src_ip, target_dp, target_name, target_ip, spaceres); + goto out_unlock; + } /* * Try to reserve quota to handle an expansion of the target directory. @@ -3092,12 +3107,13 @@ xfs_rename( xfs_trans_log_inode(tp, target_dp, XFS_ILOG_CORE); error = xfs_finish_rename(tp); - if (wip) - xfs_irele(wip); - return error; + + goto out_unlock; out_trans_cancel: xfs_trans_cancel(tp); +out_unlock: + xfs_iunlock_after_rename(inodes, num_inodes); out_release_wip: if (wip) xfs_irele(wip); From patchwork Sun Dec 18 10:02:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 13076001 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 7245EC4332F for ; Sun, 18 Dec 2022 10:03:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230272AbiLRKDb (ORCPT ); Sun, 18 Dec 2022 05:03:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60060 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230249AbiLRKDZ (ORCPT ); Sun, 18 Dec 2022 05:03:25 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 41F7B6333 for ; Sun, 18 Dec 2022 02:03:22 -0800 (PST) Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2BI4oS7V013418 for ; Sun, 18 Dec 2022 10:03:21 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=byIVVGAAl58XChe4HGFCUp1d4qYCSpzWqhqS9GGFqQg=; b=w5fjny89kpXDMB5kCiKt1OjwOd+MLYwZhpS+K3N3nCQsUOEYBzfyNCvrVswUPKzDi/w9 otcRh+q++wW/Y2I52i1Hra1nR+eAmVurwYQs5gULWoKqeRJfezT2aa3tcOBJYfG2hk3g aoYfiFmjJNa69RIauFyuWb7/AZWE5XQNSFaOlI/ZG6/QawdzFniSZ5HuCODdNY70A2qw oSmMuMVduwtvZJIHCsKkHI6zm5DnVn5hzeNP2P63dg6SMm5AwIho3CCISnoOIzuL1pMG CX6RE/55RP4uzs60Bq+yUl859f8VE1r/iwsOo7ZVtaF9hgXhgP/HdRynDI2oh1C6emdj Tg== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3mh6tms9b5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sun, 18 Dec 2022 10:03:21 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 2BI6oEpM006541 for ; Sun, 18 Dec 2022 10:03:20 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2176.outbound.protection.outlook.com [104.47.55.176]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3mh472m2yf-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sun, 18 Dec 2022 10:03:20 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=laKo77ckJrTrtQMFAAMkyHAPemK42LH9sy4EvQo4XEcDYg4ZCJN2QTKw2QPogY5jTIv3+V4dCqSIeEVpGBIS3eEubJOL/CWKiDwulEBxIYWxhZVczCvHMaJ0M7FJH3Dle9ntSqkq0dM8BC74LUQNx4UhviisH90g3UkfsLSwffCb/zbXaRM5eF1WLg293a5pKHxfn1T5g+5x4lV0EUW4M+7Gt9wCY/5dhmfNKiaGtyRn9O2nTYCzLwIymXj5taNrEq8Q15X/tNOB8wrM0NpdGuDgJINeVeZzHCwIbUPcYSZScWtGe620UApWGGNSB8YhOyy8v2fyrx1fkui/VxL9gg== 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=byIVVGAAl58XChe4HGFCUp1d4qYCSpzWqhqS9GGFqQg=; b=YbJ1M7UhqOv14h1G3taZLKODibw0tGY+uk5LRGfU4f3j3mXEho4XiaN8Mk0IS73SA4AUCdhFAb3HQDRZ0Tv6j3Y6pAjcqQg5Ggwamml+HdFA/NMrE/ltTJfk70fxzFGmvjuLogmtUxkf9a0qmDrjpDzSG5y27pmg2gJTVqm9n8avdzpjvWBxAjm25XOqMCTuBBk0orb9MEB9s+pIeWxcBvwVb19yiYL+gs4m1JAMnQcJEciPeJmzJiB8BnoGz5qODTzAzWSCDvx/6DlIzIfbF1NtqeW6qImkR7gdVFnzGhulwgBVRbbRxTnzwTI/K36Hok+NCswpAWPFfIXt2ZUFJA== 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=byIVVGAAl58XChe4HGFCUp1d4qYCSpzWqhqS9GGFqQg=; b=WCwyNQdP7HMe2UVgIOvIbH4cKgLVPxNcRV789mDc4ffxH1FkfTk/lOhjjRVcG6SRzMzf/Ve5zpZHuQPM9Qo3L7GbPOlPg+iZgBaJar4oXArdko9n6pkodcE38ZVMGJBH7vj6gicwBwsekdFY3ZqONh6gQxFg+ctb6ymU2Dc6EU8= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by PH0PR10MB4536.namprd10.prod.outlook.com (2603:10b6:510:40::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5924.16; Sun, 18 Dec 2022 10:03:19 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::3cab:6ff7:cb4d:b57c]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::3cab:6ff7:cb4d:b57c%4]) with mapi id 15.20.5924.016; Sun, 18 Dec 2022 10:03:19 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v7 07/27] xfs: Expose init_xattrs in xfs_create_tmpfile Date: Sun, 18 Dec 2022 03:02:46 -0700 Message-Id: <20221218100306.76408-8-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221218100306.76408-1-allison.henderson@oracle.com> References: <20221218100306.76408-1-allison.henderson@oracle.com> X-ClientProxiedBy: BYAPR02CA0020.namprd02.prod.outlook.com (2603:10b6:a02:ee::33) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY5PR10MB4306:EE_|PH0PR10MB4536:EE_ X-MS-Office365-Filtering-Correlation-Id: dd4d5e20-2b6f-4f37-b52d-08dae0df16da X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: x0OUKvFojg8mHzOcIHbvgu0uXzCULCXzMvnQUDO3SJG8NZMADOyr+1TnR96yH6Zw3ZRmgqLNEUa6bJY++6VTUuXze/lcTi4WPiPHSMvovirH5nh0hMsRLz7RONPtG7uVDm0mDZ/PiuBtGqOyW9wddUn4OTpp6g/U14WXIE9FA8ayNThhqOnsN5+ve+Hqt6saCNDgrDWSt9qHo4PogAXUG6H0rKX/WNvuJjjIdbhW9n3KrOHfAHEBlCHcjkzsqbeJ1NkoNovNkgkuHLrMIbxXw0l2/bYoxjwJ8RduTs6XdXtaRYY40UdkWXCbO67gtJZtOuS6pLtX9kSVoOB5AIFMau5HKiIP3oEIWqc2Fv/2BAgGrV6rWmGjbnRjnKjVBw439iL0aK/orduCtGv1vxet++crKSULIKxz6DhhKduaXEEpbEZZ/9Pa0Gx4vBlYqKvYDYCLxq1x/cTo9xrlQy8t2N5xwSyPaBsbwUlvuvcoRsnCnulQHKT6zJIadET8Wx6aUUpi5p+8ZlUNu5xI7sjLivLg6CN3z9lYSfGIMDBh5q+UFZahT4vrGMzlk+83urhBYvrlq4PbUM59WKpzkpvhdLq8pwE1agknbX0qqHZ86vxnGQxB2HfCRDnz9FeSw9Hh/H/XPvo3AOAs2rAfIN+8NA== 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:(13230022)(396003)(39860400002)(136003)(346002)(366004)(376002)(451199015)(83380400001)(38100700002)(86362001)(66476007)(2906002)(8676002)(66556008)(5660300002)(66946007)(8936002)(41300700001)(1076003)(9686003)(26005)(186003)(6512007)(6506007)(6666004)(2616005)(6916009)(316002)(478600001)(6486002)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: EPEGt4ohmCHM7z41sYaXCGXy8/EDNJIMe7j131zp9/hCWsdqng89/9+TB14t9wtGYACvTASrhsCxjurnarK7d7VMfk2OEXsCOEu+o6Ew8OcPKDb+AQ2QoN7lRW4rrtYZM9aLIzJA7RXVGJ461DxCBa1SaZ6QRV2NMAze8MVtfv04mf+WgAAXCXLIdbRJj0s0/xhnMXa4PXZf8gI7ygcNHInpGzFY8chEvy5q71/4sLEOnKF5MnLzEvU23SZ1J2m4cxkmeTQKNyYcdPW1UihSi7Stg9mYb8ViqiHD6MuyDmpzTKxtq1BtJg+v1mHa5gzj1YpUyv0g4t6R36vLqh/Hqy4Hv6+0O2sTo6xfqzS0y1aBjngV5Ci0JyyhZklUhAWgmDgrqW+H8xvKI6NHtAs3MFd4x9M3pker8SI61fKwPlhb5YQ3NUVKN2zH3TpN9/ybtIoSDZWvFzJKbPPOXN1xDF3Ai3UowSxbbmE7a5N6wpYHm1H9HUV2Telk2jWobS+IxVMivozdTi/AdMSvVbSXnbZiaSAKQo4Y5L0nJyOKX4bvwnumLr7tENlzPoQw9+J+DB8JA7nmUYTlK3u8cP1FOJNpxrl3+oc2OTNIZqLnPmG+3m90PUMd8wDjKV5J9SDS+Pm6epGmKpeAAbTT7Kv4r553bfoNL5uKlSA4JfSkdLFEa0PwmOPw3JBtpNN9IiBQSG9xICvyGAkiNCv0byy3nzsFLk7q96ZyWsJ4newrhNmgGplCDdEiEAO7Z28/mhF/wCX2MTC9RK33svMjc/9WvT1d6inPlUSGevj3ayw1h/Y+aFdNgn4L9HRPn+aQkQtFRPRG1QMpjGl7uojsKVYh878xK593HYje7eyQlKeTvrEGb0y/+zchjoEH1Ua03k5b9kTZ3tgkWcvBKxLZP5xICaT/sgeQwQaMJo28z9C3d/kzKycrHPz+7eE77Ji9Fz8S90MXqSrJsTw0I7I5naUyNOI4WqkrwIpc/k/uZLH1USeq1qx5xf8GmqDFVA+0mGwTeSyGSOmGSMuUG5C6XHYuW90fecKmBxzTz0SEEva+b1WqgNAMs24tWIjffXyu6+adOjgL9BmrD2WYnaRzPyOYdTgTyo98HaYORZ0TxPhp4kNDv6rJqmVcjv+bO8ZvQOAJDx8Dj43//TaY0KAGRY+I9VICP2gBmpd8+yaJImCEt3SHRZ/i7oKCLouzi55lezdvasRoyF1oPgKIx/1cpFm4XoO6KT3oCbdVcViPw1OrofMoD0x8GPL+9U/AI+FICRVzsPakCRD2bUbwV72QETnjoNb103tO27/b48S9GAKxPjvPOya6duJmgW36C+98eXfLWyTncpy/18hYd40EqRX5i4kBDetYxLeM+K2ZLzIaGgc5RNyjumo5xAJqZg6IXnMLakfO92H0sFZLA/kFpi5jeJ8FWVRTsDpiXDciadiz5PBJ8iyii697bYunjxCEWUXfJV6JaWaEUm/dbvO4nqd6lwHQ1sbkIqgzt0yjiYiEBI+uQLqVJ69UjtSw6rl9cyZyT7Qo0NQtSwh6COi2uIiau4aujHGyHd/kLFZJTF4YtqMX0ccTGLLRAq+P6eBGmea+3MCnvyJhHFHQaMMMsmHkyQ== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: dd4d5e20-2b6f-4f37-b52d-08dae0df16da X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Dec 2022 10:03:19.2732 (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: rOv7mp+5YNHNvrewewGUprV8kszV6a0vNEKUzgEmyS1Fq15kZqz84tsTJNTyP3r6Lf8oo/SG9yCY72DDvMmWDq3pw6ujOyMdNEi3qcqbTgo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4536 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-12-18_02,2022-12-15_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 bulkscore=0 mlxscore=0 adultscore=0 phishscore=0 suspectscore=0 spamscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2212180095 X-Proofpoint-ORIG-GUID: BnLHqbusH7q6nxCdRLFwIt3lrK2EtTcS X-Proofpoint-GUID: BnLHqbusH7q6nxCdRLFwIt3lrK2EtTcS Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Allison Henderson Tmp files are used as part of rename operations and will need attr forks initialized for parent pointers. Expose the init_xattrs parameter to the calling function to initialize the fork. Signed-off-by: Allison Henderson Reviewed-by: Darrick J. Wong --- fs/xfs/xfs_inode.c | 5 +++-- fs/xfs/xfs_inode.h | 2 +- fs/xfs/xfs_iops.c | 3 ++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index 4b39ec7fa5f0..ffe945335bf5 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -1109,6 +1109,7 @@ xfs_create_tmpfile( struct user_namespace *mnt_userns, struct xfs_inode *dp, umode_t mode, + bool init_xattrs, struct xfs_inode **ipp) { struct xfs_mount *mp = dp->i_mount; @@ -1149,7 +1150,7 @@ xfs_create_tmpfile( error = xfs_dialloc(&tp, dp->i_ino, mode, &ino); if (!error) error = xfs_init_new_inode(mnt_userns, tp, dp, ino, mode, - 0, 0, prid, false, &ip); + 0, 0, prid, init_xattrs, &ip); if (error) goto out_trans_cancel; @@ -2750,7 +2751,7 @@ xfs_rename_alloc_whiteout( int error; error = xfs_create_tmpfile(mnt_userns, dp, S_IFCHR | WHITEOUT_MODE, - &tmpfile); + false, &tmpfile); if (error) return error; diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h index 2eaed98af814..5735de32beeb 100644 --- a/fs/xfs/xfs_inode.h +++ b/fs/xfs/xfs_inode.h @@ -478,7 +478,7 @@ int xfs_create(struct user_namespace *mnt_userns, umode_t mode, dev_t rdev, bool need_xattr, struct xfs_inode **ipp); int xfs_create_tmpfile(struct user_namespace *mnt_userns, - struct xfs_inode *dp, umode_t mode, + struct xfs_inode *dp, umode_t mode, bool init_xattrs, struct xfs_inode **ipp); int xfs_remove(struct xfs_inode *dp, struct xfs_name *name, struct xfs_inode *ip); diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c index bf0495f7a5e1..0ada7d6140b6 100644 --- a/fs/xfs/xfs_iops.c +++ b/fs/xfs/xfs_iops.c @@ -200,7 +200,8 @@ xfs_generic_create( xfs_create_need_xattr(dir, default_acl, acl), &ip); } else { - error = xfs_create_tmpfile(mnt_userns, XFS_I(dir), mode, &ip); + error = xfs_create_tmpfile(mnt_userns, XFS_I(dir), mode, false, + &ip); } if (unlikely(error)) goto out_free_acl; From patchwork Sun Dec 18 10:02:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 13076002 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 322D1C4167B for ; Sun, 18 Dec 2022 10:03:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230249AbiLRKDc (ORCPT ); Sun, 18 Dec 2022 05:03:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60066 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230255AbiLRKD1 (ORCPT ); Sun, 18 Dec 2022 05:03:27 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C7B6D65ED for ; Sun, 18 Dec 2022 02:03:24 -0800 (PST) Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2BI4nAa6000922 for ; Sun, 18 Dec 2022 10:03:24 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=NpH4bpq1+Xtrh+QaIMamKKsgi1Pxmb/bjgghbSXttIs=; b=gt2hqGIOxiJHne1ND7d07QVHb6izLvIcNnDcz7U1DUSqS9Cbn4SpNKz2N4Bvi1fV+amR fkoa08DGEHkpWFjnNbDXAe4nhUTPuDbQrV/A92L0KKBRcNSa6zK3qCkdJ108WIMRC0g7 gIRzv+OagCGcg9FnVlEQ8AVK3JNElzJ3ema+C1NquVQcxq1yJWmWy+t2xQvkF8qwAdpY bsoky9OuYGcbMXMoX/hmd+G60I0sr9mIGKNKbcgJgOqacMHM2LqvkpAjeyhI2RC2tQtL 1SPmeSGai6L3l+0ZGU6YBlbJQwWPFAPLrS0yJUf/1hhkHtguKg2ce/lEvk+FpV/g+msI Cw== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3mh6tm19a2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sun, 18 Dec 2022 10:03:23 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 2BI6Ek2N012691 for ; Sun, 18 Dec 2022 10:03:22 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2174.outbound.protection.outlook.com [104.47.55.174]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3mh472cfse-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sun, 18 Dec 2022 10:03:22 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OoAQsoiaiOxFoDrQul64u0FhwQlACapOj144MRXRAMdEtLizuX9NkaWE0mpUGZR5sMTMzs9VBwSwMDnXEHko6Mq8dbnlcAQ2Ci/AJ5bARZDKLBUr8x/LirAK5WRasO/oLqcZzbck7Z4pHTQtlZvaJM2QoZN03r9ACE+SOAonkRlu83dgdsjwqrAe0gjmqngGWo8Vyj7ndX0bzpf97EbhnRRvWjzzBMwH/wvQ4nC2z2LiGsvNFvKNaaozUKL/AyEZIR90O9enx06GEk8d+DGjguXzHCtSsFy+Ej8z63bgLpeSFus3irzAS7CYA4bTBJe+n/Xsl+4dMb0Dr7sZRV+mqQ== 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=NpH4bpq1+Xtrh+QaIMamKKsgi1Pxmb/bjgghbSXttIs=; b=ksjcMfgNwiS4WjeneZ+txk+hY13SIXEf9+mXGvNI7gy0duyc+ma9UGCRPpxWalZrmZSQCvp/+BoAxXfCNgijL8msHqSTXRxcrqkxPDFl9sjVfe5DRAMUwoXgwO8KMwEDdVRy3eo2XVeebEK5ZOCzG3pcdVv2oUVf3ZqdBP0IAZxJ2iM7+Oc/JAKxUz5udJYbj3j/nS9BCmlyZSVtqZvgMLjglCPZfycOyG1Xl/YsDWAr6XQTfSr/EIeYNpaHQsAq8WXseUPioH0SlWwDxb0sm2agFd9LHo+54ki4uW671W2Kd7Xe8GP68cNGcuUsEPQ4DBtzZs4RZvftwovOHL1stA== 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=NpH4bpq1+Xtrh+QaIMamKKsgi1Pxmb/bjgghbSXttIs=; b=vY1WEKUd3DUBKGDQmSkO8gsoK701dLNx09jke4z+kWkhyQNbhaXqEPybAmClJ+JaovBEq73KnZ6txm1KJz3Gr1B5+Q7fdl9pdDhX6Ok/GF+brraeZueHL65WZHMFeqIf3DjgIBZ2+VGSAypxMGtoBGn5RijGIWWhkFhQIopzjJo= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by PH0PR10MB4536.namprd10.prod.outlook.com (2603:10b6:510:40::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5924.16; Sun, 18 Dec 2022 10:03:20 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::3cab:6ff7:cb4d:b57c]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::3cab:6ff7:cb4d:b57c%4]) with mapi id 15.20.5924.016; Sun, 18 Dec 2022 10:03:20 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v7 08/27] xfs: get directory offset when adding directory name Date: Sun, 18 Dec 2022 03:02:47 -0700 Message-Id: <20221218100306.76408-9-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221218100306.76408-1-allison.henderson@oracle.com> References: <20221218100306.76408-1-allison.henderson@oracle.com> X-ClientProxiedBy: SJ0PR03CA0072.namprd03.prod.outlook.com (2603:10b6:a03:331::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_|PH0PR10MB4536:EE_ X-MS-Office365-Filtering-Correlation-Id: 06138a40-b373-4913-ecd2-08dae0df17c1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: PQ0zMgcMM5ze7mhrEhkP3LQ5vrCKEj7QATdYVfqe5flZHF9igBO54CMI4KtDY3BNX9cmEuJVEgVZTRtgh9AVpzPT1z+yNwptDIu1hR4fbCV12oUQXkJfsSZ7ax+SIqkwNzKmtlXwu/F8JX65SYg4e9w6IeklEbxcKBdbcdpNqJBJp/mIC9h/qlu4YRIb1DXy+fVD9YUMvoiRUm80DTCEyO0+FgnEqdwEz3/Vg8uJDPH8ScSpyOTbJDHzP7xJeFQBlHElWFtw/TCboqu0otE8zwfgoVlYZnnxrP1OBXx3V1Ozf4ftWAGYTtjH0eRvYoUceMEHb5BHc1qGXnzmrMXJA8sCFFCtkKb6nt/oJdhJP7O4QL4YUZyrsx6QZ3uKlXOL7fBrx3+3xHmnG3wEonOnBfeWY9acIruhjm9uoGz8PYwyY5kgchIBmfJOLE8u3QbeMpUmvMT1nqhogXACvNsP/QhRMi/i2vPesR1Xytvaj83VneSGK+3ff3ucgMjvTpQuJHzwOpXvXaNrnMynGeAuXeyuJeG15T35ztNYzLVU59XVXSnH20p6qsU9Hl9lPOQ6Faygr6LOJZ9eENNK1hBgit97sIg5sMTHwRW9N3ldmyydFRlOcaL5WejnytLlUv24 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:(13230022)(396003)(39860400002)(136003)(346002)(366004)(376002)(451199015)(83380400001)(38100700002)(86362001)(66476007)(2906002)(8676002)(66556008)(5660300002)(66946007)(8936002)(41300700001)(1076003)(9686003)(26005)(186003)(6512007)(6506007)(6666004)(2616005)(6916009)(316002)(478600001)(6486002)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: dvarplOT2wUbqmIaRiM589qQdV7O325R73QnBFW36xSFAJKJGb5QwyzZgn+PYq3HSUEdxxw/XGYTHIme0nXRuqdo5C7T9XpzWpNnPiG2yp9H4uKb8710nv0MA5qSQrlUT6cFgAkZBSSTUlDQS3jgzxxLGsFtUwYDceBibzLLBcX3ZP2HbGFPEaREbt6s4yF0FLuiWEGAuOFuCX4i21CpalPH9mDXpTHQpj0tBeD6yBP1A3slMP9hI/I3gHKe43O0tR/ntZj3/Wus5l3RhIPJSkFGl1colzG+R+n0cjma1t7yXNWJa5sHO30KUHOzfop+aS6RQn8NbfPKwGVvH7f1mu44H7iZij9jdYHD/7mdaQ9VU1EhJ9UD3QZtLu/I4KkeQNnTJQ0WvtNA0cCLW/nhay04wasKjLu7iHdR6yS4GcCPGU3pKz1P8ZellW9B11IgT/GqMiHLf3qirFcviCLZK7Ug3vp1Y8TkX6ABDmf1cvpgRY5lJ7qj0fYnUzbc9D+xXZs8nuRMat3N6Ss4EVImKdX9SObB65qf+LN3hX+suCB3bgdhosaHnU0j+g3gGvqxff3/UqITqgkfAT6TQVk+3x7KZ61VO0mCIkcHEm9ttZnH98HKSHI1rXJjBZnyuU5cFK+VQxfMMTaYHsN7NQftKVnqrkYMjqTMHG7PqNTRdQlg2bsExDIu002YaTgxx1PRev2EF4O+R3kcz5UXBZLuX4z/93+joSNEz5J/6y6UTt2wlv2J6dSXx6ybwORTrg059fRIhgCnuTkXwit26cMbtkS6CBWy1yo73vU938mwcarxUaAOY2JKdYvMsd1+617lPl8G/BiRlTBw5cBLu21058dabB+/p/WsnSTKsfrdI+mScwc+SnezMdsgQYydvQohbiPMRfaodrmWrdq1vOCAohyuVcPyhikWfMJVtv9QiO24VjySyztOSQdya0vpjh16+3xYd5E+iuCqz2jH2EBiaUn3nfNSqj1yCS9qMvgK9aayCEcoEJ9bQ9L+rrqBtk/lNbbO0EmSsDy4rDz+YW/uGnqY70d/7j/sY0D5AizDHsCgchawEbytsZM/SlMX3kJsCrsIbYNSeLEDFpJR0eGxmfPZZM0NRn1F3jkyaxXn4MWjtjHdxF0XpTdont/j7q2uvkwgFTeGwmAHAsrtxCVskXUBuNQiyLZ4+J573KEIlYuqMU/h+ld+PCQ1P81RjviJgr8Dr6qd0t53DzqZS1GnEBMLMajiw53uf1PaVAe7+yrEj2bLrE8i4MHWwf3Swsvd32qmvuUNoH/BuILVusgkwkjPdrEn1dhPY63wGWp4HVP8dVQIMAYgyHwEb2Vnslj1e/v7M5dNEBL+hMVouYkWLqGdDw3ftBnUPVFPBVgInQZ7jXybvFFf4HcRFs8yOnY7PB5S2/ZXVILvj65zikaE/6Nbuyx/1scGUk6ohMqJ/+p9WYwGEuvdAxUV/RXBdCjeFcirM0Q+myoU8m6gSu8sDmoUBX1Eiz8zRWHkl4L7vL/TJVS77OR7iIu7PU8qoJl3W1T862KzFc9CB34wLE6JPellFyb3NRAhRToAiAAcA5vMjestEIovzkIqCT30ShU3Hdj5eqFvaqW3XtgneT0sWA== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 06138a40-b373-4913-ecd2-08dae0df17c1 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Dec 2022 10:03:20.8366 (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: BaBQb+OzVnV8P7ppuM0ArJsbzN6hAMXrRsoFGG80akSmLAC5O8YAqo5fi6sBARy7Pn6jNC/gVHvsjEto6hG5DB9cuC9i8lgde1uENZfsIlE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4536 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-12-18_02,2022-12-15_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 phishscore=0 suspectscore=0 adultscore=0 malwarescore=0 spamscore=0 mlxlogscore=999 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2212180095 X-Proofpoint-GUID: exlN40hOpkDVqcCHFKFPGZaHwkFrkwJX X-Proofpoint-ORIG-GUID: exlN40hOpkDVqcCHFKFPGZaHwkFrkwJX Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Allison Henderson Return the directory offset information when adding an entry to the directory. This offset will be used as the parent pointer offset in xfs_create, xfs_symlink, xfs_link and xfs_rename. Signed-off-by: Dave Chinner Signed-off-by: Allison Henderson Reviewed-by: Darrick J. Wong Reviewed-by: Catherine Hoang --- fs/xfs/libxfs/xfs_da_btree.h | 1 + fs/xfs/libxfs/xfs_dir2.c | 9 +++++++-- fs/xfs/libxfs/xfs_dir2.h | 2 +- fs/xfs/libxfs/xfs_dir2_block.c | 1 + fs/xfs/libxfs/xfs_dir2_leaf.c | 2 ++ fs/xfs/libxfs/xfs_dir2_node.c | 2 ++ fs/xfs/libxfs/xfs_dir2_sf.c | 2 ++ fs/xfs/xfs_inode.c | 6 +++--- fs/xfs/xfs_symlink.c | 3 ++- 9 files changed, 21 insertions(+), 7 deletions(-) diff --git a/fs/xfs/libxfs/xfs_da_btree.h b/fs/xfs/libxfs/xfs_da_btree.h index a4b29827603f..90b86d00258f 100644 --- a/fs/xfs/libxfs/xfs_da_btree.h +++ b/fs/xfs/libxfs/xfs_da_btree.h @@ -81,6 +81,7 @@ typedef struct xfs_da_args { int rmtvaluelen2; /* remote attr value length in bytes */ uint32_t op_flags; /* operation flags */ enum xfs_dacmp cmpresult; /* name compare result for lookups */ + xfs_dir2_dataptr_t offset; /* OUT: offset in directory */ } xfs_da_args_t; /* diff --git a/fs/xfs/libxfs/xfs_dir2.c b/fs/xfs/libxfs/xfs_dir2.c index 92bac3373f1f..69a6561c22cc 100644 --- a/fs/xfs/libxfs/xfs_dir2.c +++ b/fs/xfs/libxfs/xfs_dir2.c @@ -257,7 +257,8 @@ xfs_dir_createname( struct xfs_inode *dp, const struct xfs_name *name, xfs_ino_t inum, /* new entry inode number */ - xfs_extlen_t total) /* bmap's total block count */ + xfs_extlen_t total, /* bmap's total block count */ + xfs_dir2_dataptr_t *offset) /* OUT entry's dir offset */ { struct xfs_da_args *args; int rval; @@ -312,6 +313,10 @@ xfs_dir_createname( rval = xfs_dir2_node_addname(args); out_free: + /* return the location that this entry was place in the parent inode */ + if (offset) + *offset = args->offset; + kmem_free(args); return rval; } @@ -550,7 +555,7 @@ xfs_dir_canenter( xfs_inode_t *dp, struct xfs_name *name) /* name of entry to add */ { - return xfs_dir_createname(tp, dp, name, 0, 0); + return xfs_dir_createname(tp, dp, name, 0, 0, NULL); } /* diff --git a/fs/xfs/libxfs/xfs_dir2.h b/fs/xfs/libxfs/xfs_dir2.h index dd39f17dd9a9..d96954478696 100644 --- a/fs/xfs/libxfs/xfs_dir2.h +++ b/fs/xfs/libxfs/xfs_dir2.h @@ -40,7 +40,7 @@ extern int xfs_dir_init(struct xfs_trans *tp, struct xfs_inode *dp, struct xfs_inode *pdp); extern int xfs_dir_createname(struct xfs_trans *tp, struct xfs_inode *dp, const struct xfs_name *name, xfs_ino_t inum, - xfs_extlen_t tot); + xfs_extlen_t tot, xfs_dir2_dataptr_t *offset); extern int xfs_dir_lookup(struct xfs_trans *tp, struct xfs_inode *dp, const struct xfs_name *name, xfs_ino_t *inum, struct xfs_name *ci_name); diff --git a/fs/xfs/libxfs/xfs_dir2_block.c b/fs/xfs/libxfs/xfs_dir2_block.c index 00f960a703b2..70aeab9d2a12 100644 --- a/fs/xfs/libxfs/xfs_dir2_block.c +++ b/fs/xfs/libxfs/xfs_dir2_block.c @@ -573,6 +573,7 @@ xfs_dir2_block_addname( xfs_dir2_data_put_ftype(dp->i_mount, dep, args->filetype); tagp = xfs_dir2_data_entry_tag_p(dp->i_mount, dep); *tagp = cpu_to_be16((char *)dep - (char *)hdr); + args->offset = xfs_dir2_byte_to_dataptr((char *)dep - (char *)hdr); /* * Clean up the bestfree array and log the header, tail, and entry. */ diff --git a/fs/xfs/libxfs/xfs_dir2_leaf.c b/fs/xfs/libxfs/xfs_dir2_leaf.c index cb9e950a911d..9ab520b66547 100644 --- a/fs/xfs/libxfs/xfs_dir2_leaf.c +++ b/fs/xfs/libxfs/xfs_dir2_leaf.c @@ -870,6 +870,8 @@ xfs_dir2_leaf_addname( xfs_dir2_data_put_ftype(dp->i_mount, dep, args->filetype); tagp = xfs_dir2_data_entry_tag_p(dp->i_mount, dep); *tagp = cpu_to_be16((char *)dep - (char *)hdr); + args->offset = xfs_dir2_db_off_to_dataptr(args->geo, use_block, + (char *)dep - (char *)hdr); /* * Need to scan fix up the bestfree table. */ diff --git a/fs/xfs/libxfs/xfs_dir2_node.c b/fs/xfs/libxfs/xfs_dir2_node.c index 7a03aeb9f4c9..5a9513c036b8 100644 --- a/fs/xfs/libxfs/xfs_dir2_node.c +++ b/fs/xfs/libxfs/xfs_dir2_node.c @@ -1974,6 +1974,8 @@ xfs_dir2_node_addname_int( xfs_dir2_data_put_ftype(dp->i_mount, dep, args->filetype); tagp = xfs_dir2_data_entry_tag_p(dp->i_mount, dep); *tagp = cpu_to_be16((char *)dep - (char *)hdr); + args->offset = xfs_dir2_db_off_to_dataptr(args->geo, dbno, + (char *)dep - (char *)hdr); xfs_dir2_data_log_entry(args, dbp, dep); /* Rescan the freespace and log the data block if needed. */ diff --git a/fs/xfs/libxfs/xfs_dir2_sf.c b/fs/xfs/libxfs/xfs_dir2_sf.c index 8cd37e6e9d38..44bc4ba3da8a 100644 --- a/fs/xfs/libxfs/xfs_dir2_sf.c +++ b/fs/xfs/libxfs/xfs_dir2_sf.c @@ -485,6 +485,7 @@ xfs_dir2_sf_addname_easy( memcpy(sfep->name, args->name, sfep->namelen); xfs_dir2_sf_put_ino(mp, sfp, sfep, args->inumber); xfs_dir2_sf_put_ftype(mp, sfep, args->filetype); + args->offset = xfs_dir2_byte_to_dataptr(offset); /* * Update the header and inode. @@ -575,6 +576,7 @@ xfs_dir2_sf_addname_hard( memcpy(sfep->name, args->name, sfep->namelen); xfs_dir2_sf_put_ino(mp, sfp, sfep, args->inumber); xfs_dir2_sf_put_ftype(mp, sfep, args->filetype); + args->offset = xfs_dir2_byte_to_dataptr(offset); sfp->count++; if (args->inumber > XFS_DIR2_MAX_SHORT_INUM && !objchange) sfp->i8count++; diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index ffe945335bf5..29ebd4e2e279 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -1038,7 +1038,7 @@ xfs_create( unlock_dp_on_error = false; error = xfs_dir_createname(tp, dp, name, ip->i_ino, - resblks - XFS_IALLOC_SPACE_RES(mp)); + resblks - XFS_IALLOC_SPACE_RES(mp), NULL); if (error) { ASSERT(error != -ENOSPC); goto out_trans_cancel; @@ -1264,7 +1264,7 @@ xfs_link( } error = xfs_dir_createname(tp, tdp, target_name, sip->i_ino, - resblks); + resblks, NULL); if (error) goto error_return; xfs_trans_ichgtime(tp, tdp, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG); @@ -3000,7 +3000,7 @@ xfs_rename( * to account for the ".." reference from the new entry. */ error = xfs_dir_createname(tp, target_dp, target_name, - src_ip->i_ino, spaceres); + src_ip->i_ino, spaceres, NULL); if (error) goto out_trans_cancel; diff --git a/fs/xfs/xfs_symlink.c b/fs/xfs/xfs_symlink.c index d8e120913036..27a7d7c57015 100644 --- a/fs/xfs/xfs_symlink.c +++ b/fs/xfs/xfs_symlink.c @@ -314,7 +314,8 @@ xfs_symlink( /* * Create the directory entry for the symlink. */ - error = xfs_dir_createname(tp, dp, link_name, ip->i_ino, resblks); + error = xfs_dir_createname(tp, dp, link_name, + ip->i_ino, resblks, NULL); if (error) goto out_trans_cancel; xfs_trans_ichgtime(tp, dp, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG); From patchwork Sun Dec 18 10:02:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 13076004 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 C336BC4332F for ; Sun, 18 Dec 2022 10:03:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230241AbiLRKDd (ORCPT ); Sun, 18 Dec 2022 05:03:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60074 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230257AbiLRKD1 (ORCPT ); Sun, 18 Dec 2022 05:03:27 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7490D65E4 for ; Sun, 18 Dec 2022 02:03:24 -0800 (PST) Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2BI7pKAP027146 for ; Sun, 18 Dec 2022 10:03:24 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=1mb7kRqcNkw/e/bZlXNBO+wh8+ej77dACcQcJPKXleY=; b=dSgx8lhoeeVnPEbrGDYJb+NMlgALZRKSjeiikD+8ydt5Z2Ll0POTeAvYqQr011Pfs3m6 GC8qdgjdKyDe8uXMhrA61zYpH0UH4NZ2AHh3HTp8rzRyWarGA8nSePa1HIvfC4FJFjC7 93a4mDVhVpEF6ZxuqifbLV4gEHVDsmZQ5uPWTganKK01ZGVGGWuBlh4IobuiedR6W7Tb 4hC7iNQRxDgqtTDyF1mpHcdgRoGUsx4ntKLrs96vsgvGMEQcp4zKjGQanpw1YqTOBt+h Z7dgvElmHPpKkbqTu/UgLi4poPZoifctJWxSZPioCxinBxF+ZFFQGnhhZBCM9Dlfh9YX AQ== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3mh6tph91x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sun, 18 Dec 2022 10:03:24 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 2BI6Ek2O012691 for ; Sun, 18 Dec 2022 10:03:23 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2174.outbound.protection.outlook.com [104.47.55.174]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3mh472cfse-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sun, 18 Dec 2022 10:03:23 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VTbhWHVG26ZdnBaigKdlqUi8oiu+WgDziy7nr01jrjk698i+59FrFuSomYsZb4KMSuCX0qlVL1YZ32QsVLrjvVkU95VzqkIRuxBauY4NWPEDO6+wUgDXEKMmPZ0wHaMTUuNoPPFjYkRHqxCfAI0Snxmg+bGXilg9P7mnyizlkBc/nb0pTqoGXj++cPOmCg7CliwrpfseMgZ28cI9uaiEo6E9xn6Ze7XIoR0RyA9r31Uy/E3kaneSuwECiEBI1ffymiIncDDVUX8bFj0KGbPnG/ceIN9TPLCiWM7KoV9kSJhGP8XsGdswL+e8oa3EDHGYo2QFwxFqretz6Sy4YZYqyg== 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=1mb7kRqcNkw/e/bZlXNBO+wh8+ej77dACcQcJPKXleY=; b=DHhlUjRx+lldljVJBKOpc72d7wVLqXqiS8CVkENLJTQKEHlaix+7Mxz6206JHUPZILSJyPlPsv1suC2mNfdU03mL5DwAJ4ukvoqUtxErqrqVPUQS47c5ntESE+uXV0B7NRE15M+hSQu1tV0utgp7l7YhSXr9lBY/rMOgahIueFOi0OqBxf2RXjUfScvCnDNSdaivIpAO5l2mc9QklYoMbCjVkCww5DZ3aXIynfmm/Hovz64HG3gQhIF5RYzf0gr1CxYV5O+0O/aJK2kY4k7MVBuH8ng3d9Iwnhoa9N4zyTv1LC1hig0qft40eaA7tEy/5pnx/Dd5NzRufZnp5LLWgg== 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=1mb7kRqcNkw/e/bZlXNBO+wh8+ej77dACcQcJPKXleY=; b=YkVzoW9l7HJSEEcF1bofHKVs/FbLBsuUmKrB4GbuobxGBgjBHfzlMClqbesrggDFPBYwXjKjfJYrqSAmS0tBlYsc5s0DrFAxlH45fgnF8jTZgwl5Rh4rG84VDUGAiE8emwqSA/Fc9qCuEsXGJMvQzT3NxT8RNB/g1dHIg+s7Ph4= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by PH0PR10MB4536.namprd10.prod.outlook.com (2603:10b6:510:40::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5924.16; Sun, 18 Dec 2022 10:03:22 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::3cab:6ff7:cb4d:b57c]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::3cab:6ff7:cb4d:b57c%4]) with mapi id 15.20.5924.016; Sun, 18 Dec 2022 10:03:22 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v7 09/27] xfs: get directory offset when removing directory name Date: Sun, 18 Dec 2022 03:02:48 -0700 Message-Id: <20221218100306.76408-10-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221218100306.76408-1-allison.henderson@oracle.com> References: <20221218100306.76408-1-allison.henderson@oracle.com> X-ClientProxiedBy: SJ0PR05CA0178.namprd05.prod.outlook.com (2603:10b6:a03:339::33) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY5PR10MB4306:EE_|PH0PR10MB4536:EE_ X-MS-Office365-Filtering-Correlation-Id: 75a7e9af-abca-4a2f-574c-08dae0df18a9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: tWT5/jdfE2AgHSRfon9WUfIMd/LgrFxaSFx0ivc9uZLYfFKIfghJT5OEoiSmT6/v88tWTucXgKZ5LOhzDmghXXjSrTsf7mqPeL9HRrJmcHDzyoVl2HyK7oJJIplYX6jwpW+iIIGzE1ZFY871wdIZivy93FSbM+78N0Ge3jyHXZpp9DpXL6ht8/9yTOu3yqduKIXYV8NiJXrQ9SRswDwoOsSPhfDXXabK39bvo6wovi5ES6XBxq1IIvsnwmt8jcAx+tcEceEq0J0RLFl9+2dT1Rkj3I5jdV7MehBhjBOUmeRpCeIbSdxdO0MF6my5VEpy+lVm0TfID8blaGQkK+X6txQ68cQ436zeUCIH6i78jxdesX9s0lOtlm+7vlUitCTeuRJvGmaIus2LH8t7QteOdfeY9HhmTWIT6hQ71whgM7mtiq+G7Nz4+3nFL8lxrWlLpkj2VwYYmajBjH4NP69zMNMLR40zpYYK9nA9TwuwQtOQjHXz56arz+AYtj9P58HXU6Xa5WDJl32SIH7qReKDNixi1gBXlX8TY8A+8EqzTWR87CuSrGr/N0tzBOXIHtdJUEopcwVPqzXABgULIAHfcGf0s+4Ol3ONVDIl3o1wOCCfyyLJEPzvbVdEtRwu1nDXYII/T+XcEiMGBCh7Kk5UYw== 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:(13230022)(396003)(39860400002)(136003)(346002)(366004)(376002)(451199015)(83380400001)(38100700002)(86362001)(66476007)(2906002)(8676002)(66556008)(5660300002)(66946007)(8936002)(41300700001)(1076003)(9686003)(26005)(186003)(6512007)(6506007)(6666004)(2616005)(6916009)(316002)(478600001)(6486002)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: IZIpbYCyYqGx6Lp5CFmzitV4Mpu2e2V+clMCPSJ9CP4IexxM0FcZrqUOwC9feQ8nlPdp1HYnDxF+n5c50G3uVUSvhht6V/3nqp1NufeCLj6/nCp9B8PohWIecFfpPNENwHce0rR3MCoG3/1dM+IFvFkNNQ0w+aWDOjl2wPa6eNl6zReHvBlACu2dDgGA9mMFVzlNjwZpEcW0M6791pvVKM+txyI58YepEoJGVkJXTB/7GmVzidOp5et3vG1IaVLRToIS+fSyr5j5WIc2zbtLb+5j5X6BoyqThZdHjzE3Vi2i9ogP66RQ1uVc45Di5U/l4AG16yawGS5yDyXHxmMwy6ndlqYpsGxMWtRBXDJq3E26QR7kwDM2flk4uGFdp7s/f/jUepfu5SdUlPdv5uV3tm8sdSNKT1Arc1QYWsKqEv5+GL8CjZS/vzJ4h9EExBOXKNkQWIg3iRjYfoNv9UbZ+/ZzmX/iG+A+GmwoeoQq6Zp1N4msc/jOQMNldYom7A4aXcWEgLGXm3s8QAeLp5HqXfdVj4uhVfXwqszqfmgKyDQR3Yj65gity+RloG83pifbOMGBdDMbIXxXsH+eSlFCApdUa4DMlgbdb3cWqohCi9cJ1S+MH+h7RgxEbQh7pKPUoLftWG2u0IpfusO6BD1AP0u5utKXl6IfA9mlXEa63w+OHAXWVpJCLJ29XgMz3+iSBDRbiHjQ47ArzS2bwMc1raMJd/mxncQHXd29AUpDDlxkGij7MDz6xUz+r1kvf5nravQw9mmgVyPRxLBSOCh/sjVJ3fbfUmt2YVe4pqCQ0dh6q9LU9yuNJyjOWo/BWnEhj1xOd7m8FyzVfG44ttmOO6hhZAzxwvzhzccIEXuzW59jL7VLM4a974rFO9F2BK3118e+0C2ACXa8vqGNNhiWsm/Ga0BW37PhaI8IYgdz+vrwCh/Lm4Yp4GOGo3F1hkqwTRCphJrCeustp6Wx1l3TX8WTVTgAnNaCnQlcRWIqZwUTEzpgUy0OHZYzETU1xUdT00swuWtJnlPIns3LjlTctYRqEzLdj/TLG++evECPkIjXALNNKJVxfpYsE/dzuxUq2YWGP4+i8+lbX5+y9HnUSfkcSYrqJ0f5/FYCBWurdSIRkGOBfJ/kQkL1Ql3eYIA/XnEcUu8v5wIqde6N+53KG5EVCQt8amjv6H5+rOlLHuffjqsgiKSKHaAhRccEtsLj2WrrdFa5kj71RRVMGQTg5JwrD2PFHE9akG6cUerfxgEFCXARmGiZap3ig3w05eDPsqhFqPqzEjG8FxI0q/bTZ4+wyIZnzcZcrOFb7GvJmXerwgdn5/LvYg0y7HTsBVtHvvwIAGbh6hsoLUgK0jcLpJmXckJhLz2UmOyZuBoBuC/OE+8t9FyGNnuA62bllr2kA3A3bKwdFTgg8qvEUhjGYUms7nFymz8c6HyNheTUBmBbTHztSdoqBl7KPo+WuHwwuMfyo54uFtwHlLMVX2WVOBw26L0ma8AZ4pJlTzxWlCxFi8vMkwjaganTcWzXDCg+qFMaSrOJ1SLxBhY4pBqcoDiPAqIA9gQJGQmrK8fVjD50+gEJmx/Jv+ClP0+swHyigT5u4pu3ig+kGdicfjbHGQ== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 75a7e9af-abca-4a2f-574c-08dae0df18a9 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Dec 2022 10:03:22.3363 (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: nqepCGNJtG3/3MMWSkTCT8Z3XfVlk/yGzLT9GVpVuuC1vHD4vSVlrJlyH1IL1i+apou0uwr45E613IxwmH1yI7yZytMZPWbbHuGXXA2t/fo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4536 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-12-18_02,2022-12-15_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 phishscore=0 suspectscore=0 adultscore=0 malwarescore=0 spamscore=0 mlxlogscore=999 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2212180095 X-Proofpoint-ORIG-GUID: nv-a84k0dfEtn0_UzDqVvgrSp7nad7G_ X-Proofpoint-GUID: nv-a84k0dfEtn0_UzDqVvgrSp7nad7G_ Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Allison Henderson Return the directory offset information when removing an entry to the directory. This offset will be used as the parent pointer offset in xfs_remove. Signed-off-by: Mark Tinguely Signed-off-by: Dave Chinner Signed-off-by: Allison Henderson Reviewed-by: Darrick J. Wong Reviewed-by: Catherine Hoang --- fs/xfs/libxfs/xfs_dir2.c | 6 +++++- fs/xfs/libxfs/xfs_dir2.h | 3 ++- fs/xfs/libxfs/xfs_dir2_block.c | 4 ++-- fs/xfs/libxfs/xfs_dir2_leaf.c | 5 +++-- fs/xfs/libxfs/xfs_dir2_node.c | 5 +++-- fs/xfs/libxfs/xfs_dir2_sf.c | 2 ++ fs/xfs/xfs_inode.c | 4 ++-- 7 files changed, 19 insertions(+), 10 deletions(-) diff --git a/fs/xfs/libxfs/xfs_dir2.c b/fs/xfs/libxfs/xfs_dir2.c index 69a6561c22cc..891c1f701f53 100644 --- a/fs/xfs/libxfs/xfs_dir2.c +++ b/fs/xfs/libxfs/xfs_dir2.c @@ -436,7 +436,8 @@ xfs_dir_removename( struct xfs_inode *dp, struct xfs_name *name, xfs_ino_t ino, - xfs_extlen_t total) /* bmap's total block count */ + xfs_extlen_t total, /* bmap's total block count */ + xfs_dir2_dataptr_t *offset) /* OUT: offset in directory */ { struct xfs_da_args *args; int rval; @@ -481,6 +482,9 @@ xfs_dir_removename( else rval = xfs_dir2_node_removename(args); out_free: + if (offset) + *offset = args->offset; + kmem_free(args); return rval; } diff --git a/fs/xfs/libxfs/xfs_dir2.h b/fs/xfs/libxfs/xfs_dir2.h index d96954478696..0c2d7c0af78f 100644 --- a/fs/xfs/libxfs/xfs_dir2.h +++ b/fs/xfs/libxfs/xfs_dir2.h @@ -46,7 +46,8 @@ extern int xfs_dir_lookup(struct xfs_trans *tp, struct xfs_inode *dp, struct xfs_name *ci_name); extern int xfs_dir_removename(struct xfs_trans *tp, struct xfs_inode *dp, struct xfs_name *name, xfs_ino_t ino, - xfs_extlen_t tot); + xfs_extlen_t tot, + xfs_dir2_dataptr_t *offset); extern int xfs_dir_replace(struct xfs_trans *tp, struct xfs_inode *dp, const struct xfs_name *name, xfs_ino_t inum, xfs_extlen_t tot); diff --git a/fs/xfs/libxfs/xfs_dir2_block.c b/fs/xfs/libxfs/xfs_dir2_block.c index 70aeab9d2a12..d36f3f1491da 100644 --- a/fs/xfs/libxfs/xfs_dir2_block.c +++ b/fs/xfs/libxfs/xfs_dir2_block.c @@ -810,9 +810,9 @@ xfs_dir2_block_removename( /* * Point to the data entry using the leaf entry. */ + args->offset = be32_to_cpu(blp[ent].address); dep = (xfs_dir2_data_entry_t *)((char *)hdr + - xfs_dir2_dataptr_to_off(args->geo, - be32_to_cpu(blp[ent].address))); + xfs_dir2_dataptr_to_off(args->geo, args->offset)); /* * Mark the data entry's space free. */ diff --git a/fs/xfs/libxfs/xfs_dir2_leaf.c b/fs/xfs/libxfs/xfs_dir2_leaf.c index 9ab520b66547..b4a066259d97 100644 --- a/fs/xfs/libxfs/xfs_dir2_leaf.c +++ b/fs/xfs/libxfs/xfs_dir2_leaf.c @@ -1386,9 +1386,10 @@ xfs_dir2_leaf_removename( * Point to the leaf entry, use that to point to the data entry. */ lep = &leafhdr.ents[index]; - db = xfs_dir2_dataptr_to_db(geo, be32_to_cpu(lep->address)); + args->offset = be32_to_cpu(lep->address); + db = xfs_dir2_dataptr_to_db(args->geo, args->offset); dep = (xfs_dir2_data_entry_t *)((char *)hdr + - xfs_dir2_dataptr_to_off(geo, be32_to_cpu(lep->address))); + xfs_dir2_dataptr_to_off(args->geo, args->offset)); needscan = needlog = 0; oldbest = be16_to_cpu(bf[0].length); ltp = xfs_dir2_leaf_tail_p(geo, leaf); diff --git a/fs/xfs/libxfs/xfs_dir2_node.c b/fs/xfs/libxfs/xfs_dir2_node.c index 5a9513c036b8..39cbdeafa0f6 100644 --- a/fs/xfs/libxfs/xfs_dir2_node.c +++ b/fs/xfs/libxfs/xfs_dir2_node.c @@ -1296,9 +1296,10 @@ xfs_dir2_leafn_remove( /* * Extract the data block and offset from the entry. */ - db = xfs_dir2_dataptr_to_db(geo, be32_to_cpu(lep->address)); + args->offset = be32_to_cpu(lep->address); + db = xfs_dir2_dataptr_to_db(args->geo, args->offset); ASSERT(dblk->blkno == db); - off = xfs_dir2_dataptr_to_off(geo, be32_to_cpu(lep->address)); + off = xfs_dir2_dataptr_to_off(args->geo, args->offset); ASSERT(dblk->index == off); /* diff --git a/fs/xfs/libxfs/xfs_dir2_sf.c b/fs/xfs/libxfs/xfs_dir2_sf.c index 44bc4ba3da8a..b49578a547b3 100644 --- a/fs/xfs/libxfs/xfs_dir2_sf.c +++ b/fs/xfs/libxfs/xfs_dir2_sf.c @@ -969,6 +969,8 @@ xfs_dir2_sf_removename( XFS_CMP_EXACT) { ASSERT(xfs_dir2_sf_get_ino(mp, sfp, sfep) == args->inumber); + args->offset = xfs_dir2_byte_to_dataptr( + xfs_dir2_sf_get_offset(sfep)); break; } } diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index 29ebd4e2e279..6877266f6d7a 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -2508,7 +2508,7 @@ xfs_remove( if (error) goto out_trans_cancel; - error = xfs_dir_removename(tp, dp, name, ip->i_ino, resblks); + error = xfs_dir_removename(tp, dp, name, ip->i_ino, resblks, NULL); if (error) { ASSERT(error != -ENOENT); goto out_trans_cancel; @@ -3097,7 +3097,7 @@ xfs_rename( spaceres); else error = xfs_dir_removename(tp, src_dp, src_name, src_ip->i_ino, - spaceres); + spaceres, NULL); if (error) goto out_trans_cancel; From patchwork Sun Dec 18 10:02:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 13076003 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 CED68C3DA7B for ; Sun, 18 Dec 2022 10:03:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230255AbiLRKDc (ORCPT ); Sun, 18 Dec 2022 05:03:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60064 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230241AbiLRKD3 (ORCPT ); Sun, 18 Dec 2022 05:03:29 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 54BB455A8 for ; Sun, 18 Dec 2022 02:03:27 -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 2BI4pQni021611 for ; Sun, 18 Dec 2022 10:03:27 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2022-7-12; bh=O88cT0U2Qrx+GbX6YnlzcfyhNWca/HKq0gKxoNasJDU=; b=hu/FsMYRd3pYuMHX7pSKxJ3SiWqYpPeWzgB0dwjgzW/3dWx+OFhJ/tVEWfzs3w7uTJMn nyrM4JP1IBqNS0Tw+cf4B7mI2F4WhxFeKo14tROFCm450de6kLGFtIvl2rOvJ+Q03lyp Zc9jJKNJHo37lVqxWc3M0ds63tffinOefL6TNx/lD4aHFXihtUp1ZWb9IWUeVMQnv2+a Uo8Nrj9277Lt82RdJtjFv4CpgLP2rJZWSBN6ochIWeT1El42wo6UYxKK/pHnWbw9LATZ fAnGiCChOarYkq+r5/ntX49N4+340LUdGUbnEziktbzveGw6wxGJMQR+mqA7zFwNifZL Jg== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3mh6tqs95t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sun, 18 Dec 2022 10:03:26 +0000 Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 2BI7UHic007458 for ; Sun, 18 Dec 2022 10:03:25 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2169.outbound.protection.outlook.com [104.47.55.169]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3mh479cbn7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sun, 18 Dec 2022 10:03:25 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iyUCPmMtyEnjvwwMg2O9565nRSV8Qbz93a8/MgGZ4/I3zi/cLXgVjXPyedK+3A7tP5eigH1EgJXI3bX8NPtEJW5AKvVpk40Eld3xr22J00HzV2PeEVxNHr2qblcWg9x/dPu1+pLtupK24tzoM0onsM3dIVHpM6e4KrNgimxorjR/VNUNkpx8eT973dDEvuNa2LjG4i3/1nrmFPLWeIRPKPF/OQQnIVj2Joe0M4sIDCll8ezRlMxDrhIKx7A0mifkFIl5gc6aqpT1ebsCfLKkGxQS14pEhFFGR8uBfp933aRkoF7+IIie0Sok6J/cb5Qxg0T1B6u6cNpL9VSag+KQwg== 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=O88cT0U2Qrx+GbX6YnlzcfyhNWca/HKq0gKxoNasJDU=; b=VITGUeCaYMWCdOh5jebigcJwRF3djG3pH86xbkuve2GGT5nzFJmpbRD+4Jg+mRCcd2M4ZLj9tnF9nUpmhDEz8HVJnBa1czhpiLIHiRXRxD30w8e4T4uqU28I8FlL3ulrHkIgzulCgCtNKk9FTO5lr2z8A3XPo3Fal4CogIzNE1LlwTCkZG7D1hIPC8uxG57I1Kbagok8u2VLovL3egIlfZhuX807sGjIsXURxJ/IhD91xFv1EsAufOSlZFuXRzO/uHCbRaqs4Rd0cm8O05X2ovZedXGyQsBC/wrBR9wvqT6IdbLAEqVlcKeS0lO/MPvcGfKmTP6lxjs6olCcjJ+9Cw== 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=O88cT0U2Qrx+GbX6YnlzcfyhNWca/HKq0gKxoNasJDU=; b=r4iwEEo61nq7Oj9AQRLtgzfDq2MtPWh/HmyoYDV112ASeicmXfbxDUm/pG8xRdtBF2L8MXfuuRKE/ZS2UwTsTgbouJV/4gh7nlsz8uaTowjuvEjxsXRamJwH8ft5Cstr3wmLSMVFhM5QnB8in/SZzaJNR0dGOWFd8rxWSECCpDw= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by PH0PR10MB4536.namprd10.prod.outlook.com (2603:10b6:510:40::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5924.16; Sun, 18 Dec 2022 10:03:24 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::3cab:6ff7:cb4d:b57c]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::3cab:6ff7:cb4d:b57c%4]) with mapi id 15.20.5924.016; Sun, 18 Dec 2022 10:03:24 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v7 10/27] xfs: get directory offset when replacing a directory name Date: Sun, 18 Dec 2022 03:02:49 -0700 Message-Id: <20221218100306.76408-11-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221218100306.76408-1-allison.henderson@oracle.com> References: <20221218100306.76408-1-allison.henderson@oracle.com> X-ClientProxiedBy: BYAPR01CA0049.prod.exchangelabs.com (2603:10b6:a03:94::26) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY5PR10MB4306:EE_|PH0PR10MB4536:EE_ X-MS-Office365-Filtering-Correlation-Id: 5e4a8194-8f38-4395-13bd-08dae0df198e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: XqXXLle7AD+766t5rjA12FlAi33TP1EnlpI7Ta+/D7R28QK2lU2/3LyAlrg5w1iu6ZGD0Y8h/3bbgwuR2/oHWb0otljhj/szsOK6EYqMZ9mgHDeCaubzoF7FdA43nyHgX0iPAg0w37iHJD/P4A10D3yvdORBX/CqRG5/IFuuQFNF6iR4yu5r0ZQM+bip4EHIrjbQmYljiStXiahDutWEH6qMyuDm96BPoz0lxYBRP7/3W0fH2rRE9KV4P3nI/2fBlGW0lTH24bejj4jxjkUqMIs5ZZnuS5ENRSj/ogrZAgrCgjNU3uDTn6oK372nMiI2BoC+wKBV9pT8UTnHOyR/AxtXUlikumIDPqa7aQcZzJ9OLUWW1JkcKN+IPU7FWwon608DGs1k3p10XJy1G3ZMRnKRrwJ2JIS/N7KfV/AqrgRYMivjmY4+WgZYlMMx37f7muFEBPdaG0uwKZfA4tvsJpIeUfcWIiejt0NGMtuWGp7XSvQuA2k0e3yRo4Zbva6mlgmGYMnBmqCeYOt1nm+yne1PowW80Mi2ygRkWNP8+5fmpKO0cwLKLKAysSiIMFhB3ZsMApUC1Ua7aQ8hhdMRT1mzzObHA8E2MN8dTlfMAFa/09k3nyVQsfOCTzlbE7hM 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:(13230022)(396003)(39860400002)(136003)(346002)(366004)(376002)(451199015)(83380400001)(38100700002)(86362001)(66476007)(2906002)(8676002)(66556008)(5660300002)(66946007)(8936002)(41300700001)(1076003)(9686003)(26005)(186003)(6512007)(6506007)(6666004)(2616005)(6916009)(316002)(478600001)(6486002)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: y2GxlVAWUPsyQRh3CxJgc5/hmfAJ0ZVjiIIE3tczpdvkW2yG+wEDkoDNezLooR/XGc1gstWkutB46skKNKOkiF6SbV6mI9I0qHCpXc8TgvxVwgcPLAKwg3CIP5h2qbqFHpPwvnUHWAKdRiwX5vPjG40ocv4fDyHcmL/WQNjyLDHz8yS7d9qyGjm+vZ+QoDThnXIAubq+Qn199EJXBZz8OmdPnvxCpW1Hj0LnD200gT0OYcX+zjUbNcNr6+gpAwDCcmV6ejbVyyq5SlgrjJ1iYtGVPjuKDLqkd02nsTc8b9Bp68Vu6awF4qIK7L/jEijNZgqtrlofnkQ+V+KQIRJoV+YH+TTfJidRHKu8VUu5y0UeVgvhPI2Cs7LpOFjFX4tFEioyJUWr1GUU2FHNgqk4VeWiT3x+corXFGkDDunghvQLpGk0imWDrP0q34Hfi/JEIVxWmJuIUeXFBboqcdO2Seyz8KKiCoq6Kg8KFY13oFaOnEHj4sfgwRYQXJdDVVZLPqGSX2WyIwd3kSsDfTKVAlRCQELjW3KciTTWBeeH9YrYDo/Xpo271SyZXGv+IbRIUl9NCJmjQdhAJvTF8tRpW2IIWrauFCC1v3sDR4R0S6T2fY8xQZBLPi6Fi8cKufqgpc03xqegqDuWXzqYN2AH+5nkWuNhZd9LONRbyRDP/65sVA2DKVyJXJF8xdPmTxjU37HdLfZuFmDWQ1TPu9PPQD7PA6dqwa/kXzrbwvdI78P2X3hstnX725zGKZHP391gqOjkZOydjaxL49BlNdWtSZTFDmgPesNd4L7qKyOHg7IbatMpdv8On651p1EuJQIVrXCnFd/hF7bhvQmGaDyOAKQBxTXtgGznXoMAmzEaUvM80YP69qe5szFGI7aoWggPGysI+m6qJe5/P2tg+Na/dO9Lgfnlb5kas34uLJEflBn0Qh0PKGQjWRLif5cwEm9++T801tgjr90VppESZjqhIA9uqrqUyDmMZHAxwMGu6IlFSmF1lxz2mo4IfcI1DwGKncPDythSwyxXhV4ZawGN58Z+rMZA03WiRNN3UfeB0btJ59ajIz4YuF0rhJSgaZGxs/Y3okdFCDHzbUmY15SfSegfXgYr9SAdWcpRuneFCzcjVf/X9fwayNjysBQh5MU+ajKZEp10yrDDDBwDjI6UdqcV7yemu1PhHcZJba5f3MAeT6tzrb83+t9ZONSgUYF3pYcNsGDEdfWLZBMnTm9OvacSVb7UV8Cmte9oRYPqzvCwVFR8cYFf06nbXzPD/6t4j4OocEvVcPJXv+fNQpfbCGHhDprHo/Mhz6pKfoTlrRJlyOVmreaTWR2T11AUCuE08TVkzgWFpKHHEEDLTnumynSVeTI/RTbset6fsW0Ko00jaUd39TTg/ZXuZBVi1E1hZm8Tk1pCr8SBjlnf7imW/4wkBLmVcVNssiX7GsLiwSrKN51/L1RfvxdyNVYGMwbIHw+jN/o05lYwySXdmpfZ99BARsfTLvzX5gzLboLs0nvnvgaxiSLCrEWldGTCxOmeByccj/J4Fhc74SAO5TvUPl5Xve4v3cLkNwCQOpBWmxBp8ji8aMhQwOmOPuOWVbljlstjvJ63vtdio+CUPmmPGg== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5e4a8194-8f38-4395-13bd-08dae0df198e X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Dec 2022 10:03:23.8353 (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: rHjO6aBN3/pEMthCdrUL19cXQ8lQI8RtJNYG215MxkU73S91Yfr33uZJwN3/0KhGDWGU+i0rzMgKi23dDq7mAjmi3SvQivSXp4jucju7bAU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4536 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-12-18_02,2022-12-15_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 malwarescore=0 phishscore=0 suspectscore=0 spamscore=0 bulkscore=0 mlxscore=0 mlxlogscore=950 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2212180095 X-Proofpoint-GUID: aPZDAMaaZPSLpDBBj7bcVcCekoZQrbqv X-Proofpoint-ORIG-GUID: aPZDAMaaZPSLpDBBj7bcVcCekoZQrbqv Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Allison Henderson Return the directory offset information when replacing an entry to the directory. This offset will be used as the parent pointer offset in xfs_rename. Signed-off-by: Mark Tinguely Signed-off-by: Dave Chinner Signed-off-by: Allison Henderson Reviewed-by: Darrick J. Wong --- fs/xfs/libxfs/xfs_dir2.c | 8 ++++++-- fs/xfs/libxfs/xfs_dir2.h | 2 +- fs/xfs/libxfs/xfs_dir2_block.c | 4 ++-- fs/xfs/libxfs/xfs_dir2_leaf.c | 1 + fs/xfs/libxfs/xfs_dir2_node.c | 1 + fs/xfs/libxfs/xfs_dir2_sf.c | 2 ++ fs/xfs/xfs_inode.c | 16 ++++++++-------- 7 files changed, 21 insertions(+), 13 deletions(-) diff --git a/fs/xfs/libxfs/xfs_dir2.c b/fs/xfs/libxfs/xfs_dir2.c index 891c1f701f53..c1a9394d7478 100644 --- a/fs/xfs/libxfs/xfs_dir2.c +++ b/fs/xfs/libxfs/xfs_dir2.c @@ -482,7 +482,7 @@ xfs_dir_removename( else rval = xfs_dir2_node_removename(args); out_free: - if (offset) + if (!rval && offset) *offset = args->offset; kmem_free(args); @@ -498,7 +498,8 @@ xfs_dir_replace( struct xfs_inode *dp, const struct xfs_name *name, /* name of entry to replace */ xfs_ino_t inum, /* new inode number */ - xfs_extlen_t total) /* bmap's total block count */ + xfs_extlen_t total, /* bmap's total block count */ + xfs_dir2_dataptr_t *offset) /* OUT: offset in directory */ { struct xfs_da_args *args; int rval; @@ -546,6 +547,9 @@ xfs_dir_replace( else rval = xfs_dir2_node_replace(args); out_free: + if (offset) + *offset = args->offset; + kmem_free(args); return rval; } diff --git a/fs/xfs/libxfs/xfs_dir2.h b/fs/xfs/libxfs/xfs_dir2.h index 0c2d7c0af78f..ff59f009d1fd 100644 --- a/fs/xfs/libxfs/xfs_dir2.h +++ b/fs/xfs/libxfs/xfs_dir2.h @@ -50,7 +50,7 @@ extern int xfs_dir_removename(struct xfs_trans *tp, struct xfs_inode *dp, xfs_dir2_dataptr_t *offset); extern int xfs_dir_replace(struct xfs_trans *tp, struct xfs_inode *dp, const struct xfs_name *name, xfs_ino_t inum, - xfs_extlen_t tot); + xfs_extlen_t tot, xfs_dir2_dataptr_t *offset); extern int xfs_dir_canenter(struct xfs_trans *tp, struct xfs_inode *dp, struct xfs_name *name); diff --git a/fs/xfs/libxfs/xfs_dir2_block.c b/fs/xfs/libxfs/xfs_dir2_block.c index d36f3f1491da..0f3a03e87278 100644 --- a/fs/xfs/libxfs/xfs_dir2_block.c +++ b/fs/xfs/libxfs/xfs_dir2_block.c @@ -885,9 +885,9 @@ xfs_dir2_block_replace( /* * Point to the data entry we need to change. */ + args->offset = be32_to_cpu(blp[ent].address); dep = (xfs_dir2_data_entry_t *)((char *)hdr + - xfs_dir2_dataptr_to_off(args->geo, - be32_to_cpu(blp[ent].address))); + xfs_dir2_dataptr_to_off(args->geo, args->offset)); ASSERT(be64_to_cpu(dep->inumber) != args->inumber); /* * Change the inode number to the new value. diff --git a/fs/xfs/libxfs/xfs_dir2_leaf.c b/fs/xfs/libxfs/xfs_dir2_leaf.c index b4a066259d97..fe75ffadace9 100644 --- a/fs/xfs/libxfs/xfs_dir2_leaf.c +++ b/fs/xfs/libxfs/xfs_dir2_leaf.c @@ -1523,6 +1523,7 @@ xfs_dir2_leaf_replace( /* * Point to the data entry. */ + args->offset = be32_to_cpu(lep->address); dep = (xfs_dir2_data_entry_t *) ((char *)dbp->b_addr + xfs_dir2_dataptr_to_off(args->geo, be32_to_cpu(lep->address))); diff --git a/fs/xfs/libxfs/xfs_dir2_node.c b/fs/xfs/libxfs/xfs_dir2_node.c index 39cbdeafa0f6..53cd0d5d94f7 100644 --- a/fs/xfs/libxfs/xfs_dir2_node.c +++ b/fs/xfs/libxfs/xfs_dir2_node.c @@ -2242,6 +2242,7 @@ xfs_dir2_node_replace( hdr = state->extrablk.bp->b_addr; ASSERT(hdr->magic == cpu_to_be32(XFS_DIR2_DATA_MAGIC) || hdr->magic == cpu_to_be32(XFS_DIR3_DATA_MAGIC)); + args->offset = be32_to_cpu(leafhdr.ents[blk->index].address); dep = (xfs_dir2_data_entry_t *) ((char *)hdr + xfs_dir2_dataptr_to_off(args->geo, diff --git a/fs/xfs/libxfs/xfs_dir2_sf.c b/fs/xfs/libxfs/xfs_dir2_sf.c index b49578a547b3..032c65804610 100644 --- a/fs/xfs/libxfs/xfs_dir2_sf.c +++ b/fs/xfs/libxfs/xfs_dir2_sf.c @@ -1107,6 +1107,8 @@ xfs_dir2_sf_replace( xfs_dir2_sf_put_ino(mp, sfp, sfep, args->inumber); xfs_dir2_sf_put_ftype(mp, sfep, args->filetype); + args->offset = xfs_dir2_byte_to_dataptr( + xfs_dir2_sf_get_offset(sfep)); break; } } diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index 6877266f6d7a..f65085645942 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -2489,7 +2489,7 @@ xfs_remove( */ if (dp->i_ino != tp->t_mountp->m_sb.sb_rootino) { error = xfs_dir_replace(tp, ip, &xfs_name_dotdot, - tp->t_mountp->m_sb.sb_rootino, 0); + tp->t_mountp->m_sb.sb_rootino, 0, NULL); if (error) goto out_trans_cancel; } @@ -2644,12 +2644,12 @@ xfs_cross_rename( int dp2_flags = 0; /* Swap inode number for dirent in first parent */ - error = xfs_dir_replace(tp, dp1, name1, ip2->i_ino, spaceres); + error = xfs_dir_replace(tp, dp1, name1, ip2->i_ino, spaceres, NULL); if (error) goto out_trans_abort; /* Swap inode number for dirent in second parent */ - error = xfs_dir_replace(tp, dp2, name2, ip1->i_ino, spaceres); + error = xfs_dir_replace(tp, dp2, name2, ip1->i_ino, spaceres, NULL); if (error) goto out_trans_abort; @@ -2663,7 +2663,7 @@ xfs_cross_rename( if (S_ISDIR(VFS_I(ip2)->i_mode)) { error = xfs_dir_replace(tp, ip2, &xfs_name_dotdot, - dp1->i_ino, spaceres); + dp1->i_ino, spaceres, NULL); if (error) goto out_trans_abort; @@ -2687,7 +2687,7 @@ xfs_cross_rename( if (S_ISDIR(VFS_I(ip1)->i_mode)) { error = xfs_dir_replace(tp, ip1, &xfs_name_dotdot, - dp2->i_ino, spaceres); + dp2->i_ino, spaceres, NULL); if (error) goto out_trans_abort; @@ -3021,7 +3021,7 @@ xfs_rename( * name at the destination directory, remove it first. */ error = xfs_dir_replace(tp, target_dp, target_name, - src_ip->i_ino, spaceres); + src_ip->i_ino, spaceres, NULL); if (error) goto out_trans_cancel; @@ -3055,7 +3055,7 @@ xfs_rename( * directory. */ error = xfs_dir_replace(tp, src_ip, &xfs_name_dotdot, - target_dp->i_ino, spaceres); + target_dp->i_ino, spaceres, NULL); ASSERT(error != -EEXIST); if (error) goto out_trans_cancel; @@ -3094,7 +3094,7 @@ xfs_rename( */ if (wip) error = xfs_dir_replace(tp, src_dp, src_name, wip->i_ino, - spaceres); + spaceres, NULL); else error = xfs_dir_removename(tp, src_dp, src_name, src_ip->i_ino, spaceres, NULL); From patchwork Sun Dec 18 10:02:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 13076005 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 8F3CFC3DA78 for ; Sun, 18 Dec 2022 10:03:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230257AbiLRKDe (ORCPT ); Sun, 18 Dec 2022 05:03:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60066 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230244AbiLRKD3 (ORCPT ); Sun, 18 Dec 2022 05:03:29 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1603A6559 for ; Sun, 18 Dec 2022 02:03:28 -0800 (PST) Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2BI7njZs016744 for ; Sun, 18 Dec 2022 10:03:27 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2022-7-12; bh=9T0GlrN+YfkG79YJEffUTVVFSrGIFrV+2zA2f1qX1ts=; b=L0yzmk97EvdvbhkvhqurgZQJG8NKXtBJSRdnbsId+hOi9/wGjySFA+SeTCZ2nZinYu83 L8wab66ZWMMb0wfdo29dYXVh6lONLTjT0YIDbrw0Ex3HrUawP1Ufb7S6jJ28i1kYMGoc HF9TJtLPv9/d5VYtqfBTztT1wDtpDGTbOSQ6ZjTBUQlNoOZbweGjTSDszUDaUivUmdal kVeWqtdxVfTHKEvC3OhISAUamR63bH944IXZTCSBuRvC3RUnck65cNVEj47hWyZQE/Tp AmiKnn9g9X8pV9Ur+jtOqmEajxUT0Kj0SxNUnY9at1jtcahwRTbhLVun7YLJblXMEwy4 FA== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3mh6tn196s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sun, 18 Dec 2022 10:03:27 +0000 Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 2BI8mHqY024871 for ; Sun, 18 Dec 2022 10:03:26 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2174.outbound.protection.outlook.com [104.47.55.174]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3mh478mxm7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sun, 18 Dec 2022 10:03:26 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZTmTp0toELZMYARifKaS1Hw0pk81LHfcjTc133aGTY9o4QKrJ+CczR5eOVuzfLg1wxTs+WXrPgyI2bpCm9WNfL3B0vuq0tge/9zPDxw/z1oz/zj3zfal/PNs6fm3tUE9DHC5qXb2FsqEbuZKflMchWWytP3LSQ69zzyLtBrfAvkU/L3iunX6K4cPtAk4N+Vv375EKvCu+QmQJOymB1YY+RpRlrUmfzK5zQsGTX3aaOFnv7pH4kgi5iQwkr1wBGgq8Lj8yeHutUKxW7FMaTJ/co4PXZqp2YGlw7YmEcXM7s2MVYkmryONR09kxctzfegWi5/DwxTFCwHUzst05H1KqQ== 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=9T0GlrN+YfkG79YJEffUTVVFSrGIFrV+2zA2f1qX1ts=; b=nYu7b9KHd+0vhISVqlI0fLzJsXMLmnvqbQqH93vbbgqqkdF3kYoi/cAThux4R+KigTxWM2YIJECJ9KN+cyxokBgjgnQskeFLzn/SgfTZ0hPJ9dCKvgoqQfY2A8Cs6t88rr5JnMwH5q02B/LANXnWi+x4ELCyoJcNDCbi7LCykRVZOr5gICYcmsvx+LQfySFu/VTeiRmh4c+NnpqCQ2wma0/o0TwHIq52Wd8jBEExXfFbMn18kPu2ZbYueLhmVi6aYiLIYCVrGMzs6BkkEECmL58FHpKN6Ll6YcxwctFcMQ5vxWp+sKmXLf+20m02z7KDsrVYfBPz6pcTJiPO1EM/hw== 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=9T0GlrN+YfkG79YJEffUTVVFSrGIFrV+2zA2f1qX1ts=; b=dSnDJWj5XrydSQuctfIXHGk8c1oWTQRcYyH3LCf2F+yzDANgqCm2/rdsqKau4LrYFFUuI+R/xLMqasZZcWv5IBsmSxrLlB+56XVKeqxkZsuL5jAU5uv/L7geCznJj88cg87v0Il2YfFgRgUWilj7NF7nGi9zCzmBLYeTw+2wgLI= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by PH0PR10MB4536.namprd10.prod.outlook.com (2603:10b6:510:40::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5924.16; Sun, 18 Dec 2022 10:03:25 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::3cab:6ff7:cb4d:b57c]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::3cab:6ff7:cb4d:b57c%4]) with mapi id 15.20.5924.016; Sun, 18 Dec 2022 10:03:25 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v7 11/27] xfs: add parent pointer support to attribute code Date: Sun, 18 Dec 2022 03:02:50 -0700 Message-Id: <20221218100306.76408-12-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221218100306.76408-1-allison.henderson@oracle.com> References: <20221218100306.76408-1-allison.henderson@oracle.com> X-ClientProxiedBy: SJ0PR13CA0229.namprd13.prod.outlook.com (2603:10b6:a03:2c1::24) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY5PR10MB4306:EE_|PH0PR10MB4536:EE_ X-MS-Office365-Filtering-Correlation-Id: 1ecd909b-a25c-40a5-6d40-08dae0df1a43 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ZjSaKWFv27J5xPKax7PaNITCPkNIEBnUoOx2Jp5QaQM7auJP+4uGeMd5qCmxJxdLCU04RGCcm/XOr6iV5JpszIVFJYBA/V5J55gvLjjjx92e9BK0p0PLI7TofV6EyxR4SwUx/+/zw2ZDws+QaHjAocISutTqP2hXy/t1W6En3/r4nfWCcwbJwD0OHQXF4gGdWAhtg2cZJxaHw6i+nqyhK//Lq3bZvbotLL5wO4sN73gAb2osnHw9zYTd3Wk4eozUgbxRGLoOmFVr7MkXwPHts5OKtSls5/InIUeMM07YB1jRS41jJWC4P10P2b6T1jt/1Phs0I5uwg99dYbZ604RjZ/A8BqjwYKCI5r5JKSykzyTTZXClYiRfGFSkOCop3pWWa/ib07ZzX+1hhHOWyGn9w4Rtu8E8va7+tifF7OUlDTDz2g1liVc/im/To61tpAlcHc3sjTBy9UnPg2tFpnhs7R9YUV+lgZjmbjOozTFJKY3CnKjoq3U25oYz0uQHJBMuGlOVkcFIOoPIOrHz9lQ6YeUoNQdAu3fuM6gBpJAMG1tkes38glGH74IiEZG5Jcmoa1YyUVCR5V6NYmy7t54oLPCKNUz/OisEliP24ByKwlG2kFwbNAZYWZ5RVNlMP4m500rtUvREuwtwCdpjYKwRA== 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:(13230022)(396003)(39860400002)(136003)(346002)(366004)(376002)(451199015)(83380400001)(38100700002)(86362001)(66476007)(2906002)(8676002)(66556008)(5660300002)(66946007)(8936002)(41300700001)(1076003)(9686003)(26005)(186003)(6512007)(6506007)(6666004)(2616005)(6916009)(316002)(478600001)(6486002)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: rTG4yCVKy8t/62ul/hWOj9qZBm6ZTBTBjC6RH3gi5A/JS4gFG+Vk8zzoGWee4eCBT3TaWQ9HMNjJ7+9QYqewr5J1k824r8lmd7H30IO8AVUDXtHV+YAM+DnMYtLwuhH3/+nXbqxgCN2z3eajLjsbRk63Hw7d+mhAE2bA9sq8zHvOP+CtRxZBNZWwIuOpx92D6u8CEfQ6goqgFDm+QmG+ZpWNGaAuDCmrS1RQ8zhL5N6I94YESdEZPztF58IemJE+UU/ppNFhUccH3DSwd6mM5EkQ2ywf4pviwdo8sgipNDZ1ApiS8tley1e6Sk06H09I7H68Oanf+1DjmQ2ZGXfvkjKBnxrgZ+vOfzE8noqFTqC13VRknLXHmogfeKsPgBYWigT9kiAGmMps2+1pUJen6aF8DPR/Ace59JwLAUzIi3tGq1lwiL0Qzj3n6QrXBlKhTlHshHK1j2gKG5D/8lg+cuXWdtXudeC7ISOLnon1rqQ+KWfF15YXaKUEGgvxxyImhmAfYJGT91NuzOO9ukm1uaRWsf1aqj9nKpobeb9JFIPDIZC4Q0FvTIcbMib2fC/B/jEVKWY8MumAUvN9RE1HLdCnAKL+ZSYre81pR5Pswn+s4GuO2j78En6jRSoz15E/csDcyeWJSZf3Vr81ClW1A72iXzQ9ceJ5DNm52mYT4YhSxmiNkWvfZTooyVwSPp5RCP0oB5SDC/9nOIZPzO5vHuJCDfWvkI4X7Hugaz+4ndeX6DAj3brPQos1SvX9I9nCBYTx6uFM6kH3QZk2pO56jKvK3az3IXss+7Jh8YK5m1nNn9sgnay2umnnMCa3iJLPOBVJdtAE2HDCW6LuwAjCzZ8yQJIZqvYxt6WzKsq8gbMufy4ciDHB2CdGZkZwtNPO/xeeoeWz8r0iYJpG9N0rTYXp9+DA1McBf5i8A5AKAx/ZXSbmR+M5XRfXHA2GEvUsUS2VDevORD4k0hDOWIS4CvWowDIZs+1QajlSzAtHdToMKXC+VqJLNK6h9XklPlLQh/pIFaV0mai6yxAI+hULJqRWpPUZNW+uLyIPlyjdWZTR6umGXNMsrbJTqF30k8NFbgQN1mj+sl4WG2HXwVmIzlEbu/0tsKEnWVJ3KXSC7pDLpYF6NlipY6oAhw11kIPvO52+DLc2aXWecQyaHTjUEABTY7Z3zGMhZ9oq+1qbdrrubrkBYPLOULXDb0tpjvxw2UQsvWsrringVqZamLOZ+q2ekaUzQegd04sZwEajWlYXKAXvm7r+9IkYvlwuHgk8uZ25KqfgTEu4QPQEoKuPkMnHX5XyktIId/iidU32ehMd5oFUbU+xTPu7lpG/dQCboTPJxmtxaSLmKQaxsWh+wfH9urMVCPjjp003PjZqtHrYaUSZuIES0RVGQwAKJPdjQMq6INZR98kic94VG3pteN3iUqzu4dZfKp3dc5ZDTrWWBiiaqP8b4xmBpXs4CoA/bTh3kLjtdwrX+SHkpWmkOArYflutJPDi5MsxmxeU+TlY5AKhfOeuRurfrl1ZWWfxf6dcsfztKb1QSMgtOZr7FGFjjoOGFYdjbxV40utMrTwKrpKW2vPMcKi1sD3VGeJ57tK0xVA2i03Zg7+ZaTl2nQ== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1ecd909b-a25c-40a5-6d40-08dae0df1a43 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Dec 2022 10:03:24.9926 (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: 07WgQvwOvYjyjPUIlSQNeRJkOVdBWJ2+QaS5nCSeQyZ2Pr+JTrMgus1KDrrrGITLEND2wR3CM+Hpjf4bo90kYp5iTjgwvGZZ79d8aZ4wocY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4536 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-12-18_02,2022-12-15_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 mlxlogscore=999 phishscore=0 bulkscore=0 malwarescore=0 spamscore=0 adultscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2212180095 X-Proofpoint-ORIG-GUID: mYWmNnT7ep70pFm42EcYBOMAbrduLXBv X-Proofpoint-GUID: mYWmNnT7ep70pFm42EcYBOMAbrduLXBv Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Allison Henderson Add the new parent attribute type. XFS_ATTR_PARENT is used only for parent pointer entries; it uses reserved blocks like XFS_ATTR_ROOT. Signed-off-by: Mark Tinguely Signed-off-by: Dave Chinner Signed-off-by: Allison Henderson Reviewed-by: Darrick J. Wong --- fs/xfs/libxfs/xfs_attr.c | 4 +++- fs/xfs/libxfs/xfs_da_format.h | 5 ++++- fs/xfs/libxfs/xfs_log_format.h | 1 + 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c index b1dbed7655e8..101823772bf9 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -976,11 +976,13 @@ xfs_attr_set( struct xfs_inode *dp = args->dp; struct xfs_mount *mp = dp->i_mount; struct xfs_trans_res tres; - bool rsvd = (args->attr_filter & XFS_ATTR_ROOT); + bool rsvd; int error, local; int rmt_blks = 0; unsigned int total; + rsvd = (args->attr_filter & (XFS_ATTR_ROOT | XFS_ATTR_PARENT)) != 0; + if (xfs_is_shutdown(dp->i_mount)) return -EIO; diff --git a/fs/xfs/libxfs/xfs_da_format.h b/fs/xfs/libxfs/xfs_da_format.h index 25e2841084e1..3dc03968bba6 100644 --- a/fs/xfs/libxfs/xfs_da_format.h +++ b/fs/xfs/libxfs/xfs_da_format.h @@ -688,12 +688,15 @@ struct xfs_attr3_leafblock { #define XFS_ATTR_LOCAL_BIT 0 /* attr is stored locally */ #define XFS_ATTR_ROOT_BIT 1 /* limit access to trusted attrs */ #define XFS_ATTR_SECURE_BIT 2 /* limit access to secure attrs */ +#define XFS_ATTR_PARENT_BIT 3 /* parent pointer attrs */ #define XFS_ATTR_INCOMPLETE_BIT 7 /* attr in middle of create/delete */ #define XFS_ATTR_LOCAL (1u << XFS_ATTR_LOCAL_BIT) #define XFS_ATTR_ROOT (1u << XFS_ATTR_ROOT_BIT) #define XFS_ATTR_SECURE (1u << XFS_ATTR_SECURE_BIT) +#define XFS_ATTR_PARENT (1u << XFS_ATTR_PARENT_BIT) #define XFS_ATTR_INCOMPLETE (1u << XFS_ATTR_INCOMPLETE_BIT) -#define XFS_ATTR_NSP_ONDISK_MASK (XFS_ATTR_ROOT | XFS_ATTR_SECURE) +#define XFS_ATTR_NSP_ONDISK_MASK \ + (XFS_ATTR_ROOT | XFS_ATTR_SECURE | XFS_ATTR_PARENT) /* * Alignment for namelist and valuelist entries (since they are mixed diff --git a/fs/xfs/libxfs/xfs_log_format.h b/fs/xfs/libxfs/xfs_log_format.h index ae9c99762a24..727b5a858028 100644 --- a/fs/xfs/libxfs/xfs_log_format.h +++ b/fs/xfs/libxfs/xfs_log_format.h @@ -967,6 +967,7 @@ struct xfs_icreate_log { */ #define XFS_ATTRI_FILTER_MASK (XFS_ATTR_ROOT | \ XFS_ATTR_SECURE | \ + XFS_ATTR_PARENT | \ XFS_ATTR_INCOMPLETE) /* From patchwork Sun Dec 18 10:02:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 13076006 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 8C0E5C10F1E for ; Sun, 18 Dec 2022 10:03:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230244AbiLRKDf (ORCPT ); Sun, 18 Dec 2022 05:03:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60100 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230030AbiLRKDa (ORCPT ); Sun, 18 Dec 2022 05:03:30 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EFEEF6352 for ; Sun, 18 Dec 2022 02:03:29 -0800 (PST) Received: from pps.filterd (m0333521.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2BI6o2HD027811 for ; Sun, 18 Dec 2022 10:03:29 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2022-7-12; bh=u8ANFXJemEPEl5G2uQUXpknnREMAMf1WLaiUz9lWhI8=; b=hQSGeVxMg9Oxa7zMHPoLfKmlpChEMa4ibrl58i9jUcE5JtetLqPPi8xDvRIXWlf7+0L+ yA+v59UJJNbo60V4/l2gMbl+icenkGaBK6cZFuxCGspFWE8YNMZ2+kAZ2tE8RcuutLt9 Ui8RQcfVgAUSyLyNWHqCdScRFoDqtRzIg2hZ6vDBkghwAJrA9rvlOvfhMhRrbHwDGOSJ GBLFXHknDB8DqaLsTWOif/ih4lRWruzqiORNcqMb0x0TE43HhRBAT3jzhD99qdoBfdrT krD+ak0UBoLTH+z2ql+3l9Yv6WxMf9hgzOeQ6vHxVeWdnUJulBq7vfrgmz9bGitEeJfL yw== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3mh6tn99gg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sun, 18 Dec 2022 10:03:29 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 2BI7XHr6012665 for ; Sun, 18 Dec 2022 10:03:29 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2172.outbound.protection.outlook.com [104.47.55.172]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3mh472cfty-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sun, 18 Dec 2022 10:03:28 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mFL2jJbJv5zgFoa06ypFQ6WxcQQU4qoWCCX0xEpzHDfng/3dyxc4NpSgAGdOO3zLf9DVuEGAcnL7H3TLLKp9qN5QrzOUH3zsQIgrnh1Ns9OlWT8HZATJz5AaIJwYfhGbRes/JzbVl6VACU/nI5Wmb0OGLkw0vI/jKu7bvMB1CiGObGR9wEGjuJsx+rRM1HT+aS5cx9mxCot1OrySK5KuG2nW3SDey974vURBqsUcbpGlrs+GshKSeTqfPQMH+2jsrHnHPUUHCYX5FkEqppyIyUiVYNzdK4jdiP0RFIbplcO1gnqQL+zMysSCvCc1magSOMSt+v7fFL2qJe6gZMNKAw== 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=u8ANFXJemEPEl5G2uQUXpknnREMAMf1WLaiUz9lWhI8=; b=KJkPNgvWn/yyTc4DNojS0ccXxPIkHu05XUpf5hHy8pNNTbUvnv8fybgp9VoxUMOf63oIFEhIMEAHue5vRKOaIRx42Vdstk0ieCY7yDPaPRul0WRswE6HOdH0CmodKYfzBWbl/bY1bkZOwdR1uqEHE7kGG16+OX/CUfw2iGPfqub7t9Rflb30jjTosjF/xBVRqgtTuqsWaD3OoRJXRZDxoeFBRM1ATPH/lBkkRvlY3GDfDYoSFZrxkOQfVAA51bzT7gxcYfY7uDVeoYN88JhdKskWsPORRkMtFbcuGo51njAeydfUtfo/oV3GSJOR92IBtovL/9uQPyW/IIwhVP6fmw== 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=u8ANFXJemEPEl5G2uQUXpknnREMAMf1WLaiUz9lWhI8=; b=PmxbVrDY902e2/UectKW0KlXD1Vm+NA1kuuRgWaxKZt7h0C5NNQfUfrNEKlvAKgFX3JLQP0p88wB33Oe71vu5IK1fWV36hNOjjgcPzwIlC2Ads7AU4Sot7qn9A+zfpyQYlU8eRGzw+6pAafkiYlNYIjL3zHXHKhm9cjsb82f6mk= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by PH0PR10MB4536.namprd10.prod.outlook.com (2603:10b6:510:40::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5924.16; Sun, 18 Dec 2022 10:03:27 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::3cab:6ff7:cb4d:b57c]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::3cab:6ff7:cb4d:b57c%4]) with mapi id 15.20.5924.016; Sun, 18 Dec 2022 10:03:27 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v7 12/27] xfs: define parent pointer xattr format Date: Sun, 18 Dec 2022 03:02:51 -0700 Message-Id: <20221218100306.76408-13-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221218100306.76408-1-allison.henderson@oracle.com> References: <20221218100306.76408-1-allison.henderson@oracle.com> X-ClientProxiedBy: BY3PR03CA0009.namprd03.prod.outlook.com (2603:10b6:a03:39a::14) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY5PR10MB4306:EE_|PH0PR10MB4536:EE_ X-MS-Office365-Filtering-Correlation-Id: 3e7d1cf4-d878-4c3d-5ec0-08dae0df1b72 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: o9TqdlN7elzx6ZRVD/f3gSoma2vZ7Vgt8C2wlc/cjhvq2fZgO+ora+9M+t+XE2MB43FWvPIF7TX49aZI08HhYhqdkCNwEgWRR42W2Ir6F5UA/a8MQnfnF0B7jLco/8cEnYWAFGwC6J5LNcE9TRYVEVgQjt/RivbksTF2O4T8HWZpFRnQZnNes9OgTMRm0VoHnFkit+c8P70CTiDo3L3d4jKGLfZau3zd5TL6s3XlBozFzge5nTnQ95Y+1sJXdlWen1k+46F1g1aPbVv6zl+mV4s3tyrUmcZZSYdlFui1DMUIgWgtbcFPio3w2Fsp2G3EWbi1xVu55pRq9bSXQzUPgAPE/gqZWkPGjAPvv9K7tgcODN275b76dViDrSD6JHe4zj++e+mJKHfsZWK8p0Vx17LBE+MnnSIRWqTgsjlL0oB/otf6YdWHVpCdAKXMLdulIYkurgMJNbXFSB5U4l7Xm1OnJ5o/YXQQ6sl6qDk0i1zpU5zaGFZaWVF4Wv0jbYiybaw1LJFDr1mRNNgSVMJr6xU4r0UGXoe6go6zsoZKkRn2TGd/R7rhZq7pkxrstRdt8OrXc39YHQL4gyJxw7RjmV7fLyxJSRLaCMajlhJugw5DA/COEpTs+AMt3ydQhw/t 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:(13230022)(396003)(39860400002)(136003)(346002)(366004)(376002)(451199015)(83380400001)(38100700002)(86362001)(66476007)(2906002)(8676002)(66556008)(5660300002)(66946007)(8936002)(41300700001)(1076003)(9686003)(26005)(186003)(6512007)(6506007)(6666004)(2616005)(6916009)(316002)(478600001)(6486002)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: FA7FmYEalscKPb7ltYZAxRBhdJPTVaqAPqIgF3y3ZQ7Ow3B7xVjRkAxKtHO5QL54V7cllc4xWwMHW1KmbXvx+IOJnjPXKxN40ACAYc5C/VUBqyNlgET2x7uhUEN/Mtq1ti30Y70ZiqGXbXnKNkNejp2bfiTsswXHt7XVAQS6Kg9BW4S995GpwIiLuO+PcL5xhGo0djN+cFeRZ4T/WubfT8LgcfD2qHm2m58luSPfCeke17dE2YzaDrfDFSF6L9ZTxxTI9lTII484las4dXNThJrzy4aTzPlxLd7F1dlh9kdOB/TOfqdqmJk/aLzbAwVpfrsokUlIJy+psGJKyFCe3dLjkiAcTOqm0QucCffZaMjg66+Eyz4+HuyGXW3gywCkeiMijORXtZlWRc460M7tt2QG0iwi4/+JPHEFOV0CYr1DRSPuuRaSerU2PBCkljxEWDRz0nNuLYRIMSPjQSz70xuWUqTzbRSS5izOaWrLN9UmKmB15AIohJVSloPCX+6KDv73A1cWvZybxxkG+bzsNnW9IXcSxrMGHDN14AT4PUd9B8Rgb187+BkPAijRup76ldFYPuvm0cNcvFsiGPTbCPwSMZ/OWPFp6gpRkP9zzCIBUnoBEtjYEFUT18Z1VA4J41uNp65fJnJKf3ihUaI8ZsF2kG3gcu5RbuA1wnr/umA1GpqLXsUJH6STsvM6BRtGxIvlDATGonpBenSyx5wwXIGSpUwb3OCLOkS5TBd5EhzhS+sgeCuEn1iGA5OsX3TUTKmXReokKLgLpJMVA4b/yOf8ZC7HzGghr7dpuhtksvE4ia3U7G7rNdmIMGMStt//KCMufNCGwwISBh9UZ2b8kkRvrF8/bvLSYf8cI1A19WJV4T4a32F3q6tjgLK4WUaVK+Tdc3MuO35WlXHg/EVBwQuTia+Tty/HtbvP9qp0isgn0mpcNc6DKPcKYa+0yfZsvhRMcKk5KCJ3d9RnAxJNmva0zlWiwiCoE9xo1/Hr/zCsJd8j91tV8LxRcWopAUpp0al4O6ZnMdzN74qkJijrPiz5jmc5wzzhaP6v+1Bd9vjcvBtfjkXljdG5MB3BLFUJ+5wTXqceRpGWGju8BebfTqqFfiqFabc5ulLNxli3YpFBYFG2fCjQLCSoWMRyJxGcWdRAeScr5FD6hrUKpPbwLGzzB1PKHLO3sFtkyO1ocLGxxvl308lN3dnfFWJiaB6qcQnBpsXRozTAldNyfRm3SM7xw+wea+4m2ePfKiG5/QtSsLKqVA1FWpG8RrzhPMlAQZx8EpTROwATwDwKAJiGINRlJBpuEWltOrOhNy2sFpb/iRBfmqEeHPC0QP3u1+HcJLiWsu2QablvxVziO+CBcBDJPNlNNpVFPH+zo5oDrSwQQF89cCk4Ue8hxdqKHw76WcS0fC4DQpbjevVn8nFzPA87GiC6flBNkOxselW5cxp3fxez79FntTmdNBxpHNfkOFS0Vc4YApeTfM5EBiYSQQJGzauWJvPkSox8GtyzBrJweOPHvzNdORmOl4xokBfz2uX4jjVJe/e31AmOi4UPn4nmj2984qUE0WXZ4NAF6IjkLruG27WpHNkB//tXekTEBn6raw7ftE2wzZXdbs9CCQ== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3e7d1cf4-d878-4c3d-5ec0-08dae0df1b72 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Dec 2022 10:03:26.9780 (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: gKzN2O17+HHQko0cFNwJpbfnjdtRMYA5zGx28+tjP3a3+u7/OQYIM1DmvYPhYDdsnzIdfq/hqSp/FJAhay2M227AhNmAkay6l4aiszxNWXc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4536 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-12-18_02,2022-12-15_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 phishscore=0 suspectscore=0 adultscore=0 malwarescore=0 spamscore=0 mlxlogscore=999 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2212180095 X-Proofpoint-ORIG-GUID: 1OhRuohPXyx2pNmtEhuUeWkJyx8XD73R X-Proofpoint-GUID: 1OhRuohPXyx2pNmtEhuUeWkJyx8XD73R Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Allison Henderson We need to define the parent pointer attribute format before we start adding support for it into all the code that needs to use it. The EA format we will use encodes the following information: name={parent inode #, parent inode generation, dirent offset} value={dirent filename} The inode/gen gives all the information we need to reliably identify the parent without requiring child->parent lock ordering, and allows userspace to do pathname component level reconstruction without the kernel ever needing to verify the parent itself as part of ioctl calls. By using the dirent offset in the EA name, we have a method of knowing the exact parent pointer EA we need to modify/remove in rename/unlink without an unbound EA name search. By keeping the dirent name in the value, we have enough information to be able to validate and reconstruct damaged directory trees. While the diroffset of a filename alone is not unique enough to identify the child, the {diroffset,filename,child_inode} tuple is sufficient. That is, if the diroffset gets reused and points to a different filename, we can detect that from the contents of EA. If a link of the same name is created, then we can check whether it points at the same inode as the parent EA we current have. Signed-off-by: Dave Chinner Signed-off-by: Allison Henderson Reviewed-by: Darrick J. Wong --- fs/xfs/libxfs/xfs_da_format.h | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/fs/xfs/libxfs/xfs_da_format.h b/fs/xfs/libxfs/xfs_da_format.h index 3dc03968bba6..b02b67f1999e 100644 --- a/fs/xfs/libxfs/xfs_da_format.h +++ b/fs/xfs/libxfs/xfs_da_format.h @@ -805,4 +805,29 @@ static inline unsigned int xfs_dir2_dirblock_bytes(struct xfs_sb *sbp) xfs_failaddr_t xfs_da3_blkinfo_verify(struct xfs_buf *bp, struct xfs_da3_blkinfo *hdr3); +/* + * Parent pointer attribute format definition + * + * EA name encodes the parent inode number, generation and the offset of + * the dirent that points to the child inode. The EA value contains the + * same name as the dirent in the parent directory. + */ +struct xfs_parent_name_rec { + __be64 p_ino; + __be32 p_gen; + __be32 p_diroffset; +}; + +/* + * incore version of the above, also contains name pointers so callers + * can pass/obtain all the parent pointer information in a single structure + */ +struct xfs_parent_name_irec { + xfs_ino_t p_ino; + uint32_t p_gen; + xfs_dir2_dataptr_t p_diroffset; + const char *p_name; + uint8_t p_namelen; +}; + #endif /* __XFS_DA_FORMAT_H__ */ From patchwork Sun Dec 18 10:02:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 13076007 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 6EDD9C4332F for ; Sun, 18 Dec 2022 10:03:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230030AbiLRKDg (ORCPT ); Sun, 18 Dec 2022 05:03:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60124 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230245AbiLRKDd (ORCPT ); Sun, 18 Dec 2022 05:03:33 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ADEF25F79 for ; Sun, 18 Dec 2022 02:03:31 -0800 (PST) Received: from pps.filterd (m0333520.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2BI5KweD015523 for ; Sun, 18 Dec 2022 10:03:31 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2022-7-12; bh=H3b8ZQhjDsQS/OiU2IYq+79S7oUoBWJn26hBtJprubE=; b=jshyaDu2LUkpJCUHzjYWGs4nARupubvzBSe+5rYqvkaGLQ4nq6xe9bR5v4mswhFTCIKF rK4xABKwn5UwMOTFdNS6wBaXfoq76PpgwnNC/cfQwsAjvZF1/JollsTLPJq/StNbQyji 5Lqum6z2ybuaf7mLrMK/V1gB9SUzsF4850dbsA3P18oIoKg8LZ+xn9C1efs/TG7FXMMs Kyd6CJNqbGhnFu+7eJq9eDlZg3+ozwBcK7KqvcEVGymwxJo+TYNelHHQWKyeieFa78CV U7kUakK6gfkWKVKiy+r7zYVirbAq+2cPneem3rW5MoR3vMFkzrKtOBYUQSR9ctGVJjCn Lg== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3mh6tss9my-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sun, 18 Dec 2022 10:03:30 +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 2BI8B7Eq006852 for ; Sun, 18 Dec 2022 10:03:30 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2177.outbound.protection.outlook.com [104.47.55.177]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3mh478n3tp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sun, 18 Dec 2022 10:03:30 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kho00Ttoo2r9TW7+f5XSS8udp27TsDhOYsdklT/iGL4hwoIgRzUecyZW6rKUADLBRCUZvg4rCDhkBYaYxwivfY8qI46oo55Bc6zEBijNEm3MADBmOpy9bEh3qcNmGg6tuoEK7Z//xhNyUNZY+xy/zWAU7UHhgkd24+OgVE4EdUeCoXatR0BHetIyvk6wZAf8c2OPo2yOyMGFKXnxexomp6/L2CG3UgdjWhsAdrXaJuteMga4bBOuUPsGISByLDsE4wpWpwcu4pTNCiScXG89mLCjPQWhN7daf1hOw8d7EcnHnrtX8AsBQhuXfYmdlQu3XzEWfEbeMT31GnSxKAQNIg== 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=H3b8ZQhjDsQS/OiU2IYq+79S7oUoBWJn26hBtJprubE=; b=Ze5h0tZ3RsNSfWU6fO/QVHiEBxoQIlU0AMX1qkbRwiap7dspfRmrjBNqnxgLr6IFJHM7T0s0fkWpqyOnBT3ylFXL3lIJGIkgviSed+1lnbtgkvr+PAnUl0M2N3mvKm/81EBByRWW4BnoE7ODa7o18i8PzQt3ToyI3luwcGs3XSX2pB5+qrpibX22Ac13eNn6uzodqDkgVhDMHWnP2uXJ7zZnRdqb8U0e8zGLkASZF5c7Ly9AlmdDWyye2MxwqZh2rWgP9PClXD/hr6nIMGg3kDg7WXnlGTqVG55KFRR+ZTBL9A57wNhcmVWa3lXtJk57MNnL0Jo2eogylUSBrrKK3w== 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=H3b8ZQhjDsQS/OiU2IYq+79S7oUoBWJn26hBtJprubE=; b=ycudqvo88eAV7U2qnkupjg5gZycpBxOjoPGWydrh+VEVSwsYG23wgnfFW1gH8g1lRHyN1B6EtevFLurI7RE1JORECzA+IGS2sM+RWX3TStbQUbvIv+RuHDZYLq0MLCBcZZ/rhPvC15YYz9/fj/vC5ZiPVjI0IwYhg0qTy1RTB64= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by PH0PR10MB4536.namprd10.prod.outlook.com (2603:10b6:510:40::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5924.16; Sun, 18 Dec 2022 10:03:28 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::3cab:6ff7:cb4d:b57c]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::3cab:6ff7:cb4d:b57c%4]) with mapi id 15.20.5924.016; Sun, 18 Dec 2022 10:03:28 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v7 13/27] xfs: Add xfs_verify_pptr Date: Sun, 18 Dec 2022 03:02:52 -0700 Message-Id: <20221218100306.76408-14-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221218100306.76408-1-allison.henderson@oracle.com> References: <20221218100306.76408-1-allison.henderson@oracle.com> X-ClientProxiedBy: BYAPR01CA0050.prod.exchangelabs.com (2603:10b6:a03:94::27) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY5PR10MB4306:EE_|PH0PR10MB4536:EE_ X-MS-Office365-Filtering-Correlation-Id: 6ca719ad-d719-4e6d-7e50-08dae0df1c54 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ByXfqUPqko7C9jnYyfwq665rW0x8lvArJGBvms2QKbIYpo72O9mdZSYrstNHAxtP72D4KbyD7bKjswfVBmW8O7TNA1RvZgkOfD+h8Rk5U+k9wXk7n6RKUOf+b7jUA0zhqzIBHsxFx3gr+ii6Klt4AB31iFIloUkUE4TZqEuI6Yiqo3OwuqtvGz0RahS04HWHFSxSMS0eWN064rji9o3hKCxf8agi6yQtn4EpY0VMYRulhWVSV3/2jFUWAfcAcIaLrvc/54fOeRHbQnfs586NvcA4F3mBiHsNrX2jKPBqYK7MlxcOmkXnHpRAwx7aNYnYYYRTHQAb0wT48Ce5io90oameqWxXwmryc0a7pMl3ibFMeQD6jH0/km5If3RtTrsY5FWuzM9K62caPN3patsW0M2vxg15knlHT8x1ZgTb2Cd2tDD1z8SVLa9Aqawmt0zJF5gmZI/j0L5dpT030K78DDYN+ktJ3/+Uaru8QWdw/dOVUUunkWkZ/Zquv0T8iEc4pqXg0njDEfHuuTDDBtD4D3xTnJroC8aKR/aIGd//5JUXoUnbVqfn4Eqx8Dcmj/A3fhNpaVlOOXNaMagzAO+BqfNNpHushGMEuA3+G4l9TEg252fsThezAnCUb0HRQcKkLk/GgK61681INqszqd2wUQ== 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:(13230022)(396003)(39860400002)(136003)(346002)(366004)(376002)(451199015)(83380400001)(38100700002)(86362001)(66476007)(2906002)(8676002)(66556008)(5660300002)(66946007)(8936002)(41300700001)(1076003)(9686003)(26005)(186003)(6512007)(6506007)(6666004)(2616005)(6916009)(316002)(478600001)(6486002)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: KzrzG8cHGYog+Lo5q3MCSToAgWYMGBw6UGIfcjEKUkxfAiCWQtrT/BApwQFifjASBNGIdGx9SX5iONIvVkjUyEEYvHkyYZjkaBHWV6A29hf3YbojYhFse9psS/k/F0c0AHp6G5cB6MrXin8rGruLdSR/AJN/KuCchllSdno1qxE1umSS+su/HdhE/FSd3nCs7ITxczITlN1plPykCbtCHnEKupQj6IIAkM8C6fMqJwE2b87avPvAlee9ogXSCXtL7F2IyOA9kZdMpUEDOXRgRCElq+LIj5Crgq+YN7js6iYx7w047aj3RRbVyNwyqzalsfuuuTJwJlgiEGdxvmpStCre5B/EhVZjUlbVn+odM4ZiP1Rosl1Imw7jg6RAtpCfhnpgUiPr6Hmfsxm0j0i/ZZKx1IbBHRvTngHxusMOTtJzgstzpPBPYPxjgluIv2dHdMhapEdPh10/ZjDDySr2hX+OIcn5S9dPQy2i9XRF55TePrutDpAZUmBFOoaT30xKbwk2Wd+mGZ50LXoszVoceutd2a81jm16UbIuBlzzqs/HqC2xEGnDP0TGQFHATFwC3eEB/uik+5QnA6sCqPh5WhrS+WRn5vM5joyOzIu9fXQ0qQdafjm0Iozk8Dm8yKALCvgm/gq39uKKonYJ+ZH2VumP57/aDOCX1S+s0rgD+BeSmm+HxTV0ByHNUKieVGcRdoISkwaER4VyPsy5UxGqlV5/zkLwISOUT3cAHzkB9B0T49nPkm0BWNADtRdPmbjcaGHPypEYDGYzze+tf8XThPX513CYrZoPOF89H92go3j0QWkQ1EDCJSJghFidl/RVGj64LhKTwa7KZ+BsEYD/Tahw7JoeaSHsuPsRibDHtGiRVorgtvJLp9jA9EmRNrdEvHndIsfv0CbMUrEHjtNjqXZmGF5gJGlWAHCJWOtFKFlp8Rls+GnIIjvQ+dDtYPyjzAc2UyEq5H0YFuwclEGt1b76T19rTiqTIkOmF4VPVs19erp4Hrkm0E5sPgPdpyVRCuE8298TUq3KxzrYVq/z6CyJLGvY2pse4JnPhvS+zI42HOpK/vPdfrOUDq0UD6uBYREG/g0JhFSOqZM27N4YH14EaAv8yy3e9M1m8OrYGP5d+ktM+nXfgGiPnajaMjT3PowmdNswNy23GTnqFu+1I9aydEpv+ZMZa/WjTt296DJMDNbQL1vlCnFjfLvSKbuji6yCHlTtuiTWNkgn4kB42cTydoGGVZT6FDk2S3NDVbptKllo8V1MeiHViITrEbdHmxq6X20CFBH7eblUFgMphvyRTLd97k3++dERII3Z/txXodVpxHg15HmoEyDbkiBwerPDt60YaNoKE9QabNQ4hm2WPBZo2tACMDDvs+EpVZ8mTTBur2YY0kQtZDkigQHJKehX56I0E/Zgf/CYkQh0DWzWuZatk/9urbu2BGz6QJmy4O7iLEqWIl/j3re8DQ8wnAs9HR03TRHHHmMXgoLjb/kyxgigvjaK+SDn/FBDgxDqOyqlq9OcLIS/5OnBQv+9nAWY9L4+V+5/nMPlAlr1kE+yELq77WxAhhGYIoht1nk6qe8zUkY5lA5gPWcdEe5VkoPZ3FG6FCtM+dAdLfcLdw== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6ca719ad-d719-4e6d-7e50-08dae0df1c54 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Dec 2022 10:03:28.4768 (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: Yqbf/cM6FGd1Z3pcETeCblNE5qRgKyDi9h/wvt1t/apTKcItRhAStn71n5hZZk089woPHetbtCSnSaTmwR2YNUpmHWMfc/i0RI8KbJbA1DM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4536 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-12-18_02,2022-12-15_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 adultscore=0 phishscore=0 mlxlogscore=999 bulkscore=0 malwarescore=0 suspectscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2212180095 X-Proofpoint-ORIG-GUID: 5YCcPr7_Bgu8gCSJrsvPW5lvbIp7KHOU X-Proofpoint-GUID: 5YCcPr7_Bgu8gCSJrsvPW5lvbIp7KHOU Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Allison Henderson Attribute names of parent pointers are not strings. So we need to modify attr_namecheck to verify parent pointer records when the XFS_ATTR_PARENT flag is set. Signed-off-by: Allison Henderson Reviewed-by: Darrick J. Wong --- fs/xfs/libxfs/xfs_attr.c | 47 ++++++++++++++++++++++++++++++++--- fs/xfs/libxfs/xfs_attr.h | 3 ++- fs/xfs/libxfs/xfs_da_format.h | 8 ++++++ fs/xfs/scrub/attr.c | 2 +- fs/xfs/xfs_attr_item.c | 11 +++++--- fs/xfs/xfs_attr_list.c | 17 +++++++++---- 6 files changed, 74 insertions(+), 14 deletions(-) diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c index 101823772bf9..711022742e34 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -1577,9 +1577,33 @@ xfs_attr_node_get( return error; } -/* Returns true if the attribute entry name is valid. */ -bool -xfs_attr_namecheck( +/* + * Verify parent pointer attribute is valid. + * Return true on success or false on failure + */ +STATIC bool +xfs_verify_pptr( + struct xfs_mount *mp, + const struct xfs_parent_name_rec *rec) +{ + xfs_ino_t p_ino; + xfs_dir2_dataptr_t p_diroffset; + + p_ino = be64_to_cpu(rec->p_ino); + p_diroffset = be32_to_cpu(rec->p_diroffset); + + if (!xfs_verify_ino(mp, p_ino)) + return false; + + if (p_diroffset > XFS_DIR2_MAX_DATAPTR) + return false; + + return true; +} + +/* Returns true if the string attribute entry name is valid. */ +static bool +xfs_str_attr_namecheck( const void *name, size_t length) { @@ -1594,6 +1618,23 @@ xfs_attr_namecheck( return !memchr(name, 0, length); } +/* Returns true if the attribute entry name is valid. */ +bool +xfs_attr_namecheck( + struct xfs_mount *mp, + const void *name, + size_t length, + int flags) +{ + if (flags & XFS_ATTR_PARENT) { + if (length != sizeof(struct xfs_parent_name_rec)) + return false; + return xfs_verify_pptr(mp, (struct xfs_parent_name_rec *)name); + } + + return xfs_str_attr_namecheck(name, length); +} + int __init xfs_attr_intent_init_cache(void) { diff --git a/fs/xfs/libxfs/xfs_attr.h b/fs/xfs/libxfs/xfs_attr.h index 3e81f3f48560..b79dae788cfb 100644 --- a/fs/xfs/libxfs/xfs_attr.h +++ b/fs/xfs/libxfs/xfs_attr.h @@ -547,7 +547,8 @@ 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_attr_intent *attr); int xfs_attr_remove_iter(struct xfs_attr_intent *attr); -bool xfs_attr_namecheck(const void *name, size_t length); +bool xfs_attr_namecheck(struct xfs_mount *mp, const void *name, size_t length, + int flags); int xfs_attr_calc_size(struct xfs_da_args *args, int *local); void xfs_init_attr_trans(struct xfs_da_args *args, struct xfs_trans_res *tres, unsigned int *total); diff --git a/fs/xfs/libxfs/xfs_da_format.h b/fs/xfs/libxfs/xfs_da_format.h index b02b67f1999e..75b13807145d 100644 --- a/fs/xfs/libxfs/xfs_da_format.h +++ b/fs/xfs/libxfs/xfs_da_format.h @@ -731,6 +731,14 @@ xfs_attr3_leaf_name(xfs_attr_leafblock_t *leafp, int idx) return &((char *)leafp)[be16_to_cpu(entries[idx].nameidx)]; } +static inline int +xfs_attr3_leaf_flags(xfs_attr_leafblock_t *leafp, int idx) +{ + struct xfs_attr_leaf_entry *entries = xfs_attr3_leaf_entryp(leafp); + + return entries[idx].flags; +} + static inline xfs_attr_leaf_name_remote_t * xfs_attr3_leaf_name_remote(xfs_attr_leafblock_t *leafp, int idx) { diff --git a/fs/xfs/scrub/attr.c b/fs/xfs/scrub/attr.c index 31529b9bf389..eed743adb0cc 100644 --- a/fs/xfs/scrub/attr.c +++ b/fs/xfs/scrub/attr.c @@ -129,7 +129,7 @@ xchk_xattr_listent( } /* Does this name make sense? */ - if (!xfs_attr_namecheck(name, namelen)) { + if (!xfs_attr_namecheck(sx->sc->mp, name, namelen, flags)) { xchk_fblock_set_corrupt(sx->sc, XFS_ATTR_FORK, args.blkno); return; } diff --git a/fs/xfs/xfs_attr_item.c b/fs/xfs/xfs_attr_item.c index 95e9ecbb4a67..da807f286a09 100644 --- a/fs/xfs/xfs_attr_item.c +++ b/fs/xfs/xfs_attr_item.c @@ -593,7 +593,8 @@ xfs_attri_item_recover( */ attrp = &attrip->attri_format; if (!xfs_attri_validate(mp, attrp) || - !xfs_attr_namecheck(nv->name.i_addr, nv->name.i_len)) + !xfs_attr_namecheck(mp, nv->name.i_addr, nv->name.i_len, + attrp->alfi_attr_filter)) return -EFSCORRUPTED; error = xlog_recover_iget(mp, attrp->alfi_ino, &ip); @@ -804,7 +805,8 @@ xlog_recover_attri_commit_pass2( } attr_name = item->ri_buf[i].i_addr; - if (!xfs_attr_namecheck(attr_name, attri_formatp->alfi_name_len)) { + if (!xfs_attr_namecheck(mp, attr_name, attri_formatp->alfi_name_len, + attri_formatp->alfi_attr_filter)) { XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, item->ri_buf[i].i_addr, item->ri_buf[i].i_len); return -EFSCORRUPTED; @@ -822,8 +824,9 @@ xlog_recover_attri_commit_pass2( } attr_nname = item->ri_buf[i].i_addr; - if (!xfs_attr_namecheck(attr_nname, - attri_formatp->alfi_nname_len)) { + if (!xfs_attr_namecheck(mp, attr_nname, + attri_formatp->alfi_nname_len, + attri_formatp->alfi_attr_filter)) { XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, item->ri_buf[i].i_addr, item->ri_buf[i].i_len); diff --git a/fs/xfs/xfs_attr_list.c b/fs/xfs/xfs_attr_list.c index 99bbbe1a0e44..a51f7f13a352 100644 --- a/fs/xfs/xfs_attr_list.c +++ b/fs/xfs/xfs_attr_list.c @@ -58,9 +58,13 @@ xfs_attr_shortform_list( struct xfs_attr_sf_sort *sbuf, *sbp; struct xfs_attr_shortform *sf; struct xfs_attr_sf_entry *sfe; + struct xfs_mount *mp; int sbsize, nsbuf, count, i; int error = 0; + ASSERT(context != NULL); + ASSERT(dp != NULL); + mp = dp->i_mount; sf = (struct xfs_attr_shortform *)dp->i_af.if_u1.if_data; ASSERT(sf != NULL); if (!sf->hdr.count) @@ -82,8 +86,9 @@ xfs_attr_shortform_list( (dp->i_af.if_bytes + sf->hdr.count * 16) < context->bufsize)) { for (i = 0, sfe = &sf->list[0]; i < sf->hdr.count; i++) { if (XFS_IS_CORRUPT(context->dp->i_mount, - !xfs_attr_namecheck(sfe->nameval, - sfe->namelen))) + !xfs_attr_namecheck(mp, sfe->nameval, + sfe->namelen, + sfe->flags))) return -EFSCORRUPTED; context->put_listent(context, sfe->flags, @@ -174,8 +179,9 @@ xfs_attr_shortform_list( cursor->offset = 0; } if (XFS_IS_CORRUPT(context->dp->i_mount, - !xfs_attr_namecheck(sbp->name, - sbp->namelen))) { + !xfs_attr_namecheck(mp, sbp->name, + sbp->namelen, + sbp->flags))) { error = -EFSCORRUPTED; goto out; } @@ -465,7 +471,8 @@ xfs_attr3_leaf_list_int( } if (XFS_IS_CORRUPT(context->dp->i_mount, - !xfs_attr_namecheck(name, namelen))) + !xfs_attr_namecheck(mp, name, namelen, + entry->flags))) return -EFSCORRUPTED; context->put_listent(context, entry->flags, name, namelen, valuelen); From patchwork Sun Dec 18 10:02:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 13076008 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 254BDC4332F for ; Sun, 18 Dec 2022 10:03:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230296AbiLRKDj (ORCPT ); Sun, 18 Dec 2022 05:03:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60152 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230245AbiLRKDh (ORCPT ); Sun, 18 Dec 2022 05:03:37 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 98AC755B0 for ; Sun, 18 Dec 2022 02:03:33 -0800 (PST) Received: from pps.filterd (m0333521.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2BI5WDjO010788 for ; Sun, 18 Dec 2022 10:03:33 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=6tYSEWWb1wiKYWw2+XP6sFmWvJlNNBn4jDtZsPv6VNo=; b=JvYNAxTy47ctoLj+n81Qs3UCuJd8vQN1/d5nPCnUt2K+nbQiKs9DQAQuq633bexcePr3 S70k6KmwJlcshsWMUbAlJgD0NxOowVph3KhvwCIauOLARRxKH2k2yzGSuX23xWrxD2FD IMhnW3cqbhoqFknoPGKUNh4kHYTXKhdVltNsNcDXxksts+W/3DuztE259qs1PnELc/FB tm3W+1HLtLmiT5S2G4Nvb6Bz++0cZyG6ZSf3cTcEXmUOSfqk7BnYGubkqf5jzcw6cWL0 22TXBLG44VDvBpDJcTOHfdcU4XCp6w4qvlrZ5vPXam1reeKLRqM2wgs2w4jyDYGTxiJW /g== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3mh6tn99gh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sun, 18 Dec 2022 10:03:33 +0000 Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 2BI8SAqj007072 for ; Sun, 18 Dec 2022 10:03:31 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2169.outbound.protection.outlook.com [104.47.55.169]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3mh479cbpp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sun, 18 Dec 2022 10:03:31 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ToaZfIjmk318q6xLa1M2HJJ1E8i4B8E9vkaXet5WsSIDAP/b5BUElXrAWb7ve+jIl+6Mnn1DFjo92Bn6uqim5aJyz5s5GQmAuXd9nkRFbJUoPcxKf45jgCwJfvalfJvtVtrug0JrB1S5WAvl0Up4x7kCqGL/ScNPfENIuuCFTGOWynUFAjaDR/iNLaXg8TPm2o+zeix5NhtwmoF+W+zv4VYyigviIPgjtQxEyUvkQta5wotnZOetXS7DT8SqcwBLDUMacWpRvtZsJdaQjQQ0QkKXlhNexBkp5dNjQPnW+NlIJglj4NIE0x3vI1ECzW1cAN9XFLZlSftgMZ42Q6Z41A== 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=6tYSEWWb1wiKYWw2+XP6sFmWvJlNNBn4jDtZsPv6VNo=; b=bycbFuZh0h9nawiOdZ7ZeAJovKeLAHuzUAtrKPm8yNphvYXQ28FhbpLRYB7paZ9AjpFiC8tG1MJjXcF+jbEHCosm72Lu1RpJzgBp7Ijg0+GvjdkmT3WBOFYFalthnIBkj25PBT8Y6KiTR50c0B6dIkbswm9TxBAxMJSEk0hvgERkak4LR9Wghv2d2YukzLp7XQL+b6V2czmrsZMEaISfklqDeSfKTKFiZOXTA1EqJXM8XPH0g6RIhfa8yBHE5mst7ho3nQ7HOj9O5t1rMZWI6e9rVd2Ev18bMcBdozx/ZntUDzb1SbBL3xLqDUbAvtnnlFkR7em8EC4lQuVsyKwldQ== 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=6tYSEWWb1wiKYWw2+XP6sFmWvJlNNBn4jDtZsPv6VNo=; b=thKw0kBvjGXiuXUq3A1tMEmiB5ClnMfY56nEhXCwxC7Q7fsDMk1i1mjRJJDVj/68IW2PjPCAGAHXsN6U+sPqSUexotQSDOTb4gXa+Gzz6L0YNa4J3TrodQuYaUVk55cuP5fM73E56TYSjJ95yC9hx31CHT1KzKozn3gn3PigVMc= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by PH0PR10MB4536.namprd10.prod.outlook.com (2603:10b6:510:40::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5924.16; Sun, 18 Dec 2022 10:03:30 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::3cab:6ff7:cb4d:b57c]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::3cab:6ff7:cb4d:b57c%4]) with mapi id 15.20.5924.016; Sun, 18 Dec 2022 10:03:30 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v7 14/27] xfs: extend transaction reservations for parent attributes Date: Sun, 18 Dec 2022 03:02:53 -0700 Message-Id: <20221218100306.76408-15-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221218100306.76408-1-allison.henderson@oracle.com> References: <20221218100306.76408-1-allison.henderson@oracle.com> X-ClientProxiedBy: SJ0PR13CA0234.namprd13.prod.outlook.com (2603:10b6:a03:2c1::29) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY5PR10MB4306:EE_|PH0PR10MB4536:EE_ X-MS-Office365-Filtering-Correlation-Id: 6c339123-d9fd-4a87-7e5e-08dae0df1d3e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ewk9d7K3SDutxh1U5KmjVOlX5GooCFOS49Vz4VYBjdBcyTy6lWOVrdYvYeG6I5pDeTzNJJ8KRyy6rti1Tg+3zrz+BiSh15UvAAY2PVkNl4aHhzCQ1MiN9gy/osxkBWzOX+KUG8vu6C1VbbkM8ZT3WjwEk6cQcIVeUotEQiZ7QdBmZsPrJwN7oD4fiuDeG2mlg+DJAPFm9eHp0PMhlo25D3ukooY7Rq30W/CtOJOWv1pNVvP8hKmo1q4SPrT+79H0uAAtk85iZo5+cKfjQyJnBhgLXyBEJcp0LavsxQFDv+j8EopgddhxoyXMQRxy0TisOc/W/w1C9X+06sSJQKzghIUJv36oe350G3+IU+FdnVHRgJOkC9cymFdwao7AUzBOGwqKpxC6ekAZpL0GXaC81Nv6btdtVxrf5d99QafRc6hhFenS4FInPPJjg2dU8JeGuS8PQHF9yaUPJzRleaLpL/pkcBSo80BAt15e2DDRddZ24iN5Fq8TRUPYiWFCn95eLkpwbnB+DJnfpy9SkwNH0/nnohKgxDdYNIJQonKzEdNSMngR9Kb4oHPjt/okJBgdsQLL6Hjgp+HYr3EEKvqt+8MnFE3rIS+MntEjo4RJSp726wYdVsQEgsQbK8CUHna6YhqLBXyY9Oilr8rJxrlXJg== 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:(13230022)(396003)(39860400002)(136003)(346002)(366004)(376002)(451199015)(83380400001)(38100700002)(86362001)(30864003)(66476007)(2906002)(8676002)(66556008)(5660300002)(66946007)(8936002)(41300700001)(1076003)(9686003)(26005)(186003)(6512007)(6506007)(6666004)(2616005)(6916009)(316002)(478600001)(6486002)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 0XT4bZ9Sg8ZLZQoqvfqJR6xy5Ds+Kq0cIWi2bHcnz3u3abphz7GiQYx7pUuCWCiq5nDyC1UdOTHekyFMKU2IfuJgQMg1PyIsh56tp0dGhP8DP/QAnL7998e9H3zxaYbx5pYMOc220n+4AfeCiOHRt+AK/8bJ8xy1B7xxUwZIAuCOPFd64x2VLTHmWBfrQNBr+Rk3QzlP8fHfWQPkwo3pAomTPTDNJ1ohTE+LqcnqJOryyZvAbLrpsPbpYydWZz/I0wc2YFkZpoeNOFNFf2108H3OULbuaEyjuUU21m3Pwxu8qS07nQjOUa9JSfmioU1MZ3OoDmvTxyNL8sNs67OGzJ1cO+WPNzCB7pfIMnbGF0u8LgaBxu3lHUbXgPGaZDac/Vt3v8IwzoPKMIsEBF4CZatokvAjoQRq9wDN1RK6o2v9bwxxHmCXovb2zl5cXp1+yZew7ORYOlAO8SBOc5S3Dzc0THWgc7V4EpWqfOSBXzUvZ024OLiQDx+OtTS+GgMj+3F7IQFqCg/4w3VfqWVsTfFAL/sEZoUcRxyNUrZ5qFODX15J/8Qi6uU3WYsESy+ZTU8rnxNP7xKGhfhYcaj7svp9bhVeXnu5ZbFOThdnFLXKL0Hwo1KkZaxhsR0Kgfe7CLJuoxDdxYiYj4CuXtI4bTSNPsmgbXSt3X7PecfVx0W8tOZRq7dAthmHoHRWj00pqaly3xkS9gqDVfqewtnGPz7MrQ8NGqiqeidvks9t+CB1GjSBpY8YPIDEZ/GBTEkNlngmfAtJdi2D7D60xdvj/N7pLuSC86uGX0XEMrz+qLSiWChGS5qf9l/ltxBbdMytqnDLBBTuAmt2j2xEQqkwvD+lEktsvaG/YkaYxyFBidk4YYJVPn8F23kjpx9fz79ihfZcEaP8wVk8XnVQ0nvpBd9Gh7Q7vUQ6O3LSwLenEOTx8HkLqnZDLQqzP+qRSmrVxoj4kD9BP4zjO8zztDo6rVwO1+xPEWyoNyhd41nqlMuq/SA+6iaG2pY2xH7h0Ld79ZwbjdBTFPcryXYUBsTnymmVaAnPXpMKal+/Ursal9Xv7TPXPr+UG1ITBIjxx5av1JyDfitGdr8oUXbo0MBnF2C3WixyghkNJoG0/l99srwANAQWlCml1wQR9nAjbeE39YrzLWiid2mGRLoOYGgjpnMOzcVZpFjFETUNEc4tfAN7NIxYAc/ep1uCmtVpdX27DkcTsjuuAhAocxBrPyEkPTuleS2jozzIPfEKgbj9/WranGYGp9DWdXBaRY69vYFYoFgWdH2LAUl+Kb2oMcnG3nveswgYR9T1Hv5h4qi3FJlyvTJLrouhN+axjifGMwNjw0o/K55+FEtTjJx+yHMW4//iJ0+qqzl0S6gFpMR7MBn5YKqiIhDFT8xZLh9lI2BtNshESJpMLwUu/tvhI2b6kBMrRn29tFG7qUNrPDeEIRz8JKb+kM6M9T/qKjpG7EMaTrimf+XiyttwqiIG++jIpalRxyA4+bd9xGdT9uw1Yl00CafQaVDXhsXFs3kd7LTomTo9jJvZbhSbo+pdHpZYhSCCmQjuMiKWkZ8drstuj/caoRTdvPIMLkLXsHDkF/KldcVLdmbM7aIHKgcoosRGqA== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6c339123-d9fd-4a87-7e5e-08dae0df1d3e X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Dec 2022 10:03:30.0089 (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: u+203Niz61EURBJ9kyPT1+ZZfGfWZeB2GFt+m8Og9x2/ORdQJ8ZyH8PG0QuwzGojWzAebrG1GygsOb0EYRGPwtyIlVTGdL94iJqXwHUJvDE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4536 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-12-18_02,2022-12-15_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 malwarescore=0 phishscore=0 suspectscore=0 spamscore=0 bulkscore=0 mlxscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2212180095 X-Proofpoint-ORIG-GUID: vtpAqIeeziTYz32ZVjLYtiqcA90efOo0 X-Proofpoint-GUID: vtpAqIeeziTYz32ZVjLYtiqcA90efOo0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Allison Henderson We need to add, remove or modify parent pointer attributes during create/link/unlink/rename operations atomically with the dirents in the parent directories being modified. This means they need to be modified in the same transaction as the parent directories, and so we need to add the required space for the attribute modifications to the transaction reservations. Signed-off-by: Dave Chinner Signed-off-by: Allison Henderson --- fs/xfs/libxfs/xfs_trans_resv.c | 324 +++++++++++++++++++++++++++------ 1 file changed, 272 insertions(+), 52 deletions(-) diff --git a/fs/xfs/libxfs/xfs_trans_resv.c b/fs/xfs/libxfs/xfs_trans_resv.c index 5b2f27cbdb80..93419956b9e5 100644 --- a/fs/xfs/libxfs/xfs_trans_resv.c +++ b/fs/xfs/libxfs/xfs_trans_resv.c @@ -19,6 +19,9 @@ #include "xfs_trans.h" #include "xfs_qm.h" #include "xfs_trans_space.h" +#include "xfs_attr_item.h" +#include "xfs_log.h" +#include "xfs_da_format.h" #define _ALLOC true #define _FREE false @@ -420,29 +423,108 @@ xfs_calc_itruncate_reservation_minlogsize( return xfs_calc_itruncate_reservation(mp, true); } +static inline unsigned int xfs_calc_pptr_link_overhead(void) +{ + return sizeof(struct xfs_attri_log_format) + + xlog_calc_iovec_len(XATTR_NAME_MAX) + + xlog_calc_iovec_len(sizeof(struct xfs_parent_name_rec)); +} +static inline unsigned int xfs_calc_pptr_unlink_overhead(void) +{ + return sizeof(struct xfs_attri_log_format) + + xlog_calc_iovec_len(sizeof(struct xfs_parent_name_rec)); +} +static inline unsigned int xfs_calc_pptr_replace_overhead(void) +{ + return sizeof(struct xfs_attri_log_format) + + xlog_calc_iovec_len(XATTR_NAME_MAX) + + xlog_calc_iovec_len(XATTR_NAME_MAX) + + xlog_calc_iovec_len(sizeof(struct xfs_parent_name_rec)); +} + /* * In renaming a files we can modify: * the five inodes involved: 5 * inode size * the two directory btrees: 2 * (max depth + v2) * dir block size * the two directory bmap btrees: 2 * max depth * block size * And the bmap_finish transaction can free dir and bmap blocks (two sets - * of bmap blocks) giving: + * of bmap blocks) giving (t2): * the agf for the ags in which the blocks live: 3 * sector size * the agfl for the ags in which the blocks live: 3 * sector size * the superblock for the free block count: sector size * the allocation btrees: 3 exts * 2 trees * (2 * max depth - 1) * block size + * If parent pointers are enabled (t3), then each transaction in the chain + * must be capable of setting or removing the extended attribute + * containing the parent information. It must also be able to handle + * the three xattr intent items that track the progress of the parent + * pointer update. */ STATIC uint xfs_calc_rename_reservation( struct xfs_mount *mp) { - return XFS_DQUOT_LOGRES(mp) + - max((xfs_calc_inode_res(mp, 5) + - xfs_calc_buf_res(2 * XFS_DIROP_LOG_COUNT(mp), - XFS_FSB_TO_B(mp, 1))), - (xfs_calc_buf_res(7, mp->m_sb.sb_sectsize) + - xfs_calc_buf_res(xfs_allocfree_block_count(mp, 3), - XFS_FSB_TO_B(mp, 1)))); + unsigned int overhead = XFS_DQUOT_LOGRES(mp); + struct xfs_trans_resv *resp = M_RES(mp); + unsigned int t1, t2, t3 = 0; + + t1 = xfs_calc_inode_res(mp, 5) + + xfs_calc_buf_res(2 * XFS_DIROP_LOG_COUNT(mp), + XFS_FSB_TO_B(mp, 1)); + + t2 = xfs_calc_buf_res(7, mp->m_sb.sb_sectsize) + + xfs_calc_buf_res(xfs_allocfree_block_count(mp, 3), + XFS_FSB_TO_B(mp, 1)); + + if (xfs_has_parent(mp)) { + unsigned int rename_overhead, exchange_overhead; + + t3 = max(resp->tr_attrsetm.tr_logres, + resp->tr_attrrm.tr_logres); + + /* + * For a standard rename, the three xattr intent log items + * are (1) replacing the pptr for the source file; (2) + * removing the pptr on the dest file; and (3) adding a + * pptr for the whiteout file in the src dir. + * + * For an RENAME_EXCHANGE, there are two xattr intent + * items to replace the pptr for both src and dest + * files. Link counts don't change and there is no + * whiteout. + * + * In the worst case we can end up relogging all log + * intent items to allow the log tail to move ahead, so + * they become overhead added to each transaction in a + * processing chain. + */ + rename_overhead = xfs_calc_pptr_replace_overhead() + + xfs_calc_pptr_unlink_overhead() + + xfs_calc_pptr_link_overhead(); + exchange_overhead = 2 * xfs_calc_pptr_replace_overhead(); + + overhead += max(rename_overhead, exchange_overhead); + } + + return overhead + max3(t1, t2, t3); +} + +static inline unsigned int +xfs_rename_log_count( + struct xfs_mount *mp, + struct xfs_trans_resv *resp) +{ + /* One for the rename, one more for freeing blocks */ + unsigned int ret = XFS_RENAME_LOG_COUNT; + + /* + * Pre-reserve enough log reservation to handle the transaction + * rolling needed to remove or add one parent pointer. + */ + if (xfs_has_parent(mp)) + ret += max(resp->tr_attrsetm.tr_logcount, + resp->tr_attrrm.tr_logcount); + + return ret; } /* @@ -459,6 +541,23 @@ xfs_calc_iunlink_remove_reservation( 2 * M_IGEO(mp)->inode_cluster_size; } +static inline unsigned int +xfs_link_log_count( + struct xfs_mount *mp, + struct xfs_trans_resv *resp) +{ + unsigned int ret = XFS_LINK_LOG_COUNT; + + /* + * Pre-reserve enough log reservation to handle the transaction + * rolling needed to add one parent pointer. + */ + if (xfs_has_parent(mp)) + ret += resp->tr_attrsetm.tr_logcount; + + return ret; +} + /* * For creating a link to an inode: * the parent directory inode: inode size @@ -475,14 +574,23 @@ STATIC uint xfs_calc_link_reservation( struct xfs_mount *mp) { - return XFS_DQUOT_LOGRES(mp) + - xfs_calc_iunlink_remove_reservation(mp) + - max((xfs_calc_inode_res(mp, 2) + - xfs_calc_buf_res(XFS_DIROP_LOG_COUNT(mp), - XFS_FSB_TO_B(mp, 1))), - (xfs_calc_buf_res(3, mp->m_sb.sb_sectsize) + - xfs_calc_buf_res(xfs_allocfree_block_count(mp, 1), - XFS_FSB_TO_B(mp, 1)))); + unsigned int overhead = XFS_DQUOT_LOGRES(mp); + struct xfs_trans_resv *resp = M_RES(mp); + unsigned int t1, t2, t3 = 0; + + overhead += xfs_calc_iunlink_remove_reservation(mp); + t1 = xfs_calc_inode_res(mp, 2) + + xfs_calc_buf_res(XFS_DIROP_LOG_COUNT(mp), XFS_FSB_TO_B(mp, 1)); + t2 = xfs_calc_buf_res(3, mp->m_sb.sb_sectsize) + + xfs_calc_buf_res(xfs_allocfree_block_count(mp, 1), + XFS_FSB_TO_B(mp, 1)); + + if (xfs_has_parent(mp)) { + t3 = resp->tr_attrsetm.tr_logres; + overhead += xfs_calc_pptr_link_overhead(); + } + + return overhead + max3(t1, t2, t3); } /* @@ -497,6 +605,23 @@ xfs_calc_iunlink_add_reservation(xfs_mount_t *mp) M_IGEO(mp)->inode_cluster_size; } +static inline unsigned int +xfs_remove_log_count( + struct xfs_mount *mp, + struct xfs_trans_resv *resp) +{ + unsigned int ret = XFS_REMOVE_LOG_COUNT; + + /* + * Pre-reserve enough log reservation to handle the transaction + * rolling needed to add one parent pointer. + */ + if (xfs_has_parent(mp)) + ret += resp->tr_attrrm.tr_logcount; + + return ret; +} + /* * For removing a directory entry we can modify: * the parent directory inode: inode size @@ -513,14 +638,24 @@ STATIC uint xfs_calc_remove_reservation( struct xfs_mount *mp) { - return XFS_DQUOT_LOGRES(mp) + - xfs_calc_iunlink_add_reservation(mp) + - max((xfs_calc_inode_res(mp, 2) + - xfs_calc_buf_res(XFS_DIROP_LOG_COUNT(mp), - XFS_FSB_TO_B(mp, 1))), - (xfs_calc_buf_res(4, mp->m_sb.sb_sectsize) + - xfs_calc_buf_res(xfs_allocfree_block_count(mp, 2), - XFS_FSB_TO_B(mp, 1)))); + unsigned int overhead = XFS_DQUOT_LOGRES(mp); + struct xfs_trans_resv *resp = M_RES(mp); + unsigned int t1, t2, t3 = 0; + + overhead += xfs_calc_iunlink_add_reservation(mp); + + t1 = xfs_calc_inode_res(mp, 2) + + xfs_calc_buf_res(XFS_DIROP_LOG_COUNT(mp), XFS_FSB_TO_B(mp, 1)); + t2 = xfs_calc_buf_res(4, mp->m_sb.sb_sectsize) + + xfs_calc_buf_res(xfs_allocfree_block_count(mp, 2), + XFS_FSB_TO_B(mp, 1)); + + if (xfs_has_parent(mp)) { + t3 = resp->tr_attrrm.tr_logres; + overhead += xfs_calc_pptr_unlink_overhead(); + } + + return overhead + max3(t1, t2, t3); } /* @@ -569,12 +704,40 @@ xfs_calc_icreate_resv_alloc( xfs_calc_finobt_res(mp); } +static inline unsigned int +xfs_icreate_log_count( + struct xfs_mount *mp, + struct xfs_trans_resv *resp) +{ + unsigned int ret = XFS_CREATE_LOG_COUNT; + + /* + * Pre-reserve enough log reservation to handle the transaction + * rolling needed to add one parent pointer. + */ + if (xfs_has_parent(mp)) + ret += resp->tr_attrsetm.tr_logcount; + + return ret; +} + STATIC uint -xfs_calc_icreate_reservation(xfs_mount_t *mp) +xfs_calc_icreate_reservation( + struct xfs_mount *mp) { - return XFS_DQUOT_LOGRES(mp) + - max(xfs_calc_icreate_resv_alloc(mp), - xfs_calc_create_resv_modify(mp)); + struct xfs_trans_resv *resp = M_RES(mp); + unsigned int overhead = XFS_DQUOT_LOGRES(mp); + unsigned int t1, t2, t3 = 0; + + t1 = xfs_calc_icreate_resv_alloc(mp); + t2 = xfs_calc_create_resv_modify(mp); + + if (xfs_has_parent(mp)) { + t3 = resp->tr_attrsetm.tr_logres; + overhead += xfs_calc_pptr_link_overhead(); + } + + return overhead + max3(t1, t2, t3); } STATIC uint @@ -587,6 +750,23 @@ xfs_calc_create_tmpfile_reservation( return res + xfs_calc_iunlink_add_reservation(mp); } +static inline unsigned int +xfs_mkdir_log_count( + struct xfs_mount *mp, + struct xfs_trans_resv *resp) +{ + unsigned int ret = XFS_MKDIR_LOG_COUNT; + + /* + * Pre-reserve enough log reservation to handle the transaction + * rolling needed to add one parent pointer. + */ + if (xfs_has_parent(mp)) + ret += resp->tr_attrsetm.tr_logcount; + + return ret; +} + /* * Making a new directory is the same as creating a new file. */ @@ -597,6 +777,22 @@ xfs_calc_mkdir_reservation( return xfs_calc_icreate_reservation(mp); } +static inline unsigned int +xfs_symlink_log_count( + struct xfs_mount *mp, + struct xfs_trans_resv *resp) +{ + unsigned int ret = XFS_SYMLINK_LOG_COUNT; + + /* + * Pre-reserve enough log reservation to handle the transaction + * rolling needed to add one parent pointer. + */ + if (xfs_has_parent(mp)) + ret += resp->tr_attrsetm.tr_logcount; + + return ret; +} /* * Making a new symplink is the same as creating a new file, but @@ -909,54 +1105,76 @@ xfs_calc_sb_reservation( return xfs_calc_buf_res(1, mp->m_sb.sb_sectsize); } -void -xfs_trans_resv_calc( +/* + * Namespace reservations. + * + * These get tricky when parent pointers are enabled as we have attribute + * modifications occurring from within these transactions. Rather than confuse + * each of these reservation calculations with the conditional attribute + * reservations, add them here in a clear and concise manner. This requires that + * the attribute reservations have already been calculated. + * + * Note that we only include the static attribute reservation here; the runtime + * reservation will have to be modified by the size of the attributes being + * added/removed/modified. See the comments on the attribute reservation + * calculations for more details. + */ +STATIC void +xfs_calc_namespace_reservations( struct xfs_mount *mp, struct xfs_trans_resv *resp) { - int logcount_adj = 0; - - /* - * The following transactions are logged in physical format and - * require a permanent reservation on space. - */ - resp->tr_write.tr_logres = xfs_calc_write_reservation(mp, false); - resp->tr_write.tr_logcount = XFS_WRITE_LOG_COUNT; - resp->tr_write.tr_logflags |= XFS_TRANS_PERM_LOG_RES; - - resp->tr_itruncate.tr_logres = xfs_calc_itruncate_reservation(mp, false); - resp->tr_itruncate.tr_logcount = XFS_ITRUNCATE_LOG_COUNT; - resp->tr_itruncate.tr_logflags |= XFS_TRANS_PERM_LOG_RES; + ASSERT(resp->tr_attrsetm.tr_logres > 0); resp->tr_rename.tr_logres = xfs_calc_rename_reservation(mp); - resp->tr_rename.tr_logcount = XFS_RENAME_LOG_COUNT; + resp->tr_rename.tr_logcount = xfs_rename_log_count(mp, resp); resp->tr_rename.tr_logflags |= XFS_TRANS_PERM_LOG_RES; resp->tr_link.tr_logres = xfs_calc_link_reservation(mp); - resp->tr_link.tr_logcount = XFS_LINK_LOG_COUNT; + resp->tr_link.tr_logcount = xfs_link_log_count(mp, resp); resp->tr_link.tr_logflags |= XFS_TRANS_PERM_LOG_RES; resp->tr_remove.tr_logres = xfs_calc_remove_reservation(mp); - resp->tr_remove.tr_logcount = XFS_REMOVE_LOG_COUNT; + resp->tr_remove.tr_logcount = xfs_remove_log_count(mp, resp); resp->tr_remove.tr_logflags |= XFS_TRANS_PERM_LOG_RES; resp->tr_symlink.tr_logres = xfs_calc_symlink_reservation(mp); - resp->tr_symlink.tr_logcount = XFS_SYMLINK_LOG_COUNT; + resp->tr_symlink.tr_logcount = xfs_symlink_log_count(mp, resp); resp->tr_symlink.tr_logflags |= XFS_TRANS_PERM_LOG_RES; resp->tr_create.tr_logres = xfs_calc_icreate_reservation(mp); - resp->tr_create.tr_logcount = XFS_CREATE_LOG_COUNT; + resp->tr_create.tr_logcount = xfs_icreate_log_count(mp, resp); resp->tr_create.tr_logflags |= XFS_TRANS_PERM_LOG_RES; + resp->tr_mkdir.tr_logres = xfs_calc_mkdir_reservation(mp); + resp->tr_mkdir.tr_logcount = xfs_mkdir_log_count(mp, resp); + resp->tr_mkdir.tr_logflags |= XFS_TRANS_PERM_LOG_RES; +} + +void +xfs_trans_resv_calc( + struct xfs_mount *mp, + struct xfs_trans_resv *resp) +{ + int logcount_adj = 0; + + /* + * The following transactions are logged in physical format and + * require a permanent reservation on space. + */ + resp->tr_write.tr_logres = xfs_calc_write_reservation(mp, false); + resp->tr_write.tr_logcount = XFS_WRITE_LOG_COUNT; + resp->tr_write.tr_logflags |= XFS_TRANS_PERM_LOG_RES; + + resp->tr_itruncate.tr_logres = xfs_calc_itruncate_reservation(mp, false); + resp->tr_itruncate.tr_logcount = XFS_ITRUNCATE_LOG_COUNT; + resp->tr_itruncate.tr_logflags |= XFS_TRANS_PERM_LOG_RES; + resp->tr_create_tmpfile.tr_logres = xfs_calc_create_tmpfile_reservation(mp); resp->tr_create_tmpfile.tr_logcount = XFS_CREATE_TMPFILE_LOG_COUNT; resp->tr_create_tmpfile.tr_logflags |= XFS_TRANS_PERM_LOG_RES; - resp->tr_mkdir.tr_logres = xfs_calc_mkdir_reservation(mp); - resp->tr_mkdir.tr_logcount = XFS_MKDIR_LOG_COUNT; - resp->tr_mkdir.tr_logflags |= XFS_TRANS_PERM_LOG_RES; - resp->tr_ifree.tr_logres = xfs_calc_ifree_reservation(mp); resp->tr_ifree.tr_logcount = XFS_INACTIVE_LOG_COUNT; resp->tr_ifree.tr_logflags |= XFS_TRANS_PERM_LOG_RES; @@ -986,6 +1204,8 @@ xfs_trans_resv_calc( resp->tr_qm_dqalloc.tr_logcount = XFS_WRITE_LOG_COUNT; resp->tr_qm_dqalloc.tr_logflags |= XFS_TRANS_PERM_LOG_RES; + xfs_calc_namespace_reservations(mp, resp); + /* * The following transactions are logged in logical format with * a default log count. From patchwork Sun Dec 18 10:02:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 13076011 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 778ECC46467 for ; Sun, 18 Dec 2022 10:03:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230282AbiLRKDm (ORCPT ); Sun, 18 Dec 2022 05:03:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60164 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230287AbiLRKDh (ORCPT ); Sun, 18 Dec 2022 05:03:37 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 308825F79 for ; Sun, 18 Dec 2022 02:03:35 -0800 (PST) Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2BI8tY8u027000 for ; Sun, 18 Dec 2022 10:03:35 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=Jd0hWVbByU4V5w5WG+gKmIYE4aeq7M8v0EcUQ1NtWjw=; b=jXNgI+fOiJ6tOQ649/YqK4T3c08ht3nK7nbJPoh/DKBLWBKPyib0eShaQKuzI+TIvvHI RyIS1FzPfXZJNxT1956lbJC4rIqPwwBaSqOu2uhBfivmPvTFpQg+JQMMNYhFAJBk2h3h pHe3YYz1G0rmhUhjBVGxHU+qzI4aG+q81Uj1a+z8u/b6W/DtuCb3Gu4cEpPXFVggj70N BUNN9tCWnJ8AL8lGPhPYfguED6Ac6hI35RWcD5OBDokVWn3R7bE12/F0NJD7cGfrJ8L9 TV87j3YBKXnjKxAuxvpMRbI3KMzRmE4pwvsfkLARhWzLgBes0+jA/9S9K58wyXJWMUZ3 KA== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3mh6tph924-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sun, 18 Dec 2022 10:03:34 +0000 Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 2BI8VBBA024761 for ; Sun, 18 Dec 2022 10:03:33 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2174.outbound.protection.outlook.com [104.47.55.174]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3mh478mxp2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sun, 18 Dec 2022 10:03:33 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FhMUSOzcY32ZDVCkLEQPTWD57ozCDdHXkwYjsRSVtMPfLiI4BtTspSgaQUio8vQwB9z6O2TyJwfa9b16keBl/yHYwIEWH0SBYLFbEITZb6QugDDlUIo54e6TtCNhifAK0zCRG6WRTgr4ga6H9AgUfcUdTBvjU4stWkV5umC8Nco6suE76N5k0ivrXvBn+WTKYZJH2V0cQU8RXb0eLfVSe8Fi0/VIS0evOCsfX7HgzDjMdtRplOCq7NsX0rXLnttBMGbtA3EJ+TF3XjlGlyFAPm+pnkE7xwT2zIJjFcJqDp0ZxcAWGcSnGz8uPCsgFlWc1CaS2o+8CycjkJAXOoIAIg== 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=Jd0hWVbByU4V5w5WG+gKmIYE4aeq7M8v0EcUQ1NtWjw=; b=AslHCB8duJi/3g0gEjpaoBU5DozGM/XWAPa931dP+lxHTyX5sz/pZWdzFxbMxR2bCX5hk/3C7r2gvJUE8mXaYFAw3XpXgtbYODSBqwXqK+2oJpEfxO5ETI3FefjcDKiVcxBe9W50rthgnhM3TN0znUdG1/nj0gvUjKVgejLqvU5OEGPEQskeuMXe/RVwbVu4F8/oxx9t+W/lyRb8q168I0ABD6UI9YbotioUOPzvajslrHfcXwA5AnE8s/jMkaSWKD/6gRDb8zH06/X/oOe7749rOxXqk8gLz0aaOXqulIs5H0sYep9UJMmpDEvdP/0Q5ic07HNYxcKMm2YGaPoRvA== 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=Jd0hWVbByU4V5w5WG+gKmIYE4aeq7M8v0EcUQ1NtWjw=; b=e3Kw839v9IUhl8U5z4Zke6WrUmy2lZ7EPy/ydZEvaAGogZvljltiFbIEPbIb7o5wAVzeDy91zEL8OGTVoEhl24XmViSbXYgvKrGYDXwnhTxNO2zBfGzD4dUbzIb2DYWFPpLbrZg4LU6QUIyiwUZgBDdXBR+e5GO3356fXGHiX98= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by PH0PR10MB4536.namprd10.prod.outlook.com (2603:10b6:510:40::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5924.16; Sun, 18 Dec 2022 10:03:31 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::3cab:6ff7:cb4d:b57c]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::3cab:6ff7:cb4d:b57c%4]) with mapi id 15.20.5924.016; Sun, 18 Dec 2022 10:03:31 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v7 15/27] xfs: parent pointer attribute creation Date: Sun, 18 Dec 2022 03:02:54 -0700 Message-Id: <20221218100306.76408-16-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221218100306.76408-1-allison.henderson@oracle.com> References: <20221218100306.76408-1-allison.henderson@oracle.com> X-ClientProxiedBy: BY3PR10CA0003.namprd10.prod.outlook.com (2603:10b6:a03:255::8) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY5PR10MB4306:EE_|PH0PR10MB4536:EE_ X-MS-Office365-Filtering-Correlation-Id: 284bbd3b-cc83-470b-a501-08dae0df1e2a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9ldxksO5C+bj2qKllUN4PWN9hz2tpVkug6S1UGMk2rstYD5WIGVAM+CuoTMzybrrxbUwUQkc4bylsZyg71KyWqOwpzVfE+qspHmVTaYcmKoD7SNM7HJXzLXBDEIVq1n4yg39VhorH4NOq7rBh0xfdmdxw5iXEKkFwv2FH9nY08z/jV0Z32BxoqBaWZ1IzTzO2bicz3Z9FtQaCzgBaqRfrGAckDJ8H3X3jNw3BSmkauCQpMWWnLeHjy8j7swYhkvlQcOxOxZZ3UuB6xYb4FF9lA6RRr3kpJjQCLQfS1WbMm1BP+JghC3VJ8Fw6MVLB4lP49DJRtCZukxS4HnOP2DnErgwi8DkN/zvTUqnUvnGSGDDtlZJ1zwYXWiDGKgaLkX468I9lL2qqaVb80wYSx8iKlNpUr6GAFulk4iiZ9a1U3ENg4bCK4DqGsbICQS2NW8BS2bax0IXOuT9V4Jcy1PM+P3LWyo5g+rh1iYb4hjfWKl0uJEJMnzahRpCnrpN+kWKkqgr8DTzNWjDLehQxOxFwl/Zg24AmrJawVrW1VZPM0et31ERmpL6H3w8mKG6QA0iDdfC2oj3Sw044FvWnfQH3XvIZewTQ9vb3dttX1WLK1ftM4rgTxc8fwSHbJe+AD1A 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:(13230022)(396003)(39860400002)(136003)(346002)(366004)(376002)(451199015)(83380400001)(38100700002)(86362001)(30864003)(66476007)(2906002)(8676002)(66556008)(5660300002)(66946007)(8936002)(41300700001)(1076003)(9686003)(26005)(186003)(6512007)(6506007)(6666004)(2616005)(6916009)(316002)(478600001)(6486002)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: +z0AxqrU26imcZM06rZBwIx4m2LdogI9CsvQM4+HhbVj3Sy6LlLfOmp0OMhlQTrr4irfzN7RSVpnHV2yBsPvoGKBAqNreITOl8V0q5Rhm9f5+E4xEUQB3zfK74Mbmtj9Of9EDyI1FAeQjm2V9xubIgQKmo1dXKhqAuRvtRXcieHSK/uUgT0d724rnEJdcWm1WAx6LQOIAzFiAgp0VMg7ITgnNn48Q728EMt9/SUwb2SoUV9MnnrD8DLhspVHTN1pnIQfMyfMbinHKPmYVH6JUkdRzMlOKqDmEA8yZdQEeshWkSewOrud0nM4PkCIajDSb9WJeObc5ijkVvvI1ykFx0dU5kZX5YzgJmbdXpZwaP3sheTLU3tDM7lpE/2MwbVsQ7KczAzKBOBiz3sYJ8Pfrsv3+v4jyT28icb5KRVu9les5+iXMnAZwp2KJsyRCuzkenQrWx4oRsFkyCeMq5Q9uUoq4fphCR1PWJP30jPr+gkiPJDmhrS/M6XZUog3I31mL1Ytu+ktNsv1tCv/KBbnLyro1/PvoNmIMxSOs17K1jsDVEovBdAbqIc8yIk/V9/cj0mbmMqNl49/lcbTHJvyArmxBWeWx/c7jaAFr9ZUvpnlcEEbgXOCNw4BuDx4ajMIhmqxxVzjyH7q4MzJLwas9iEYUJsNSbtbVus8161cVz1i1g/KeukpfUsneFpnfgoKkkbq7GM4DlvtHQVNu9jcbyo76DEg3IuK3aXu8UjK0y109/BmM6nRYdA7IY8w70rbcTo769+x4GNHFxTn+9eWaRgtWfQC3TZgnR8MrHMOdSpQrgQYBZC02+MwQ1J9U6rBe/ic68u+73v+E4y6y/zq2CbyA3LfQVAWCBptVYEbqUkAOhcNIvmV5w0Fj52iAiiZzuWazRKGvu++JN3oJ24gyJCfsp0GrLRLZQmFGbMUZQIjLof2M5wNH8uVgKRKFNndYNmKCSPuoIGHEXsPpB7JkCcRaYvi09BGmiKagc/P4dnWsNPwJATVMvLFTacue5a6PDwqiIB7cCBkHpCk/L+1svDMWQLG7G3Fyt6f+CQ1D6yMpUGs0liiixh1W59ubKZbtNlrVlpeP1PZmfsjC59ENoryPUb4Iox2WR5Wl1PuE2twDfg5NCSwUXc7XP/DfI0mPrcszVvUftZLjDvtMxroynubQlfu0AN/GOwFLR+esRwp+ngP3rczC3Q/hZxwjQvh5xAofepB5c5q4YiHfr5pGiHnNF5RaspkBB8nzS7WAGhgOiEwnfqMGO4mZwRaudWQ3DpF4f/Y5vpthMyqKmMCnwB/jKDWrevLmmnqSYZUlpjkPIB85BAfv9tVV7u6oovQKNOgBVTlY0NlSLbdqFdo2M4qQSDs2OZUwy2v3ZptlzDaba6pkyDIMM6tNHNr6cnkftLbXMnkAq5IXfAHrUh+DFV5Jxx9hDjXueOpgzm12GqLGEnIb+M9q2/t3wxV0kygHfAkgzxSJR/GH+/pU7YuhOm2kP8Cn4B9LUqCag76r+z4qYMOi8ycuGU3Rx07WBxL0/ld0EMLPb3cdP36WOLNchxSt5RorYbhfi3Mmx0GooCmVegi8UNc5L2USw8U5j3vwARJNs8P4YrO3mc366zfnw== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 284bbd3b-cc83-470b-a501-08dae0df1e2a X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Dec 2022 10:03:31.5723 (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: JED2t+cYcb2J6OoHh1A0nyNDfDapcwUHYSO6G+p/efMUeMiHSxKNnX6aIaM5z5Eqy9mmlc/k9ar3w/9BQtgcibgcVKSw6e3R2/JGL+PflHM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4536 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-12-18_02,2022-12-15_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 mlxlogscore=999 phishscore=0 bulkscore=0 malwarescore=0 spamscore=0 adultscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2212180095 X-Proofpoint-ORIG-GUID: qTOS3axWI96VDCcNFHEITHD1cfV3Ep9F X-Proofpoint-GUID: qTOS3axWI96VDCcNFHEITHD1cfV3Ep9F Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Allison Henderson Add parent pointer attribute during xfs_create, and subroutines to initialize attributes Signed-off-by: Dave Chinner Signed-off-by: Allison Henderson --- fs/xfs/Makefile | 1 + fs/xfs/libxfs/xfs_attr.c | 4 +- fs/xfs/libxfs/xfs_attr.h | 4 +- fs/xfs/libxfs/xfs_parent.c | 149 +++++++++++++++++++++++++++++++++++++ fs/xfs/libxfs/xfs_parent.h | 34 +++++++++ fs/xfs/xfs_inode.c | 64 ++++++++++++++-- fs/xfs/xfs_xattr.c | 2 +- fs/xfs/xfs_xattr.h | 1 + 8 files changed, 247 insertions(+), 12 deletions(-) diff --git a/fs/xfs/Makefile b/fs/xfs/Makefile index 03135a1c31b6..e2b2cf50ffcf 100644 --- a/fs/xfs/Makefile +++ b/fs/xfs/Makefile @@ -40,6 +40,7 @@ xfs-y += $(addprefix libxfs/, \ xfs_inode_fork.o \ xfs_inode_buf.o \ xfs_log_rlimit.o \ + xfs_parent.o \ xfs_ag_resv.o \ xfs_rmap.o \ xfs_rmap_btree.o \ diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c index 711022742e34..f68d41f0f998 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -886,7 +886,7 @@ xfs_attr_lookup( return error; } -static int +int xfs_attr_intent_init( struct xfs_da_args *args, unsigned int op_flags, /* op flag (set or remove) */ @@ -904,7 +904,7 @@ xfs_attr_intent_init( } /* Sets an attribute for an inode as a deferred operation */ -static int +int xfs_attr_defer_add( struct xfs_da_args *args) { diff --git a/fs/xfs/libxfs/xfs_attr.h b/fs/xfs/libxfs/xfs_attr.h index b79dae788cfb..0cf23f5117ad 100644 --- a/fs/xfs/libxfs/xfs_attr.h +++ b/fs/xfs/libxfs/xfs_attr.h @@ -544,6 +544,7 @@ int xfs_inode_hasattr(struct xfs_inode *ip); 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_defer_add(struct xfs_da_args *args); int xfs_attr_set(struct xfs_da_args *args); int xfs_attr_set_iter(struct xfs_attr_intent *attr); int xfs_attr_remove_iter(struct xfs_attr_intent *attr); @@ -552,7 +553,8 @@ bool xfs_attr_namecheck(struct xfs_mount *mp, const void *name, size_t length, int xfs_attr_calc_size(struct xfs_da_args *args, int *local); void xfs_init_attr_trans(struct xfs_da_args *args, struct xfs_trans_res *tres, unsigned int *total); - +int xfs_attr_intent_init(struct xfs_da_args *args, unsigned int op_flags, + struct xfs_attr_intent **attr); /* * Check to see if the attr should be upgraded from non-existent or shortform to * single-leaf-block attribute list. diff --git a/fs/xfs/libxfs/xfs_parent.c b/fs/xfs/libxfs/xfs_parent.c new file mode 100644 index 000000000000..cf5ea8ce8bd3 --- /dev/null +++ b/fs/xfs/libxfs/xfs_parent.c @@ -0,0 +1,149 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2022 Oracle, Inc. + * All rights reserved. + */ +#include "xfs.h" +#include "xfs_fs.h" +#include "xfs_format.h" +#include "xfs_da_format.h" +#include "xfs_log_format.h" +#include "xfs_shared.h" +#include "xfs_trans_resv.h" +#include "xfs_mount.h" +#include "xfs_bmap_btree.h" +#include "xfs_inode.h" +#include "xfs_error.h" +#include "xfs_trace.h" +#include "xfs_trans.h" +#include "xfs_da_btree.h" +#include "xfs_attr.h" +#include "xfs_da_btree.h" +#include "xfs_attr_sf.h" +#include "xfs_bmap.h" +#include "xfs_defer.h" +#include "xfs_log.h" +#include "xfs_xattr.h" +#include "xfs_parent.h" +#include "xfs_trans_space.h" + +/* + * Parent pointer attribute handling. + * + * Because the attribute value is a filename component, it will never be longer + * than 255 bytes. This means the attribute will always be a local format + * attribute as it is xfs_attr_leaf_entsize_local_max() for v5 filesystems will + * always be larger than this (max is 75% of block size). + * + * Creating a new parent attribute will always create a new attribute - there + * should never, ever be an existing attribute in the tree for a new inode. + * ENOSPC behavior is problematic - creating the inode without the parent + * pointer is effectively a corruption, so we allow parent attribute creation + * to dip into the reserve block pool to avoid unexpected ENOSPC errors from + * occurring. + */ + + +/* Initializes a xfs_parent_name_rec to be stored as an attribute name */ +void +xfs_init_parent_name_rec( + struct xfs_parent_name_rec *rec, + struct xfs_inode *ip, + uint32_t p_diroffset) +{ + xfs_ino_t p_ino = ip->i_ino; + uint32_t p_gen = VFS_I(ip)->i_generation; + + rec->p_ino = cpu_to_be64(p_ino); + rec->p_gen = cpu_to_be32(p_gen); + rec->p_diroffset = cpu_to_be32(p_diroffset); +} + +/* Initializes a xfs_parent_name_irec from an xfs_parent_name_rec */ +void +xfs_init_parent_name_irec( + struct xfs_parent_name_irec *irec, + struct xfs_parent_name_rec *rec) +{ + irec->p_ino = be64_to_cpu(rec->p_ino); + irec->p_gen = be32_to_cpu(rec->p_gen); + irec->p_diroffset = be32_to_cpu(rec->p_diroffset); +} + +int +xfs_parent_init( + struct xfs_mount *mp, + struct xfs_parent_defer **parentp) +{ + struct xfs_parent_defer *parent; + int error; + + if (!xfs_has_parent(mp)) + return 0; + + error = xfs_attr_grab_log_assist(mp); + if (error) + return error; + + parent = kzalloc(sizeof(*parent), GFP_KERNEL); + if (!parent) + return -ENOMEM; + + /* init parent da_args */ + parent->args.geo = mp->m_attr_geo; + parent->args.whichfork = XFS_ATTR_FORK; + parent->args.attr_filter = XFS_ATTR_PARENT; + parent->args.op_flags = XFS_DA_OP_OKNOENT | XFS_DA_OP_LOGGED; + parent->args.name = (const uint8_t *)&parent->rec; + parent->args.namelen = sizeof(struct xfs_parent_name_rec); + + *parentp = parent; + return 0; +} + +int +xfs_parent_defer_add( + struct xfs_trans *tp, + struct xfs_parent_defer *parent, + struct xfs_inode *dp, + struct xfs_name *parent_name, + xfs_dir2_dataptr_t diroffset, + struct xfs_inode *child) +{ + struct xfs_da_args *args = &parent->args; + + xfs_init_parent_name_rec(&parent->rec, dp, diroffset); + args->hashval = xfs_da_hashname(args->name, args->namelen); + + args->trans = tp; + args->dp = child; + if (parent_name) { + parent->args.value = (void *)parent_name->name; + parent->args.valuelen = parent_name->len; + } + + return xfs_attr_defer_add(args); +} + +void +xfs_parent_cancel( + xfs_mount_t *mp, + struct xfs_parent_defer *parent) +{ + xlog_drop_incompat_feat(mp->m_log); + kfree(parent); +} + +unsigned int +xfs_pptr_calc_space_res( + struct xfs_mount *mp, + unsigned int namelen) +{ + /* + * Pptrs are always the first attr in an attr tree, and never larger + * than a block + */ + return XFS_DAENTER_SPACE_RES(mp, XFS_ATTR_FORK) + + XFS_NEXTENTADD_SPACE_RES(mp, namelen, XFS_ATTR_FORK); +} + diff --git a/fs/xfs/libxfs/xfs_parent.h b/fs/xfs/libxfs/xfs_parent.h new file mode 100644 index 000000000000..9b8d0764aad6 --- /dev/null +++ b/fs/xfs/libxfs/xfs_parent.h @@ -0,0 +1,34 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2022 Oracle, Inc. + * All Rights Reserved. + */ +#ifndef __XFS_PARENT_H__ +#define __XFS_PARENT_H__ + +/* + * Dynamically allocd structure used to wrap the needed data to pass around + * the defer ops machinery + */ +struct xfs_parent_defer { + struct xfs_parent_name_rec rec; + struct xfs_da_args args; +}; + +/* + * Parent pointer attribute prototypes + */ +void xfs_init_parent_name_rec(struct xfs_parent_name_rec *rec, + struct xfs_inode *ip, + uint32_t p_diroffset); +void xfs_init_parent_name_irec(struct xfs_parent_name_irec *irec, + struct xfs_parent_name_rec *rec); +int xfs_parent_init(xfs_mount_t *mp, struct xfs_parent_defer **parentp); +int xfs_parent_defer_add(struct xfs_trans *tp, struct xfs_parent_defer *parent, + struct xfs_inode *dp, struct xfs_name *parent_name, + xfs_dir2_dataptr_t diroffset, struct xfs_inode *child); +void xfs_parent_cancel(xfs_mount_t *mp, struct xfs_parent_defer *parent); +unsigned int xfs_pptr_calc_space_res(struct xfs_mount *mp, + unsigned int namelen); + +#endif /* __XFS_PARENT_H__ */ diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index f65085645942..11e0dd16ba94 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -37,6 +37,8 @@ #include "xfs_reflink.h" #include "xfs_ag.h" #include "xfs_log_priv.h" +#include "xfs_parent.h" +#include "xfs_xattr.h" struct kmem_cache *xfs_inode_cache; @@ -946,10 +948,32 @@ xfs_bumplink( xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); } +static unsigned int +xfs_create_space_res( + struct xfs_mount *mp, + unsigned int namelen) +{ + unsigned int ret; + + ret = XFS_IALLOC_SPACE_RES(mp) + XFS_DIRENTER_SPACE_RES(mp, namelen); + if (xfs_has_parent(mp)) + ret += xfs_pptr_calc_space_res(mp, namelen); + + return ret; +} + +static unsigned int +xfs_mkdir_space_res( + struct xfs_mount *mp, + unsigned int namelen) +{ + return xfs_create_space_res(mp, namelen); +} + int xfs_create( struct user_namespace *mnt_userns, - xfs_inode_t *dp, + struct xfs_inode *dp, struct xfs_name *name, umode_t mode, dev_t rdev, @@ -961,7 +985,7 @@ xfs_create( struct xfs_inode *ip = NULL; struct xfs_trans *tp = NULL; int error; - bool unlock_dp_on_error = false; + bool unlock_dp_on_error = false; prid_t prid; struct xfs_dquot *udqp = NULL; struct xfs_dquot *gdqp = NULL; @@ -969,6 +993,8 @@ xfs_create( struct xfs_trans_res *tres; uint resblks; xfs_ino_t ino; + xfs_dir2_dataptr_t diroffset; + struct xfs_parent_defer *parent = NULL; trace_xfs_create(dp, name); @@ -988,13 +1014,19 @@ xfs_create( return error; if (is_dir) { - resblks = XFS_MKDIR_SPACE_RES(mp, name->len); + resblks = xfs_mkdir_space_res(mp, name->len); tres = &M_RES(mp)->tr_mkdir; } else { - resblks = XFS_CREATE_SPACE_RES(mp, name->len); + resblks = xfs_create_space_res(mp, name->len); tres = &M_RES(mp)->tr_create; } + if (xfs_has_parent(mp)) { + error = xfs_parent_init(mp, &parent); + if (error) + goto out_release_dquots; + } + /* * Initially assume that the file does not exist and * reserve the resources for that case. If that is not @@ -1010,7 +1042,7 @@ xfs_create( resblks, &tp); } if (error) - goto out_release_dquots; + goto drop_incompat; xfs_ilock(dp, XFS_ILOCK_EXCL | XFS_ILOCK_PARENT); unlock_dp_on_error = true; @@ -1020,6 +1052,7 @@ xfs_create( * entry pointing to them, but a directory also the "." entry * pointing to itself. */ + init_xattrs = init_xattrs || xfs_has_parent(mp); error = xfs_dialloc(&tp, dp->i_ino, mode, &ino); if (!error) error = xfs_init_new_inode(mnt_userns, tp, dp, ino, mode, @@ -1034,11 +1067,11 @@ xfs_create( * the transaction cancel unlocking dp so don't do it explicitly in the * error path. */ - xfs_trans_ijoin(tp, dp, XFS_ILOCK_EXCL); - unlock_dp_on_error = false; + xfs_trans_ijoin(tp, dp, 0); error = xfs_dir_createname(tp, dp, name, ip->i_ino, - resblks - XFS_IALLOC_SPACE_RES(mp), NULL); + resblks - XFS_IALLOC_SPACE_RES(mp), + &diroffset); if (error) { ASSERT(error != -ENOSPC); goto out_trans_cancel; @@ -1054,6 +1087,17 @@ xfs_create( xfs_bumplink(tp, dp); } + /* + * If we have parent pointers, we need to add the attribute containing + * the parent information now. + */ + if (parent) { + error = xfs_parent_defer_add(tp, parent, dp, name, diroffset, + ip); + if (error) + goto out_trans_cancel; + } + /* * If this is a synchronous mount, make sure that the * create transaction goes to disk before returning to @@ -1079,6 +1123,7 @@ xfs_create( *ipp = ip; xfs_iunlock(ip, XFS_ILOCK_EXCL); + xfs_iunlock(dp, XFS_ILOCK_EXCL); return 0; out_trans_cancel: @@ -1094,6 +1139,9 @@ xfs_create( xfs_irele(ip); xfs_iunlock(ip, XFS_ILOCK_EXCL); } + drop_incompat: + if (parent) + xfs_parent_cancel(mp, parent); out_release_dquots: xfs_qm_dqrele(udqp); xfs_qm_dqrele(gdqp); diff --git a/fs/xfs/xfs_xattr.c b/fs/xfs/xfs_xattr.c index 10aa1fd39d2b..3644c5bcb3c0 100644 --- a/fs/xfs/xfs_xattr.c +++ b/fs/xfs/xfs_xattr.c @@ -27,7 +27,7 @@ * they must release the permission by calling xlog_drop_incompat_feat * when they're done. */ -static inline int +int xfs_attr_grab_log_assist( struct xfs_mount *mp) { diff --git a/fs/xfs/xfs_xattr.h b/fs/xfs/xfs_xattr.h index 2b09133b1b9b..3fd6520a4d69 100644 --- a/fs/xfs/xfs_xattr.h +++ b/fs/xfs/xfs_xattr.h @@ -7,6 +7,7 @@ #define __XFS_XATTR_H__ int xfs_attr_change(struct xfs_da_args *args); +int xfs_attr_grab_log_assist(struct xfs_mount *mp); extern const struct xattr_handler *xfs_xattr_handlers[]; From patchwork Sun Dec 18 10:02:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 13076009 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 BEC02C10F1E for ; Sun, 18 Dec 2022 10:03:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230245AbiLRKDk (ORCPT ); Sun, 18 Dec 2022 05:03:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60162 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230280AbiLRKDh (ORCPT ); Sun, 18 Dec 2022 05:03:37 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 889CA65ED for ; Sun, 18 Dec 2022 02:03:35 -0800 (PST) Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2BIA11Yl012981 for ; Sun, 18 Dec 2022 10:03:35 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=4tiIiFg2GkzN4wyQ3W7YSGo1tSeK6JVT5I3pzAPY87M=; b=pQIjhcCDgG+nui2pFd6NmELyNowROJGRom0AlrgMh4aP6+z951lnEP86EnnkSVcBm+sm mVgdFFCfELpVJnF1VXaA/kLjXaMX9OnNwi2070gSDbT0JI9dLwMoHr0OYbyBsRhznHug W2G9ziuwikQ+os35LRtDZ7SA1XzDucyVSXjeSFMceEeha7jbURs2S4h651Mzubv61MG1 nH0ZHU52I/yMpN/s8pdvdzJLSdMEr4Rerlk0k5X61PbzJSqdPm9Xhlvy5JZbvCRoPgVS 90wqzdO0X3qcycndAr24FyYgM+2RZcPVRx/edknJwtLkdki1LA/gSevM338H+vVF1zAd DA== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3mh6tp1917-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sun, 18 Dec 2022 10:03:35 +0000 Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 2BI8VBBB024761 for ; Sun, 18 Dec 2022 10:03:33 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2174.outbound.protection.outlook.com [104.47.55.174]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3mh478mxp2-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sun, 18 Dec 2022 10:03:33 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VYL6/fAM1Mb3J8UkDwlDFjUO5eZeL5m+pzugLVnFrkI+Tuf7QV9idMib3wq9ZGxLPUzmlii+D9CqlQL31/wCQIftre2ZviL8lYsD9hM5g297AJXT7ywr+vNgEWqSUxQ1x2HE51NsS9u3PTSoMg/KPokOyfWf4XEtY4TjRlSZWOWrdr2vjPHfDEjBb/E1eMV8rhIgLBFMOWHo8RV7mHO+tU+IqNKlKZ9L5D2V2p/DsbobgMfpdYY5bQez/eoOwkW2+oHoC6JrQDh/5+us2k6DmRnDGxPsVSdpapKC9WJffaeVYDPYnidPv04Zu5H8o9jw8U3qbC97wfFsQ1r+U1uTkw== 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=4tiIiFg2GkzN4wyQ3W7YSGo1tSeK6JVT5I3pzAPY87M=; b=hV79hxRNnaRGEZxA4DFVho2BE852e+nx9Fx/oXyHLdsdDkNr/F3Q117JGyjwm8ByO/x25NTo2p8YClyW0Gp4JIY5VsNp5pmFaoZY7LStDbPucKM2hmDjqchN4YijyJc0KpYxiGf2nzqXedtcjHo5wCKHRI+ASngCgcU33gXyIYoN8zYwm1ewCUUPXvlT+/yrgic/Hv4ZWsqT4NLl/a/bme2tKxjU9gKQrg9wU9PCQG9ffwDwVIcyF492BjKzkArC1ozaoHhmVmN5kuusLsyLjcg9cuZuaMf8Q0q/PvndekTt5/nEKGrtyS0dRyQ5awOCIr7cK3MpUmu7WwQGKa0nBQ== 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=4tiIiFg2GkzN4wyQ3W7YSGo1tSeK6JVT5I3pzAPY87M=; b=TuXL6eXe22tmdLKwRcdmTdVo98oG7idXkBLCYJ4KrJnLp/M/DQJ+5x/tGcDAyukBGcKkP0/ZWUUrPWYPgQFP0VufhT4pCG7/PmQis2iROFR5wnb6mXu7/ON7m2Hy5G+QS4PPLE8oQnP6hs3Qfy0QSwNX8U4DzaNSvkdU0hFXb70= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by PH0PR10MB4536.namprd10.prod.outlook.com (2603:10b6:510:40::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5924.16; Sun, 18 Dec 2022 10:03:32 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::3cab:6ff7:cb4d:b57c]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::3cab:6ff7:cb4d:b57c%4]) with mapi id 15.20.5924.016; Sun, 18 Dec 2022 10:03:32 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v7 16/27] xfs: add parent attributes to link Date: Sun, 18 Dec 2022 03:02:55 -0700 Message-Id: <20221218100306.76408-17-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221218100306.76408-1-allison.henderson@oracle.com> References: <20221218100306.76408-1-allison.henderson@oracle.com> X-ClientProxiedBy: BY3PR10CA0002.namprd10.prod.outlook.com (2603:10b6:a03:255::7) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY5PR10MB4306:EE_|PH0PR10MB4536:EE_ X-MS-Office365-Filtering-Correlation-Id: 840b76f6-de0f-44dc-94be-08dae0df1ec5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: naF8MsxbB3FgN6thzi1IhRTjAZxXZieI/shFCV4Qy+O31fvfbtq9+p5PIPcPsp6ej55V9uwbnKQl7JDEbQsfwl+Q910KwI0LQfpdnD3X6Rs9Laz1pjOs6tM3pnTmCIKBB4KdXU3MJBCW/kB+Ujjjh65N94gLrRvRS27YwTYd5CINnI/6swvYWGWYCIgHgSrB6Xh7UZMKNhBAa1G1SkPrwOCAir4ZjYK8VRlv4aYL21kZ1XWKvb6DLwzjcp5AmB2R7s555C9QZ92P+DBVO8p6p1tprKNv8tzpBjkhSYVpW9zf3zFxjG88yh+oTx+DpCH0CWETWxyzzGBOHmZe+MRKHjByHAehO4D5dIwod+FMIN7CyAJcLIHXAq4cEo6mQyxFbI82nWIjY6ZKXz4SL/I1fniQ3L/YGp7ZbZLpSwAzC6Qvy0fHP02e4ZiKTrgYRXxZoR+TpSR1aYKiN2I7VZARfoufc9fsYRqGF5EFXPOcQS2vUHFItcGipLPImvCh9KqYhfr50BDMbRr/hKrXJJqc4+LavQVJHI7u4Qe1F9kD3HSTlP8RPJpVdy0lqRR6nagjLfligftiRc3Vy5csU0QW6ggnFqTty+uVEdq7YqJRezuU/MYk9WCMFhex5y/zZTYM 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:(13230022)(396003)(39860400002)(136003)(346002)(366004)(376002)(451199015)(83380400001)(38100700002)(86362001)(66476007)(2906002)(8676002)(66556008)(5660300002)(66946007)(8936002)(41300700001)(1076003)(9686003)(26005)(186003)(6512007)(6506007)(6666004)(2616005)(6916009)(316002)(478600001)(6486002)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Y3ytiAwAHcMJtNtGpLseHwf9XjVPDmPwD8GB/eADV1WLfFUVvfryGRnduDuLLDvAp/LwGt8zTwBROAGGYF1cWHl3a0uGV5oMy7KUGk8jf0ZyfpzOKrWrg5vn7mMgzl4iUb1eMUuP+5vf3MKojmAPmrArFRgSKYB5w5AoE7MGCJZsxMWx6RW4dLe6s5ephYtno8MfT/7bOVAiYfZo2MV/7bPatIJCjG0Qsy15HDQWpyoko5XhdKIJ+7zMPIqTrNGr5gTU+dy0S1MJgfDy7j9DOhEnjPlML9KUfgfLkcc/SeiUyRrg734K/ZtxtEUDYSW871xi0lfj70VzHv4ZGfHziEO6MLhVeQIvySWnc4SdgF5r0vQglSfAs997/cv5/MDIuyMsIGSmHx2+ouYFOhluO+d2QzPslI6f3Bp0iBqcR8b65dffp8tEe/QVhGrXQmBnwTronAT6DJofu4xiKyiFDg2m1MXeHnRKBszG5n/plpbOP6CdpGk4MNxUz5N/Bai9ugEidJKZE0bVViJ2VnuyhnF9CdPLY0KaKVFMpI4z623q/2bNDB0knSZvZtGel+fX6OWjJwlgZDpgn/RWYy2yRdvqOfJWVm4KBaY5SNAtwFTNCAtjmq826mbntA45qpSa7PragSMeNXUjy3oj+vXp1A/2hKhWbrdu07rJ5h1EjnXgXpjGzdW2rACBYYLJcHidox61TiXISIJPIn1nDaTvaOQ6wBFZ8GvdvBnCYWqkj7jdlbVnCnxrq5ZjBbuDxKrNiOHuP7IXw4mMs+QxeNydEvL17NEQQwl40LhOxrWZE6NaLVS1GA+E/6SVhai6IMs1I7MKCorLuCgbOtsdVzuctnOThPUES42YliH7EtwhB8geW1rhbyhrykHuvpm4rmQh+14sDz4Q3IFAW448pQXIothsYOhrlmNaxvfWVzOnkYEqLtzoeFqPnprQWzHDaXAzDknIE9Zm9V/RRL7Uakp/FexjV1vhdlxAszTYvOOOyYO77GLl6brXFPseOZBJF8Qlz9RuqN+GcM+xbsAu1l0rqrmkqgRVfbaXwrnvyQZfp9r+jpcQxs5PcwMY1SW314mDnBQlBexFkbH61OY6nJeoPvi94NtDZN8f9JOWJbc1HSYRKS4Zzr1BQ/0fucYR2wiOn26GanNcFMJi28wr/szzRpRl8okKi6W1Ybo83WB8WU1QsKiedGJBeIfW43IHyEbCd2PSzGbvU4BcjHq+0dLihP/J0KGVepCDZ6qVH6pa4kG+W3X6+RTasj8tay5dXOzJrcWOrmFebP5fp8gY+0uJK006ZlMXTzw4U5zVEuryVTwO/rM/V0jCuN6c0n44dTi2Pg2B8rLo0kUKQmb4nFWuJ6XHFVxL3DZjF4LSrLaQXwCglPhIwL0ne8w1/rvT0RS2erJSbIX//S0vTFYzmKzfyKn5PF21Iy0cl4z9/Z48vr8oAS6h5NTHVli93/cT/d5D2IkWzi66hjPzXwFzrA6aAmARgAIo0ajI372iD/gcXJV/Lrj9h90O/kVcTP3c9MmsHIh5BcIYY8f2Xm5J4crC5iz2eVp+3aOxht7f3LJ333eS/xDqnzgSD0AG0gM6VhpV5LafhRhZlTms4N4CCcsTQA== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 840b76f6-de0f-44dc-94be-08dae0df1ec5 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Dec 2022 10:03:32.5721 (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: qqyDQTYcnUusQs6oqo9jYuewljbuKILtLA4uptvE3j427AiRzKqkcv4dv2205ZROliVvURY1XfY3L490mwRWJHfyl8ijRxITEi51fJN/sk4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4536 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-12-18_02,2022-12-15_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 mlxlogscore=999 phishscore=0 bulkscore=0 malwarescore=0 spamscore=0 adultscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2212180095 X-Proofpoint-GUID: P_YtCfEarU3afR9NSC-EnRYhV7HV9rsh X-Proofpoint-ORIG-GUID: P_YtCfEarU3afR9NSC-EnRYhV7HV9rsh Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Allison Henderson This patch modifies xfs_link to add a parent pointer to the inode. Signed-off-by: Dave Chinner Signed-off-by: Allison Henderson Reviewed-by: Darrick J. Wong --- fs/xfs/libxfs/xfs_trans_space.h | 2 -- fs/xfs/xfs_inode.c | 52 ++++++++++++++++++++++++++++----- 2 files changed, 45 insertions(+), 9 deletions(-) diff --git a/fs/xfs/libxfs/xfs_trans_space.h b/fs/xfs/libxfs/xfs_trans_space.h index 87b31c69a773..f72207923ec2 100644 --- a/fs/xfs/libxfs/xfs_trans_space.h +++ b/fs/xfs/libxfs/xfs_trans_space.h @@ -84,8 +84,6 @@ (2 * (mp)->m_alloc_maxlevels) #define XFS_GROWFSRT_SPACE_RES(mp,b) \ ((b) + XFS_EXTENTADD_SPACE_RES(mp, XFS_DATA_FORK)) -#define XFS_LINK_SPACE_RES(mp,nl) \ - XFS_DIRENTER_SPACE_RES(mp,nl) #define XFS_MKDIR_SPACE_RES(mp,nl) \ (XFS_IALLOC_SPACE_RES(mp) + XFS_DIRENTER_SPACE_RES(mp,nl)) #define XFS_QM_DQALLOC_SPACE_RES(mp) \ diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index 11e0dd16ba94..fbeba9cbf85d 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -1249,16 +1249,32 @@ xfs_create_tmpfile( return error; } +static unsigned int +xfs_link_space_res( + struct xfs_mount *mp, + unsigned int namelen) +{ + unsigned int ret; + + ret = XFS_DIRENTER_SPACE_RES(mp, namelen); + if (xfs_has_parent(mp)) + ret += xfs_pptr_calc_space_res(mp, namelen); + + return ret; +} + int xfs_link( - xfs_inode_t *tdp, - xfs_inode_t *sip, + struct xfs_inode *tdp, + struct xfs_inode *sip, struct xfs_name *target_name) { - xfs_mount_t *mp = tdp->i_mount; - xfs_trans_t *tp; + struct xfs_mount *mp = tdp->i_mount; + struct xfs_trans *tp; int error, nospace_error = 0; int resblks; + xfs_dir2_dataptr_t diroffset; + struct xfs_parent_defer *parent = NULL; trace_xfs_link(tdp, target_name); @@ -1275,11 +1291,17 @@ xfs_link( if (error) goto std_return; - resblks = XFS_LINK_SPACE_RES(mp, target_name->len); + if (xfs_has_parent(mp)) { + error = xfs_parent_init(mp, &parent); + if (error) + goto std_return; + } + + resblks = xfs_link_space_res(mp, target_name->len); error = xfs_trans_alloc_dir(tdp, &M_RES(mp)->tr_link, sip, &resblks, &tp, &nospace_error); if (error) - goto std_return; + goto drop_incompat; /* * If we are using project inheritance, we only allow hard link @@ -1312,7 +1334,7 @@ xfs_link( } error = xfs_dir_createname(tp, tdp, target_name, sip->i_ino, - resblks, NULL); + resblks, &diroffset); if (error) goto error_return; xfs_trans_ichgtime(tp, tdp, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG); @@ -1320,6 +1342,19 @@ xfs_link( xfs_bumplink(tp, sip); + /* + * If we have parent pointers, we now need to add the parent record to + * the attribute fork of the inode. If this is the initial parent + * attribute, we need to create it correctly, otherwise we can just add + * the parent to the inode. + */ + if (parent) { + error = xfs_parent_defer_add(tp, parent, tdp, target_name, + diroffset, sip); + if (error) + goto error_return; + } + /* * If this is a synchronous mount, make sure that the * link transaction goes to disk before returning to @@ -1337,6 +1372,9 @@ xfs_link( xfs_trans_cancel(tp); xfs_iunlock(tdp, XFS_ILOCK_EXCL); xfs_iunlock(sip, XFS_ILOCK_EXCL); + drop_incompat: + if (parent) + xfs_parent_cancel(mp, parent); std_return: if (error == -ENOSPC && nospace_error) error = nospace_error; From patchwork Sun Dec 18 10:02:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 13076010 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 BC4C6C4167B for ; Sun, 18 Dec 2022 10:03:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230280AbiLRKDl (ORCPT ); Sun, 18 Dec 2022 05:03:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60168 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230294AbiLRKDi (ORCPT ); Sun, 18 Dec 2022 05:03:38 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 25A336559 for ; Sun, 18 Dec 2022 02:03:37 -0800 (PST) Received: from pps.filterd (m0333521.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2BI4ovMu007685 for ; Sun, 18 Dec 2022 10:03:36 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=/ZHnu17wX0EAsrcsvCpkMDiXHfRRSu/Q4x3Y74OEdMM=; b=VZj2JwOcoalk3cMDghe5TXjn2cZ3Rp6hH+ZoqrDaXxE4HElRJHWjEiADNRpUR/6zxZcn J5DuoZGSox05HYkKkygCSxtFvcCaTI56m0jzOU4hq+ignvCkqjD+4viVZpFjNYARqjBV Cutpvk86fICiHwEtf7YI/sdHENiR8HTDoWpcrc64BqJJGqRYTiMxySRKY/PjncC+sJa3 MgzLvxnZQp5aZ6nxw7kT5b4sDhwGLfS29gUwYVlRC5D9gdN4LJsNgYtWKs2CSg4fP+1r A5k5Xeb9lGH+wExmQOLFh3Xx+jpZPDg3TYpFK+s132ZyW026hb4PrKyAxQary7XIe1B6 +A== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3mh6tn99gk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sun, 18 Dec 2022 10:03:36 +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 2BI8B7Es006852 for ; Sun, 18 Dec 2022 10:03:35 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2176.outbound.protection.outlook.com [104.47.55.176]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3mh478n3v4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sun, 18 Dec 2022 10:03:35 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=a/ljt9390a81SOZ4j6il71AVuo9FV/VAfQ6STN+rNh1cXETbAkPQzndHWDC3yuzc92GcxKgQaQx8wpwfWOqPfBKXFmN13rJFCc7yT54MxA5jaYUOkmcKCB01y59JMRu2oXrEEhYQln8WTyk0KVEnMfWOP/LEtssppKjUlICTrTpCjgvwwjsfuJd0fccw+XNhWD202194/l3W/Gu86hFcAY9o+mSVuKpaWGjbDK1rm4695Cxv5+T6qKVRUF4je28U3ugMVEiNnrkAF/5I2MuY7dG/bEHwfNf5RuuotXI1q9mbfXsH6tLDb/DGHP1FqFnWXGbWB4J3BVSRSqSnsLgaZQ== 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=/ZHnu17wX0EAsrcsvCpkMDiXHfRRSu/Q4x3Y74OEdMM=; b=XFJXWOpeXTOxsm1TJFvoH3LANFFCAZ55KVgvyucL6gRXeVi04ovk3lm6AHQbTb0dD2AOpvwQ48C+FxgqyQa2JLg51kwsMph0Yhu82piShBcRBOAlVJwBnn/cHZ/F9iqir5MVJUO6eKz5Mue0e0LAirQbcGiSBRbZlgoqyEJHb6HYTgQM7tVCNjaiixwhXFGBBwrhxmQmW4O8aDzvcfo6/Ola6VoiuAkQdsFH/YJjFC3khFEJYSVzeiVQSHtb1YFNS8nUeGGuhy55g/pkOMw6GmmVG/QVDYi5SQnbzNmqmW9R+Cnr7b5nXhwHgdopmILisPsGbUt4KE/oPk+ydVrnFg== 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=/ZHnu17wX0EAsrcsvCpkMDiXHfRRSu/Q4x3Y74OEdMM=; b=sgO9REMBBZsa0/xRHi+l5aDrcrFHggPbZi99UPLzoxvToRzXI4dtPlngO/EstHx9NhqoXdrbJ4kXLPB4WxS72QWlWEoPzjs9GIGdi0pAxURHNzbth3lOzfbANxuFAfSJJN/WRLWHTlGFMf1zeQihaQPYAXeQZbEhAASbBeUitrc= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by PH0PR10MB4536.namprd10.prod.outlook.com (2603:10b6:510:40::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5924.16; Sun, 18 Dec 2022 10:03:34 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::3cab:6ff7:cb4d:b57c]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::3cab:6ff7:cb4d:b57c%4]) with mapi id 15.20.5924.016; Sun, 18 Dec 2022 10:03:33 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v7 17/27] xfs: add parent attributes to symlink Date: Sun, 18 Dec 2022 03:02:56 -0700 Message-Id: <20221218100306.76408-18-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221218100306.76408-1-allison.henderson@oracle.com> References: <20221218100306.76408-1-allison.henderson@oracle.com> X-ClientProxiedBy: BYAPR01CA0004.prod.exchangelabs.com (2603:10b6:a02:80::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_|PH0PR10MB4536:EE_ X-MS-Office365-Filtering-Correlation-Id: 117ea4da-b5d1-4ce3-529a-08dae0df1f90 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 7y9dDz9Kzhj2yT8UO5ZE3Sqojvps4a+LIB5mCTlTgON2DzYXaYokVZNCbI6bhb6uSccEVaeZndPj0nBWeV0Z5m5f7DeiEjffzyidjlf4Wkqn+BnlxgK4pcMjM0byQzAaQyOYBl0iDKl7CYZ7ajX2pCUq+hvyyERDbN1ffkTs/dlahL+BogNLqJPFg0D1LZICXCeMoM9HVIuFyV0sR2ZGCFxNNfDXzRtx63YGJK9Zt1wCaHgiYf0JMgkOt13OklSwnHB+j6Q4Kj4x/PmQnKQf1b+5qxAGQrfTcV6x8Awi+Ne9+BCFNrn03zRQWKqPpeBiLQ0S2XUz2PMpee6b0F2+6MecMOSn16/BN5V35hzhFVHl05QMEGTaOJzhRywUiWiilcf67TEbS8PE8DyirYnS61R6D++jptWWz52Bp1uzErZUk7I5sl1HVEwTBKy0wlgwBHNxF4HaT1J2jVLBBAM31vlHsmq/1xYSu21OMZufXTrAUuYF/yWk9xEN2VbAqUjvzhiMcN1BzSmEYwvU1MaH7CSFXc9oYxKdOx38B6mYBMcIXDWV57PQtZpwrcF5ECeKyzOAhsRHtl8JWuPTgnQOM/ak4Lf8kYjhPtvU1N3eSgKf4rLK/6dT1vW6WmavykBwS0HJuVqVcynT+OjaP7HUEA== 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:(13230022)(396003)(39860400002)(136003)(346002)(366004)(376002)(451199015)(83380400001)(38100700002)(86362001)(66476007)(2906002)(8676002)(66556008)(5660300002)(66946007)(8936002)(41300700001)(1076003)(9686003)(26005)(186003)(6512007)(6506007)(6666004)(2616005)(6916009)(316002)(478600001)(6486002)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 6D/BfThLJIT5DrqDi86KpuZZ+MNYsfVnXFRrob7XmvwgwtXqKlu5RDFSjqxPmaQGlCrjjQueZqgaVHVYGu8Ehzk5sdu6VGn1DEue3JfdAH2kQWYDPELMzjCa1SZFWvrwG1M4hvLXVD9SP+gLhrQ7ELB+kwE570nGHuYbEr+OlvgOGsjbL9xXvyN56AgR/4LrgGqX1QR8CaSK8LXMs0rY7s4eg9B14a+tP3Lh4NfKq/Te+YxnlT5b5MntuLEioRTuCpEUUrO5NSwJZdST3dp/j0lwyO1TEx/l4ioZSLaumag+KKN1mxozH8rah0uIZ+fwmugmcVaFJZR+HDCkiHBXWpBgGPXFRj1BdwxZ0MFh6GLHBWnXyS5JleQev8jg3g5bgFYJVpXAI5ziiXVQGxKW7l2phrKL/o0zW0BElEtpMnAHdWCJBiDdtYcD1MDRpD1PpK5RG6hZhpiVWSzoEZ1KYt3v9mA3kGtQpS2BRBFFFyq2ZA3X8dotMcjTv+BOhq4UARZZnJzNQo4Ex5rRjs5ci/GoEr21L/uSbkSI5DqikF4NEdsdlh+6KVVZ36sgZAC0JoGoE03CpZ0xhQ4ea+2mfhiVrS74pYiNExl2iPOnRzyybAPuJrA+kUto4BbwKJfKp2je2qsBXyrBJiWRnExvR97CU93Keq90Jv0VNc+6Mrnt2hphwT7tv+lffLCMpNzC+FSSeUs7bbF9AwRX4Z4wnQ9OwOwfz2q1XPVhQQELm4uwSEUzbtAayQdwEyO2hzadtFoPUeEHxog83kQ7YrzFXeD8nkbSO1LeRriDlcgwqItA/mlX6u2eBTm5JXlQ7BW0NAk6VIJswbmXjVbCJCfu/JX7FsEI131jeHJBDuWrFUGIOKauKJ6XFKBbuEwvqOqvM8bCaG/cgHSO1i54/qvmjugQtEA4w0A2mpJXQ3lZFok5Z9cqKU/+XtTJSmdwoqy5aNskPe7Ha2U5U0bmXEdyfPvuZ9R651N3TDf+iW88AgjrLcrUJWFMDTZA3rPazHlYSBdJ9mADEEvAMOVs9S9Oo2n60cHQWTEM9io3PyVpHCoEoD4TgNjJBpo6p1e3AH2obsVWF3b8ma6Xnn92f8TOKL3LKMz8RRzk/SiWOA4jZvFPetlVSLT4aetfCUFpb7exEQ7bwKAp2CaTGEzMRs7zngX6ggxUC3Stu+8tBCg9o9l5Pm/+O9vnttYDZoiGBdd5pIgxVcTMuXT15rv9QW9A4eFsYkjTciH9p7CCWjeYPO/IQj8961CIxbT9jtPVwE1Fcu/6Da79dOlQI6ApJgg1IHKpgDIrAZID+BT/U+gMhZrOUCW+W2BnZ9hf3KQ5wCYX/Ljnhp2Vrd5Dx7zQb2Wqz0dKdzoJ9a991CVyVhDnzm95ZczJ2MRQxb2KV+iYLdD2RF/ruoI4HPbNbo8K4VbxQ4dd5QZU8IUG55xCQRRWYjmZQtu2fK2zlNvggcpOlaZwfth1q1LeJYXTACp0Cb5ERLYeTW+WF9NPhk9gK48Yym+bxoCOQi/GmSHHEYhPQI5rGVVkrTgFe7QWcU/ME4CCJhQxiin3qTO6NbokSnzpCBmLeynnc2HTKDbZS1lMNcpw41zeL/ohbPuc96mV7KXHYw== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 117ea4da-b5d1-4ce3-529a-08dae0df1f90 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Dec 2022 10:03:33.9008 (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: LgzRVTBgzWtBwVmTIilwx3dE3XhMQ3PQHFUzQs1EnhveYN+giWUNYxXD4M6HicKtMR40EIxglNWTFdgzFsegZNioS5Lg9urg+cy7fqtF9vU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4536 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-12-18_02,2022-12-15_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 adultscore=0 phishscore=0 mlxlogscore=999 bulkscore=0 malwarescore=0 suspectscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2212180095 X-Proofpoint-ORIG-GUID: cIakoNF-4qGiSJOLz7RsrOeWHr7fU0n8 X-Proofpoint-GUID: cIakoNF-4qGiSJOLz7RsrOeWHr7fU0n8 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Allison Henderson This patch modifies xfs_symlink to add a parent pointer to the inode. Signed-off-by: Allison Henderson --- fs/xfs/libxfs/xfs_trans_space.h | 2 -- fs/xfs/xfs_symlink.c | 54 ++++++++++++++++++++++++++++----- 2 files changed, 47 insertions(+), 9 deletions(-) diff --git a/fs/xfs/libxfs/xfs_trans_space.h b/fs/xfs/libxfs/xfs_trans_space.h index f72207923ec2..25a55650baf4 100644 --- a/fs/xfs/libxfs/xfs_trans_space.h +++ b/fs/xfs/libxfs/xfs_trans_space.h @@ -95,8 +95,6 @@ XFS_DIRREMOVE_SPACE_RES(mp) #define XFS_RENAME_SPACE_RES(mp,nl) \ (XFS_DIRREMOVE_SPACE_RES(mp) + XFS_DIRENTER_SPACE_RES(mp,nl)) -#define XFS_SYMLINK_SPACE_RES(mp,nl,b) \ - (XFS_IALLOC_SPACE_RES(mp) + XFS_DIRENTER_SPACE_RES(mp,nl) + (b)) #define XFS_IFREE_SPACE_RES(mp) \ (xfs_has_finobt(mp) ? M_IGEO(mp)->inobt_maxlevels : 0) diff --git a/fs/xfs/xfs_symlink.c b/fs/xfs/xfs_symlink.c index 27a7d7c57015..92d69b3ca28d 100644 --- a/fs/xfs/xfs_symlink.c +++ b/fs/xfs/xfs_symlink.c @@ -23,6 +23,8 @@ #include "xfs_trans.h" #include "xfs_ialloc.h" #include "xfs_error.h" +#include "xfs_parent.h" +#include "xfs_defer.h" /* ----- Kernel only functions below ----- */ int @@ -142,6 +144,23 @@ xfs_readlink( return error; } +static unsigned int +xfs_symlink_space_res( + struct xfs_mount *mp, + unsigned int namelen, + unsigned int fsblocks) +{ + unsigned int ret; + + ret = XFS_IALLOC_SPACE_RES(mp) + XFS_DIRENTER_SPACE_RES(mp, namelen) + + fsblocks; + + if (xfs_has_parent(mp)) + ret += xfs_pptr_calc_space_res(mp, namelen); + + return ret; +} + int xfs_symlink( struct user_namespace *mnt_userns, @@ -172,6 +191,8 @@ xfs_symlink( struct xfs_dquot *pdqp = NULL; uint resblks; xfs_ino_t ino; + xfs_dir2_dataptr_t diroffset; + struct xfs_parent_defer *parent = NULL; *ipp = NULL; @@ -202,13 +223,21 @@ xfs_symlink( /* * The symlink will fit into the inode data fork? - * There can't be any attributes so we get the whole variable part. + * If there are no parent pointers, then there wont't be any attributes. + * So we get the whole variable part, and do not need to reserve extra + * blocks. Otherwise, we need to reserve the blocks. */ - if (pathlen <= XFS_LITINO(mp)) + if (pathlen <= XFS_LITINO(mp) && !xfs_has_parent(mp)) fs_blocks = 0; else fs_blocks = xfs_symlink_blocks(mp, pathlen); - resblks = XFS_SYMLINK_SPACE_RES(mp, link_name->len, fs_blocks); + resblks = xfs_symlink_space_res(mp, link_name->len, fs_blocks); + + if (xfs_has_parent(mp)) { + error = xfs_parent_init(mp, &parent); + if (error) + return error; + } error = xfs_trans_alloc_icreate(mp, &M_RES(mp)->tr_symlink, udqp, gdqp, pdqp, resblks, &tp); @@ -233,7 +262,7 @@ xfs_symlink( if (!error) error = xfs_init_new_inode(mnt_userns, tp, dp, ino, S_IFLNK | (mode & ~S_IFMT), 1, 0, prid, - false, &ip); + xfs_has_parent(mp), &ip); if (error) goto out_trans_cancel; @@ -244,8 +273,7 @@ xfs_symlink( * the transaction cancel unlocking dp so don't do it explicitly in the * error path. */ - xfs_trans_ijoin(tp, dp, XFS_ILOCK_EXCL); - unlock_dp_on_error = false; + xfs_trans_ijoin(tp, dp, 0); /* * Also attach the dquot(s) to it, if applicable. @@ -315,12 +343,20 @@ xfs_symlink( * Create the directory entry for the symlink. */ error = xfs_dir_createname(tp, dp, link_name, - ip->i_ino, resblks, NULL); + ip->i_ino, resblks, &diroffset); if (error) goto out_trans_cancel; xfs_trans_ichgtime(tp, dp, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG); xfs_trans_log_inode(tp, dp, XFS_ILOG_CORE); + if (parent) { + error = xfs_parent_defer_add(tp, parent, dp, link_name, + diroffset, ip); + if (error) + goto out_trans_cancel; + } + + /* * If this is a synchronous mount, make sure that the * symlink transaction goes to disk before returning to @@ -339,6 +375,7 @@ xfs_symlink( *ipp = ip; xfs_iunlock(ip, XFS_ILOCK_EXCL); + xfs_iunlock(dp, XFS_ILOCK_EXCL); return 0; out_trans_cancel: @@ -362,6 +399,9 @@ xfs_symlink( xfs_iunlock(dp, XFS_ILOCK_EXCL); if (ip) xfs_iunlock(ip, XFS_ILOCK_EXCL); + if (parent) + xfs_parent_cancel(mp, parent); + return error; } From patchwork Sun Dec 18 10:02:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 13076012 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 4B2D5C4332F for ; Sun, 18 Dec 2022 10:03:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230287AbiLRKDn (ORCPT ); Sun, 18 Dec 2022 05:03:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60184 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229585AbiLRKDk (ORCPT ); Sun, 18 Dec 2022 05:03:40 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E4E955B2 for ; Sun, 18 Dec 2022 02:03:38 -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 2BI507FY007702 for ; Sun, 18 Dec 2022 10:03:38 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=j1uF1962JupdkqwTaiZqcYccXWKqKx+j/ONP8CHpYy0=; b=0J4gNOtsghQG5gf3yyu/cR0F/agv1pobeRQZqI6EjCvpJAA1KK5KFN8u8BGtgqPYSpux /4LzSsUSJ95HEN0rXSRaOW1vJMOxAqPEmfG0KLFnIzT9+hkB6lUf1A2/eID1n27LBjrt WSMZJ/Wy92AWainkacC8UrAyc9Oa0RtEyJ24Pv79y7YIlSKCJbSGJbv4YDdu+kVvcIxQ d3MkLfIj20QBlLMxJzEnpk0HDBs/1pQovIft+sdycn8CzDcUpXomafQuaOlBXDlJHdc/ HHnRw1OmHGcJzZXZzSozHRnNXoNwK8IWpP/lytDmzOxi+0SEC3gDyoiBN9+YdfqssMKt 2w== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3mh6tqs960-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sun, 18 Dec 2022 10:03:38 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 2BI909Wq012804 for ; Sun, 18 Dec 2022 10:03:37 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2171.outbound.protection.outlook.com [104.47.55.171]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3mh472cfwr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sun, 18 Dec 2022 10:03:37 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XZqP2FDIuqRbDicmJm8SuL5bto3xoAl+29YHSG2PtQRxaXsiIQU7658vi6cs5HxYb7VSkcmZqf0eX425zpCss1FAoLfWhioxK7Iao084u7zP+Nwkyy3ySxuqvXInEU+J9fVQjmmGnpdDdxRs85z7I1mLhyKffbuH14WoHqycEUS3TXjPvxe1G9munT+cLtWGBqmnA6ImRM26dkljWdmCSnu3N3xpgxML2ACVIA8st+GWAwMBp2DOuKymoep6CgsSEkdo4M1ywxaSOiQY/QyBzLEhswmc+svftEFa5JDYlVMwL0j7XDdouWFLbZLddbY24fkrcnmNwFLX4FOhObMTwg== 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=j1uF1962JupdkqwTaiZqcYccXWKqKx+j/ONP8CHpYy0=; b=cwZbEXMvzv8QR1Xbc7hfYjU30un048iWn6gh81hlSp3EH/9CV5fdGXedlt8gTobH3wHewegh65MsBU0bZl6ZWeSj4t/wUhBzLu2ACpi8PFHGzbxXW79ngoX3Mpvuvpc5CSbT6KMwZl/Y1/lS+XMPz3CPQC1Lpuz6hITGP9I9l61Jr9aT6eG75jrowoCpH077reiXF4BHwQapCeCsdTc2G5OvC0r076fEZvWVdf5mgpMUMAcfCtvgV5xrZiPWKdgUto3wD7rH4S4aFKCrggFBZaqetJGqvzfo8it+raOI9O+WtuglqPuJsaqONjQY7UQmCJOfsCX4vyv/ks6CWg37gw== 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=j1uF1962JupdkqwTaiZqcYccXWKqKx+j/ONP8CHpYy0=; b=a1O0qEGxYa35HJYepgkjJ7hlY+GFgEGHfGhW0PYuXN9ZXuyboNAbHjjVQQf3pK3cUlEUVWM5UloOKQKTgd/VKO7lgWi/MVXK+tGio2Ar5DSyB8Z5/QF0dHAgZXUzdbCus4tr9Y6gydlLEXDR9HK5WJl92smNHthFQ01i3OpFS/c= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by PH0PR10MB4536.namprd10.prod.outlook.com (2603:10b6:510:40::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5924.16; Sun, 18 Dec 2022 10:03:35 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::3cab:6ff7:cb4d:b57c]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::3cab:6ff7:cb4d:b57c%4]) with mapi id 15.20.5924.016; Sun, 18 Dec 2022 10:03:35 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v7 18/27] xfs: remove parent pointers in unlink Date: Sun, 18 Dec 2022 03:02:57 -0700 Message-Id: <20221218100306.76408-19-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221218100306.76408-1-allison.henderson@oracle.com> References: <20221218100306.76408-1-allison.henderson@oracle.com> X-ClientProxiedBy: SJ0PR03CA0235.namprd03.prod.outlook.com (2603:10b6:a03:39f::30) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY5PR10MB4306:EE_|PH0PR10MB4536:EE_ X-MS-Office365-Filtering-Correlation-Id: b720471c-5ece-4831-d183-08dae0df208a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LUAk7mlssa2KxYOsSZVWZ1fFnpZSYp18NoljhhBylVaVLYAdkC9oLGXRtiDJ6Nij7+yGPG8ug0kLXMDl1E4LPxZL4oKebRqfl0H/oCLiqZOuGTrajjvP9NCEHB2Xv5G84yD/2KDARmJ+u6uQlgj80Z0WBWtXtkA4y24x/G6rNtssY+3XYbuis206MdWtQWHoD9H6mdPV4DXVj/pqT4MoSX2xswioT+C3UPWQFriYCYAbKUjMLPGxrq03rH/nwtt7e1A5iUSHJQD0qsUlO1O5zTitztHRpP+Tq2FTXI9Y5f3+niOqOthCqTOGBXQ4Qbj+1BJcor4WMFDdqR+Ha/UhNzMCccr4htZ98DKBW3baNWvlTQJa2HFRsYB8+fjEln5NZa9bmLe3cWS8wf7o5Ix1SjIlL3TqYq4FFWIghVEuXw9Lkh+jhB9IIOusQqTAU0yTIf6Naw/+oq+9pR3s8lLOvPXkyX7Fz3XKfJ1W+KcpF0MRhHA2IuOCbsTecJK6AXcPsU/yT1nB2W/WmbFc3JDdMgUOQ70k6VVmEknFIYgAPf4QZybmbH6GepGoo6fQ9TvIy/SaCl2XRoZlkqfnm+px4Lkzk/Y51eSZ0ipw/v/Atx/LTqWaaqZzia+MGd3Kro5QuaZB7Hd+B6NJBBSjfwdb5w== 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:(13230022)(396003)(39860400002)(136003)(346002)(366004)(376002)(451199015)(83380400001)(38100700002)(86362001)(66476007)(2906002)(8676002)(66556008)(5660300002)(66946007)(8936002)(41300700001)(1076003)(9686003)(26005)(186003)(6512007)(6506007)(6666004)(2616005)(6916009)(316002)(478600001)(6486002)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ZVrz+bTfopumINWY3DQIIWuWkJoWrKFSlZ3BiYa/wzP0FDEvAgm5uO2b6SkLRvfuSy9RAZGEgHI+xahpNKR1IftvvtM+10ZDliMnX+sD3lW0wQGNs++JlVUvkyKyMJVfeHa9alCdHz5cecVhVAOkjKZViNTbCAJ6wKLVDj9E1I2bF6vj3/uE9kGn84ywVWDGpMQyemiVw1i18vUHT8KoTxJNylefWSOVEPYD9LGZtq4ltCkx0/CDg+/N+gcEA9tMHhV6pJFK+rMD+Fvy3ArK9Yt/ZuQTDsa2eLn0u5eRrTdYnWe7Jl/HW90wGVyJaPVh0TAc0KhRbBZfsf0qLVv6RHCG43f3lZ8nlzVYOOkeVFmmpUnrRiYhF/PS/NMU8bZvmwctxioiSsCMVBrT6eN4gg/rlqlFwfWB6KRbzQXLVqpbjT2cVyMwY6TwggXBiLANeoCcTjrHAXGTISKz3NeU2n90pWKqY9wr1pE3KbvpHsBv4T0mQWDdgN7L2ptSM42KnjL19enJDatb+7vitpzdM8Avo/gtdgep/uf+xYNo0KBc6se+RWQ7njN6/bH77iPbZoiguBNKEkOpqPEGQS/5zWzv5Nr2vRK2HbgbbBKYaz0OvrBthtxMVMynQ32KH+DKdRVwCSPtV2l1ulLHS2EKWAZIdFKgMFFF8cXsAhdxTURmnjPbjJmQU9Nu+CusV1CbRIkvbBq6YWb7lNV5YMVGpgbDv6NhkWTeTN/HW2m30e9gzV59dW06jQwbBCZKmDMn4nD2YGCh9Szt7luorRoOzA3VS7BdNHyk0RPo+7c3PZu0ET0ueW/v3I7Z5G/Jp1Lyjtya5e44TUceGMurZtc3StOgRc44Z1mJBcRAGPdM+mJ7aCPfI/5YQbJVmJazP+6U3Bd9IoeerAGXOv5ITqphukOhxGN/Hjg4UFF0/lvV+sRaSsfY3CYyuxJzlz++0YJj2cirieFGr8VTRMypQvYSpEn7j0oB4PjIkg8lLaXqe4B9CcvTgs3j7i2KTwjiWHkeV1qrEmj3hFxRnxU9RoxSjn5BJk2SvFlcbuRN87ivKwgQamO/2XUr5WnqZAEuRTbVAyp1MagH0S2Q619dCb06kU1gKOo5+IiAO8o+bV09+MsxXIahCGw8Ws6mojpLWgRbXoKztasJPRIoF9Up5cs/37EEfGKWS2zaURlD4cnXIfI/0e/frqvyNlyO0K93vTUMkbRxut/tfDcyISn0HBCDhfBH9N2D9Ibta/gOuRj7ph9QMPJTDUP4fnZIf25arUQQtpOxXzaEO1eCjW8pAuE43ESc4osvP5toaXbA/ml3UTupfT6nhdduuZYAxS38odtU+ATs7JADq3lG92o1LQXyUF1v/5aE83ptc5suTkoFAp/g/isiyYtbt/XLdsWMlpjXfgq4Q6cNZGoHghJoyw8uwEV1+6CV5MgkTg6/5hR/fCpgl10JdxGkgKOLfLQoaCK9yKIor/xbkyX3YtDTpkNP2KxxYJCLXhvUN6U8Rn8GT4VRxlGYvQ4vE8wAOn9HC0VgpFTDngHxGxvhm++RVLHauiDmOOH5GGC9KbB/ptotIeABdzKiHZn7IM1Ahfjnssd6E1vZReKLU7WJ3LyRA2uaDw== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: b720471c-5ece-4831-d183-08dae0df208a X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Dec 2022 10:03:35.6050 (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: Jp+thdSAIDyxTsUfnMa59QOgUB/6I295UBpuYWVP7/vYBU+H06Ye1NsqW2KCxB6IRWpaHbvBSza5MxKh5hznEb+NqAlbmVAofmicfA2hLjc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4536 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-12-18_02,2022-12-15_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 phishscore=0 suspectscore=0 adultscore=0 malwarescore=0 spamscore=0 mlxlogscore=999 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2212180095 X-Proofpoint-GUID: z9GgbwJ32pcAoIfEfMR8sogDSKOlNmg- X-Proofpoint-ORIG-GUID: z9GgbwJ32pcAoIfEfMR8sogDSKOlNmg- Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Allison Henderson This patch removes the parent pointer attribute during unlink Signed-off-by: Dave Chinner Signed-off-by: Allison Henderson Reviewed-by: Darrick J. Wong --- fs/xfs/libxfs/xfs_attr.c | 2 +- fs/xfs/libxfs/xfs_attr.h | 1 + fs/xfs/libxfs/xfs_parent.c | 17 +++++++++++++ fs/xfs/libxfs/xfs_parent.h | 4 +++ fs/xfs/libxfs/xfs_trans_space.h | 2 -- fs/xfs/xfs_inode.c | 44 +++++++++++++++++++++++++++------ 6 files changed, 60 insertions(+), 10 deletions(-) diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c index f68d41f0f998..a8db44728b11 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -946,7 +946,7 @@ xfs_attr_defer_replace( } /* Removes an attribute for an inode as a deferred operation */ -static int +int xfs_attr_defer_remove( struct xfs_da_args *args) { diff --git a/fs/xfs/libxfs/xfs_attr.h b/fs/xfs/libxfs/xfs_attr.h index 0cf23f5117ad..033005542b9e 100644 --- a/fs/xfs/libxfs/xfs_attr.h +++ b/fs/xfs/libxfs/xfs_attr.h @@ -545,6 +545,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_defer_add(struct xfs_da_args *args); +int xfs_attr_defer_remove(struct xfs_da_args *args); int xfs_attr_set(struct xfs_da_args *args); int xfs_attr_set_iter(struct xfs_attr_intent *attr); int xfs_attr_remove_iter(struct xfs_attr_intent *attr); diff --git a/fs/xfs/libxfs/xfs_parent.c b/fs/xfs/libxfs/xfs_parent.c index cf5ea8ce8bd3..c09f49b7c241 100644 --- a/fs/xfs/libxfs/xfs_parent.c +++ b/fs/xfs/libxfs/xfs_parent.c @@ -125,6 +125,23 @@ xfs_parent_defer_add( return xfs_attr_defer_add(args); } +int +xfs_parent_defer_remove( + struct xfs_trans *tp, + struct xfs_inode *dp, + struct xfs_parent_defer *parent, + xfs_dir2_dataptr_t diroffset, + struct xfs_inode *child) +{ + struct xfs_da_args *args = &parent->args; + + xfs_init_parent_name_rec(&parent->rec, dp, diroffset); + args->trans = tp; + args->dp = child; + args->hashval = xfs_da_hashname(args->name, args->namelen); + return xfs_attr_defer_remove(args); +} + void xfs_parent_cancel( xfs_mount_t *mp, diff --git a/fs/xfs/libxfs/xfs_parent.h b/fs/xfs/libxfs/xfs_parent.h index 9b8d0764aad6..1c506532c624 100644 --- a/fs/xfs/libxfs/xfs_parent.h +++ b/fs/xfs/libxfs/xfs_parent.h @@ -27,6 +27,10 @@ int xfs_parent_init(xfs_mount_t *mp, struct xfs_parent_defer **parentp); int xfs_parent_defer_add(struct xfs_trans *tp, struct xfs_parent_defer *parent, struct xfs_inode *dp, struct xfs_name *parent_name, xfs_dir2_dataptr_t diroffset, struct xfs_inode *child); +int xfs_parent_defer_remove(struct xfs_trans *tp, struct xfs_inode *dp, + struct xfs_parent_defer *parent, + xfs_dir2_dataptr_t diroffset, + struct xfs_inode *child); void xfs_parent_cancel(xfs_mount_t *mp, struct xfs_parent_defer *parent); unsigned int xfs_pptr_calc_space_res(struct xfs_mount *mp, unsigned int namelen); diff --git a/fs/xfs/libxfs/xfs_trans_space.h b/fs/xfs/libxfs/xfs_trans_space.h index 25a55650baf4..b5ab6701e7fb 100644 --- a/fs/xfs/libxfs/xfs_trans_space.h +++ b/fs/xfs/libxfs/xfs_trans_space.h @@ -91,8 +91,6 @@ XFS_DQUOT_CLUSTER_SIZE_FSB) #define XFS_QM_QINOCREATE_SPACE_RES(mp) \ XFS_IALLOC_SPACE_RES(mp) -#define XFS_REMOVE_SPACE_RES(mp) \ - XFS_DIRREMOVE_SPACE_RES(mp) #define XFS_RENAME_SPACE_RES(mp,nl) \ (XFS_DIRREMOVE_SPACE_RES(mp) + XFS_DIRENTER_SPACE_RES(mp,nl)) #define XFS_IFREE_SPACE_RES(mp) \ diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index fbeba9cbf85d..a53a000a7169 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -2471,6 +2471,19 @@ xfs_iunpin_wait( __xfs_iunpin_wait(ip); } +static unsigned int +xfs_remove_space_res( + struct xfs_mount *mp, + unsigned int namelen) +{ + unsigned int ret = XFS_DIRREMOVE_SPACE_RES(mp); + + if (xfs_has_parent(mp)) + ret += xfs_pptr_calc_space_res(mp, namelen); + + return ret; +} + /* * Removing an inode from the namespace involves removing the directory entry * and dropping the link count on the inode. Removing the directory entry can @@ -2500,16 +2513,18 @@ xfs_iunpin_wait( */ int xfs_remove( - xfs_inode_t *dp, + struct xfs_inode *dp, struct xfs_name *name, - xfs_inode_t *ip) + struct xfs_inode *ip) { - xfs_mount_t *mp = dp->i_mount; - xfs_trans_t *tp = NULL; + struct xfs_mount *mp = dp->i_mount; + struct xfs_trans *tp = NULL; int is_dir = S_ISDIR(VFS_I(ip)->i_mode); int dontcare; int error = 0; uint resblks; + xfs_dir2_dataptr_t dir_offset; + struct xfs_parent_defer *parent = NULL; trace_xfs_remove(dp, name); @@ -2524,6 +2539,12 @@ xfs_remove( if (error) goto std_return; + if (xfs_has_parent(mp)) { + error = xfs_parent_init(mp, &parent); + if (error) + goto std_return; + } + /* * We try to get the real space reservation first, allowing for * directory btree deletion(s) implying possible bmap insert(s). If we @@ -2535,12 +2556,12 @@ xfs_remove( * the directory code can handle a reservationless update and we don't * want to prevent a user from trying to free space by deleting things. */ - resblks = XFS_REMOVE_SPACE_RES(mp); + resblks = xfs_remove_space_res(mp, name->len); error = xfs_trans_alloc_dir(dp, &M_RES(mp)->tr_remove, ip, &resblks, &tp, &dontcare); if (error) { ASSERT(error != -ENOSPC); - goto std_return; + goto drop_incompat; } /* @@ -2594,12 +2615,18 @@ xfs_remove( if (error) goto out_trans_cancel; - error = xfs_dir_removename(tp, dp, name, ip->i_ino, resblks, NULL); + error = xfs_dir_removename(tp, dp, name, ip->i_ino, resblks, &dir_offset); if (error) { ASSERT(error != -ENOENT); goto out_trans_cancel; } + if (parent) { + error = xfs_parent_defer_remove(tp, dp, parent, dir_offset, ip); + if (error) + goto out_trans_cancel; + } + /* * If this is a synchronous mount, make sure that the * remove transaction goes to disk before returning to @@ -2624,6 +2651,9 @@ xfs_remove( out_unlock: xfs_iunlock(ip, XFS_ILOCK_EXCL); xfs_iunlock(dp, XFS_ILOCK_EXCL); + drop_incompat: + if (parent) + xfs_parent_cancel(mp, parent); std_return: return error; } From patchwork Sun Dec 18 10:02:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 13076013 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 1BC17C4332F for ; Sun, 18 Dec 2022 10:03:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230309AbiLRKDs (ORCPT ); Sun, 18 Dec 2022 05:03:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60246 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229585AbiLRKDp (ORCPT ); Sun, 18 Dec 2022 05:03:45 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C488555A8 for ; Sun, 18 Dec 2022 02:03:41 -0800 (PST) Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2BI4oS7W013418 for ; Sun, 18 Dec 2022 10:03:41 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=caHGey35nRfvCGaR7VD5GKq+MGhJCdpWWJh7rrbhUVg=; b=Na30nVJqvHNKuLCAp78fPKBCULWRZT8a2qhKiIY/vwBoyHq1aTD1PcPWobcrv1jeRI28 TsdeYQtjJ9+6tJ6NMWr8Tfyd5PH9coEUHewPgslF+kd4Yo3cBANhOaDLrs+0YfKV3T7R 1wTMgedbRoyDRGqS8LlRTMHxMQr1G3cKsKT0a1fpHQV49I7lISqNOgEon2P6hNX55hyw WuPgYr0aVXCpC41SibQOE9FSa3Hp1sTT/OVS4p2GvxDuOdiQp2cuYa8cayFi7uq4eKll ZTkrD93ZuZZ95RNg02AAxqs6nCGdVlT/rCZOfEeVL4YZAdE2nZfZps3wgTOV08D0qa7D jQ== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3mh6tms9b9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sun, 18 Dec 2022 10:03:40 +0000 Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 2BI87lfN007145 for ; Sun, 18 Dec 2022 10:03:40 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2173.outbound.protection.outlook.com [104.47.56.173]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3mh479cbr1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sun, 18 Dec 2022 10:03:40 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YyMLoC0/IA9XZL3ZbVMfM9LQ1n2MhzR2esAWgSS2a8yfoq1vztZ1xUMgowXZ8/y26mVgRm8ZkC/as60LyIQKKY+/cj3JCDZ6q6X7z0dzv6QpLvvsoCC9x9mpMNCEe2ay2LdSkYaquj4lJ1xujmx562TaOs7y/lQey5VPLgFTizvOful9fKYdmfYdND3HAM5iweUnPCaIEQ7J5aHeXiNRIV7CBocrDz4ZN96REsKr3x17j+Wu8VZc1ZFzrLp6cDpWDfI401PjnNtmt99tVzf2nJcpuqrfHcpQzM+6lgVR/k7ujdgIeTnWQzgtT6X8ImqZcF+b8qwqwz/gnmUdXVSL5w== 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=caHGey35nRfvCGaR7VD5GKq+MGhJCdpWWJh7rrbhUVg=; b=Eaewh1uUTCPImsqFAApKggM3oFS+DivCmSPaEOBxrys7dK0oHTAY3SX3QbntQovdP4XM967KVbxZz9dNqZVMaGXyb6zQcuUcGyLP81e7V2gKxug2otggmFx5omHBb5NsxfabrYuCldjSC4/HzXUdl9UeWC49loqHlO3n8pCoaKvkAYOJ/9eaOVQxN4E4rEQtJMdXlQzyYpfzG3+zrzIRsMR7+jTtLM1VqFaYm5sZdPP9MBfo7KfB/4dL++A3hOuvdKyTFEzstxU6+TNV0O/taZ+w/UJ3X9e3PW3ZDJ33FNTkj6QETRCVkZQtqXhLsZKqgKiegG9fIIueGswecmhMcQ== 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=caHGey35nRfvCGaR7VD5GKq+MGhJCdpWWJh7rrbhUVg=; b=ITXDhi3bx/UbpRBeJukWK6vepXsW+kjJgZPbsChTjvpdjzLDZSA0yw3XtpxT1SkAaH86KQxR9h8xjCjI+bEjNbK4hX/sNUsrb+Xavqlj5CedglFhNI/d+q0xCdfwOtdo1mYggUoDkrLeAwWMfWZDzGj48Ot5yJsCfrIWi8Ilbzo= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by IA0PR10MB7181.namprd10.prod.outlook.com (2603:10b6:208:400::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5924.16; Sun, 18 Dec 2022 10:03:38 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::3cab:6ff7:cb4d:b57c]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::3cab:6ff7:cb4d:b57c%4]) with mapi id 15.20.5924.016; Sun, 18 Dec 2022 10:03:37 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v7 19/27] xfs: Indent xfs_rename Date: Sun, 18 Dec 2022 03:02:58 -0700 Message-Id: <20221218100306.76408-20-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221218100306.76408-1-allison.henderson@oracle.com> References: <20221218100306.76408-1-allison.henderson@oracle.com> X-ClientProxiedBy: BY5PR04CA0028.namprd04.prod.outlook.com (2603:10b6:a03:1d0::38) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY5PR10MB4306:EE_|IA0PR10MB7181:EE_ X-MS-Office365-Filtering-Correlation-Id: 909a0a82-fe80-4430-6058-08dae0df2179 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: FB183crl+dzXgw9jDYcPS9kVzJaNh+8oGopMjqSCuho1Yq+GCsGq4mJTyc2BTOIC+7OBeOVi1gsSQWD2fWZ+zhHc4ea+RqLQxBY3JyTWBVRMM1z9JoLpWU1REG8eM+TjNFw6px1ZhLObmz9iTscvOu1BfpYNt0IOP7OWlW98otQKgm0pEV7YL38pPGiGH5JIR8P/O09YyxjdVFjvuWfaOt9gJLGCqE09pxl+ntyYI8BpUohCimCWLxRLHBLQvYFHy5+1VJRoUTHwg6NJaXIwm/nb1SmG2hDOE3FsohP3kj2opY1A1zbndWJS39DnyFJz48jCzepx0eEr2ag4h4Fq0DvLxbEuIK/Anx2OkApTXK59L6KFin1kT6qTp2QRrFL312LQdkcmLpcuLKs48KAB07CxQonQqMRWRN/ONhHSlNBG7+5082TwFw9+hkR7YzSUCx7sVxy6ziPURkD2wTtNP1V2VY5qvOjzWWbEomiY45+GgSocYswsGGAvWGiqRrfKrBxX1pmqRGWi5LR/cqUhWU/TyhTxPfp2vuez4mPu/qr+YDQJZBsDlxLWBLYCJzzhC3rX0sBIp26RgZ0o35HpqBV/4CNB2iorS2YsW7tVITu0SdAIkuaVR0symADtnMWv 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:(13230022)(39860400002)(136003)(366004)(376002)(396003)(346002)(451199015)(83380400001)(2906002)(41300700001)(8936002)(5660300002)(86362001)(38100700002)(36756003)(316002)(6506007)(6916009)(478600001)(6486002)(186003)(26005)(6512007)(66946007)(9686003)(2616005)(66476007)(8676002)(6666004)(66556008)(1076003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: hWJlyzA2o3ZJNfjowoYfqrcWuOi8E//TtTbaodZlihFe9e189gnmQ5tuhjOsxqF2af+H6OGvDjQLG5OMJKLPQTZj13wNdIAag7eSB+FXDkBZb+2oIBTEvsiJBfAXYtJJit0x0SMItN2dKdFaOpjyjehgihDw4EP2dTrRtlQy/0v9tTi2RxWO8JuD3NujGSt40HYJeMqCD169wjZjjm4duZUXasmSbHdA+CCOH3KtNU4ESacCcPCbQir0+7D1OkRO0+ZWD2WpeoOfSyRVaBnfcmml/26gnQamkjG2m0a7SypPli1HB9wXU6XKvO2PX3/GdQGCjvyQ9HGUrO/8JuQhml/aX2Y7Bhus5O8OiIQiE1S3jvzpmtooaFh2Hdex03KSS8UnGu83mIshK294sMlvVOHfEbuvJA6go5N01xx8yXQlgUDiafHJB9/uKINFxXUG/JuLm+4YVTjUmwqRW3wx59GP8SlEB1PPaseD6oBYqcclVV6IsgDD/riXUCO9dbnIY+l6vCz5jHXuNuhsDJOPUwcJ45jaCr6idTpdWTV16RCUoLD/l8wSmpQM2nzmlv03VWudDhDNOy8cxii5U3k+nZCdRWOH1wr84XfMV8fqvAQgz4l1DavDMSAY4OuqW23iYgv6nFL4gDWKTZosy/V3DcxLZ/Q42YHsvZslUk1FSM6qzjpW/b04eZTd6E56rxwYfGAfjlqdQ2fsomD8k96qn0fVD/CfOJXAm2tFTQEiUuawNpW5FOKqAj/A0CseSfJmKpbgHRgmg1wdPad5cAIcIVaTQhtWVL7rpkb+UnNqqh9buTZDbE5IwyeVcxBFHMP4NZywtqMLWZUZSXP/+gBNPDSXYrROwDiqcz4jsj3sy8h2tlRYBqirYmEa7BxRajmiinyXG2W47ZKX65WGWsLruZbm50BVwiZ5HqxpnPfuO027SFTHU5kzpoS/BJ4AYg8OdUE5PLZqQEC2CsjLRfDjOoPldfrGFp1yfMxafKr4u2GxnTNqHGJh+uyAMBg8gq7htBTkqpSWEhwANC+gNXcK1cdLhi+s+hTfUhAZxxs5pQEhfp1P++GN91OAXtvH0XosczvSjublffkDqAAXfKHskiiINbipC4to8yKHbr/qgQDXVWkIh6ib4Xswt9DB9Wk1XI1gzSTtTiI5t7Dv9g87T8YC86oUEbWAWWoCtbb2udQXRgPBzgAEFNMzTzbrzmyewdxAqQ8WPqMZr7VBS9fZU28WlZCWrlQ6dOkMODrRRUW8vPwsEpmlRTHfwq7FUfVvxIciyGMHBciE9X74+C8/Tlhcu/HylNqTiq6GnOvtvHWJ8o9KkBhKFYEEuWKfTM3kUJpeyfWka8YHVEsOLmfUjaS8qnzqEo9H+EeoRNvy9+GWbPXCS5HEgBZfZTLoTQfnxsiXlCe1uXw1QhdFNtAR6NckaTnhGKFigJ0T3mXFTkgW1AIreqDyyBVmoTT2A4dn6FFJnb6WulOx1EYKU1+ngt9zncL4/FTHDaUPaxVGjg7ayjIYNkIyMagT9DVZOjVYKACNL6qv4QL4GwoCkzj23rMdyqbazH22Vi5jqDBV4/jxxlOxfED13I/JbwtzJB0MBx/yXH5W7xjQceqSRgUsXw== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 909a0a82-fe80-4430-6058-08dae0df2179 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Dec 2022 10:03:37.0746 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: ug3rumNUWMJ5zmw640gnFl/Auwozt/OmBPyVvI3dZnng8ez87oXNEdUjPwBdVrb36zJBIe7SAwMQPMCzQIpziqbAfaj0wzZC9iYov4O/BYs= X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR10MB7181 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-12-18_02,2022-12-15_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 malwarescore=0 phishscore=0 suspectscore=0 spamscore=0 bulkscore=0 mlxscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2212180095 X-Proofpoint-ORIG-GUID: zohKegcfPMlch488zrYPa7rs4sFYmTPA X-Proofpoint-GUID: zohKegcfPMlch488zrYPa7rs4sFYmTPA Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Allison Henderson Indent variables and parameters in xfs_rename in preparation for parent pointer modifications. White space only, no functional changes. This will make reviewing new code easier on reviewers. Signed-off-by: Allison Henderson Reviewed-by: Darrick J. Wong --- fs/xfs/xfs_inode.c | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index a53a000a7169..34bc6db0cfd7 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -2898,26 +2898,27 @@ xfs_rename_alloc_whiteout( */ int xfs_rename( - struct user_namespace *mnt_userns, - struct xfs_inode *src_dp, - struct xfs_name *src_name, - struct xfs_inode *src_ip, - struct xfs_inode *target_dp, - struct xfs_name *target_name, - struct xfs_inode *target_ip, - unsigned int flags) -{ - struct xfs_mount *mp = src_dp->i_mount; - struct xfs_trans *tp; - struct xfs_inode *wip = NULL; /* whiteout inode */ - struct xfs_inode *inodes[__XFS_SORT_INODES]; - int i; - int num_inodes = __XFS_SORT_INODES; - bool new_parent = (src_dp != target_dp); - bool src_is_directory = S_ISDIR(VFS_I(src_ip)->i_mode); - int spaceres; - bool retried = false; - int error, nospace_error = 0; + struct user_namespace *mnt_userns, + struct xfs_inode *src_dp, + struct xfs_name *src_name, + struct xfs_inode *src_ip, + struct xfs_inode *target_dp, + struct xfs_name *target_name, + struct xfs_inode *target_ip, + unsigned int flags) +{ + struct xfs_mount *mp = src_dp->i_mount; + struct xfs_trans *tp; + struct xfs_inode *wip = NULL; /* whiteout inode */ + struct xfs_inode *inodes[__XFS_SORT_INODES]; + int i; + int num_inodes = __XFS_SORT_INODES; + bool new_parent = (src_dp != target_dp); + bool src_is_directory = + S_ISDIR(VFS_I(src_ip)->i_mode); + int spaceres; + bool retried = false; + int error, nospace_error = 0; trace_xfs_rename(src_dp, target_dp, src_name, target_name); From patchwork Sun Dec 18 10:02:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 13076015 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 BB551C4167B for ; Sun, 18 Dec 2022 10:03:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230314AbiLRKDt (ORCPT ); Sun, 18 Dec 2022 05:03:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60248 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230294AbiLRKDq (ORCPT ); Sun, 18 Dec 2022 05:03:46 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 48E5755B0 for ; Sun, 18 Dec 2022 02:03:42 -0800 (PST) Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2BI4w3de017492 for ; Sun, 18 Dec 2022 10:03:41 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=ffc5bc1QySHFyRSNnA6bj3jfBI6UpYpnn8MFEsc6vlM=; b=f6tkY/Za8ptPsYmRc/FTJHZb5extTTQYC3lNsCddi5bQt1BTZtkI8i3iS+dENnEunW37 XAA1Eqo4UhILj1P+j24m9fR0UgtjhMn698LJe2NlWqNrbmmSrFPzZan3x8ncBLfrf0Af 2VnnmKpHHl4OosTJW/iUCEv5lrqqaS5Db2If034iFkZBYg4fApSVSZNwLEOLBIQDXCOm 8lcKybdPCYtfMFOjWptJii60pEG04B4Qyr1EeNd0g826dKldzvFLEN42pGHUxscioFsu hKwV9FuGe5LM7rGbVbcijndFtPZJ3v+BhO+xM+lTTNkKwT/bYBVXy9Lh2grveeTIlzUz BA== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3mh6tm19a5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sun, 18 Dec 2022 10:03:41 +0000 Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 2BI87lfO007145 for ; Sun, 18 Dec 2022 10:03:40 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2173.outbound.protection.outlook.com [104.47.56.173]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3mh479cbr1-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sun, 18 Dec 2022 10:03:40 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cVbuS+4OnTQNscXrcHJx+QhCDVpUnSWoXYKoSpZKcD124IApwjV5NAIfQPDC3qvMjWcxO5GdmgPgKWkrRS9p01ZDB/QJirFGeCZg+rzCpkZlm/3pJFORCv/xfw+Kh1KcETmONIa1oNwuT9bfF8AGJbB5NaMl+aC5oaCjgUsI42rfaVbj0lK5d8HYSexAGL4nixK0/BFnW1AQp286cDBJqqm8mZHiBzfheEN5GD3aLYh5kwL8xpEJgaJ/oBYvIGt0LHJCvoE7L/VDf3rgfq4vWK84v5+OtxE2CfultlPjOxdgledBcvW09ndg6+P8kevGVntieXSnvHmBSQI5siwWFg== 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=ffc5bc1QySHFyRSNnA6bj3jfBI6UpYpnn8MFEsc6vlM=; b=Az1B0/dLKKmejB+FZT6MuXkkL+nIAX+AH9yFqISCN6++kGtF0b8HjSw6NhcL3O83mp6oAZTPnP0tbqzN07ASfVnr70fVN/luXFS2SjyqMkaX4Q1WJ2WaAuF76iGk1g4oCyQdUd2zm/0eSlYR61xSiwOL3CF/xzw52SmHceOviRFf+VD1B+JHx9RQzzTcHuFi/6kTN75k9ij6TMcjU6HosJq8OGdIt+v9J4pYmi6bYklpyqSiGEpsQhP+pxLucPbl7dz7uvfqhFzJ0pxwxNK0yyFb5SZGDO7ijuJCBJb8xgGSEk1CbIpEMa/edbNJ5xSbiZvn2dW56YsI3F7WDb/OmA== 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=ffc5bc1QySHFyRSNnA6bj3jfBI6UpYpnn8MFEsc6vlM=; b=nDRjZjbss8JP1Ex50mioQvLPZwvez0SDIZlvt8GzTsjyghBwVtV7rxl6iTJ7uf/gnyB3Jp8WgFLiCLv5eBJ4AS/gHx5lQA2KIGwLXGWzC/FHBcwzDFOoaouoxnPwXarVkB3pN8FJk/gBvVteORRJk3iplYd3O+YMhWww/YRHORc= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by IA0PR10MB7181.namprd10.prod.outlook.com (2603:10b6:208:400::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5924.16; Sun, 18 Dec 2022 10:03:38 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::3cab:6ff7:cb4d:b57c]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::3cab:6ff7:cb4d:b57c%4]) with mapi id 15.20.5924.016; Sun, 18 Dec 2022 10:03:38 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v7 20/27] xfs: Add parent pointers to rename Date: Sun, 18 Dec 2022 03:02:59 -0700 Message-Id: <20221218100306.76408-21-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221218100306.76408-1-allison.henderson@oracle.com> References: <20221218100306.76408-1-allison.henderson@oracle.com> X-ClientProxiedBy: BY3PR10CA0015.namprd10.prod.outlook.com (2603:10b6:a03:255::20) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY5PR10MB4306:EE_|IA0PR10MB7181:EE_ X-MS-Office365-Filtering-Correlation-Id: 1cc20ca8-660c-47d9-e7a1-08dae0df221f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: TuI3cfHwfPT9SmZC3j+7L3Z4ZV1uyya0gDM2PE5lvRutjVC+eLJIkcrW2mqfmzDpg1ilQbGt8HXg7fqCBq/FSMTXgsZBdeDMGC2Ma+6xbhUEumgB88LsM11LckIlayGPn73Z7Cov8UKuJTUk9PP8bvsFtIjhkyoDmkQuvJm6uOeyTja4gGhZ3igA7UivxyY3z6F+cgBuU5Yeyw0R9ITwsl3Vys83CitoZiNdy/5+H1gJa7J50t4KCziv+yPZZYRHHiB0eiZPs0GgCqBkoYDvNIxD+szYjRX08ocZIYeER6VIeGSfw9uvNzICsWAscfphcm9tEsnLCXyZHbOyVnG1pejkC9De4YxtIjt5Vpat7QmqNTDwELuXvV3/KCRLOV9o5WSF9/t1+9PfBHG0OmLy/tk2gXyPPsSlOgv/nkOFd9UFY0te4QAmYfeEzzCo/iyzB06bwu/71HpPeBQSq4LNZmjNy65QOYvaH9nwtoeqWup6jMfOoE+B1C8xOzdeavtOCP3YbLsOa1rIUNnZ1l73Tnk0OzkkFwZvPi9E2zR+1Ag7aC3mIK1kKEJRPlsem3oHrjCpayZrlD04eVREUUIP4nBZ0B8AdCZ5EF6gg5GGg7uBpoJv9d5G+H/FT5uw3f12 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:(13230022)(39860400002)(136003)(366004)(376002)(396003)(346002)(451199015)(83380400001)(2906002)(41300700001)(8936002)(5660300002)(86362001)(38100700002)(36756003)(316002)(6506007)(6916009)(478600001)(6486002)(186003)(26005)(6512007)(66946007)(9686003)(2616005)(66476007)(8676002)(6666004)(66556008)(1076003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 8b9KAdck4E+5P0YyNGI/O5W0CFTLD5WPYHscdn6JFJ0TPpIXbJWBfKsnbF4CUn+N1iklyL+ifjattxFfJuVoXEP1RWIz9aEv6nbZdnRmnhm0CQ5mEVbcI+I9AetSoHpOpK22pJbyC1D2NeiR36Dk+PjCCN4+s7Ah2ToKEzwAl4UBBy8qW/gSt2rrvLq7tM3zh5pOioLbUxw3z+/zijGsdt+MWdwHWxTTVGjIhhlgwuy8aibkCs6bo4mqnupy0B5I2tZHwa1OrC1FuhYPZL4le+krVB/wNSXSFAto3Vv/o6f8h2DV5FY+OKJQzPUUtb/sIaK0HAEWdcRc2grQc0d95y/W+deo1y0BKnpdUa8JeHzxYD+bMWzdbE1Q0iqdnwMfbOVqgEI8ljSDIxNiZ3O0pWU1EwRQK6kMcQVV1myB7pcYfoL6bk1yyDivYk62ZenqodW+262jeNsBM7UiM8ED/Yo5OBQXnb+Bu374bVQNSVF1jEzrxYD2ctUTQJkxFUq9ekz/WHCJq7vI6bpNpgVZ/WGCEh1p8yqVFiKbLtHxGteNVgdfNl6k4aEOgSND365jLtXu/e2x76lS145+APCL3eOKWr9VJnpKdBKZ181Y3RWeTCJnlpFkCPycjhQv+mjsjVK7CF3OrFS24L/Fpe/mHpRA8jzyqvSIJ45Z0O2TrdlIWEcD1G95351dWkYnTfRoRo8nJJhPstXzsJBSVxlppb2yimAG0SpsGB5kPn0RKyE5ibS3v4vtWh7DZvITl6HmaXYHRrRABjNyrKZgcD2JjSG0J5051QADuYl/+92MyewUcg/xyVMch6PUlwgvZzD2QVUFnvI51VIQT70m7nrKzulziuGAPSCwY6AL5gJsIVdG4ybodtjZkQzT6CNL8VDLhRe38Iq5BSVBhc04B1LvN9n38nO3pUCwgoB4lfxfw4XaaxA2GnKxXfb3D2Dd2Sty9JnY/NMXP2/tX3NL9jI6DEIPJPP7ACA+QvpeCEw5wO04SC1iA9wx7hPe/CR/gRA8oAE/260m01+Ui38OsLxn3bn7kmOVCUQD5/qaoLyMBhXYQeRBliAyF3iXDcRTeFX4PivxRahVXSPoE5Jw6uOcfaV2SH1Crd79THIjY1xDBWQbgLNeVLKuBnYxDyONBCmBlurTRWft6fFZRKG7uMb1FAmhH9tAf88pdMmzO1GjnUxHMlz29rWVWCm+Zm89KbVHHNNYeKU4hrexNxyU8ImNNpIZuniNCuk5JUZI/vv2l79AQwUWs7B86jrzOM0AYQTcEGiaZNfU+Sv2cu4y/9L1hnfEeeobB4/coM9AuvzT2hE/fd33UlyyQLaA0PWM0IWd2gdWP50hUBI95JI2mWFEn61ndQ6iXd/5BZjcf+eOV5eFixnumpToJHHxziHAPqyGRpVlPyPSRiHyqf9znFzrzXzn/Cc/DPMDXDN5/432n6qaR0Q7djF6BHwqUNGdCi6gPs5Ny6NicVKswTX/7VBUqnyTp42fs3crAlschnN+eODalrXDwNVJCCEl3CRmD3rgnfnm3H1mRWGIYhMdNNOOJEqLsNU37rYtQHNE3G+Av/uqq3dtGc/0nfEqWFI0VvVOkIDBi/gt+cwIIdRz1k15WA== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1cc20ca8-660c-47d9-e7a1-08dae0df221f X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Dec 2022 10:03:38.2284 (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: Dp2lnMqh1xOJT22jYbGw6+vcKGyrgS/OYvEtfi98oR391ZDQVebkEvpfQDTSo4kHkBwYGeJKKqDM8cp5VFpVly0iO4bfzBTIENahLCO8kfc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR10MB7181 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-12-18_02,2022-12-15_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 malwarescore=0 phishscore=0 suspectscore=0 spamscore=0 bulkscore=0 mlxscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2212180095 X-Proofpoint-GUID: JjGxyZwxwlEgSctx13uNGWdZ3ovJAHeO X-Proofpoint-ORIG-GUID: JjGxyZwxwlEgSctx13uNGWdZ3ovJAHeO Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Allison Henderson This patch removes the old parent pointer attribute during the rename operation, and re-adds the updated parent pointer. In the case of xfs_cross_rename, we modify the routine not to roll the transaction just yet. We will do this after the parent pointer is added in the calling xfs_rename function. Signed-off-by: Allison Henderson --- fs/xfs/libxfs/xfs_attr.c | 2 +- fs/xfs/libxfs/xfs_attr.h | 1 + fs/xfs/libxfs/xfs_parent.c | 31 ++++++++++++ fs/xfs/libxfs/xfs_parent.h | 6 +++ fs/xfs/libxfs/xfs_trans_space.h | 2 - fs/xfs/xfs_inode.c | 89 ++++++++++++++++++++++++++++++--- 6 files changed, 122 insertions(+), 9 deletions(-) diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c index a8db44728b11..57080ea4c869 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -923,7 +923,7 @@ xfs_attr_defer_add( } /* Sets an attribute for an inode as a deferred operation */ -static int +int xfs_attr_defer_replace( struct xfs_da_args *args) { diff --git a/fs/xfs/libxfs/xfs_attr.h b/fs/xfs/libxfs/xfs_attr.h index 033005542b9e..985761264d1f 100644 --- a/fs/xfs/libxfs/xfs_attr.h +++ b/fs/xfs/libxfs/xfs_attr.h @@ -546,6 +546,7 @@ int xfs_attr_get_ilocked(struct xfs_da_args *args); int xfs_attr_get(struct xfs_da_args *args); int xfs_attr_defer_add(struct xfs_da_args *args); int xfs_attr_defer_remove(struct xfs_da_args *args); +int xfs_attr_defer_replace(struct xfs_da_args *args); int xfs_attr_set(struct xfs_da_args *args); int xfs_attr_set_iter(struct xfs_attr_intent *attr); int xfs_attr_remove_iter(struct xfs_attr_intent *attr); diff --git a/fs/xfs/libxfs/xfs_parent.c b/fs/xfs/libxfs/xfs_parent.c index c09f49b7c241..954a52d6be00 100644 --- a/fs/xfs/libxfs/xfs_parent.c +++ b/fs/xfs/libxfs/xfs_parent.c @@ -142,6 +142,37 @@ xfs_parent_defer_remove( return xfs_attr_defer_remove(args); } + +int +xfs_parent_defer_replace( + struct xfs_trans *tp, + struct xfs_parent_defer *new_parent, + struct xfs_inode *old_dp, + xfs_dir2_dataptr_t old_diroffset, + struct xfs_name *parent_name, + struct xfs_inode *new_dp, + xfs_dir2_dataptr_t new_diroffset, + struct xfs_inode *child) +{ + struct xfs_da_args *args = &new_parent->args; + + xfs_init_parent_name_rec(&new_parent->old_rec, old_dp, old_diroffset); + xfs_init_parent_name_rec(&new_parent->rec, new_dp, new_diroffset); + new_parent->args.name = (const uint8_t *)&new_parent->old_rec; + new_parent->args.namelen = sizeof(struct xfs_parent_name_rec); + new_parent->args.new_name = (const uint8_t *)&new_parent->rec; + new_parent->args.new_namelen = sizeof(struct xfs_parent_name_rec); + args->trans = tp; + args->dp = child; + + ASSERT(parent_name != NULL); + new_parent->args.value = (void *)parent_name->name; + new_parent->args.valuelen = parent_name->len; + + args->hashval = xfs_da_hashname(args->name, args->namelen); + return xfs_attr_defer_replace(args); +} + void xfs_parent_cancel( xfs_mount_t *mp, diff --git a/fs/xfs/libxfs/xfs_parent.h b/fs/xfs/libxfs/xfs_parent.h index 1c506532c624..9021241ad65b 100644 --- a/fs/xfs/libxfs/xfs_parent.h +++ b/fs/xfs/libxfs/xfs_parent.h @@ -12,6 +12,7 @@ */ struct xfs_parent_defer { struct xfs_parent_name_rec rec; + struct xfs_parent_name_rec old_rec; struct xfs_da_args args; }; @@ -27,6 +28,11 @@ int xfs_parent_init(xfs_mount_t *mp, struct xfs_parent_defer **parentp); int xfs_parent_defer_add(struct xfs_trans *tp, struct xfs_parent_defer *parent, struct xfs_inode *dp, struct xfs_name *parent_name, xfs_dir2_dataptr_t diroffset, struct xfs_inode *child); +int xfs_parent_defer_replace(struct xfs_trans *tp, + struct xfs_parent_defer *new_parent, struct xfs_inode *old_dp, + xfs_dir2_dataptr_t old_diroffset, struct xfs_name *parent_name, + struct xfs_inode *new_ip, xfs_dir2_dataptr_t new_diroffset, + struct xfs_inode *child); int xfs_parent_defer_remove(struct xfs_trans *tp, struct xfs_inode *dp, struct xfs_parent_defer *parent, xfs_dir2_dataptr_t diroffset, diff --git a/fs/xfs/libxfs/xfs_trans_space.h b/fs/xfs/libxfs/xfs_trans_space.h index b5ab6701e7fb..810610a14c4d 100644 --- a/fs/xfs/libxfs/xfs_trans_space.h +++ b/fs/xfs/libxfs/xfs_trans_space.h @@ -91,8 +91,6 @@ XFS_DQUOT_CLUSTER_SIZE_FSB) #define XFS_QM_QINOCREATE_SPACE_RES(mp) \ XFS_IALLOC_SPACE_RES(mp) -#define XFS_RENAME_SPACE_RES(mp,nl) \ - (XFS_DIRREMOVE_SPACE_RES(mp) + XFS_DIRENTER_SPACE_RES(mp,nl)) #define XFS_IFREE_SPACE_RES(mp) \ (xfs_has_finobt(mp) ? M_IGEO(mp)->inobt_maxlevels : 0) diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index 34bc6db0cfd7..713ced7fa87a 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -2867,7 +2867,7 @@ xfs_rename_alloc_whiteout( int error; error = xfs_create_tmpfile(mnt_userns, dp, S_IFCHR | WHITEOUT_MODE, - false, &tmpfile); + xfs_has_parent(dp->i_mount), &tmpfile); if (error) return error; @@ -2893,6 +2893,31 @@ xfs_rename_alloc_whiteout( return 0; } +static unsigned int +xfs_rename_space_res( + struct xfs_mount *mp, + struct xfs_name *src_name, + struct xfs_parent_defer *target_parent_ptr, + struct xfs_name *target_name, + struct xfs_parent_defer *new_parent_ptr, + struct xfs_inode *wip) +{ + unsigned int ret; + + ret = XFS_DIRREMOVE_SPACE_RES(mp) + + XFS_DIRENTER_SPACE_RES(mp, target_name->len); + + if (new_parent_ptr) { + if (wip) + ret += xfs_pptr_calc_space_res(mp, src_name->len); + ret += 2 * xfs_pptr_calc_space_res(mp, target_name->len); + } + if (target_parent_ptr) + ret += xfs_pptr_calc_space_res(mp, target_name->len); + + return ret; +} + /* * xfs_rename */ @@ -2919,6 +2944,11 @@ xfs_rename( int spaceres; bool retried = false; int error, nospace_error = 0; + xfs_dir2_dataptr_t new_diroffset; + xfs_dir2_dataptr_t old_diroffset; + struct xfs_parent_defer *new_parent_ptr = NULL; + struct xfs_parent_defer *target_parent_ptr = NULL; + struct xfs_parent_defer *wip_parent_ptr = NULL; trace_xfs_rename(src_dp, target_dp, src_name, target_name); @@ -2942,10 +2972,26 @@ xfs_rename( xfs_sort_for_rename(src_dp, target_dp, src_ip, target_ip, wip, inodes, &num_inodes); + if (xfs_has_parent(mp)) { + error = xfs_parent_init(mp, &new_parent_ptr); + if (error) + goto out_release_wip; + if (wip) { + error = xfs_parent_init(mp, &wip_parent_ptr); + if (error) + goto out_release_wip; + } + if (target_ip != NULL) { + error = xfs_parent_init(mp, &target_parent_ptr); + if (error) + goto out_release_wip; + } + } retry: nospace_error = 0; - spaceres = XFS_RENAME_SPACE_RES(mp, target_name->len); + spaceres = xfs_rename_space_res(mp, src_name, target_parent_ptr, + target_name, new_parent_ptr, wip); error = xfs_trans_alloc(mp, &M_RES(mp)->tr_rename, spaceres, 0, 0, &tp); if (error == -ENOSPC) { nospace_error = error; @@ -3117,7 +3163,7 @@ xfs_rename( * to account for the ".." reference from the new entry. */ error = xfs_dir_createname(tp, target_dp, target_name, - src_ip->i_ino, spaceres, NULL); + src_ip->i_ino, spaceres, &new_diroffset); if (error) goto out_trans_cancel; @@ -3138,7 +3184,7 @@ xfs_rename( * name at the destination directory, remove it first. */ error = xfs_dir_replace(tp, target_dp, target_name, - src_ip->i_ino, spaceres, NULL); + src_ip->i_ino, spaceres, &new_diroffset); if (error) goto out_trans_cancel; @@ -3211,14 +3257,38 @@ xfs_rename( */ if (wip) error = xfs_dir_replace(tp, src_dp, src_name, wip->i_ino, - spaceres, NULL); + spaceres, &old_diroffset); else error = xfs_dir_removename(tp, src_dp, src_name, src_ip->i_ino, - spaceres, NULL); + spaceres, &old_diroffset); if (error) goto out_trans_cancel; + if (new_parent_ptr) { + if (wip) { + error = xfs_parent_defer_add(tp, wip_parent_ptr, + src_dp, src_name, + old_diroffset, wip); + if (error) + goto out_trans_cancel; + } + + error = xfs_parent_defer_replace(tp, new_parent_ptr, src_dp, + old_diroffset, target_name, target_dp, + new_diroffset, src_ip); + if (error) + goto out_trans_cancel; + } + + if (target_parent_ptr) { + error = xfs_parent_defer_remove(tp, target_dp, + target_parent_ptr, + new_diroffset, target_ip); + if (error) + goto out_trans_cancel; + } + xfs_trans_ichgtime(tp, src_dp, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG); xfs_trans_log_inode(tp, src_dp, XFS_ILOG_CORE); if (new_parent) @@ -3233,6 +3303,13 @@ xfs_rename( out_unlock: xfs_iunlock_after_rename(inodes, num_inodes); out_release_wip: + if (new_parent_ptr) + xfs_parent_cancel(mp, new_parent_ptr); + if (target_parent_ptr) + xfs_parent_cancel(mp, target_parent_ptr); + if (wip_parent_ptr) + xfs_parent_cancel(mp, wip_parent_ptr); + if (wip) xfs_irele(wip); if (error == -ENOSPC && nospace_error) From patchwork Sun Dec 18 10:03:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 13076014 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 026FFC10F1E for ; Sun, 18 Dec 2022 10:03:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229585AbiLRKDs (ORCPT ); Sun, 18 Dec 2022 05:03:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60250 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230307AbiLRKDq (ORCPT ); Sun, 18 Dec 2022 05:03:46 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3930655B2 for ; Sun, 18 Dec 2022 02:03:44 -0800 (PST) Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2BI5xtWv012952 for ; Sun, 18 Dec 2022 10:03:43 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=4VBrNxMZQEeLepM/geuKUuUyquKAEv/4X48t+t0DtxM=; b=vSgncTyP0iPjM/AZIUgwS6+vXJge0baIiH0IePM5j3QsCquAiwNjsIzgFtEsrs4eVl1b /zuF9NU5lLpk8ENi072DOZ0SK/vQqv+aZ6mywp5bn3gpWDRprLtqSDM+c80r3npal0Zd 7BXABO4fgzFCOHn56zbPZafg/7my1PExWHnUbiBs9Zz+SzJKhCWC+rGBVcJjxBOwg5pW 7jkRz5ONTS7OR2keV2vYZJ+rnXJG+pSJ2lisXOaEM+4rAtRHN5cz5si1PPpNxz59xgUt WDsdD4ZYti73rg6m4hrEkN92b72obSkhWzJ/pigLZQRRGcBuFuyWXAiszGb4vn9uWbZR Og== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3mh6tms9ba-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sun, 18 Dec 2022 10:03:43 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 2BI909Wr012804 for ; Sun, 18 Dec 2022 10:03:42 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2170.outbound.protection.outlook.com [104.47.56.170]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3mh472cfxp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sun, 18 Dec 2022 10:03:42 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EDZIBCS68JbVqlVu4J6Uuty/lpoi4qPbXhQNh316tA7/h9Gu1gRI62RHfXj/Edw6Ub41Zdl3/hrs16GEVlU0qwnxE/eumNVtnl4LCBVXJDZc+FOL0485Z5ZF+SqsKw4Ti7G8gl9hSlfKKF/iZfPWjqHFvtizPRSEYyfCkJX76thCyF2L5hRdrplvDm6umF41tb373GMBzYqBW13XWKa3KmOeveIERW7JuzwOndeank3I9g+OZcdf38fmI3fWZpsLdTjqRp6GavKAZXpiWIKUWlnMMkZ4VLgFgoK6cX8odHw8BXwuaxspCPbYqw5BE7aOfPIHOnZCEC0fuxHmPFqscw== 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=4VBrNxMZQEeLepM/geuKUuUyquKAEv/4X48t+t0DtxM=; b=VJkIsCZoAQB+J4ueY87d0E+CsBPFTQ422gv5q5vNIfXYwFuy8Nue80uLc5Y4FtcslWDqHyCLMLKkrsq8u9Hw3ZO5t5QapSPHxCIkBwxESrdwOvofOn9y4iMviyHFr1yr1gXO5KXC8pIyAQVGbbVjXO8KBONF2OIsbZ6F0IyaGQHdC0LVYFXg4B3vmbCgG6GU2Zx6s+auF0Y58RxPgjQOznNXLIlm3TB57wBkkO35G0tT8jl7hYcEel5q5ENdJ3h6gnDErSQyAOz6qXHitvoe5S304YHSd/pgX4CnrlbbtRbIxZvm7eGyGdkQhHQVVswbvmax38oG5KUNEPVjBSqU3Q== 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=4VBrNxMZQEeLepM/geuKUuUyquKAEv/4X48t+t0DtxM=; b=P0wS+W4MqS8t3GHVvI8uh/qwl8k+UPMtY4MRkprU5VIYVoBqAtgqxGfYi4ecZ1Sh4hDZiRpoVIZG9RiODiuInM9x8bSznkRRhSpVQ9Yuh/BUl/mjiNFLKvSG7OUe+Urf7bHAj6axYRv+0FHCMF/N8oV7LNUhat5GrKHwRTbAPuY= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by IA0PR10MB7181.namprd10.prod.outlook.com (2603:10b6:208:400::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5924.16; Sun, 18 Dec 2022 10:03:39 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::3cab:6ff7:cb4d:b57c]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::3cab:6ff7:cb4d:b57c%4]) with mapi id 15.20.5924.016; Sun, 18 Dec 2022 10:03:39 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v7 21/27] xfs: Add parent pointers to xfs_cross_rename Date: Sun, 18 Dec 2022 03:03:00 -0700 Message-Id: <20221218100306.76408-22-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221218100306.76408-1-allison.henderson@oracle.com> References: <20221218100306.76408-1-allison.henderson@oracle.com> X-ClientProxiedBy: SJ0PR13CA0169.namprd13.prod.outlook.com (2603:10b6:a03:2c7::24) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY5PR10MB4306:EE_|IA0PR10MB7181:EE_ X-MS-Office365-Filtering-Correlation-Id: b82ab37e-cfd6-4ed2-f3b9-08dae0df231c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2Q0W4tLaB+q9hAUnBQvDMT86QYtx7Xbf2sg/z5u16BVk0/fLeETXsWnTrW+o8R/S+sVgs9sjk5cbx1+2NQENNWdgkMSLofXufP0Zx/wJznQH5e4MDz9rIDuNujFp6zq6SD2ZstUstLQxs8VE1ttWV/0OslDthF3yBhYU95nIlzx3qqSLX6XyZLgjIxkv6xlXEVb3kgNU26PFElHFtMh6HX+l9F4gIi4ayLPdGL/VFf2BKkYmI1+vd6c5cYP7aTH8bFIE8kEOZwKDncXnE9v5Gclx6J7ZSjHNY/TB8F9CMThoGHmIq4XbY4hv7UyPB1cYlxMsrvV3w3q6lLMZcpS8OGksUJxVvYYmicH+tQoQOOAqb4DB3dYDJLKp8KviGJ1qxWHzW+m5gAKsnTQHyOCQUpEo+rYkV9+8vt+a/NsXQCXP8U2KmyJoT/uiCyw1xly4gfwbFOujBgeMd65APIQneMKhvbYs0iunRof34Q2XBUtMmc0bafMMaCmpu7/Lwi/qsy6Mb2wEahZQ912ZcIobob1hTFA8wAnESRdpV57xiPQ0F9AtpZ5ix73WC/Sb8ODNEVz9p2B5mxgfisUynBGBEvSh9qyPJNK/T4+qrSwVui7GMHM8hSclmNQ0cK4HTZyW 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:(13230022)(39860400002)(136003)(366004)(376002)(396003)(346002)(451199015)(83380400001)(2906002)(41300700001)(8936002)(5660300002)(86362001)(38100700002)(36756003)(316002)(6506007)(6916009)(478600001)(6486002)(186003)(26005)(6512007)(66946007)(9686003)(2616005)(66476007)(8676002)(6666004)(66556008)(1076003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: owRfTHuw+vwmWgRgz06M71HRhplfkIMJXe0Zu0JVicnEJEYgln8K6fEJ4LkDOzNl8Xv+xNhZDvJhS4VwmI8sM72hMHOxY0bU8ErPgUEfXFfDk13tUNQGxLPSRJoZO2ygP/mgwCgJ5hPgRcxp1i8kfBeA6TP0pHdxkzBwSDv6/FeUo7tckn/EWF6FotAd1YX3onn58PEjhnfR/R+6e4Bkaxkk2FCIhkz0G2ETkUSc5rz1SfmDyeRnEEnHjgjURssTIuYXz0CvtkislyO3blCkaz9hssKhoWHyq7qrK/GKYxNnsMyb7n32Rc2INVaqxvaW0xPFp8N+IDV2AiyVXTYIgTz1XOOrPA2nsm0Huzxd0Fqyn0c4hBepPpOEh4+wibQ0FIfBWffPso5u7PU3XNFjNAjLRF+b5Bg2rNMpvyCQPTpd/6ZMiX0Hv6IrDGRd07L0snNYEijxJ1gnv9tRAtyaaoQyhZ/of2DUw2LJy3hdWCmN4Osl/G0M0MXCWWlMhiXnuU6Xb1+R4sFjqtolUfygfOqVw21mWsE2kXtRudRZsIsknapt6xuDCjJ+YJrL4Vs/1tk8ADGO00vksB5zX5lOKH4/BfIVzqYdLqfSj9gwoOGK3wBxEN6FrBw4w9W097K4EM299WOL92lLHcuMWzOZhJwJMmcHty/XrPWmIzvA3Y0oxTbMOPFiiNkIxIFJ4zRHAiJchCnKhtvFNZRaxW+xb04j2tQ/NIeb2DBeFm/QcTrOZ8l4Ux8e7Qb+K5KVIHIvQnZQ1wDT0DxH8ilT4raeyk7ox5f7BmACqrrYGthO9Mh/lYz8JaklzfbffxUo2EMYStWfN8za9BjhDuAhMT356PTzGpY1eNYv8FTPmKFZFAc26knVt8Ug7qGrR1sWAhR/tVJsOGFbULWDmbJ6z6DmuQM3gSWj0J6AZ5LPfUhiEaBHy4qBeILT21Z3EhZtPfMjL/eqCStZKRBIh9zofXm34n74bSe43SiSXqCHhdqilvRrf5s2knYKArlCgXEIipjceeMEhyRXA20d3hohwqKl8gfuWrqZidPcWcirkj8zi3ZVpllro4tVt9wMdRsgcGvjtMf0HxzjNLJmWvwobDv2zAyKcBPp/UJ8pKWq5dWZbgjJsfAWBPkis4soN4BkUnrtJJSI68D6BIYYxADQ0ou+lLNxAcq8Yq0jIe1O1JPYapi9mXE+dycZvAwEZcGOCDz8xbdtklRqdyk3sEJTqxeBAbyHGgfpRvAWeyrdslsW2qaYNnQO/3sn0LzrEo6VFg5PHkZY/R5Z4kqcCeERIIzVbp+0177zeCgAI211OQ+S/fbBAvj+0m2JpNeiJjbrBLPCXVRf2NWgW2uzh3fw+t1TJlfZFa1KGJYSM+quQ/6SQN2d7CxuF/Kh2Tsx4Avi6MbGYcOMJ6UDGlsx417luoAbeVQKHadz7Qq8dkFXOp4aqGUjHgoI85dnfOXFFAehlOOhh/b7JLupirQZbeLqogtSHt3zjcVKyME8nI6mKX0O58I0VAAQ96SOo4DHZYGr5r4cjfDxt0u1HAtWghlpgXz9eSiuRjDbyV1cS3rGn/H3+cvy8Kc010eNUHY4sBdUR/5hl3ujVSigteKaXqYtBVaxfQ== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: b82ab37e-cfd6-4ed2-f3b9-08dae0df231c X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Dec 2022 10:03:39.8556 (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: apbMibz5hDLs5WYvPvnJx0FFLVghcj8ALAozA2IvqHjvmUXwhijlP4/hhIv2A5EYTsgCQvaRPfObvBe1rbu3/+iR4bzh33/3Kari9m2q9Bk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR10MB7181 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-12-18_02,2022-12-15_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 phishscore=0 suspectscore=0 adultscore=0 malwarescore=0 spamscore=0 mlxlogscore=999 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2212180095 X-Proofpoint-ORIG-GUID: TqK8o0bfSpZu0iv1d8ryeyXQDiFyVpPo X-Proofpoint-GUID: TqK8o0bfSpZu0iv1d8ryeyXQDiFyVpPo Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Allison Henderson Cross renames are handled separately from standard renames, and need different handling to update the parent attributes correctly. Signed-off-by: Allison Henderson --- fs/xfs/xfs_inode.c | 64 ++++++++++++++++++++++++++++++++++------------ 1 file changed, 48 insertions(+), 16 deletions(-) diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index 713ced7fa87a..cc0a994599d0 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -2745,27 +2745,40 @@ xfs_finish_rename( */ STATIC int xfs_cross_rename( - struct xfs_trans *tp, - struct xfs_inode *dp1, - struct xfs_name *name1, - struct xfs_inode *ip1, - struct xfs_inode *dp2, - struct xfs_name *name2, - struct xfs_inode *ip2, - int spaceres) -{ - int error = 0; - int ip1_flags = 0; - int ip2_flags = 0; - int dp2_flags = 0; + struct xfs_trans *tp, + struct xfs_inode *dp1, + struct xfs_name *name1, + struct xfs_inode *ip1, + struct xfs_inode *dp2, + struct xfs_name *name2, + struct xfs_inode *ip2, + int spaceres) +{ + struct xfs_mount *mp = dp1->i_mount; + int error = 0; + int ip1_flags = 0; + int ip2_flags = 0; + int dp2_flags = 0; + int new_diroffset, old_diroffset; + struct xfs_parent_defer *parent_ptr = NULL; + struct xfs_parent_defer *parent_ptr2 = NULL; + + if (xfs_has_parent(mp)) { + error = xfs_parent_init(mp, &parent_ptr); + if (error) + goto out_trans_abort; + error = xfs_parent_init(mp, &parent_ptr2); + if (error) + goto out_trans_abort; + } /* Swap inode number for dirent in first parent */ - error = xfs_dir_replace(tp, dp1, name1, ip2->i_ino, spaceres, NULL); + error = xfs_dir_replace(tp, dp1, name1, ip2->i_ino, spaceres, &old_diroffset); if (error) goto out_trans_abort; /* Swap inode number for dirent in second parent */ - error = xfs_dir_replace(tp, dp2, name2, ip1->i_ino, spaceres, NULL); + error = xfs_dir_replace(tp, dp2, name2, ip1->i_ino, spaceres, &new_diroffset); if (error) goto out_trans_abort; @@ -2826,6 +2839,18 @@ xfs_cross_rename( } } + if (xfs_has_parent(mp)) { + error = xfs_parent_defer_replace(tp, parent_ptr, dp1, + old_diroffset, name2, dp2, new_diroffset, ip1); + if (error) + goto out_trans_abort; + + error = xfs_parent_defer_replace(tp, parent_ptr2, dp2, + new_diroffset, name1, dp1, old_diroffset, ip2); + if (error) + goto out_trans_abort; + } + if (ip1_flags) { xfs_trans_ichgtime(tp, ip1, ip1_flags); xfs_trans_log_inode(tp, ip1, XFS_ILOG_CORE); @@ -2840,10 +2865,17 @@ xfs_cross_rename( } xfs_trans_ichgtime(tp, dp1, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG); xfs_trans_log_inode(tp, dp1, XFS_ILOG_CORE); - return xfs_finish_rename(tp); + error = xfs_finish_rename(tp); + goto out; out_trans_abort: xfs_trans_cancel(tp); +out: + if (parent_ptr) + xfs_parent_cancel(mp, parent_ptr); + if (parent_ptr2) + xfs_parent_cancel(mp, parent_ptr2); + return error; } From patchwork Sun Dec 18 10:03:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 13076016 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 58F00C4332F for ; Sun, 18 Dec 2022 10:03:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230294AbiLRKDu (ORCPT ); Sun, 18 Dec 2022 05:03:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60302 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230311AbiLRKDq (ORCPT ); Sun, 18 Dec 2022 05:03:46 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DCAD5D2E1 for ; Sun, 18 Dec 2022 02:03:45 -0800 (PST) Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2BI88nMX023742 for ; Sun, 18 Dec 2022 10:03:45 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=lIC8fdeyODQX4149WUoke6Xnl+AOfMDBbJODIBnqukw=; b=QKvLNgMADSwIys7Z9r3xQwR4akbPNIA5CAmYUt91gLGFGW35XxazCtJ0TWdGJ+LsRdMW tKigHrdSDGlomUjYvpns8zdG3SfyUbAvsBUrLC2hE0nipBswhLAHyXy6h+OjvWIx5xGt a7zGxK2uzelYdStDJcciyDB7jHD+ZPYGZtAEdKaw5rOH0EJSXbNCSHSbZ9K03ZE1ihR5 23rmHgIQVREAsTMC8RxSnilXiDUMql/yi2Dz0GerpM2kdU9bY1509reTfcqlkDMcCG13 qT6Q323JizfX3wCFXUrYTT19bwEhRYVYsDXWHhYYslCG1+kaXP9kqo8bwPx/bK5syOT/ aQ== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3mh6tn196x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sun, 18 Dec 2022 10:03:44 +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 2BI8UK3V006898 for ; Sun, 18 Dec 2022 10:03:44 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2172.outbound.protection.outlook.com [104.47.56.172]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3mh478n3x9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sun, 18 Dec 2022 10:03:44 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IvMZqha84sRHi5anWJZTRH855rLIB5btkCJyZ18aytofIlhHR/g6bDD3WUncZfWZHdZGUru9Invt1V2BAyrEmW+mK7TWmg032bCD1X5MrBgDF/0t5vK4Cidyh/Wi4S+MofJCcIkZbRppLBM3bgNqjAoLWiDBbutafQG8aRW80Ls4DUk0SnCzJuvM5upd5YR/sX+N/xpM3njuBvsiNZmZjDIhRdsI6dIqkjk9MitDJ7+vHJotSbEdmNdaRlNCqtlq30Y4TQJcjONrIseIGbh/f3v5UUSEKjfOr0hVJuErXriqpgaE8bb08zxEcqAzqzpAby7ihitR5Gfk011RZ0K7ag== 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=lIC8fdeyODQX4149WUoke6Xnl+AOfMDBbJODIBnqukw=; b=e3AQjsa2QtCnlZ1BSQv4ubQ2wkjvCWN03o+jNSJNBq+5p6odHDddNKlHy/UXV+TEjoIFltyLbvox+rjAH1SqRZaTf6GO/Zu96csPLKbvwQhoVe7rCGRvfLmHZQDpCzRBOk3Lf1Sj/3hMi3Zg+b62jcBWcGBvNsSNI0As+RsBR1ahAQmRpKUfvHSaBY8+AWpJUH1RtNgrcp37j5vriT2Wk9G3G4ExNuNBoxKzQQCmDqVuxLMBfk2d/C2EGzTn3IHvpnKzRuOmA3RmZY7nVR3zOXtIlW1Vm1qCi9YHhTFRzrbbBlGgg6QzaXgjMH7TBRPYr4Jx5kNjRiA5r1RW71u8qA== 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=lIC8fdeyODQX4149WUoke6Xnl+AOfMDBbJODIBnqukw=; b=S5o2na+ORxBM2SFdFoE/5RsHilPYlS+8kt5BHPCy/Nbj8p28wmlb6B9y3E3Xmq+80mHKabCzuLZZcn7pxnXdz8SJo1czqoYko7rZKpgN0J+Rqcpkqtv7nVo6Mx3vqPoZM+RH1GXNb1I2KxUBdunj/1cdfqCdkqqYKqXh6OTBuLk= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by IA0PR10MB7181.namprd10.prod.outlook.com (2603:10b6:208:400::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5924.16; Sun, 18 Dec 2022 10:03:41 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::3cab:6ff7:cb4d:b57c]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::3cab:6ff7:cb4d:b57c%4]) with mapi id 15.20.5924.016; Sun, 18 Dec 2022 10:03:41 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v7 22/27] xfs: Add the parent pointer support to the superblock version 5. Date: Sun, 18 Dec 2022 03:03:01 -0700 Message-Id: <20221218100306.76408-23-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221218100306.76408-1-allison.henderson@oracle.com> References: <20221218100306.76408-1-allison.henderson@oracle.com> X-ClientProxiedBy: SJ0PR13CA0156.namprd13.prod.outlook.com (2603:10b6:a03:2c7::11) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY5PR10MB4306:EE_|IA0PR10MB7181:EE_ X-MS-Office365-Filtering-Correlation-Id: 94bfe6fd-6e5f-40c8-0c9e-08dae0df2434 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: m8Ad4+0sLoPyxSzUkU2fvZ8vAk/qaU7HTzJLWilngFuGLOF+IwyhMk7OyZtHG+Q7syd0qtPtx2VetANntLMhsyCCenzEJB3CLrTp6RKH5y3zohQPpr4NIPEXL2ZAJcWvac4fcFnDfIAz3bU0nlWEfcPMssr49Y27G6Hfoa0W2qPREjRidw5guJarrt9kFTSF/P0id2WYFYjdp2vDRNXE+w8aO77SOc9/v0KRNSJxTaotnKnx5kHgLpa7ocXdyDujryZT8ZM1EoH6FErn7vh1SLSXY2ufhuNxIJAcDn/dDZJXqez/CLh3+g/Ouh1Sq4DN7nOg1vSGtzb77N8sKXrMNoUPyckTxgGolKUW2extlyeekH3wL9tGklTt/iFYcjDdPbqB7NVJgJj/VwubVz/D5ujwedI7vwiNASZAFBlL+zu7YECumE3gsIkdY/GnSOa2A6eruVglkh7ELbcZ3B9SvTEIq/PKq3O5oBInUi0+R+pWOQzutqsFtok88uNOZeyE+ioQluTwh/VoG3HtgCBNMx5QZdpGNjoG/WmK9CnfPw3CdESuMR36eV3grexfoSCueSv9nU0gag+gZMog4WHhwE67qazDEHWYFwmxDSi6QRJ0YAQWhWGbSnkYyXzQsCwWeCLH9LJq6g2BBs9v01GmSQ== 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:(13230022)(39860400002)(136003)(366004)(376002)(396003)(346002)(451199015)(83380400001)(2906002)(41300700001)(8936002)(5660300002)(86362001)(38100700002)(36756003)(316002)(6506007)(6916009)(478600001)(6486002)(186003)(26005)(6512007)(66946007)(9686003)(2616005)(66476007)(8676002)(6666004)(66556008)(1076003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: pL+HFc98FVSTn1MxlEiX5XOxpmAJIE9y+DEayTP99E5ZPteBIF81R2dfTmGcN9Z019DWP7L634VBzUBvTmNg7X8o66qIFPUw+ZVItefisjvxDTd2pZWqA5YuKmR7nU8tgVyRDCUBnJSOcxmr/oxibRm/hPMmdwna5fPoA9BDtpE0yecirJJWdGgpDZD8Esl/h0pKkGti/X1Izprori9UoJrOI1bUhf7DvwYXWsnrjHxGW7fVoJay+PxwcanR0yaMAUVmw4L36gzz1C7yjBt+Bt90pN9zxnok+5UXYJiZTbHiG0L9en5RO/CF9bGJyYvZzr3tVMWD6VNptXtvgvCtSJs5ipF9USoVm7gzG1EHbi+gU6+jA2ONeL9cjVkLBp4rmRRyragqnjEHHIzJfe0Cw2t2ex+aJV3IhBtDQNmUEQWyxtmUck6xU/nooOgxoNevfGC0B8pWr10FFbFetXcaha3tF+p6hD/pH2l7JUeq0HjoNWY3nuCB/cfiWlhU37udKrONBOZrBGLkmf53sdWjzCHuf8t3RCwlXhDoI4k+af5HIUMzvhaeZ7LfnPKESB73sg5QuCzRrIQouOjxC+7jbnZx0jqSIwPMLG0+Dgzqq64ojaKUecFGJ7cFA0D1S+pJC+d7hVcwc57dyyfT1luuFv91ICy5dpIBJjTzFhdKUoV1pDoW837yN+WGlqBLAAAd++PYieDkwr+QvoobAfl2hyxDO6d6UV033i732jc/lHijDDeDnMigruiWCvgjOiQxcAm2K08xC2RbJqF7vwdDK7Y/wL8+vgOVlNeerGyGk5YZqCXT5GP5TTECOJZI41aNFfuqRQ6I7KgvH2mZ51Dut5F1kvpPiucWVmhik4Tb5/stfZGo7rf6aH7K/ERlWyh/LEbA6rOSJsLxgZJL9cpgb8yb7TBWV/UgS129a911q2+RAOHfgycskmJfUrUUshogxMhDIhgAFQ6IcLoDiQfToCIXaj4kb78kwe1+r5ghjA95y0iJr4YAItpII4WIxl47I4oBV+E1unwLnTgK9wikz4t0MmfP1N1mGIT/mpayOrUMXQG8xhFJZkhO66IFxFS92iH5V9Ie9vE7BmS+cNCTbkwFgrjw0ojc/J4/R3x+zcgQRDam8ItN5wqJEODgQauc5Ty82kfpoIfAaqZw+9tkhwU+cEYoiouFiQ/QTTieceadGILMGzUBVVUTo+hyFOssNvzyN5CaIg0Xk95pgfp0eq1GchplSgB8+MiMBbb7Yz5ubVsxXogLD/7BV/Q4B4o4MlScqOxkzbVW64wW6hGDOdw1rrfGAZJkyIs+5xb2Dwl79eEqfVOimUDcQc33SN1xdouT+mfx0YufTClMXe2IWUnQZ/lNcecKofITlXmxlzS3/jlD7H3vkWgjoK72vVnhYQv0XqO+F6cGOhALI1qzXwXy62AaHpaxc6DMy70akSLwBuwTzZfRWG8oCc8jXSiG+erZXnHidF/D6Gat5mtrRnbpJE0HlqCbgUXfzfm4DfA15I4+/6rMOK0VViFeu2jw02DEVhqnB6vVV96G4J7P5JitNHO/v1M2EFDW2+2HxL8KOd5PdDs1ezm0cp72W9gXdo2GYfhaqSDnUdKlrUm/WQ== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 94bfe6fd-6e5f-40c8-0c9e-08dae0df2434 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Dec 2022 10:03:41.6847 (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: LQKY4tMqb7Av80S7h/7Z25d/1XqRYUCMV16EVu/oPRTjXyTXqiTVa7sxPVpk5MIAiMyzc8KZ0DZWDq3NM0tVxffwviZYKfLlgfNxcisunEA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR10MB7181 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-12-18_02,2022-12-15_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 adultscore=0 phishscore=0 mlxlogscore=999 bulkscore=0 malwarescore=0 suspectscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2212180095 X-Proofpoint-ORIG-GUID: 0BP29eCL5-FFNPfAMjHrflY3CxC20Uxb X-Proofpoint-GUID: 0BP29eCL5-FFNPfAMjHrflY3CxC20Uxb Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Allison Henderson Signed-off-by: Mark Tinguely Signed-off-by: Dave Chinner Signed-off-by: Allison Henderson Reviewed-by: Darrick J. Wong --- fs/xfs/libxfs/xfs_format.h | 4 +++- fs/xfs/libxfs/xfs_fs.h | 1 + fs/xfs/libxfs/xfs_sb.c | 4 ++++ fs/xfs/xfs_super.c | 4 ++++ 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/fs/xfs/libxfs/xfs_format.h b/fs/xfs/libxfs/xfs_format.h index 371dc07233e0..f413819b2a8a 100644 --- a/fs/xfs/libxfs/xfs_format.h +++ b/fs/xfs/libxfs/xfs_format.h @@ -373,13 +373,15 @@ xfs_sb_has_ro_compat_feature( #define XFS_SB_FEAT_INCOMPAT_BIGTIME (1 << 3) /* large timestamps */ #define XFS_SB_FEAT_INCOMPAT_NEEDSREPAIR (1 << 4) /* needs xfs_repair */ #define XFS_SB_FEAT_INCOMPAT_NREXT64 (1 << 5) /* large extent counters */ +#define XFS_SB_FEAT_INCOMPAT_PARENT (1 << 6) /* parent pointers */ #define XFS_SB_FEAT_INCOMPAT_ALL \ (XFS_SB_FEAT_INCOMPAT_FTYPE| \ XFS_SB_FEAT_INCOMPAT_SPINODES| \ XFS_SB_FEAT_INCOMPAT_META_UUID| \ XFS_SB_FEAT_INCOMPAT_BIGTIME| \ XFS_SB_FEAT_INCOMPAT_NEEDSREPAIR| \ - XFS_SB_FEAT_INCOMPAT_NREXT64) + XFS_SB_FEAT_INCOMPAT_NREXT64| \ + XFS_SB_FEAT_INCOMPAT_PARENT) #define XFS_SB_FEAT_INCOMPAT_UNKNOWN ~XFS_SB_FEAT_INCOMPAT_ALL static inline bool diff --git a/fs/xfs/libxfs/xfs_fs.h b/fs/xfs/libxfs/xfs_fs.h index 1cfd5bc6520a..b0b4d7a3aa15 100644 --- a/fs/xfs/libxfs/xfs_fs.h +++ b/fs/xfs/libxfs/xfs_fs.h @@ -237,6 +237,7 @@ typedef struct xfs_fsop_resblks { #define XFS_FSOP_GEOM_FLAGS_BIGTIME (1 << 21) /* 64-bit nsec timestamps */ #define XFS_FSOP_GEOM_FLAGS_INOBTCNT (1 << 22) /* inobt btree counter */ #define XFS_FSOP_GEOM_FLAGS_NREXT64 (1 << 23) /* large extent counters */ +#define XFS_FSOP_GEOM_FLAGS_PARENT (1 << 24) /* parent pointers */ /* * Minimum and maximum sizes need for growth checks. diff --git a/fs/xfs/libxfs/xfs_sb.c b/fs/xfs/libxfs/xfs_sb.c index 1eeecf2eb2a7..a59bf09495b1 100644 --- a/fs/xfs/libxfs/xfs_sb.c +++ b/fs/xfs/libxfs/xfs_sb.c @@ -173,6 +173,8 @@ xfs_sb_version_to_features( features |= XFS_FEAT_NEEDSREPAIR; if (sbp->sb_features_incompat & XFS_SB_FEAT_INCOMPAT_NREXT64) features |= XFS_FEAT_NREXT64; + if (sbp->sb_features_incompat & XFS_SB_FEAT_INCOMPAT_PARENT) + features |= XFS_FEAT_PARENT; return features; } @@ -1189,6 +1191,8 @@ xfs_fs_geometry( geo->flags |= XFS_FSOP_GEOM_FLAGS_BIGTIME; if (xfs_has_inobtcounts(mp)) geo->flags |= XFS_FSOP_GEOM_FLAGS_INOBTCNT; + if (xfs_has_parent(mp)) + geo->flags |= XFS_FSOP_GEOM_FLAGS_PARENT; if (xfs_has_sector(mp)) { geo->flags |= XFS_FSOP_GEOM_FLAGS_SECTOR; geo->logsectsize = sbp->sb_logsectsize; diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c index 0c4b73e9b29d..8f1e9b9ed35d 100644 --- a/fs/xfs/xfs_super.c +++ b/fs/xfs/xfs_super.c @@ -1663,6 +1663,10 @@ xfs_fs_fill_super( xfs_warn(mp, "EXPERIMENTAL Large extent counts feature in use. Use at your own risk!"); + if (xfs_has_parent(mp)) + xfs_alert(mp, + "EXPERIMENTAL parent pointer feature enabled. Use at your own risk!"); + error = xfs_mountfs(mp); if (error) goto out_filestream_unmount; From patchwork Sun Dec 18 10:03:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 13076017 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 046F9C3DA7B for ; Sun, 18 Dec 2022 10:03:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230311AbiLRKDv (ORCPT ); Sun, 18 Dec 2022 05:03:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60310 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230312AbiLRKDr (ORCPT ); Sun, 18 Dec 2022 05:03:47 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3BE716575 for ; Sun, 18 Dec 2022 02:03:46 -0800 (PST) Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2BI7TTxq016354 for ; Sun, 18 Dec 2022 10:03:45 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=GNgaV7JWpSSDmwJUzqf9/qHqiLneHt6SZLDisea9h4A=; b=cC5Px+3NVlR2mxEgA3BZyRwh9j9nXDPkk3JhCur8W796Md2ID/ZSxnANDzR7IS1e6Wql YlE8Kt74GyB6xbJW+FUe/BMdOV/7hAogR44DVFIwCqSSb6htVqyepwf+pyflCI3Ia2IQ lpEzq79M3f7G7zxm87g6v+KrsNZN/34DSEbKRsTXk/wj3p+A8j1yH3/2KrhPVGbZlFtL XpINX0EqAZkM4xu9yfqyrGmQDR0m+IBQOXDRpOYX3UhP9C8cyyj4YBF2L8zYNu8pZndZ aayq0/xMjl8mkCa+9pAiRrvW92YysBdh/j+doijRQ7WdsLWaa2rpbEhDndnkHOgnDQV0 CQ== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3mh6tms9bb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sun, 18 Dec 2022 10:03:45 +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 2BI8UK3W006898 for ; Sun, 18 Dec 2022 10:03:44 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2172.outbound.protection.outlook.com [104.47.56.172]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3mh478n3x9-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sun, 18 Dec 2022 10:03:44 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KC/NaoFJ1uUBDkYXsbhhQaijcM/9+Sl9cuhmJa1F4SdXzqzDn5OLSmHvN2dp+UOSIvrE6FKzoq9mXqH4Ti7Td2MJCJoj+FYybcVFXBxm++frg/cORv7NNtqe1wSKdfxrLIJLJ2hvPvYIWCIeO3frRt5Lzf1LLFOgZSCsjgd5Mb9NLuko4SW25bVFERjdev+U8AaoNwIPHtjTCzGqlwssL33lTvLR9AiZd8YqiekofilxQiMYCFabW4zFCPUBBuF2cvKh1bM4omzp5k0CEQ8R7QUlAUc94hepic6aDWGMdRCix28HVCQTdHt/gs1pnNcmxfYdL+L0QUlrOrzjtktxRA== 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=GNgaV7JWpSSDmwJUzqf9/qHqiLneHt6SZLDisea9h4A=; b=IkcQDWKz5NAzsojKhaCsbSPHCvP2zUkO/mRao5SO/GJU4Ihwg4J9nt2QcBGNVsHS4Ow09yQ6tLK4oXmDgjQtJiaiD8jZc3oLdpQSDPXZ8gCZ8EddNtCa0LDA5jgnFJUn6Z4X9I5fp8pfP++D1AuLDcE4kTvEbvDF1b917DLneff7JUeI6oLFejxFuHgGJt8CN1dcJ8siyCFh7oKpQ3K0C9EEpDcAPJejKIA4th86luOtqCm+6N3tYZjMjHWxUpHmOCrbr58N23zt0vWsPbccbrjigiYdfJ0RSXcw8NDi1byOFE31JyjLvzSk2YebgIg2e23IWjjKjQuB6ubt2UEW5g== 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=GNgaV7JWpSSDmwJUzqf9/qHqiLneHt6SZLDisea9h4A=; b=DmkJxxbP15tVRLxEu5dwaW+ZpvDrCQm7F8YB7BYMSAK4aQZicT2ygD4/Mbc3HEK3iIgAFe/EDHtr6wXxSb7OCzmNzmJ0KN1fcmiOylJug1GrUsRIygx/fb8Qz1XupqLAkEmHuMmnvd4mCg2VXmHVIY8/roedReTJrNN4u+WAsX8= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by IA0PR10MB7181.namprd10.prod.outlook.com (2603:10b6:208:400::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5924.16; Sun, 18 Dec 2022 10:03:43 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::3cab:6ff7:cb4d:b57c]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::3cab:6ff7:cb4d:b57c%4]) with mapi id 15.20.5924.016; Sun, 18 Dec 2022 10:03:43 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v7 23/27] xfs: Add helper function xfs_attr_list_context_init Date: Sun, 18 Dec 2022 03:03:02 -0700 Message-Id: <20221218100306.76408-24-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221218100306.76408-1-allison.henderson@oracle.com> References: <20221218100306.76408-1-allison.henderson@oracle.com> X-ClientProxiedBy: BYAPR03CA0024.namprd03.prod.outlook.com (2603:10b6:a02:a8::37) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY5PR10MB4306:EE_|IA0PR10MB7181:EE_ X-MS-Office365-Filtering-Correlation-Id: cde44a2d-3594-4cc3-d7ed-08dae0df24fe X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LFA4/OmIqcsVcFvOSZucqeH0SL9W3YenzaTV8m+eQzJhURpuVvkc79jn4GYYTUEbyj9Ci+luU6gZhxf7ttz61mBMDOwDCdFoTBOdmiX3LPhz67+2mHtJnsGaDZCCNdZ1Jc622AOh1OxujDbpZe+G6e4x7eNreijqG7wxMwLckK6kZKjf2qZ6gaIWMco2Jxmq1e+QBiahNlnXNby1eFRlZ/ZbKR6db/9Aud23zyQ/FD9lY7zdCK9p8T3yGB6oXvz0LsrTUXW59hMB/nLUskKBCNUKE6Xzxa5yZr6za2nfLjo/C0R7swU6RNdCaiIqXeAjZmAdCypwkq+xvCcXKPfrCBvsiIPQXrI0otf+AwlNBXy2xwK54+M5Cta7hangvPT6uMG0EA0xZZxsVczhUo7dGq3DOghjE6uNOA4f1+/lpLNRhEOqU0/yuv3lC/C/pyOsZtbinM90tb/zRIK6yOwzi0N9DR4abU0pARycbrbE6ljQCq94DtFnt201rhfP6SZ9bAabN+n99tgI1n4rz5w/qhWR7QZsjjjeSPFoEZC07GG9UotE2+kdiSUE/0duGKLhLgZGsVnBj9tfVSM+m6UnrVBwX4c5BXNbSM3b4DtwhQzi9DkomnvfP76SLJ72ENFOWl0JtS7s6xN+ONff1eXhYA== 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:(13230022)(39860400002)(136003)(366004)(376002)(396003)(346002)(451199015)(83380400001)(2906002)(41300700001)(8936002)(5660300002)(86362001)(38100700002)(36756003)(316002)(6506007)(6916009)(478600001)(6486002)(186003)(26005)(6512007)(66946007)(9686003)(2616005)(66476007)(8676002)(6666004)(66556008)(1076003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 9LnjMwG4y+PhieWj2MNXcHJbR4WAuNDXyA2vXyK1SAM2TJIpM6skGeikxq1DuuQFmxkWrRD9iIyXwgbcBAcsOjpXz5l4apXm/s7tftsq8Z/PRgqTLwvTDk0s9FC0v30AVtZQoEmyEaoLMpybRXqWWeN3XHadRkuPHgPNtUEZgc/26e3iQ23P+r2DOju4mxKm3w0MePVwyU+LI+pszi3Zad3rXyrxPXudehgAdn097JEnVs6CpDGXFvfOGjZ17ePlgUh2WZMe6bFzTLikRr8Q6NqSZiIOBAAlpHGo8eywhCLpXUYPDkjfURzJPrZc9m5UmEh6zOIpCX70QW44mshZG/lHf2pCRLXfiye6KGrOHSzC6ZotL5sHR3mp3HrgZswcr/eON1xmmrRaP18/a8LZB5JcnVdTolQxmnCQqB3DH0Noh9t41zMqcMSWeD5Ib29DMWboQwlVg74a0nKmq3Qyws4i/hxg33SqLeQt7P/L1jFmbUI8SUnffikqZOBDJZFqlv81R28c88KECMgvmCxVAdAL7rvkcBKSNo5JZYibBeRSHHxZL8aeZAGAg0At1im4PlHy/GIwINcFKHwj8gFtIbM0qXXdNhTKPAro8FwwMbJxlNgyjVOSXZD+yjl/G8h0AOL0r3cbgiSkPqaDVcrEdUTeUA8DgB+RbjK8pwT5nEzmnIDAIP9hxH/MJztgK60HgKd4bD7cmijDh4x0j7wlJ0QuUuTVMwS3VxOcOhTR0PHuBYdLmxH+azJtd8ahIB9vMoBZLnGKgTi+BA6rKGxIcympzHgQShRa/NQSALr5rY1es8HSXh6anZYdlyilEN9X07GpF7+pi+Yk7rCrS49h5hjmm3pCgT0J2SilWnt3z8vBasS7S58+C3+o9kQ9a+d+ad0c4Ealq+X6CQSlKpdlQWnU9JPT5M2nWmpkV1SiGuWhqqnNBMj59yBgpn241bJlYzNcEkZQh3vYiUhMUrECYAgvzkRjs6x8xcqb+nBoUiW/6zeV1c9hLxyTCqG3yjUqofiTXODPUmOB7vvaaRf5aV1UoePb3/n/l5XdvmZOdkDWZXaZYKayMYtON+Gx9AI4h4h6uOfJQfYq/dSErWI1a7KE+wGoDjH4G0b7jkCpy1JrzWe0T5FR+aZSNS0vQAxCxXvM2eCSAMSqo5B7O8ZXwHxHEs0Eaw8VSalaSgkmarmOMrfomSVN8Pm7J63ypn0FDRu34ODi5B8BDpspfdgfPmZgf8x79FsykQjd6hHPGYL/R4XWU/UmIZC/PldGM1l2SI5zyQKnue/e5Hq1CdWTS0Yhamw7UFybheCQi5e/HH0fiohSW7NqXJMEE+r2UAOsH06ijOyxmzeAGcSAL3yQFyZDZJnWM2jbXGM4eMthkOHT+lOLdkmzvWLqBsbh4xzYASKC9RrJ0gKBPWO2H3I3dQ7ddL4/kpvSiYfsiIaukR08TEHqQahwpCHFLzxelrC3GMVVW1jnkyyqRFPNiOS3SYk3pUxG1LfvOWbZsCHfhU95/tG3KlLDJp8UzEBXxDjZny/SCK2tSVFP2byxq5EPmG3TKs4lZEBrhf0m+DUqfGSs2o65SnKZBZLiG0BrSeOJRkgD4+8NGAnILa0LjgPKcQ== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: cde44a2d-3594-4cc3-d7ed-08dae0df24fe X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Dec 2022 10:03:43.0137 (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: qKZ7VBmxFyo9ylv6n/MHqfQLew+ceO0GI/5+g480rDWUK9kI6hj2hV/hJ05zenzM9XShCVZ/pwPQKQ2wyFV/XRoxDFIJqJPihI1qrETpOi8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR10MB7181 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-12-18_02,2022-12-15_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 adultscore=0 phishscore=0 mlxlogscore=999 bulkscore=0 malwarescore=0 suspectscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2212180095 X-Proofpoint-ORIG-GUID: s6Ha_gnmySNbBVOL2FuiosiiDajaOEiA X-Proofpoint-GUID: s6Ha_gnmySNbBVOL2FuiosiiDajaOEiA Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Allison Henderson This patch adds a helper function xfs_attr_list_context_init used by xfs_attr_list. This function initializes the xfs_attr_list_context structure passed to xfs_attr_list_int. We will need this later to call xfs_attr_list_int_ilocked when the node is already locked. Signed-off-by: Allison Henderson Reviewed-by: Darrick J. Wong --- fs/xfs/xfs_file.c | 1 + fs/xfs/xfs_ioctl.c | 54 ++++++++++++++++++++++++++++++++-------------- fs/xfs/xfs_ioctl.h | 2 ++ 3 files changed, 41 insertions(+), 16 deletions(-) diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c index 595a5bcf46b9..9c09d32a6c9e 100644 --- a/fs/xfs/xfs_file.c +++ b/fs/xfs/xfs_file.c @@ -17,6 +17,7 @@ #include "xfs_bmap_util.h" #include "xfs_dir2.h" #include "xfs_dir2_priv.h" +#include "xfs_attr.h" #include "xfs_ioctl.h" #include "xfs_trace.h" #include "xfs_log.h" diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c index 13f1b2add390..01faef8ad1fe 100644 --- a/fs/xfs/xfs_ioctl.c +++ b/fs/xfs/xfs_ioctl.c @@ -369,6 +369,40 @@ xfs_attr_flags( return 0; } +/* + * Initializes an xfs_attr_list_context suitable for + * use by xfs_attr_list + */ +int +xfs_ioc_attr_list_context_init( + struct xfs_inode *dp, + char *buffer, + int bufsize, + int flags, + struct xfs_attr_list_context *context) +{ + struct xfs_attrlist *alist; + + /* + * Initialize the output buffer. + */ + context->dp = dp; + context->resynch = 1; + context->attr_filter = xfs_attr_filter(flags); + context->buffer = buffer; + context->bufsize = round_down(bufsize, sizeof(uint32_t)); + context->firstu = context->bufsize; + context->put_listent = xfs_ioc_attr_put_listent; + + alist = context->buffer; + alist->al_count = 0; + alist->al_more = 0; + alist->al_offset[0] = context->bufsize; + + return 0; +} + + int xfs_ioc_attr_list( struct xfs_inode *dp, @@ -378,7 +412,6 @@ xfs_ioc_attr_list( struct xfs_attrlist_cursor __user *ucursor) { struct xfs_attr_list_context context = { }; - struct xfs_attrlist *alist; void *buffer; int error; @@ -410,21 +443,10 @@ xfs_ioc_attr_list( if (!buffer) return -ENOMEM; - /* - * Initialize the output buffer. - */ - context.dp = dp; - context.resynch = 1; - context.attr_filter = xfs_attr_filter(flags); - context.buffer = buffer; - context.bufsize = round_down(bufsize, sizeof(uint32_t)); - context.firstu = context.bufsize; - context.put_listent = xfs_ioc_attr_put_listent; - - alist = context.buffer; - alist->al_count = 0; - alist->al_more = 0; - alist->al_offset[0] = context.bufsize; + error = xfs_ioc_attr_list_context_init(dp, buffer, bufsize, flags, + &context); + if (error) + return error; error = xfs_attr_list(&context); if (error) diff --git a/fs/xfs/xfs_ioctl.h b/fs/xfs/xfs_ioctl.h index d4abba2c13c1..ca60e1c427a3 100644 --- a/fs/xfs/xfs_ioctl.h +++ b/fs/xfs/xfs_ioctl.h @@ -35,6 +35,8 @@ int xfs_ioc_attrmulti_one(struct file *parfilp, struct inode *inode, int xfs_ioc_attr_list(struct xfs_inode *dp, void __user *ubuf, size_t bufsize, int flags, struct xfs_attrlist_cursor __user *ucursor); +int xfs_ioc_attr_list_context_init(struct xfs_inode *dp, char *buffer, + int bufsize, int flags, struct xfs_attr_list_context *context); extern struct dentry * xfs_handle_to_dentry( From patchwork Sun Dec 18 10:03:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 13076020 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 18F74C4332F for ; Sun, 18 Dec 2022 10:04:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230315AbiLRKEC (ORCPT ); Sun, 18 Dec 2022 05:04:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60464 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230313AbiLRKEA (ORCPT ); Sun, 18 Dec 2022 05:04:00 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 22CAC6597 for ; Sun, 18 Dec 2022 02:03:59 -0800 (PST) Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2BI4nAa7000922 for ; Sun, 18 Dec 2022 10:03: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-2022-7-12; bh=6r5E+jUVmqy2GQaGZCtwPHOxi4Rm8gm673bMX9XGoY0=; b=ki6jJqgbEo1d1hHZa8//4+1R6rAryQMB0diTh88Yx/UDGP3loNoqrlg7w9DW2difiPgk +pbfyTcta/9SWwoHRc+RXcl2eTTf0NkmimJndwN+IZrlKEEvUyZS3f7qj+gXq8D4qrHj aijKvH1EmvmK1DR0YNGA/Vxl0tGRbaP3i8uXSJVULxM5y7cMS3qYE/L7FIvW3nozRPj/ KlyLp7xRWdKP6mMlq5wk8hYAv4x5RmHhPhFK3+TYwxMf/d5GQ/qoPts5YhsLeMmBp3JI 8WVCfChm6LQ7rkmybH1OYUjUVAlvFkFNKqQzDBVbpfe27WNaNjLvzf6UXtnXWGbfZ2Tc 6A== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3mh6tm19ab-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sun, 18 Dec 2022 10:03:58 +0000 Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 2BI8JeXH024870 for ; Sun, 18 Dec 2022 10:03:53 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2177.outbound.protection.outlook.com [104.47.56.177]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3mh478mxs8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sun, 18 Dec 2022 10:03:52 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WyECK8/kPhO3ShNvdW3L5+LY15BfP2TLEd7XRsopVfWdmx97oisHBZ0N3QKCzn8kqYm/kDb6mfIO1hLPJOevIM82HpOCWIXN5ueBxaGMgU3fRbmGzirnPLnDqb3yp1bpW2166xphVnckeHFZzUF8YTj5sLUG+PGSlpvBdJu6GyYM+E1clrXuRt++9RCRG2uNdnYtKG1/LSroMxdXgAdLZmyPAP5H39UlAH3u6IxCwvsQXo/wmxxuF6uz2aJM9XUCcxpAws8YtjTgencZAFJYs07tTAfSOWT0pjRJMzGWRXKDik7id2/mRCMvPHF2HR8E1/MVhWse7YR4B/D2mCm3Bg== 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=6r5E+jUVmqy2GQaGZCtwPHOxi4Rm8gm673bMX9XGoY0=; b=KSgSL40OgZ63JyzUfGITMtJJeUQumgNq2wsICRgjQaYE71muGMYuU6M+33uH4JAPZIOEFFpdFcfqNknVqJKV14rm+0JpZb5AFvXUkpWe/RGfNwy5xpoK5umXtDz/dIvlNV7LJx/ikhnnqnvL1j8SSF4Sxk+nFXXeoD9DYr3eLTKBfmdxFLp7dEJ7eMM6fa1+SCa0xn8WCKL0lDbdKLvfVHaamXSxvjJDM8VaLQ7dzV2CrGRZbTW0Tl8kY01vNjpdrdXH059PunG9HIFJo1tH62NldUEj8Bbs+aOW7gMpb/vCB51ITy+UAO2RwRjIg6U/oMhAZgrStsMJmJ3ZTtck2A== 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=6r5E+jUVmqy2GQaGZCtwPHOxi4Rm8gm673bMX9XGoY0=; b=PUBrdMHOlq0bQwwQyOlekOTIlzMlviXRPKMhiljXC3yC3EwybCI6mPKgjyCy2cqYWPYF6x3zXl5IgPt6xtDBL2SNhB6VMPC2CY3Eb/HdDoJX1/+/R35Hzv2WGF1gIE5q8hZCQ8QHbgt0iMjkAgzg/+nafmztjfo/nNCs3BudXJE= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by IA0PR10MB7181.namprd10.prod.outlook.com (2603:10b6:208:400::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5924.16; Sun, 18 Dec 2022 10:03:44 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::3cab:6ff7:cb4d:b57c]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::3cab:6ff7:cb4d:b57c%4]) with mapi id 15.20.5924.016; Sun, 18 Dec 2022 10:03:44 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v7 24/27] xfs: Filter XFS_ATTR_PARENT for getfattr Date: Sun, 18 Dec 2022 03:03:03 -0700 Message-Id: <20221218100306.76408-25-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221218100306.76408-1-allison.henderson@oracle.com> References: <20221218100306.76408-1-allison.henderson@oracle.com> X-ClientProxiedBy: SJ0PR13CA0194.namprd13.prod.outlook.com (2603:10b6:a03:2c3::19) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY5PR10MB4306:EE_|IA0PR10MB7181:EE_ X-MS-Office365-Filtering-Correlation-Id: 5871f842-6c5b-4c3e-882b-08dae0df25dc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8/d4dynlFpi5++OL8XzKB+1iuugzQhFR2UdW7o0Fonct/R1cfUPPoVlgdYDhnwariCtucUEZwSrGyLZBRCmGoupL3sU+TBVZ2lTZCstFMIlCHWJvHUinXX44GAxj6/oNsMH344srk2eqFtOvG6XzHMfpBik+jiqNOR+j6oomleyCY5gI2vZ2YDI5fKHcQqC8pQe+8OHiKpzHtAmIkyxo++wChnDfLm8l+9xgeFBxf4V4GBZG+gC0kUYNJX4diSC164U5v+nRimyr+XG3rBXUE3D4/6q7dNsVpZ4Ic3DOEWi6zKFjVwXyjjaiPHtp5n+KDw4IPkmUZ4T9pHz+OdEVcAUGNVmLgDjjPjKwTC4XQI87K/pSKl/2oVm1OLVwxo9bqD2jV7ElXhudq50fm4bfDJ96ZlJehJyKqzs95WZrA/9OKZ4DxUnRg5o0Abe/RdLKtVxF2FFJLalznVhgBDtkx73vCfEE3W8eVBm9HtQs5h15DLRX/o7lEj6oW3FPwVl/58YWkxlWdoUR2JOkXWQq7o1+dgZ1ylya6KR81IjBqr0Sbyjjk7u5EF+T9g8RqynQBew46hq59qBc22CgToTSDVEDA0Ni1bALlDZJXH2765x6UvSqqt5bHo4tAy1PkDr6/gC3QOHHpen0fqobRQtGrA== 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:(13230022)(39860400002)(136003)(366004)(376002)(396003)(346002)(451199015)(4744005)(2906002)(41300700001)(8936002)(5660300002)(86362001)(38100700002)(36756003)(316002)(6506007)(6916009)(478600001)(6486002)(186003)(26005)(6512007)(66946007)(9686003)(2616005)(66476007)(8676002)(6666004)(66556008)(1076003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: /mcp2s3uXaj3ek4RsL9YbzRYEFUoPhOgpS1k7h3/l3vW9Yg7/cA9g9ZFORQB3HqIlgCcWevJuwc+oe+DyeAIuk6yFLzt98x34rjRDBELcXqQCLsBQ6ix55pCk0dU3+4xgVPgou3w6+hSpSifmqfjZt19owVhTwEAYxizI3rLD69YDZsc4ZaVxAX1z4Kz2RxaKIgOXXL3h+rGhf17bPQ5SFl0bok3AKWde6A94UM7KHsiikKSl4l6a1pi4d5JJLTqJI7wm2oyRGZDvwpeA4cCU6azzjgmoLAKC81VYHW6PE8Qoy/RuO7hlr8UbRvb1wsW01oGzTdpfLM2dzD2uCYbRPmHYLwCLvc+SSRwyhTMQRqIoQhvvfWo3iJki/d+X+2LeJPqUHP1ytdfN8Ay2mvI2kLoeS3hinN1hNG7RPvPaC8qDheJhZZD7zW/4jsQpGKXoYdbzSdP/Dvh+z9d7m3Zc/T4wSClVE3TAN14oNc9zS47sPioFagn2AzR8f8o/XGdAoqtDHQ/LqKvCD8WDWzS8tRGTWK7suT8+1+SQaySakqL+6qAbgPfY2SYiLSeT/DxciV1dzr9gbudBjC6iuv5IUmnbyBHuYhx6usLX3wTQMXU9ZIo6lUm1qQ1JOazS6OHzHr6CD8E3nq8qBtNjXljBN5NilUHvsQSPoqARRGeOfrLsaxJLO7OOMLGst2T53/7L8b3vqKJ6CUop9BCBR4o8vacAXgA6Qhh/gomQklbwRrMZxtUNf7nlTGIjLKRE3cWGA6SU/K1jmw5hHgwDlYPOi7rLIAP/87Mq/NeipgtAKerkGgk3QNt1GU4gceaCI0UjifybyHbHr4xkH4FmqpeEHOGCfS4I+Zk7qiwwTzYWQeG/9ikwTSFavfPwHKDVDvNFalIPF46xZ9sR+h+LUObGJWBwXDg/1+qNcGSvY6K9r+LNBNF5mKtrHGPtDssP3+67XDLdtuDjKzHc1qxh0OTOSGtc/PugEcEG6TxOvp2Lp5mGuYbklfSKrd7CSVhADbQUrA3H0udPLf37WFbzVl8LB11TPf5/y+bK0qIpJtCrljiM0A4+iKuD9c9Ruj+Xlz3Q2712obr9dFX0bsF8+pQ5l/+ocoBhduvI03BmGSQzBfy4p7C5W3fNbxAlQLjTrjq4qgY6P3M9qbrAMUdb5SMPsml4hVuRs+NceCwfRMUOlUh62C4s1pyeDhRZdJdwuhIdhLzr473hjTajDjNPi0O2CgNUh5Cggsd5ApWkR5QGTkXJoK8cc/9ni5p78aeB3OtMtwoKb2UIqCLnb+IW/jLkFrqKzTESIPMreSBMrjO09dtQ2zV/uUqN9rRU6APViLJHoUUdmcXzbMXrpqcuCHStk64uTxT6VIHU13THKQoCTdfXMZwVsmTUCxK9MNXav5K7A2Ii/PzXnAy9Zg5LdOiKKcooRQ/dA+jRntXn2UvPhJhE2PWAfXZ94wtLNRalwl9DheQ1nAAk2tB/Sqi1OuSaNe10iyQMhKR13MV3YtfzQ1lOX6M9+e5YHjez4JHjBOitZkH1sgCMcmg5gAFD7tzoiOp3LWJhktXNHoHgBkGbKlamNEsd0cTB0kqcHPC7EqCrTrDgZBtIXLzH58cClX3eQ== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5871f842-6c5b-4c3e-882b-08dae0df25dc X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Dec 2022 10:03:44.4665 (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: TI+APPz+n4aZHpAzCHJ9w69iWivqNLPwQOSs8Psw55AQwu82Rx0acpeEn8ueW5w6qjXfrH2denQKRNYkqGovanFvED3Mf11VQZg1rKrdpYw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR10MB7181 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-12-18_02,2022-12-15_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 mlxlogscore=999 phishscore=0 bulkscore=0 malwarescore=0 spamscore=0 adultscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2212180095 X-Proofpoint-GUID: y6iq9CU_-4kuuRBBxHRELOmXBH7y0CZs X-Proofpoint-ORIG-GUID: y6iq9CU_-4kuuRBBxHRELOmXBH7y0CZs Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Allison Henderson Parent pointers returned to the get_fattr tool cause errors since the tool cannot parse parent pointers. Fix this by filtering parent parent pointers from xfs_xattr_put_listent. Signed-off-by: Allison Henderson --- fs/xfs/xfs_xattr.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/xfs/xfs_xattr.c b/fs/xfs/xfs_xattr.c index 3644c5bcb3c0..3d54701716ab 100644 --- a/fs/xfs/xfs_xattr.c +++ b/fs/xfs/xfs_xattr.c @@ -234,6 +234,9 @@ xfs_xattr_put_listent( ASSERT(context->count >= 0); + if (flags & XFS_ATTR_PARENT) + return; + if (flags & XFS_ATTR_ROOT) { #ifdef CONFIG_XFS_POSIX_ACL if (namelen == SGI_ACL_FILE_SIZE && From patchwork Sun Dec 18 10:03:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 13076021 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 4BA93C4167B for ; Sun, 18 Dec 2022 10:04:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230319AbiLRKEE (ORCPT ); Sun, 18 Dec 2022 05:04:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60508 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230312AbiLRKEC (ORCPT ); Sun, 18 Dec 2022 05:04:02 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 20B5565F8 for ; Sun, 18 Dec 2022 02:04:01 -0800 (PST) Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2BI5FLLO016670 for ; Sun, 18 Dec 2022 10:04:00 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2022-7-12; bh=tW4XcK4z08ZwBMsWp9AIWXwolRj0L0bDYr26ueWtvC0=; b=yb3wz6QR/7Xs/vqF5URVbs+8H0aUSY15d8v0NLTK8AsbsJ3BRbVo+jvq6UKH3b2UE9Jg rYwf2i5EsnerweB2klgxaI1gcVzldyvpeed4genXT9kbdJD4dxDLvydfW2sBuKsJk9wF I6lgC2IVRnIRA3G36ba/U7oO2NCcKeF9G/7VTKncM13JhYWeXwkLQJYUDevS0q6XN6da PtBCDhewoj+6ml1Lbo3heGp8SKYFwp5yKi/TehLf+7CUPN2Gj88UI22wIHMimkAL5NCS Kq/eRSpCk7YeYAXb3NKRqf1fq5ZoOe4G6Kx4q3oomBaKbqtguK8fs0cAfhWxD2dTzGGC 4A== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3mh6tn1972-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sun, 18 Dec 2022 10:04:00 +0000 Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 2BI8JeXI024870 for ; Sun, 18 Dec 2022 10:03:53 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2177.outbound.protection.outlook.com [104.47.56.177]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3mh478mxs8-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sun, 18 Dec 2022 10:03:53 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=j++hBxVYqIEk7KeYJPbxEQaEo7Qu3deQVv7WuVX+HVzTvwTXNHNNreQBN85tCVHhxJ6O0l07EuTiAEyce9PrDryOM9HtWbaZmRyeyrjoXWyObhSNZevmx0jWCNtKyQ7NLrciq74P7afPkVYcByh7bEuH4M1yk7QiXkFhbQdvwiuD8awJabUgbrdqwGFVYB0GOohBwsE98V+TX8f8fQrC9ct9pj6NSN6D/v5TyXAQ405tSAUNLBFBdp96BAJgO9/tyv4mWwSglGimch9slhvkh+IrWZpfh1U3S4JSdnvkao1ZAVvFMjKTvKoP4Sc1Hp1arHLBOdZEeQIAunV5020HwQ== 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=tW4XcK4z08ZwBMsWp9AIWXwolRj0L0bDYr26ueWtvC0=; b=YGudPqLce6UNHmcXyG9cEzm4Bh+8V1ff0zVxQTf5qEj5+GVd1kCPLnkteEN5Epr2BevZoA7+fuENMmnsvMQHjkvYU06BpSP3WTfQQxJauqb7rR7yqT+e14K63EB3gznSXCEDILhQ2uy6+GIf8gLmL3AYo3xSj1rk00eciAj9Hmxy8mpSq2hdyaG3DpoqOK0hIuU/UdNLuM1HnIuuCC4aejyd7tagsyZTDUiWzoVO+rHq1/sCI5+jUQJoVKOEm6PHdZF7G2bCE+6ePZw1asvayiIbUiEu7OJbgXAM2+b3ANF2cP/pnbMFUkG57HyakLjnftrFFKx2R+XcgNpSJVkYcA== 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=tW4XcK4z08ZwBMsWp9AIWXwolRj0L0bDYr26ueWtvC0=; b=PI/o6lZQrO8oPkD463hFUBIoD7h0cCqIE4i5C54NzfFlRKHjinIR6X3IRGNbRx27M7ACmZb0MsyryQiLuzOGvbplu3RUB2yuAFGuicfLPdjN5rpdXvCeCZcTDLLQBktTOY5kif0VQ/7B4sNrZaxrPJXp2Jbwy8+04yPOnrOhJ08= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by IA0PR10MB7181.namprd10.prod.outlook.com (2603:10b6:208:400::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5924.16; Sun, 18 Dec 2022 10:03:46 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::3cab:6ff7:cb4d:b57c]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::3cab:6ff7:cb4d:b57c%4]) with mapi id 15.20.5924.016; Sun, 18 Dec 2022 10:03:46 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v7 25/27] xfs: Add parent pointer ioctl Date: Sun, 18 Dec 2022 03:03:04 -0700 Message-Id: <20221218100306.76408-26-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221218100306.76408-1-allison.henderson@oracle.com> References: <20221218100306.76408-1-allison.henderson@oracle.com> X-ClientProxiedBy: SJ0PR13CA0191.namprd13.prod.outlook.com (2603:10b6:a03:2c3::16) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY5PR10MB4306:EE_|IA0PR10MB7181:EE_ X-MS-Office365-Filtering-Correlation-Id: 93e452bb-88b4-461f-9f1b-08dae0df26f3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: XS0VMEESsyuSzL+2j9/eqkqPmyM1TsakUQAG+M+n+oR10r+3QCzazlTyQGuVUYAbv7GrIFlWqWKqytJ2VSS6M5DtO0nQzyQvCy0Si1I3wNbBlQ1cQ4arZZ59UAjoHTqBewITRCvFQRpxQ48OjyfqVnFq49+mcjpRarYSCjhrwGBnjNT+z4eYUyspmatfWQJatatav/YIPGvmgeHrmwkqi/A2oQdH8ophZw7iwHZR+6SlhsF44DQwRAG5LjnBV7/SdbtirAaRMsWjSHtiQUG11HbuOLutBIh4tLnfVFKK6w/3TZPRBy+al1k57tBPXxz0TnIeJe1FBspzzU7pvBN9tzPCgfIuMqtAL6Uwl8Rk6Wzx6txpGCtsdqszu4bVOkW4sS8LadKwFKEsIRYI38CxerOUErlfS3MHme8Yvkzh/B+dtutK5rWlJiLETQ6lHvhILYxD7i0RUJu6Vqm0AHGLzGf/RAo0kHsM5u1BEG1NgEYqvpgGL0YuUL1g6uZ4rB9SxRfm7ujaygMjP+0YNBvNBqgPgYopuZLfX1D0ENMg5onXbYLaCciUxK4ft7whaG16BPsvpy1Uq7w/ip3noLYp8+sIf+v4A5kb7gwtmHNj/ocbw9XSuauD8fXSFIVh3VLDJabuM7vrOj8XgNDmVn5o1w== 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:(13230022)(39860400002)(136003)(366004)(376002)(396003)(346002)(451199015)(30864003)(83380400001)(2906002)(41300700001)(8936002)(5660300002)(86362001)(38100700002)(36756003)(316002)(6506007)(6916009)(478600001)(6486002)(186003)(26005)(6512007)(66946007)(9686003)(2616005)(66476007)(8676002)(6666004)(66556008)(1076003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: nfQvM7jqLcMd7ZrI/iymAXktx44c1pryre+d7gUWQcZ7onf48CyfsmXNecf4WsjAmnPnAWRQ8why7VmBKWHYgqjQlPQFZZRv9hIlm9W+2hI0C3ErzrEiqs91dspZC3fhYcIDNkycYHU7JpKEwx1/q7Ht9Da8jznSRxH1dEjPCZA1YTx+u0X5NZ/zeFSGNvmYJvZkw0dI+Jn3sDZQDtlx7LTyY6hzTgPpvlrxz7CGoxjLi4eizDmx58Lpywhtm7Bn2DGUlxUiCZTz6ls2foX3GRZK/2G+ikTtqGJrUGevA3rERpGGi8S+JkMUMtnAETjkKKdlAnsqfPd9kKqX/PS3/ouDRoLlsEn52+dq1IKSDhlZak7vnZtUhEJ3SZs846msXVXpRZ+8SAOOEGnyjYEGUezDvrprJTKhdPTzVTu2vnKDf5P8s9T5JC1m3XtrLf30NohPoOp0eka6ij1bsNc3B7JRQ+/+dd2NsIdxKw2tb+TX45zYNt6LBQvqn2+9vKC4gly5SJmMsNOP9rX5W7eHI4+aasM9NZInkaMGUg6Rdg2T+9FmesookUippKS2XPMETgl7c6uSkLgf7jBekmKgpzJEa2Kk7W1nYTpng86EmA7dEf3LHos45S7nH0QSyTwu8ntSvhoNvzagTieB4ChtULgiUosetkUqEkOb+2KsRdX0zqXszrG1mEHP5COPDY+ijxjFRUd4pSUE60prRYkRTxdUOEnt/8V4MxVSZNBcZPLzw3ghFnt53Ai03ZSrTvJLVeI5piSjfnyZpgiXXgT0bV6FVrYEl3ejWlTRJhXPWQgzAmDXnAA6TXwILHpdagTyZ2syfDDAV9loy8sIlA0of/Xd3209+coxaoetN+QFN54Io/AAL2CK9TOtq6zDVW6NTJTyp5fam1t3FLd/Yu0ETX3kd4CCrpTAMYK5Iwmi7ldbqP/9zEHIMbIbqWshFtaX4b9FI6iY23CbQZR9ycxk/JRMQ9Ez4j4e/WpgDfmFT3Q1gLZUCuwutsCtSDG1RPWJ19U3W5cNz89FREklePWF803IM3MnaDifUHOQXDN4lseYHk2LnhvS4h+OK2qf1XTav2lV4wiIj64HAUqvCTmTYTnMjJT6YM6cASCnyr/PptxqVFp2dh7bXiDkuQ2KbLvR/q0kDaO/Gx69okrTzclXn0rTZORgMhJ0ZuQisYNxdbl4VUgg4fE2ui1d/k5zMIFTfpZ+Z1lRn1kzQ04X1SzqhxXtmceRIM21kPU9gvdabk2143wqNFCuHVx6u+BbSmFRPXgWQiGL4ygF5RuH+IXYIXM019PSZozcmdbllsylpvazJbMgEZFkVsUL/Sy7UZD9Ev5apDN+87KkFbWS3XQWXLbN5HedH3wW5Nt4fUS5K3aWqX7pjjPT5sXo8+VMwOuW5Eu/StgAc/lH0qGn4hXknWJ6nksG8h6Yo072tQg+ahpGRxqFFK+QeNDsEPu4vMDGU3hkknZOYyfhzfHYPDVRTL/gRX7X/u9WsMDGMpcC91DuHCCoo2HHyXdRz1O0UCL5HXySFuOng5cWJDFtGBr3Ost+ra5DzeE3If0CWBvZEDPsdJKcf1YQ7I+vrfsw5oSBy+Ooa48iiOlwQvdov0XDLw== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 93e452bb-88b4-461f-9f1b-08dae0df26f3 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Dec 2022 10:03:46.3112 (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: 9v8CRRr4fO+22lUAn8MHVUrvKO1Mq1GRPidRKlzPsM7/G539y05Qhy4fgZNhpRFRiqBKZXK2mRk1aLzXGjWH4prz3t5ikaWj6vC7mGXebRE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR10MB7181 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-12-18_02,2022-12-15_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 mlxlogscore=999 phishscore=0 bulkscore=0 malwarescore=0 spamscore=0 adultscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2212180095 X-Proofpoint-ORIG-GUID: pvVliNZBctqHCSvUHYbaDvNmZT0hm4t7 X-Proofpoint-GUID: pvVliNZBctqHCSvUHYbaDvNmZT0hm4t7 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Allison Henderson This patch adds a new file ioctl to retrieve the parent pointer of a given inode Signed-off-by: Allison Henderson --- fs/xfs/Makefile | 1 + fs/xfs/libxfs/xfs_fs.h | 74 ++++++++++++++++++++++ fs/xfs/libxfs/xfs_parent.c | 10 +++ fs/xfs/libxfs/xfs_parent.h | 2 + fs/xfs/xfs_ioctl.c | 94 +++++++++++++++++++++++++++- fs/xfs/xfs_ondisk.h | 4 ++ fs/xfs/xfs_parent_utils.c | 125 +++++++++++++++++++++++++++++++++++++ fs/xfs/xfs_parent_utils.h | 11 ++++ 8 files changed, 320 insertions(+), 1 deletion(-) diff --git a/fs/xfs/Makefile b/fs/xfs/Makefile index e2b2cf50ffcf..42d0496fdad7 100644 --- a/fs/xfs/Makefile +++ b/fs/xfs/Makefile @@ -86,6 +86,7 @@ xfs-y += xfs_aops.o \ xfs_mount.o \ xfs_mru_cache.o \ xfs_pwork.o \ + xfs_parent_utils.o \ xfs_reflink.o \ xfs_stats.o \ xfs_super.o \ diff --git a/fs/xfs/libxfs/xfs_fs.h b/fs/xfs/libxfs/xfs_fs.h index b0b4d7a3aa15..9e59a1fdfb0c 100644 --- a/fs/xfs/libxfs/xfs_fs.h +++ b/fs/xfs/libxfs/xfs_fs.h @@ -752,6 +752,79 @@ struct xfs_scrub_metadata { XFS_SCRUB_OFLAG_NO_REPAIR_NEEDED) #define XFS_SCRUB_FLAGS_ALL (XFS_SCRUB_FLAGS_IN | XFS_SCRUB_FLAGS_OUT) +#define XFS_PPTR_MAXNAMELEN 256 + +/* return parents of the handle, not the open fd */ +#define XFS_PPTR_IFLAG_HANDLE (1U << 0) + +/* target was the root directory */ +#define XFS_PPTR_OFLAG_ROOT (1U << 1) + +/* Cursor is done iterating pptrs */ +#define XFS_PPTR_OFLAG_DONE (1U << 2) + + #define XFS_PPTR_FLAG_ALL (XFS_PPTR_IFLAG_HANDLE | XFS_PPTR_OFLAG_ROOT | \ + XFS_PPTR_OFLAG_DONE) + +/* Get an inode parent pointer through ioctl */ +struct xfs_parent_ptr { + __u64 xpp_ino; /* Inode */ + __u32 xpp_gen; /* Inode generation */ + __u32 xpp_diroffset; /* Directory offset */ + __u64 xpp_rsvd; /* Reserved */ + __u8 xpp_name[XFS_PPTR_MAXNAMELEN]; /* File name */ +}; + +/* Iterate through an inodes parent pointers */ +struct xfs_pptr_info { + /* File handle, if XFS_PPTR_IFLAG_HANDLE is set */ + struct xfs_handle pi_handle; + + /* + * Structure to track progress in iterating the parent pointers. + * Must be initialized to zeroes before the first ioctl call, and + * not touched by callers after that. + */ + struct xfs_attrlist_cursor pi_cursor; + + /* Operational flags: XFS_PPTR_*FLAG* */ + __u32 pi_flags; + + /* Must be set to zero */ + __u32 pi_reserved; + + /* # of entries in array */ + __u32 pi_ptrs_size; + + /* # of entries filled in (output) */ + __u32 pi_ptrs_used; + + /* Must be set to zero */ + __u64 pi_reserved2[6]; + + /* + * An array of struct xfs_parent_ptr follows the header + * information. Use xfs_ppinfo_to_pp() to access the + * parent pointer array entries. + */ + struct xfs_parent_ptr pi_parents[]; +}; + +static inline size_t +xfs_pptr_info_sizeof(int nr_ptrs) +{ + return sizeof(struct xfs_pptr_info) + + (nr_ptrs * sizeof(struct xfs_parent_ptr)); +} + +static inline struct xfs_parent_ptr* +xfs_ppinfo_to_pp( + struct xfs_pptr_info *info, + int idx) +{ + return &info->pi_parents[idx]; +} + /* * ioctl limits */ @@ -797,6 +870,7 @@ struct xfs_scrub_metadata { /* XFS_IOC_GETFSMAP ------ hoisted 59 */ #define XFS_IOC_SCRUB_METADATA _IOWR('X', 60, struct xfs_scrub_metadata) #define XFS_IOC_AG_GEOMETRY _IOWR('X', 61, struct xfs_ag_geometry) +#define XFS_IOC_GETPARENTS _IOWR('X', 62, struct xfs_parent_ptr) /* * ioctl commands that replace IRIX syssgi()'s diff --git a/fs/xfs/libxfs/xfs_parent.c b/fs/xfs/libxfs/xfs_parent.c index 954a52d6be00..fa3d645731a9 100644 --- a/fs/xfs/libxfs/xfs_parent.c +++ b/fs/xfs/libxfs/xfs_parent.c @@ -27,6 +27,16 @@ #include "xfs_parent.h" #include "xfs_trans_space.h" +/* Initializes a xfs_parent_ptr from an xfs_parent_name_rec */ +void +xfs_init_parent_ptr(struct xfs_parent_ptr *xpp, + const struct xfs_parent_name_rec *rec) +{ + xpp->xpp_ino = be64_to_cpu(rec->p_ino); + xpp->xpp_gen = be32_to_cpu(rec->p_gen); + xpp->xpp_diroffset = be32_to_cpu(rec->p_diroffset); +} + /* * Parent pointer attribute handling. * diff --git a/fs/xfs/libxfs/xfs_parent.h b/fs/xfs/libxfs/xfs_parent.h index 9021241ad65b..898842b4532d 100644 --- a/fs/xfs/libxfs/xfs_parent.h +++ b/fs/xfs/libxfs/xfs_parent.h @@ -24,6 +24,8 @@ void xfs_init_parent_name_rec(struct xfs_parent_name_rec *rec, uint32_t p_diroffset); void xfs_init_parent_name_irec(struct xfs_parent_name_irec *irec, struct xfs_parent_name_rec *rec); +void xfs_init_parent_ptr(struct xfs_parent_ptr *xpp, + const struct xfs_parent_name_rec *rec); int xfs_parent_init(xfs_mount_t *mp, struct xfs_parent_defer **parentp); int xfs_parent_defer_add(struct xfs_trans *tp, struct xfs_parent_defer *parent, struct xfs_inode *dp, struct xfs_name *parent_name, diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c index 01faef8ad1fe..2e56762e8de7 100644 --- a/fs/xfs/xfs_ioctl.c +++ b/fs/xfs/xfs_ioctl.c @@ -37,6 +37,7 @@ #include "xfs_health.h" #include "xfs_reflink.h" #include "xfs_ioctl.h" +#include "xfs_parent_utils.h" #include "xfs_xattr.h" #include @@ -1675,6 +1676,96 @@ xfs_ioc_scrub_metadata( return 0; } +/* + * IOCTL routine to get the parent pointers of an inode and return it to user + * space. Caller must pass a buffer space containing a struct xfs_pptr_info, + * followed by a region large enough to contain an array of struct + * xfs_parent_ptr of a size specified in pi_ptrs_size. If the inode contains + * more parent pointers than can fit in the buffer space, caller may re-call + * the function using the returned pi_cursor to resume iteration. The + * number of xfs_parent_ptr returned will be stored in pi_ptrs_used. + * + * Returns 0 on success or non-zero on failure + */ +STATIC int +xfs_ioc_get_parent_pointer( + struct file *filp, + void __user *arg) +{ + struct xfs_pptr_info *ppi = NULL; + int error = 0; + struct xfs_inode *ip = XFS_I(file_inode(filp)); + struct xfs_mount *mp = ip->i_mount; + + if (!capable(CAP_SYS_ADMIN)) + return -EPERM; + + /* Allocate an xfs_pptr_info to put the user data */ + ppi = kmalloc(sizeof(struct xfs_pptr_info), 0); + if (!ppi) + return -ENOMEM; + + /* Copy the data from the user */ + error = copy_from_user(ppi, arg, sizeof(struct xfs_pptr_info)); + if (error) { + error = -EFAULT; + goto out; + } + + /* Check size of buffer requested by user */ + if (xfs_pptr_info_sizeof(ppi->pi_ptrs_size) > XFS_XATTR_LIST_MAX) { + error = -ENOMEM; + goto out; + } + + if (ppi->pi_flags & ~XFS_PPTR_FLAG_ALL) { + error = -EINVAL; + goto out; + } + ppi->pi_flags &= ~(XFS_PPTR_OFLAG_ROOT | XFS_PPTR_OFLAG_DONE); + + /* + * Now that we know how big the trailing buffer is, expand + * our kernel xfs_pptr_info to be the same size + */ + ppi = krealloc(ppi, xfs_pptr_info_sizeof(ppi->pi_ptrs_size), 0); + if (!ppi) + return -ENOMEM; + + if (ppi->pi_flags & XFS_PPTR_IFLAG_HANDLE) { + error = xfs_iget(mp, NULL, ppi->pi_handle.ha_fid.fid_ino, + 0, 0, &ip); + if (error) + goto out; + + if (VFS_I(ip)->i_generation != ppi->pi_handle.ha_fid.fid_gen) { + error = -EINVAL; + goto out; + } + } + + if (ip->i_ino == mp->m_sb.sb_rootino) + ppi->pi_flags |= XFS_PPTR_OFLAG_ROOT; + + /* Get the parent pointers */ + error = xfs_attr_get_parent_pointer(ip, ppi); + + if (error) + goto out; + + /* Copy the parent pointers back to the user */ + error = copy_to_user(arg, ppi, + xfs_pptr_info_sizeof(ppi->pi_ptrs_size)); + if (error) { + error = -EFAULT; + goto out; + } + +out: + kmem_free(ppi); + return error; +} + int xfs_ioc_swapext( xfs_swapext_t *sxp) @@ -1964,7 +2055,8 @@ xfs_file_ioctl( case XFS_IOC_FSGETXATTRA: return xfs_ioc_fsgetxattra(ip, arg); - + case XFS_IOC_GETPARENTS: + return xfs_ioc_get_parent_pointer(filp, arg); case XFS_IOC_GETBMAP: case XFS_IOC_GETBMAPA: case XFS_IOC_GETBMAPX: diff --git a/fs/xfs/xfs_ondisk.h b/fs/xfs/xfs_ondisk.h index 9737b5a9f405..6a6bd05c2a68 100644 --- a/fs/xfs/xfs_ondisk.h +++ b/fs/xfs/xfs_ondisk.h @@ -150,6 +150,10 @@ xfs_check_ondisk_structs(void) XFS_CHECK_OFFSET(struct xfs_efi_log_format_32, efi_extents, 16); XFS_CHECK_OFFSET(struct xfs_efi_log_format_64, efi_extents, 16); + /* parent pointer ioctls */ + XFS_CHECK_STRUCT_SIZE(struct xfs_parent_ptr, 280); + XFS_CHECK_STRUCT_SIZE(struct xfs_pptr_info, 104); + /* * The v5 superblock format extended several v4 header structures with * additional data. While new fields are only accessible on v5 diff --git a/fs/xfs/xfs_parent_utils.c b/fs/xfs/xfs_parent_utils.c new file mode 100644 index 000000000000..0bca1814dcf4 --- /dev/null +++ b/fs/xfs/xfs_parent_utils.c @@ -0,0 +1,125 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2022 Oracle, Inc. + * All rights reserved. + */ +#include "xfs.h" +#include "xfs_fs.h" +#include "xfs_format.h" +#include "xfs_log_format.h" +#include "xfs_shared.h" +#include "xfs_trans_resv.h" +#include "xfs_mount.h" +#include "xfs_bmap_btree.h" +#include "xfs_inode.h" +#include "xfs_error.h" +#include "xfs_trace.h" +#include "xfs_trans.h" +#include "xfs_da_format.h" +#include "xfs_da_btree.h" +#include "xfs_attr.h" +#include "xfs_ioctl.h" +#include "xfs_parent.h" +#include "xfs_da_btree.h" + +/* + * Get the parent pointers for a given inode + * + * Returns 0 on success and non zero on error + */ +int +xfs_attr_get_parent_pointer( + struct xfs_inode *ip, + struct xfs_pptr_info *ppi) +{ + + struct xfs_attrlist *alist; + struct xfs_attrlist_ent *aent; + struct xfs_parent_ptr *xpp; + struct xfs_parent_name_rec *xpnr; + char *namebuf; + unsigned int namebuf_size; + int name_len, i, error = 0; + unsigned int lock_mode, flags = XFS_ATTR_PARENT; + struct xfs_attr_list_context context; + + /* Allocate a buffer to store the attribute names */ + namebuf_size = sizeof(struct xfs_attrlist) + + (ppi->pi_ptrs_size) * sizeof(struct xfs_attrlist_ent); + namebuf = kvzalloc(namebuf_size, GFP_KERNEL); + if (!namebuf) + return -ENOMEM; + + memset(&context, 0, sizeof(struct xfs_attr_list_context)); + error = xfs_ioc_attr_list_context_init(ip, namebuf, namebuf_size, 0, + &context); + if (error) + goto out_kfree; + + /* Copy the cursor provided by caller */ + memcpy(&context.cursor, &ppi->pi_cursor, + sizeof(struct xfs_attrlist_cursor)); + context.attr_filter = XFS_ATTR_PARENT; + + lock_mode = xfs_ilock_attr_map_shared(ip); + + error = xfs_attr_list_ilocked(&context); + if (error) + goto out_unlock; + + alist = (struct xfs_attrlist *)namebuf; + for (i = 0; i < alist->al_count; i++) { + struct xfs_da_args args = { + .geo = ip->i_mount->m_attr_geo, + .whichfork = XFS_ATTR_FORK, + .dp = ip, + .namelen = sizeof(struct xfs_parent_name_rec), + .attr_filter = flags, + }; + + xpp = xfs_ppinfo_to_pp(ppi, i); + memset(xpp, 0, sizeof(struct xfs_parent_ptr)); + aent = (struct xfs_attrlist_ent *) + &namebuf[alist->al_offset[i]]; + xpnr = (struct xfs_parent_name_rec *)(aent->a_name); + + if (aent->a_valuelen > XFS_PPTR_MAXNAMELEN) { + error = -EFSCORRUPTED; + goto out_unlock; + } + name_len = aent->a_valuelen; + + args.name = (char *)xpnr; + args.hashval = xfs_da_hashname(args.name, args.namelen), + args.value = (unsigned char *)(xpp->xpp_name); + args.valuelen = name_len; + + error = xfs_attr_get_ilocked(&args); + error = (error == -EEXIST ? 0 : error); + if (error) { + error = -EFSCORRUPTED; + goto out_unlock; + } + + xfs_init_parent_ptr(xpp, xpnr); + if (!xfs_verify_ino(args.dp->i_mount, xpp->xpp_ino)) { + error = -EFSCORRUPTED; + goto out_unlock; + } + } + ppi->pi_ptrs_used = alist->al_count; + if (!alist->al_more) + ppi->pi_flags |= XFS_PPTR_OFLAG_DONE; + + /* Update the caller with the current cursor position */ + memcpy(&ppi->pi_cursor, &context.cursor, + sizeof(struct xfs_attrlist_cursor)); + +out_unlock: + xfs_iunlock(ip, lock_mode); +out_kfree: + kvfree(namebuf); + + return error; +} + diff --git a/fs/xfs/xfs_parent_utils.h b/fs/xfs/xfs_parent_utils.h new file mode 100644 index 000000000000..ad60baee8b2a --- /dev/null +++ b/fs/xfs/xfs_parent_utils.h @@ -0,0 +1,11 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2022 Oracle, Inc. + * All rights reserved. + */ +#ifndef __XFS_PARENT_UTILS_H__ +#define __XFS_PARENT_UTILS_H__ + +int xfs_attr_get_parent_pointer(struct xfs_inode *ip, + struct xfs_pptr_info *ppi); +#endif /* __XFS_PARENT_UTILS_H__ */ From patchwork Sun Dec 18 10:03:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 13076018 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 5A6DBC4332F for ; Sun, 18 Dec 2022 10:04:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230327AbiLRKD7 (ORCPT ); Sun, 18 Dec 2022 05:03:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60424 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230315AbiLRKD4 (ORCPT ); Sun, 18 Dec 2022 05:03:56 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6C5FD9FE0 for ; Sun, 18 Dec 2022 02:03:55 -0800 (PST) Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2BI5xtWw012952 for ; Sun, 18 Dec 2022 10:03: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-2022-7-12; bh=0HDc5oSRZUZiwCZrUG1G6lMOEEvHfQHLGVwhC+kxeKs=; b=X4vRhx0gklUDC2Z9Zalg72jVwP+Fbu7HxQ+hTNk2yX5TBbLXg1bQqdxkyz8+VzzjuqEZ rCtn75a7N0uZklPG9qd0JR6R/YWpoZKaoyQY1gzKZwEI8PfjzxGc0P8F0VqQziTQHjEd 8egyN9tiWwP2nqbKmNlyYpCtwNqMh1GSnNDYZJAQT4gAMkZXzziExDtDRv3+qG/6WCob +oRLNdzOA+EsRjky/jWr62IJw5HxYUjwJWCp6ta2hqYFpZJNaX+6TTKqts0XR6RbbjEF hSegNrPSWRLH3pgln0QqsmNCsfRxe77m8QTKeezMkEQwC2q1c/gJpNtMNETS6Q6yjjle gw== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3mh6tms9bf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sun, 18 Dec 2022 10:03:54 +0000 Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 2BI8JeXJ024870 for ; Sun, 18 Dec 2022 10:03:53 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2177.outbound.protection.outlook.com [104.47.56.177]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3mh478mxs8-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sun, 18 Dec 2022 10:03:53 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JJ5+ZXSNMfXiKQo4+RoPivt6lIfb0Istv6SNCJuUaXwKOJEPIocALXH5J0k2jGS+0+e8zwxMezcJKxDaMPbHU6ejMyP3NCTDhoPtFhbPgpVU2/ingAx/X3YQX1bwroxRuRIC+DSDEsDvATmD3UeN3PO9tcXxyPFCSsdG5Ne6FS59azIF0zZ1nj3a/7ox4gm8a3o3RYP7jwGH8+N9afq+j5IlWU0mvRYPcI9HY0kT13xmrOG0lARqs8cbbTntuDjbkewA3agQwWnj2gs+LrDpYZHk+NAMuvVwfRUPjbSIlJ4Mi+NiE1ogz3lySPGRqMgJxyhS/jPm71AxUS/+8cJpgg== 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=0HDc5oSRZUZiwCZrUG1G6lMOEEvHfQHLGVwhC+kxeKs=; b=lwzRnOoO+dqQIqnhZzlQ1jotfncV6sWWdx1MMds/xgMQrTLeuQfPwshleUTMMLkNLyC/21vTUWmVsr7aUY1m88dO9hmWLUxk5smWJN12gQTonQ8AI/SIlZtNskRkARNHjzKm5ao1JY6CZa1b3Jkllhaepuo9iXwbbdlsk5zxs65DKQCFEaV50w4fZ3nilV1xir6NIl1UeP41zCRORjGISWyD/RzeXIZMPD/q0wvNVldpFnGARgCkuCaemqTMu74/HxHZDj341O6UrHg6QV/xH8aL/LulBqWBx74cwdCGKZYV0Oj+JSIYXu4S8ghTsraWOPteIuDDI5/oliy/troeAQ== 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=0HDc5oSRZUZiwCZrUG1G6lMOEEvHfQHLGVwhC+kxeKs=; b=WIllfz2Tkj+mRW+tPWzgUL726yObNyM0kRAZ+41w25mBuTrYTqM01OM/xLYn0XOrlkmaoFHvwiAVyR35M55gBtduf+Pg9493I4G72ITlpznkF+U/GJxs/0m6eGZ1qQNZRD2wt6BYLrb6YWWoXkvFjE3Xo6EbGhfv9AJwfSz/P6o= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by IA0PR10MB7181.namprd10.prod.outlook.com (2603:10b6:208:400::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5924.16; Sun, 18 Dec 2022 10:03:47 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::3cab:6ff7:cb4d:b57c]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::3cab:6ff7:cb4d:b57c%4]) with mapi id 15.20.5924.016; Sun, 18 Dec 2022 10:03:47 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v7 26/27] xfs: fix unit conversion error in xfs_log_calc_max_attrsetm_res Date: Sun, 18 Dec 2022 03:03:05 -0700 Message-Id: <20221218100306.76408-27-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221218100306.76408-1-allison.henderson@oracle.com> References: <20221218100306.76408-1-allison.henderson@oracle.com> X-ClientProxiedBy: SJ0PR03CA0389.namprd03.prod.outlook.com (2603:10b6:a03:3a1::34) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY5PR10MB4306:EE_|IA0PR10MB7181:EE_ X-MS-Office365-Filtering-Correlation-Id: c501fe9b-2597-4c71-bb7c-08dae0df27cc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: x/gt+hkf42PvyhGn2IaTOT6KtR23O+ZzvvGgY16FbxPCdqv4vsZoJzIYqte8ym9mdsBZeUft2Wp91AZKjBTnNg1OHEWyC0oD1XSYv1/MvaY9NGnPjXsSLUUdm45K5w1B7C0QeyXqYNrctuAyuaEfyM5PW7zgR9/Ofsq4FtDl4oDZiJ83RgVjiXndTZ8dmXW84zG5h6nd27Tq7D1WWCvZ6B2noORQTWpWqMnEUnqV2f+m1dU8iqPIRb0Ygt2lBMhbZFcyub4UjU80J5b5HydoIY635jDPp0sefMFnzIc0xWRw0fkf2aL/0rClsBLrodk3ox9hDtqz8R/ZjIiVkNVuCA+NkPvECcb0w5Nbg+1aAqpMScFjhX/nE8pmaWVC9TsMD88VpaVxF20nv3/VtFG1+pYKNXKcrfpElHGuur1CTFnXO04Bnxlbq/bcwAPgNBRQj4leeOQt+zlpwmnTDo1eLuXdREuPMgHPiZ4xzgT8s1EFu5Et8auVEuxkFqWOu/jI68sOiTRW4tvnLK1EPZIYjnIqVn7KQzec5f4t5h6G72YOZCBrdzls/k3BanS+HsFo3BIpEmmaH6deVEsltR91f5bu+mLtcUnbg9bmkYedHJyy+SKtUsCxjbFZ/zg19ni3 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:(13230022)(39860400002)(136003)(366004)(376002)(396003)(346002)(451199015)(83380400001)(2906002)(41300700001)(8936002)(5660300002)(86362001)(38100700002)(36756003)(316002)(6506007)(6916009)(478600001)(6486002)(186003)(26005)(6512007)(66946007)(9686003)(2616005)(66476007)(8676002)(6666004)(66556008)(1076003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: xwiuze93jYRrvy3DLc2XufFpVk5XvgwNr4xp9fxZGq76/9JCZX6JZjcuuJSrFV4ECFWXEOaL7RHACPIt7ts62mnjJs9fegCDNEtmP6B1Jltu1TaI0Uik+7kp30erM1/2btA/+PHbp4l2IVTSAq1Efw7dqbBI18AHIcS9kqa2oKvl5QXQgHSH0dEQekBpVdvByMoWxyMGMrn4nA53YFj2pbR81/D4uWJHqyEzQ1OE9Vy/uetDybVjbA8UvYs/9/z2cQIGCCIcyqL2/5WyZObi40C8dQwAnRaS/N3w3Gw5s9aMIA/iYY96U6x6geIH05AlMwiE7w5J0MsOZYB0gdtMgBO+VgJvM8muzZND0t17BzUvtORSPurnXvvf8luVn175Ual3urVgEROpJyz0rgwZAqaLyErBfa/JvH900h+pssvUIK0C0IcB/afGD8MKfx2wCFP6ShodpMLUaWLxo/O59mq95yz0CVaRP8cdIUkHlVsX9LwX7cqHj8zR2wMZeHvB9B1lU2+ERSYGq0F10N249bTAER7wD7TfjAQ8pxgARy3vDzTBhsnE6xHg6aokge3/oGB70+uXMzVRXR7C+f0P2/35ddpgjx801+S7L6WedMwCP6KimSTifDlstPvkJKpCkklLVmCgyEvbo3GbvHiE4jwyhoANgzyu/f1JUs+RpuTwnwW7dWE3HA8dJLGE9Irj1MPCMbLyTIWzT9bk4p3R3qaA1GIEn2nJ2qQxEHNkALJcX7GvPsTAa3M+e3yCwk2S1R7ZFR9+uCg6kadEPXBOnRo2c+Xl1X1JAwpFIAiKpMbvkkg/cfzfVWeAKS1mF5bHNG/7Scfscj1bJBry6dOb5JCWiuO5chWwHv21sVHDVTG5V6Y1M3NOrj626UezX8TKy0wssYHN5w+bKLGIPX91RdINVoeT1IwFiLPOLuUrBVTEHBqIrWQaEn+DyXdWvhPWLK98t2l+yLYgmmAGLWnwDjUCfnc+HnKmxK3X0furryuIlCb6yZzEqIxumkTgvaUqhfPauehh+LKumae8jUgvA00zQE9uKv1QQnYRuj64njA37l8K+xqcyIKD03eU74shGx2z/FE/owTNZX4JmIgW2ioO+KgGltk1r2zwEOM/WGgpkonpBSnvDgpYNhIA/nIZqWnWu3/X1GjI2WVuearTOHKmZzRrhAusHYr1QiGYe5fyPxjTjuxcRt3w4alRdi5T0fx0GSUZzRHi5VBAtMgyvLAeoGJkkYZ0Q2QlQpppT2bOKMXZou4sivVkQdiL0aCLu73MZvr0XSnW7M+RaU8O7ByE56z/jDqFt7upGt6ISJw8l4od3eSBVqs6hM9tb4438NCzmVrJy6YkHUesNkrCP62JsRvweeo5X49EcKtx2RtSbp4Ezi6wQssp/Njkdm4q+opK6SimFTgrASdYCcDTW4aolTLfylpQEgEgCxmHhg8k2ejOrdGC9NLcQz9TlzXyY52x9vdXr+F5tTHx8hwshomOlIK+IfTnJ7eGxz0NJpXvyYAWzSXKDuLZGuSrpQ4oXj5RS3+mdfHJT2ngD3qTYiwDqWy1mlgHLXdvES/mrnFjvBKhCiOs8xYicSqo8ME7mNL3tsQm12+52Gi8DfMzPQ== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: c501fe9b-2597-4c71-bb7c-08dae0df27cc X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Dec 2022 10:03:47.7028 (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: pL2UrKjKAADBhRZihWgfvIDXTjXgEYXcjcKaLs23PlutV88VX1qdnPArnd9zwWB6HJTeDhcAxy7YWnBkD8gQWNDDs7bgeU1ZUCzumqe6fmc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR10MB7181 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-12-18_02,2022-12-15_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 mlxlogscore=999 phishscore=0 bulkscore=0 malwarescore=0 spamscore=0 adultscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2212180095 X-Proofpoint-ORIG-GUID: ENVuVMGjXcUSWQMsNjVeCiO78ie_ZjsI X-Proofpoint-GUID: ENVuVMGjXcUSWQMsNjVeCiO78ie_ZjsI Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Allison Henderson Dave and I were discussing some recent test regressions as a result of me turning on nrext64=1 on realtime filesystems, when we noticed that the minimum log size of a 32M filesystem jumped from 954 blocks to 4287 blocks. Digging through xfs_log_calc_max_attrsetm_res, Dave noticed that @size contains the maximum estimated amount of space needed for a local format xattr, in bytes, but we feed this quantity to XFS_NEXTENTADD_SPACE_RES, which requires units of blocks. This has resulted in an overestimation of the minimum log size over the years. We should nominally correct this, but there's a backwards compatibility problem -- if we enable it now, the minimum log size will decrease. If a corrected mkfs formats a filesystem with this new smaller log size, a user will encounter mount failures on an uncorrected kernel due to the larger minimum log size computations there. However, the large extent counters feature is still EXPERIMENTAL, so we can gate the correction on that feature (or any features that get added after that) being enabled. Any filesystem with nrext64 or any of the as-yet-undefined feature bits turned on will be rejected by old uncorrected kernels, so this should be safe even in the upgrade case. Signed-off-by: Darrick J. Wong Reviewed-by: Allison Henderson Signed-off-by: Allison Henderson --- fs/xfs/libxfs/xfs_log_rlimit.c | 43 ++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/fs/xfs/libxfs/xfs_log_rlimit.c b/fs/xfs/libxfs/xfs_log_rlimit.c index 9975b93a7412..e5c606fb7a6a 100644 --- a/fs/xfs/libxfs/xfs_log_rlimit.c +++ b/fs/xfs/libxfs/xfs_log_rlimit.c @@ -16,6 +16,39 @@ #include "xfs_bmap_btree.h" #include "xfs_trace.h" +/* + * Decide if the filesystem has the parent pointer feature or any feature + * added after that. + */ +static inline bool +xfs_has_parent_or_newer_feature( + struct xfs_mount *mp) +{ + if (!xfs_sb_is_v5(&mp->m_sb)) + return false; + + if (xfs_sb_has_compat_feature(&mp->m_sb, ~0)) + return true; + + if (xfs_sb_has_ro_compat_feature(&mp->m_sb, + ~(XFS_SB_FEAT_RO_COMPAT_FINOBT | + XFS_SB_FEAT_RO_COMPAT_RMAPBT | + XFS_SB_FEAT_RO_COMPAT_REFLINK | + XFS_SB_FEAT_RO_COMPAT_INOBTCNT))) + return true; + + if (xfs_sb_has_incompat_feature(&mp->m_sb, + ~(XFS_SB_FEAT_INCOMPAT_FTYPE | + XFS_SB_FEAT_INCOMPAT_SPINODES | + XFS_SB_FEAT_INCOMPAT_META_UUID | + XFS_SB_FEAT_INCOMPAT_BIGTIME | + XFS_SB_FEAT_INCOMPAT_NEEDSREPAIR | + XFS_SB_FEAT_INCOMPAT_NREXT64))) + return true; + + return false; +} + /* * Calculate the maximum length in bytes that would be required for a local * attribute value as large attributes out of line are not logged. @@ -31,6 +64,16 @@ xfs_log_calc_max_attrsetm_res( MAXNAMELEN - 1; nblks = XFS_DAENTER_SPACE_RES(mp, XFS_ATTR_FORK); nblks += XFS_B_TO_FSB(mp, size); + + /* + * Starting with the parent pointer feature, every new fs feature + * corrects a unit conversion error in the xattr transaction + * reservation code that resulted in oversized minimum log size + * computations. + */ + if (xfs_has_parent_or_newer_feature(mp)) + size = XFS_B_TO_FSB(mp, size); + nblks += XFS_NEXTENTADD_SPACE_RES(mp, size, XFS_ATTR_FORK); return M_RES(mp)->tr_attrsetm.tr_logres + From patchwork Sun Dec 18 10:03:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 13076019 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 D16C8C10F1E for ; Sun, 18 Dec 2022 10:04:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230131AbiLRKEB (ORCPT ); Sun, 18 Dec 2022 05:04:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60470 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230312AbiLRKEA (ORCPT ); Sun, 18 Dec 2022 05:04:00 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 74FCF55A8 for ; Sun, 18 Dec 2022 02:03:58 -0800 (PST) Received: from pps.filterd (m0333520.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2BI5KweF015523 for ; Sun, 18 Dec 2022 10:03:57 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2022-7-12; bh=QnZjoGgIcEUP40CqmQBJYUuAmBfobRJOlbitbtUwDrQ=; b=gHB4gd2SrDgMI0H36yNm72CoVfr4ZttrnkKxCIuYTJMTBlYri6mn7vmylXBsNrawceNW EiDX34WnQ/hFuG5ARLWRG/rYsU6lEFEv6UzipRrrfFxABFvqJ68FkWv+v0rh2nUWWiL5 aUJbWg1bbh54T4i4bTG869JKBb7GwlwTTdgQ+qIhkQVCxGu9oz/2q0V4yPY/gMxiHNrh 8kdx8/m2eKH5fYtXNHEd5u0UsEEpb0mDEmr8GS3Uttgj08XW+hYBEABF0bN69Ooygmlp iLXbJjxha8xloyqWPuOZGkrTMVDY3kWP/FYF9WTFuUJyzcDOYfVYdLTAD4CLWtnXBobY pw== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3mh6tss9n9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sun, 18 Dec 2022 10:03:57 +0000 Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 2BI8JeXK024870 for ; Sun, 18 Dec 2022 10:03:54 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2177.outbound.protection.outlook.com [104.47.56.177]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3mh478mxs8-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sun, 18 Dec 2022 10:03:54 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dNDuth2RSjUwQtkKYQRyUYmlz1Mdcd4iLIqP6CYWr8JPXssaRLSHMd2gP1nAyxNeA9BCeQa3vmXeHjZRxAVqIyRGwSAt1hurb9ZPbgDnwHLY98sZwoWcPtiKKzeuybnamUV49FgDWFGxz/NMDO8KLo/eulkIeG/mDK55hnl2BpN/jpVLJ4AmlcO0lCLcEbbdmjd/xZvlBe8CXlvBqgqtQBuSSi1tWHljbd/jJJcQO1tEnTXIPpEp8SKsMn25N3XxggYoMiUUR1udGPFBVHoQNngiBvfTR9+vI/XjPk08Kwy5EBQGe3bg0xJVrbwNj6K2vn4TTgbTfsesMM5fzg2tmQ== 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=QnZjoGgIcEUP40CqmQBJYUuAmBfobRJOlbitbtUwDrQ=; b=NSzRRa6lQOP+cP7HwsrtIeGlg4uziW2Wn2h+pd7F4QGsnVf8tW3ecn0jekuslQMnHhWb0q7fcQUb4AZ9zZ26R/FmZ3QVUrssyXxM7AzmvUmk8dfEoeHkzImQZbL3waCAe9Vu1o32aLzjhGdUQP8y4E6F4b6STwYUc7Hwr3TvOHbbRViGgtQXUgAw8ckO8/ksI1l0xaQ6kXRM2jD7RmCLRxI5Pb0KVIsDm6QkVdLj+WaBZ26znSke5wzHwhAPOxGyY1bI93jXO/o6WS3u6wNDA+tdUBFczIoR4sO9YWNm/o3cxALMA5ncJv/eSUjxaH4YLVmGULHuqiupiU8fOwwPCQ== 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=QnZjoGgIcEUP40CqmQBJYUuAmBfobRJOlbitbtUwDrQ=; b=sc6NKCMzamZbzGBSFbShgeogIxC+OFVR0da0TaZgPVUG10lFRP78L+izBPZVV3yjXZ4pv+INWsfHDODBZ8R2dbjfc7MymogqqCyOfuDuZYvLGnzNAL1NMAh3vZg2B+gnWRGKVLUH8YOPItwnbPvy1GG+XcWfk3H2Ino7eNFSUEE= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by IA0PR10MB7181.namprd10.prod.outlook.com (2603:10b6:208:400::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5924.16; Sun, 18 Dec 2022 10:03:49 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::3cab:6ff7:cb4d:b57c]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::3cab:6ff7:cb4d:b57c%4]) with mapi id 15.20.5924.016; Sun, 18 Dec 2022 10:03:49 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v7 27/27] xfs: drop compatibility minimum log size computations for reflink Date: Sun, 18 Dec 2022 03:03:06 -0700 Message-Id: <20221218100306.76408-28-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221218100306.76408-1-allison.henderson@oracle.com> References: <20221218100306.76408-1-allison.henderson@oracle.com> X-ClientProxiedBy: BY3PR03CA0013.namprd03.prod.outlook.com (2603:10b6:a03:39a::18) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY5PR10MB4306:EE_|IA0PR10MB7181:EE_ X-MS-Office365-Filtering-Correlation-Id: aab44ed5-a0d4-4553-db2c-08dae0df288d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2lrcLKbYNudM31e8w7S0PtFrshRmib+A5imBrGgu3Dav+Mu/oEUgK7Q3CPe7aurlpx7R6FT4fHQsQOeZA+8yaICOON6NrkLwZoxUVFdEJy5oGCg5XCTqS9MCPQrrsEKPirm/STd4yfBN7jJlc5pOgWtCjv3IpnBhiCgwXqEqCclrkgQQqxl1Z+3o+io4FaajtXuakimR9j3/RWeKkx2Un6am2khyF5dTZ3Sp8XJ2ovZSiWHAnDFuWIVY5+Y8MY7y+q9+ECCzfHZUDE9oB9Vkz4unGAtEiz73ElhOUVNiplGwOmdF67sKIBmyzetaxJnjDH2S8E4H2aX6SDfp9380KHtiZsVxQBYTGGpHt/48kOe7WHRx9x0TrQ4iIgJoShuglx08Wvy6/PWWzGlNtWcVa+DrPDPWFFtOzF4hJfMgvOz1Iox3xZ+eiGL2Gh5WZ8zz1Ulxb+F5FEiTqYeTnyslm7hP40DBNa6qqER+aBwzmPwlwZq+2w5TGVpdURd+1PWmBSr78SwmTzLsoGcLWjWlz7hUmFc1X/zeozhL2oSsBS4YW9zIDzEwugnOHutWbDuYJ/wtUHyZTUEHX+BO5wzUfEDc8A679NtopkCYHt7ZMgT722FBOTI7gLkKaysVu5en4G14RA6rQcloB39ijUdNZg== 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:(13230022)(39860400002)(136003)(366004)(376002)(396003)(346002)(451199015)(83380400001)(2906002)(41300700001)(8936002)(5660300002)(86362001)(38100700002)(36756003)(316002)(6506007)(6916009)(478600001)(6486002)(186003)(26005)(6512007)(66946007)(9686003)(2616005)(66476007)(8676002)(6666004)(66556008)(1076003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 3vnbWH3h79eZJ86MC5T9Uh8rxLlDgKZByFla9JSrP4LWa95/whd6cPBtwVrFsClEvOgKtsEZ+yE1F0CQzKcjVzmqb0waZm8qE1qmOeYyLN6dj5HA1Vh8F846ql+HO4U1ODjYCfqWAW45ywqfV7FBYW6gFTT97agAFaejaNr7TVsTwyne8KFmvLXR8yWjXymn6yP2IX22C1YShIM16bLu9We9liHpzzp0Y8EgvHptPZZTiVUW6Ml5PM8P2330RtDDG4VPFlx3iJjS2q6gLAlB9ZRQGUc7OW3+g1c4dhKbZYRcDfcRvqmYMohbqhZHuIu0eOcekPW7J9GZoQoWEC7+rdw6u8+bHyxtD/Ln1IgCbqZxuAvw9CmMmfbLKY63R7hy+iATafpOGIjTyl9UTcY6tGPI0BEkvFlwnkKn6nr+PS8+t6SFCwtmJ9/9rqcwccMFhGuWCax2ux8VeFZzvnW3qT6qzD5d+HMX02v38FmO8G81Vt62XvQ4M5+dMV2594Ap3+iYL3yD3shewt26j79Vz10ggBWhHB+q8TqQGju2yXY+a2PuwW2UGAT9QjaiaSyra11DlwyEd+wfqLXgm89G28Ra6Jqku9WPDxu4gyWFd3TRxenP0Hf2QY7IBf8wpBcI7jG/7dXdlTy66nNSoAFjTp93fvhOjZcVSNXGOURy8t5qzrItJGkY0vxc9RE593DJDb/zZ/t/2Pl5NSE8KIb4KbehZjaERiZ7jB0zPoDQkT/gUkckH2tuVky6Kfr0tOOn4jY0L8Hz5NjIkMWngcvEv3IJovNUtLIW/ENhfkEyJyg7DdKj89HGxydNG6M+MTBJfwYsv22lptzwmC1RiMeGdsvpoyFSzSQWA3aeQL+0BSM3EL3BBf5Coi9eLohbOzFGOBKZDHXSSZLnjfWl6X4mBH2MKamvSt2SPVYg3/L2P7EkVtuAU+yooG6JW8wQRF8SbuaYCWSxLPV6Ka14GVv0DdvHFLX7MLiwLOHzb7dRAgTLzHfwMb5P/uwmrTs4RRGtao5loZkIfEDzhTwxALhoeqHO1XEf5QNKJQrmjxkhlz1lwThPlSLP4T8zI/e0P7WjdiXAoVLu2s5lXGyy3UVS1ili8BFKbM3jsy9nSBH2CjzjR6PrbsK/sOVIAc3x5q8Kwy56q6U1hslOcC2vINawciuGPhzowfqglmlKt6qqD/WmCGcKU98FgAfmAHSPOeGlDxHhol2z8jEYpo4y08oXrGbJ8VtWOTvt5OwEX+S+TgCKduUrXhBjPw9/n0lvdY4e/gwreUFI5brKQj65Z1+BoFEKAh1v3ljW4a8V2uD3WSxwGXeBoBl0unkXpyBbsgm5vUMDlSSqRjmOMj9D/BacovGPoxhkDhWBPjcnQOMD6CA/T0v27nTJ/yw7cItRv+XSKzew6ujzfU21cIy7ySP/MOe/8OUqU2Zz1sD+wHmS+VByL7iqHAcLnNuqdBQgytvsQJrw3ZU76S1qNLlmmI0B5B+UbPRTrLhaeoNdMn6cPhTs85LZTgKSQLAv2T+Q3TqSczxjRFEeqZmi5pEPEEwLEjyaMix1ZtHPxEUoO/HpZFMuj3aGvybVrI3vAJ/WtLgENKitMhQ4iCuKKW9fb9amTg== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: aab44ed5-a0d4-4553-db2c-08dae0df288d X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Dec 2022 10:03:48.9685 (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: CMWJRvG7kQD4mxdGGipbb9F/fFnDv0SjJ5FJAtYraeto2rBR3wRdiR/CPNN/I0qkV8HS+JDVXTLRSVgqYO8aQMIq7V1d20Yc9l8lS0Rw/Bc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR10MB7181 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-12-18_02,2022-12-15_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 mlxlogscore=999 phishscore=0 bulkscore=0 malwarescore=0 spamscore=0 adultscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2212180095 X-Proofpoint-ORIG-GUID: 9qgU5CX_aqXyXcPEXRtoIWTz5j4V8zmN X-Proofpoint-GUID: 9qgU5CX_aqXyXcPEXRtoIWTz5j4V8zmN Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Allison Henderson Having established that we can reduce the minimum log size computation for filesystems with parent pointers or any newer feature, we should also drop the compat minlogsize code that we added when we reduced the transaction reservation size for rmap and reflink. Signed-off-by: Darrick J. Wong Reviewed-by: Allison Henderson Signed-off-by: Allison Henderson --- fs/xfs/libxfs/xfs_log_rlimit.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/fs/xfs/libxfs/xfs_log_rlimit.c b/fs/xfs/libxfs/xfs_log_rlimit.c index e5c606fb7a6a..74821c7fd0cc 100644 --- a/fs/xfs/libxfs/xfs_log_rlimit.c +++ b/fs/xfs/libxfs/xfs_log_rlimit.c @@ -91,6 +91,16 @@ xfs_log_calc_trans_resv_for_minlogblocks( { unsigned int rmap_maxlevels = mp->m_rmap_maxlevels; + /* + * Starting with the parent pointer feature, every new fs feature + * drops the oversized minimum log size computation introduced by the + * original reflink code. + */ + if (xfs_has_parent_or_newer_feature(mp)) { + xfs_trans_resv_calc(mp, resv); + return; + } + /* * In the early days of rmap+reflink, we always set the rmap maxlevels * to 9 even if the AG was small enough that it would never grow to