From patchwork Thu Feb 9 08:01:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 13134147 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 02DC5C05027 for ; Thu, 9 Feb 2023 08:02:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229586AbjBIICA (ORCPT ); Thu, 9 Feb 2023 03:02:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58448 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229450AbjBIIB7 (ORCPT ); Thu, 9 Feb 2023 03:01:59 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5BB4D1351B for ; Thu, 9 Feb 2023 00:01:54 -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 3197PfLU011325 for ; Thu, 9 Feb 2023 08:01: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=p+Mj2o48KZIU06tjOsGJKlU3MX9+qMBJYtvtML+DC1k=; b=m2r8fEeGXzlcIrhZZYoESkqjIZGbaWOYbZx38y0IwsuaEGeqFR0ljLZXkBbUI9tv7/Kl QBByHf8U2OVyy9L2Giz/SfIcVghQytkka+MfZC4CetNLxBbI0gxdxvTSI6gOfnyHkgK/ qMVVlevXbxeBjAyGVCot3bCCiin4Vs723Lxw5RxH/BihUsZEtpp14xwQijJVTpt2GR8W K3WNd0+R1XeFqIAsgJX0IU4/XGYn/Kzwit6Mxvphx8EfWMiLZkRMfehoArQMfWCdmvQ6 t/TxncQCfta6UKpG3DndGMztvpV6ixohQlWmew8BrHC+NpX2INKn75IH3GG+bsQBUXXP KA== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3nhdy1a75f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 09 Feb 2023 08:01:53 +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 3196U9Io036257 for ; Thu, 9 Feb 2023 08:01:52 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2040.outbound.protection.outlook.com [104.47.66.40]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3nhdtfg3gn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 09 Feb 2023 08:01:52 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BcGhb5wKjMzL/4OqiVdV0xszJZ1K9KncSzDFsXwPqnRPRPZJLFQyih1A2ToSN6zWLRra687nPybDFHCsPhYCiLg+UWLpkhG7hKAWBFVRVhqWLIe3BTxkmQKZAGVCa3Pg8puHTF7DaQSMrS9oZAIY4LxUzSBC2L1CmH5AgOF8TIMHU9u2rk7ZKyHa/N8RR90x6KjI/UiH1U35SSoTcruFtiR3snz8tJeDF2VftzbqbhMf2xmk9Z2lBNNFuskKr3Ih3cH73stH22wvgIiGc14ieFh1Zr0yoWRh7GRAm7NCrqESypAgrMHV4UycoT1+TU5gFkPYIpSixIqU8+jUsYUVjA== 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=m71fydUGpIhIa0FwsS5Zyj++MiCmuGtYNbu3WT0hKk/tDFoFyWXHR+30pMiv/aMMQzafrUCCNEd+DdF/xMY1s2SpBOx6xnrxdZj8O/rwWHZJGmuwzWoH1mWsSDujiOHpBZyXGnQSSGwgGKDEhAD6Q0sjsOt46vD78NIE2nZrKN1jqqW4BRWbxAfO6e0Gxl+/PBlL+VYV7hFIoiOMB3xlFpprl0++GE7YoxhXdrfCA7DcNtTRfUbWX+KUTckhZLEP8MzGkVs6pD2WEmsOZxSHa7BC0V3jEq1EhEMfLtxX6omPyOcTvEsILmeL7T9xMZLWu5QV+3PSnZNvNghSV3VUGQ== 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=sSEI3BqQZMe3/bZDmomfegx2t2NTMo7nvu9+toX95Grl7Mkfwj2Po6Kb6UbSWx5PEruYeczSBTRJh4wDJ9JFOpVs/W5og0RAed/O8n9G+06ABOCw8hBERVNSi6upk6rgywZjJUJ05rzowlyw1m7S8kXVHtVaJqu/14N2MNYgThc= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by SJ0PR10MB5787.namprd10.prod.outlook.com (2603:10b6:a03:3dd::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.17; Thu, 9 Feb 2023 08:01:50 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::eaff:9f55:4641:db38]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::eaff:9f55:4641:db38%4]) with mapi id 15.20.6086.011; Thu, 9 Feb 2023 08:01:50 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v9 01/28] xfs: Add new name to attri/d Date: Thu, 9 Feb 2023 01:01:19 -0700 Message-Id: <20230209080146.378973-2-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230209080146.378973-1-allison.henderson@oracle.com> References: <20230209080146.378973-1-allison.henderson@oracle.com> X-ClientProxiedBy: BYAPR01CA0063.prod.exchangelabs.com (2603:10b6:a03:94::40) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY5PR10MB4306:EE_|SJ0PR10MB5787:EE_ X-MS-Office365-Filtering-Correlation-Id: ba181d6e-caeb-4990-1cc1-08db0a73e5fd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: TeRKkJ57HbeZWiy47bYQXWhDFVEMmVBTzwp5zCiY8vtW/dT2Vk4K77UqSf97PfdhrYKq+4M8d+nwPDdzlAfxp3XoDRKlLHeH4gPbStPDrPXgKZVkc77O9aDZSzyrdN2w9GEP43+6PDnzfh5nwL41+4kmgYY+mQlUWSLK85cLpCeYjjIdk87DBeeIrqkflqPHWlg0P0QuD7iPLzJ4pY0BRmsmAcAnVXjnglrbFZnwkoqvyWO+5aKW7OquGAbdEMDPhArPz5ZX9p9yYWIGcmzcA82bwZOva2dhR359yJSSd7pnOaNZEM1ZkUezAnsltniOVrstOtiD2u7Mup+WfZ/3l6THvtand6sVp0tA2wJThxF5z/x5GgALed7m42OJ/mES4M2ENoRW92w1JWVF0o/TPaNzRXd2FsTjejFm0n3xK84qKwW8uugnEhYvDuag77TUdYsVhcIxCPi/4SY0tvTJGiPOepW/ZUhMbZotougvyFGUdpGqxvEqf/nTgvLgJqQi2l9sX+SYPzIajdYKyuZ+X0usv6D7AjLShE3Y/TjHIUWwQC3d7gJpomfi5eT2And2bLbECtERjo6j45CFaGCe7jmzSdBH3yvz7mJzt5kS6YcUjQD1/uqhHviOzTfpHORWhR4JJ8J7m//wZjqkgYi31Q== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(39860400002)(376002)(366004)(136003)(396003)(346002)(451199018)(478600001)(186003)(6512007)(26005)(6666004)(30864003)(9686003)(6486002)(316002)(83380400001)(2616005)(1076003)(6506007)(66556008)(66946007)(6916009)(41300700001)(5660300002)(38100700002)(8936002)(66476007)(8676002)(86362001)(2906002)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: LjaLvpiV1xYk/HzNQSHE4XQ88BZVoDKOvK0oWWgP2gkfO8mgv8+EM5MzXigNwGSuO7fE/kW8a6BN6Y/RJle1IBaiHmv3lydrW+UC6VXs35XBaPIFApw3LuHbvu1fDF+IE5+8orYSQ+hJzhsDXLJHV9DhKVv3iOOzUbtAR3ATjn8En2KJnWyN7YigmghSpF3FJd7i41mL8PHQiI+zsyKjlYR0VFNWOf/cWvPqhPI1DIwd7TECoTv71JB4FX3hLcPWQGMGjNTH1py493mtIOmkh5w5Sn/7tZ+EY9BVZhe89PwjsgJA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O/BgY4U1I5ld1zL X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: ba181d6e-caeb-4990-1cc1-08db0a73e5fd X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Feb 2023 08:01:50.0706 (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: 3REx53Mc1bQmdRlzFlaDTIh2s/XziKO1+hjCQsjhxos7nI/eAJMH3+mohvAck43CPlngfB6ldwolCzKv0XbfGW+heeCl57IlljFjXBcD0RQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB5787 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-02-09_05,2023-02-08_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 mlxlogscore=999 malwarescore=0 adultscore=0 phishscore=0 suspectscore=0 mlxscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302090075 X-Proofpoint-GUID: PjhIO_VDM9FM8RGDEGTBG_m6mO775tmV X-Proofpoint-ORIG-GUID: PjhIO_VDM9FM8RGDEGTBG_m6mO775tmV 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 Thu Feb 9 08:01:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 13134148 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 8A643C61DA4 for ; Thu, 9 Feb 2023 08:02:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229450AbjBIICB (ORCPT ); Thu, 9 Feb 2023 03:02:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58450 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229550AbjBIIB7 (ORCPT ); Thu, 9 Feb 2023 03:01:59 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B135E1352E for ; Thu, 9 Feb 2023 00:01:54 -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 3197PtGC016242 for ; Thu, 9 Feb 2023 08:01: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=kjnJXb4QLTI/gC6onLA0jkmfXuy0GCZXIVbvceEUfO0=; b=HugSoNfaW/pWzSfyKzBtdYreMmsMTaheTgHyP8y+Jc3XJPynlhc/oq2J0sjovO+vztiD T+IcXrVUcou9TKsbfB6jW0rI4QlKjR1mwbv+yohlM1xgqLwqPnIe7S13J9SNhu75ozNa qIR9xHkYN6EIner1nDBjHEVbrdwUqH+6wOrQ7BHzodn/SS1BRE74wupiOAuJRuBi3gws s6c7nSF5qDWUnTuFjhfEx2gxrR63UxGBs6kliJWUv1g2AMlf6/s6laBgOxtarMTE59jF OwcBOqOdEdVKZxwmNuhFQIU4ncvyTviOQSIKyUvkaGV/n9g7/W/+kdx9sjKUhNv9zXUP Ag== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3nhe9nj4d2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 09 Feb 2023 08:01:54 +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 3196U9Ip036257 for ; Thu, 9 Feb 2023 08:01:52 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2040.outbound.protection.outlook.com [104.47.66.40]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3nhdtfg3gn-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 09 Feb 2023 08:01:52 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=V6LTPu06PegX00evVQ+lH5Ugr/gOcyAXbPhpXZQ/20qNod6daDtncmu8y4LwE8Hkvo1g4HfK1qDWfpbcHRy6XEU6iUfyDCRgR5Gx3j1OG6gHVCgfhF1yuiCdorJUf9Gd+aqsn6vThexu/7K/cVfBnauvtColOvZ5VLkWYoQ7p/pCbZTNzyIZlhScfrLq7dbN6hdAG8tBidWCVg78nHQVObtODbnrGySmJtz8LqFilbT+z7K1mqL1VKlpNFL5mWXaYExYwXkY/xPtLOX5pMDPSZzM9xdJJiKZ3IWTxsLKuvk52fMwzMv/7QG9Eef9dXD/G3XNJWzAeYvEU8ZB3WSS0A== 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=SGKDBqBrKBnu74HW/GvOpgOidBZzNxDjAtMZmNYlnGCAtxFiTHLL/1XvIqjHWg0fH8JZLGGqWZdOZIwBrYBYvA2b3wgiuMbhwNKYNrnp+7O+ePalMfrGeZMW8aMC/lVU118TV8DasEFq/ZAqJyHr/9SsK9FUOFLELbLvLvyDZ21fCK7NXnQNh7QR/vH3bI63YuJ2ZIW/8eKUfFE8LV2WrVb9pwYZuYfPuzpFSqIYkd/Zv8ZXYn4xn8KFjg7mdupNN3kiv3rvO2KYn4C9trUuYufeoJDNb00TfuCLHLhSbgLjsbiF4/Ud5qOO4XjNqRVWzN57k03VvgSO2GOZrGM2Gg== 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=yho5kCVQlXhScgxctoIZDDpLIM2HWFvxqhCWJkIu2s9zpM/W1DKJB1r4nLNbvF+i5CnaIyXLQYDpDFTjP+XJeBoyC5DiAW0ay3qQbgVzlPVf1/c7fRRiOdi2McRzZAj47YrrnFOrj8oXTYeGkcxOKbYNUvlZtEWoGVDnl9Likts= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by SJ0PR10MB5787.namprd10.prod.outlook.com (2603:10b6:a03:3dd::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.17; Thu, 9 Feb 2023 08:01:51 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::eaff:9f55:4641:db38]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::eaff:9f55:4641:db38%4]) with mapi id 15.20.6086.011; Thu, 9 Feb 2023 08:01:51 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v9 02/28] xfs: Increase XFS_DEFER_OPS_NR_INODES to 5 Date: Thu, 9 Feb 2023 01:01:20 -0700 Message-Id: <20230209080146.378973-3-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230209080146.378973-1-allison.henderson@oracle.com> References: <20230209080146.378973-1-allison.henderson@oracle.com> X-ClientProxiedBy: BYAPR01CA0048.prod.exchangelabs.com (2603:10b6:a03:94::25) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY5PR10MB4306:EE_|SJ0PR10MB5787:EE_ X-MS-Office365-Filtering-Correlation-Id: 5c2c6286-7d5c-4121-1767-08db0a73e6d8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: AuU3FZrq0eUxCFBtpLYMrlqsc0iWR04ZDYIp5aaMDW/+l7JmZvEZF4NDnWb69osVvPHXAAIbnPdhLdklEUpgBOaZqnhYcf3GU8tM7VK0C0HQZDOH2MWQCFozIgDwj/DR2YoAkn1yZhtQauoz6n+1jOu3gp4V+VV4z+g64nCA3goUo8EC0Mn7CJNmkb1GID9cSsaEQ8PZD/0I1fLXEdJNgYKCoH476Cy0T+UBnDNWyk/PBwZoFCPWnSm016hCtCyzPUwyKZY+6O5YeH0raYAKTHuDKy1JJU3pTtYr9To+l9+sJ9aWy+vR7bI9SHKScL+7AK8P1rg90UkMpYgdMtGj/V3UxWBEHunMt9GyshxHbdrCWjLEHCJZFBnFI1jXMEcqMQeLp2HrqIKABtRx0NBoNFwY9Lr7/RlFY3RQ7hbcRXbBAwYQ7piBeH7wokuyVEm5kAwWnDONQSTyDSrX89gyRb9wHBvGU9znkKO4ky+lNspcS2jmPDj2a2614P2qS5vpmxAetfdC4P58HqBYCg24bDkyzOwbnB3WEcguTXRBLt9dn+Ik8yjI0wokEOXi0hvmcrCFb+pLbpfpbiwGeOa/xU7C76SWWlWeZAafaAU1pE6Va9eRNpiDBjXkSkXJjLCXgOdcnA2BHn2CoJ8g4SH7dw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(39860400002)(376002)(366004)(136003)(396003)(346002)(451199018)(478600001)(186003)(6512007)(26005)(6666004)(9686003)(6486002)(316002)(83380400001)(2616005)(1076003)(6506007)(66556008)(66946007)(6916009)(41300700001)(5660300002)(38100700002)(8936002)(66476007)(8676002)(86362001)(2906002)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: oRfBNpXSZxAqew5ocGHe787PUwkMRQ8GYghEj0QIblRTieAtwce4rI+Zo76jDHOaEx8oKDo6RCuiDKiW/T+ZH7c5b117DeHd0E4iicrAiXIoBf9yFucNrnOPJNKYZeV+tFNxkmCgw4+8RsyCippJNIj8vNtrSQlQgtfEIYBYYnMJEKDOQxuCPoOBjhu33cIIiGCcHlBz+jhFNug5Vg+vWemibe6O5A3GJkgsl/S42AhceL7x/WV3QdpRKSxUj3X/oaJUarYAV9ExFOfFFwajP18HSuiwfYfGoPsRJpOSHmjyHmx+vBYk+AxcZRC42hSSsg83App9DUGSp6EYRuoYp5NLtFoBhtLNYlmJgC6JCBu7a7lbBXPmzMcoYLwA08FEm+/jb301Cu5fY0EjG9e3zlU8JObYpFEh8O7V6YaIN2PRt/IDdEgliTBoCsMOa9eo45tXf6h0VylqIBjUcJhEssJWAIAwJp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YwugEUXwyJ5Jv2sCnd0COTMOU/rwRrLUt/dPvHD2nsG7dOxH2ACDZ9ud/Ulh5AmaEAwDw== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: at3bcc3eFtpUQeEeN1/zVsg+1UMm4YpKJIgEO6QvqMTch6MxurXd3yB7tbU6fOk4deguAMEKxargy53a8diKRSk/j7S8/XG4avtlB/vTqLnNplsiSStVQ0kB0jz1cNO8xahyaAaoStR6WGTxBWbvhWM1rjftTUQMqlh4+IPL+3BZTIULT521RfvEoYwMq8zihxoOUoFdnqhaAGEsQOU2SmynnOvkfFYjQjLfvNozn+XomIJ0qlfpEQoTV2YCq6dev8scguloiWSuVRenoyykgJp0dUpYvvotVQO0/VECUBMPTMJ1oeD5pnvJ2JZNpqoEDR3GqQ9KSJIbjlTqiW24Voblcnas3SL02A02cw0XMIsclY5QyNLxF1vHAA3X3PPH7H4i6XBGInmBLYwuSA67LTD67aK6gjrJ+r0EVtzGcr9FCkQ1kgNCE2CUv6jh0tBMKLIEq6ScXIXeSdQeBOBmrpYHqU+Db7AJiS6kK09LOZQcDmaQV4jsQWAbDuYBEkE7DQMkNTO+UPMiNpiR7wAe1hY/Xrs6ejgMfQe42RDvfJVT3ddwxxXm/KW9ScpgbOCpaXxurHBZemWCzU5injjoP/EE3JBu4W+UPFY1033wAiLKapyhG1ujA9ZIDIPgig3bYKpRwvMUnimj2Rkto8tF185dBMtE/xU5Qw+iuZXy1i8dV2FVvCEC8B4+FehInbJq9lf7df3niPaxDUVrt6OOL96i0jG1Gqc5dNfGqi+AWXSVQFhxz++ZEQLxzrcttfut X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5c2c6286-7d5c-4121-1767-08db0a73e6d8 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Feb 2023 08:01:51.4745 (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: qMn6KaoueZy4Z/XipXk2et7/U+zPdXDOcztQdb5y0JkvSjAODwy4oYuujQMWJ13KdFJ479GOxl7PrGebnhrQyun7Zv+K9FzLyPPwodyyyWM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB5787 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-02-09_05,2023-02-08_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 mlxlogscore=999 malwarescore=0 adultscore=0 phishscore=0 suspectscore=0 mlxscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302090075 X-Proofpoint-ORIG-GUID: rTY7O6bp4mlOtb4O1vkySfIqYPXz3VJI X-Proofpoint-GUID: rTY7O6bp4mlOtb4O1vkySfIqYPXz3VJI 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 Thu Feb 9 08:01:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 13134151 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 1D6C3C636D4 for ; Thu, 9 Feb 2023 08:02:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229550AbjBIICC (ORCPT ); Thu, 9 Feb 2023 03:02:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58456 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229577AbjBIICA (ORCPT ); Thu, 9 Feb 2023 03:02:00 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5571313531 for ; Thu, 9 Feb 2023 00:01:56 -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 3197PjsK011365 for ; Thu, 9 Feb 2023 08:01:56 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2022-7-12; bh=Z/gy7ED2uc3DAI5xAdPVy6QP4ZkCdVt2xfjOsudSWUw=; b=xyXRzyNyCHw3+Rnz6xgH+ABGv7O/Y8VwANDwb8tsltLFRheq5fTZa3j3Vzs6ZsJsGBb6 XJdGyovaU0PZC45N95Kyglm70wOqywZ5cTSanz2BZALZPifquqTTVujP3iU8BD499muz T4+rF54UWPZlPI5R7vorC2V1ihGyjUC5E4/VJ2OpBqWycAY6oHbjsXaklSLYYp98ybvH aT+6q0wFikPbocGliKw8ZA3gZmgBPhZmE4TpOJRBHtUov763y2XtzoTRlE1lgY0DuZjg j1BhopHAQYEw275D3+So9ebYbTt6ZrWDkMM6Z12hs0oJifIOJYnW/HKTdYn5ZEwEs7LB rA== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3nhdy1a75j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 09 Feb 2023 08:01:55 +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 3196sthE021402 for ; Thu, 9 Feb 2023 08:01:55 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2044.outbound.protection.outlook.com [104.47.66.44]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3nhdt8dusk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 09 Feb 2023 08:01:55 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LjfolOVo1YIZYCU4rRcWQedU6Tfz4RtKTsFdMnRFTfLt1oca7IHENVVm66ZGt8LBCSPUOUg+NdtjPAnjRb9VizwVavYvgkU8SkZWvgooSbQSMircQ8KKw00GSP+hekojzlpL9Vh4PDIoSuxu311bSyQlvjD1GyH2bzowv80k9U71SURNiZNsEbxXcgbceR81C3mjTm5zcpbikJVEEPUjtDbTcxdmCTuXL6XnrXxS5zsrPPBJfiJsP03GMQRGuZGOzm4nbkVsBuhq8yb6oeONasDtO8LTmDY14ZRl7T93vPRwn2Xz9Qcsv1jIysiZ93tCfCk5PQS+ZsycKtkBxESW6g== 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=Z/gy7ED2uc3DAI5xAdPVy6QP4ZkCdVt2xfjOsudSWUw=; b=a+2bNzlAqAzCW5L0b3s95GedaM11DC3SLmt7xuZ4NoGii1kFqjWC5cjpgezQVPE0DvIPruKrrllJinrVmqSKS3E7Vn1oB4ZNiLSUrE4PArCQ6m0tMmLmYSCezDWA1PCXvuG0uIUxlPm2NhBc8/SMs4w9cFHaoy0KyRvrA3tq/Q3x/0oCJA/dJ90E0OPF8KShDvn+OX+JIvsI/tOLjat0Bou2TcU5Vnqmf96xvZJ0f5/Eem98sbfQN14XQags3a59cehfJuK43jFN9FIyHsY1bnIvGP2jMuOET80DsTNJd4pE21SZKCL5i3wPS6+sHVbxVWwxLlP2IM/MNx5JQk3DLA== 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=Z/gy7ED2uc3DAI5xAdPVy6QP4ZkCdVt2xfjOsudSWUw=; b=q5Eg/Y3Ot47LiIpMw353Goq28eWMKea6Et7ZGHUbUumVcgyNExtc2bHXuxh331bZO2SyW3IDkbR6IxZtbALt3eA3imkrcpiQh/wwKgf1qkznLRXkuXVIdsv8uSxJy/5FqIO7JkUyU87f1cifEYmu8HjD8of7su9W/BxnijItXh8= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by SJ0PR10MB5787.namprd10.prod.outlook.com (2603:10b6:a03:3dd::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.17; Thu, 9 Feb 2023 08:01:53 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::eaff:9f55:4641:db38]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::eaff:9f55:4641:db38%4]) with mapi id 15.20.6086.011; Thu, 9 Feb 2023 08:01:53 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v9 03/28] xfs: Increase XFS_QM_TRANS_MAXDQS to 5 Date: Thu, 9 Feb 2023 01:01:21 -0700 Message-Id: <20230209080146.378973-4-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230209080146.378973-1-allison.henderson@oracle.com> References: <20230209080146.378973-1-allison.henderson@oracle.com> X-ClientProxiedBy: SJ0PR03CA0378.namprd03.prod.outlook.com (2603:10b6:a03:3a1::23) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY5PR10MB4306:EE_|SJ0PR10MB5787:EE_ X-MS-Office365-Filtering-Correlation-Id: f2c2aad9-ad29-4134-c0f6-08db0a73e810 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: b5luzu0N7kIhpktIylJzGXzA4kx3CSNmPvZ9ZmhhkZBQqt0xCtxcuPYKRV4lk2PMDklGmymjJrc43pIJI12Js8Y8BYD3SG0ZOOP7mSXnGRGYZpDrhDE9RP3QIgTee5YxIiEdkeOlT2aPVPsvkx0h1VAdcP0cMyxFSYt9IyknRmJKgZnTBZw7DOnFYw2nuTF8kJpQrGE+hFnMMMs8i2ww2p70OP/gCbwb8pDb/MfcaBoo+FcTk1B794aAiHdcL+IVUwInKqVPP3SDXXX8ZotedrwpTEV9k59+TaM+J1FTevJG2QuuIBW5sAUseMz+c9h3vFL/JeK5N4GD6U7zuftGC2qGIcpGCeTZ83IGoVDkEGNjGHVk4h+z+wqf4M/CguygJpfz8Y9pMqvdvVbc6u7rWag8fqb1EHk0SZyzER5jGGWlyXqCk8NZyBp4atA/YBILd6P5SzDWbMe064yFe1AXdX5+/K8RkyCXfDgfoUAL7Sc0WnmN6NYLzrb0t4GPsCY1QRCa4BtY6RjKyMuwfObNEdKvTkE/NdmR0X4i79Ilm2Z3qIw3ivnNN21/9zZx25TDyzaWJzymfjVUofLJH+V+SKE9JZ1WhZBGv0Oe2iFJq4mkVm3A5vzbBf7SaUPcjN2Cz2FWjOxVESXuwNZBrG3sYA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(39860400002)(376002)(366004)(136003)(396003)(346002)(451199018)(478600001)(186003)(6512007)(26005)(6666004)(9686003)(6486002)(316002)(83380400001)(2616005)(1076003)(6506007)(66556008)(66946007)(6916009)(41300700001)(5660300002)(38100700002)(8936002)(66476007)(8676002)(86362001)(2906002)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: S7LXF9EHL676PdjOrrxqE4L6i5+71f8EC6KAtTnra797jvewh+X6Zinzy/8jURbZkzCTMk3vfnZC9No0G1UAaXWX/xhpE9WPpFEPA5f45wwFupIEiIvNTjqgHA/gSJV+0rPduAheYP8qT8mRycFRM15lpjq6ii3dosA3H9EHnXCPVnr/vFRNNSss9TbfwBfeEZiwGjCEdmHWNL+sbFam1h5Ych6jOxjr9eF1YhnytE0AhB6CmmqBodnREJ50wfyZ14E6QaPeToBW8UShBCWWpC8TtxJBI7XiQ3FsjoN/zc0zVqCNTX2N2OERVJpS05YvvCz9fFijwofliuHvprONEAiXUZ2Cn1Pijz2uebosmyHnwqzCTUQexCTLHBAlTtNMXV7oo+V18CYr0X1ynH7jo7XInS85D928RT8qAdpB6ZDfT5br6hNp+32J/tc4tnk3ReHJaH/GXDA4/Huzw1ocSwmv4bMUCg05UcM1niypPgZC3tYH8rju83GWWP51DnimFzl3bSuocaNMzCNBM7l8Cc6lI/aen5sMrL2I4R6rMj2LYqXNKcdOv1V4W8TWgzb0jPFj1Z8mcNhTD+Pv+FRQz3uVg5UVrZCTbrwm+B33rkXWnmr3Bo0pv81IpaAe/elSIgGcF5ox8B/4btwZHRBP8Fjvpq9Nb/kZ4KaTEC07kJAobWeimRYEYQCkggosfRqwaY943+anQRrxzYKGcO/Rhe6uLfYmDst6MBtzjIp4OY8uAuFwrPI6DwOt1+QYdKaHCo5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OT/CmuC4RvoqrAigIC/xKw3VwPTCCXmziOzzRbcapHSMzEbiG4z1JMlfwvGATPiPkxMs3zDVSLSVJlFo1Jv1FO8okSkjEYV/lM81B6R9ss5pLFF0w1A16WM0wF+/L2e4wtNArtnTq9uJ+uui0d2wm+T3TTTiyjOG8Kq+rgrfjPJ7X1cu/PsqmEiQbKwEvd/onlkCghty+iU6HLuq6V/Onkac/WT/8YdeHfMaevznGaybnhV6FbbmEwDdhzeuVqZH3PDW7hHZEpp2zLJYFVjKI3PVYaIazm6HHsE6ThNoKSu5pAwZ+lEKgGidXn3rmC0bhl0N8+HORp+Ka5CaHlB/tQQEPanEjgU5DF5sot5h3vCbk0s2BfhtCXnMk737Tc9tVbmi6gdDMafkxrcDdLuPN/2SbZejZnCt59efafylExmKBqZqKdJRjSl2gqXMRLRLao5VxOItZoIVEBnxeubEeC0+0hdgtf/nDmlLdRBa3hWXAx6StV5pE2k8RT3hjQb0LIDrG8ZlYkIZSDkq9HYhJGN9K+dNVIQSewyWz0yjJpstg5/Tr5Kt02G2iO2ge3rmVpV8jHjQgZHlZtDGorLv1esF04jBZcGuPdSO7+d6TOsUf9tXun21QA X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: f2c2aad9-ad29-4134-c0f6-08db0a73e810 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Feb 2023 08:01:53.6329 (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: LI+SPJMM/3ycVc8Fy09jbUwvTvD+7Uztz7DWk0me1r0zFo8whsay1XJwQkxIjK5U9VoHRWt1x2SGzfIe6dkoe47gKrECxIjvW0m2ND0mRKA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB5787 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-02-09_05,2023-02-08_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 bulkscore=0 malwarescore=0 mlxscore=0 mlxlogscore=999 adultscore=0 spamscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302090075 X-Proofpoint-GUID: HsaxICTiXpeGxkY5p_9Lp2cJSvCPVmvj X-Proofpoint-ORIG-GUID: HsaxICTiXpeGxkY5p_9Lp2cJSvCPVmvj 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 | 38 ++++++++++++++++++++++++++++++++++++++ fs/xfs/xfs_dquot.h | 1 + fs/xfs/xfs_qm.h | 2 +- fs/xfs/xfs_trans_dquot.c | 15 ++++++++++----- 4 files changed, 50 insertions(+), 6 deletions(-) diff --git a/fs/xfs/xfs_dquot.c b/fs/xfs/xfs_dquot.c index 8fb90da89787..9f311729c4c8 100644 --- a/fs/xfs/xfs_dquot.c +++ b/fs/xfs/xfs_dquot.c @@ -1333,6 +1333,44 @@ xfs_dqlock2( } } +static int +xfs_dqtrx_cmp( + const void *a, + const void *b) +{ + const struct xfs_dqtrx *qa = a; + const struct xfs_dqtrx *qb = b; + + if (qa->qt_dquot->q_id > qb->qt_dquot->q_id) + return 1; + if (qa->qt_dquot->q_id < qb->qt_dquot->q_id) + return -1; + return 0; +} + +void +xfs_dqlockn( + struct xfs_dqtrx *q) +{ + unsigned int i; + + /* Sort in order of dquot id, do not allow duplicates */ + for (i = 0; i < XFS_QM_TRANS_MAXDQS && q[i].qt_dquot != NULL; i++) { + unsigned int j; + + for (j = 0; j < i; j++) + ASSERT(q[i].qt_dquot != q[j].qt_dquot); + } + if (i == 0) + return; + + sort(q, i, sizeof(struct xfs_dqtrx), xfs_dqtrx_cmp, NULL); + + mutex_lock(&q[0].qt_dquot->q_qlock); + for (i = 1; i < XFS_QM_TRANS_MAXDQS && q[i].qt_dquot != NULL; i++) + mutex_lock_nested(&q[i].qt_dquot->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 Thu Feb 9 08:01:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 13134149 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 DF044C6379F for ; Thu, 9 Feb 2023 08:02:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229577AbjBIICD (ORCPT ); Thu, 9 Feb 2023 03:02:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58458 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229596AbjBIICB (ORCPT ); Thu, 9 Feb 2023 03:02:01 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3362B196AC for ; Thu, 9 Feb 2023 00:01:58 -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 3197Q8Ox003920 for ; Thu, 9 Feb 2023 08:01: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=1xoDYsuWG2SRerMtDZ+ug4VReqHwhjGAddR6C0EnDaI=; b=FkhVI7lpyq0SSQgZTVdv0VmzpEX8nLR2eQ7MF+sZNk3qnhVk4s3LhAlJyea3EMryxKHv /8uIJhOeon5wlwS/X1e2wKnOQUFKm28WsXRdhvzD74MjXeOvdQwpRw/gUxuWVlu2aFh6 4EvTAQYGRHDgxVXlXpsKN2PfKZH49NPSeuy7ZiNJQrlM5s4jj3+n2N1VzV+Emjw3ro99 5evp0dH8It+nnnZFD2LLxD9ohCQRouQhLfuKDC3kbi0PFP7v9q3gkCi8m0qgsvsMiy8z pOFVoRjEoqFwwugbLNUcd2h7BHuqxqJNvLeITNzCGaFPoqGJzR7Jyk8euA1BPY5nTlKx sA== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3nhf8aa43m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 09 Feb 2023 08:01:57 +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 3196GX1f021554 for ; Thu, 9 Feb 2023 08:01:57 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2049.outbound.protection.outlook.com [104.47.66.49]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3nhdt8duu2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 09 Feb 2023 08:01:57 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CJ+ft1qRVhweRZ30WYp/8VIOq6RtsNicjLPTvXR5Dk/gf8iACSmjJUW5OqIRh7zQLmg8yg/wUTubGIIFk3DMfxB0jdnwpEM4UHbrawJxKq1Oiw86jZDU5sA1SPxg13WVE3JmYwlSv1laFc4W5VCNaI6sVEsQ+SB4alRQtX0d9Vj4ygVoF5Ocb/ZJdOUNIP8V8zNdY2Dx9O2LO4b8kD6cqTNABg28w/x8WuCmHyVxDm7l0uXw7Xctx0hSVHlxJf0ZQ7aiLIIDQTm/KLcZVY+ej6hYOorU+yUyIpjwGntyz7zgmQ/smd1XA9Vm3M9gPHJSbpp8mpqrJtHygkMws0fb9A== 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=1xoDYsuWG2SRerMtDZ+ug4VReqHwhjGAddR6C0EnDaI=; b=LNQ8P+oYx1lieD1VNeoiqEGAZ5aD8ie0i+a7cop1l3qcDra9G3YOXU6xqMYPJRm/kIWMN45Wv6aGN8JON36T7LWSrWQwq8AbTt5JofjkijeAioBlU4Jm02Z2Mb+dqPYuXPSBzllwsAPGb5oISWBu/4U2Kez8sakOWyg9RxgV19P9Ta+94Bvh0jTHbozaJGza2i308dv5QFYXtp29DfHx5L/oJqNNp1JozshB/wHD+UL18wcPKyvJ8akV30koiN/Uy5pCqLihRlJetgplX5rL7HVoeU8tGO5WEOPaldRMpN44ElCK5AnrwL46ncuD7rV0XAJxuOwJPEzpEZXREpS08w== 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=1xoDYsuWG2SRerMtDZ+ug4VReqHwhjGAddR6C0EnDaI=; b=khz359vr7zlePRWquGNQW9DyLT012uVCw+W49BfWJpUOVms2AOuUrjCjdMZ7SPjJsY1OXwzCBTOZ4ZUdUY6Qjp1n/2yyFCA0VeEfS4uDpqZiX6l83CmBLf1XfNKpyd+KnfhZjghfvSZDgoMYZ96KVLniE+0jhIhwDD/ne92z9J0= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by SJ0PR10MB5787.namprd10.prod.outlook.com (2603:10b6:a03:3dd::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.17; Thu, 9 Feb 2023 08:01:55 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::eaff:9f55:4641:db38]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::eaff:9f55:4641:db38%4]) with mapi id 15.20.6086.011; Thu, 9 Feb 2023 08:01:55 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v9 04/28] xfs: Hold inode locks in xfs_ialloc Date: Thu, 9 Feb 2023 01:01:22 -0700 Message-Id: <20230209080146.378973-5-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230209080146.378973-1-allison.henderson@oracle.com> References: <20230209080146.378973-1-allison.henderson@oracle.com> X-ClientProxiedBy: SJ0PR03CA0365.namprd03.prod.outlook.com (2603:10b6:a03:3a1::10) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY5PR10MB4306:EE_|SJ0PR10MB5787:EE_ X-MS-Office365-Filtering-Correlation-Id: 919a37b4-3e26-4ce4-59f4-08db0a73e92c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: s139lcQ0bDbloQV0c4sT+r4Oo7drUieNzoaCnshiQ+i6TPGa/TBU6vD+CienMSfTgTBPnPfBJda/iajWlgNI+iXn+xpw7qtImBqnMoDLGyC8stOc6tsQnarmAbNDTbTLvUF5+bv2cFpidpGyiHPVpGTPCRSAdmNtfd+wpME9KXBSG0alJdU+MvcjpMWHYLcw8kY6KWhXIBKpXIjCKhHls/G5f4fM4PXESVtLmx28f8jNY0ZNntdfuBuO4VbWtAzw0SqEvek2AWXy5+RCJLvrEcvZ87l24jwD3ZzuSGYSKBwyJuUDEonAlKEmN2l2l63IiIYV0HMGuZAH/GICLVCNPyVgNC2mAymO7DIcXUDSLmG1IHfkHLouhqfSbb7AQ1XxtrflnNfVN+5Kzuw/5aHSAIh5hrHeJS/rxruS30+fk+Hpwj5f6x+3cz+tkhMA8z24o/Jx2DZTk1jDUElCn9hw1pG/hUyBLjF7MLPwjzur2ND6ZlWLhaFz5qb1GrY7NxoQe2SLJh9kK8wskiHhd/5HC9F3sAy3zp1q7w6dexBGJDc/GL7Yc9GJKdn+QqGtceJoRiTQ5gM36DiyVeOXwKuN9sVl1HG+MvNOVR+hYws2BFytVjb8kazHw476dnPYx3gG5Ne50tAX/TMCX8H/Ti06vw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(39860400002)(376002)(366004)(136003)(396003)(346002)(451199018)(478600001)(186003)(6512007)(26005)(6666004)(9686003)(6486002)(316002)(83380400001)(2616005)(1076003)(6506007)(66556008)(66946007)(6916009)(41300700001)(5660300002)(38100700002)(8936002)(66476007)(8676002)(86362001)(2906002)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: sZ3fK5sL9eHJxo5Gv7ZQc2bB/B1cNPObsDm7ISHxHv22+E5tj/O5g/U1gKf+jKthdqXzvo4O52wceYPBeUgqqaDB7n0NGcxh9G2+yw42ihGKi/dHEOmLamiVcJ1gn78ygcsIcR6RcRdjVudhrjblCq+AZaK/PTDTZsxIHurpDruWV6GBZGbRhJoTuLJZoCMFgujsKbZnSC9cQKUj0MNMkym2HNL3+QpCRPwQdkmPa1Hc8xX2mDXxGzYVruMfpDzJ83V4B9lnH/mfnCuLcF4iBMA+mzfVrlYCeme1I3cuo3v2huuRyV9ySj8zVYGkRpOHXINUhZfenPv4HTwDAkK87FOn7cKE7mPjHRg8dxV+qVC+1ZZ7+38XdEu0EBfoB/fGf4vcydEsw1zgNLY6Wv7PIG7BU8K+5M1Q4J8E2a9+LIhKDKKh6uyZZB/M7BUbXMo2BnDfCnfMB11MDkwquvdJsMCGP70yWZFPAREVHtl+wSP8DYGRer6nHxN0QyqW7/UzJKNYbFO47rcdhV8ncFyYMWgvIZ8aI6PikJk5X8LVDLR4SL8/6tJrdHk2cspNs4iSkg+Gu8Hwj02KGWf5yDeEUAGwI2+4G93FaYCcNYmbQyVmRnKolwTdK87FKFtPKW+achHhTdoLcSn6J+S/mHzvbXnsXo2amyj/Nzy193ADR/7unkVhZrG7B4+WxKndjdkawOqkupBNoKpacrnFHVHvOaCiMRvURO2uXupfwBzGPAoDKeGRufsfkQyRGgG2QpgOCsLJQkbqUrw1P97nbaulST1v6Lw0Ol/oZjKzuoF9eRdJndMjiVau3nn8+o4Hg5f1b6H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EIucADOR3xmoT4sY44UDpTSyLrw0JepvaCpBzYi5J52kEnreb0LSRenNWrnSMVuJWjdpCEpOF7CDUQMHD7P5mNEU2+ou+lOdadiufL4TseczvzrcUFNJpCAlF6iX3OAqoIWG9mt4Vs00zJYalM1mZ5BHXyiyLKOEeWt4HExQkkwy3Llz1vvEz2+fHEhUa0Ajp0rGFHC3cubSWqVlFb2INzgb6ajnlgut63JFw0C+psRuY8uDdwvDk9vUVA5Y97XvcoTVcKaAL0p3uRjvyB5ZdzYM1urr3vShpXlc5cHvnRtnlNJUp09+8ayvEqwCJ1DwN6dRcEJiU3B/xC8qHNss3+jBQq5vS+u0j35L0u7274x8gZjQkTrtO1/RoKiJK9PB+prSdetFVv16t2UsiFSIF5Dl9/kFTYD7h48GJOrUZXDedM2YaLOanajTSC7sEV8hl5ST05na2yrlKi+MlIS7GZ1piHNqwM4VD8SoFa2gz2JK/BqoFyaUjrbkQpxYMyj/GH0mraKuksJqKaoxpA2Adl33gvQEtD9iL X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 919a37b4-3e26-4ce4-59f4-08db0a73e92c X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Feb 2023 08:01:55.3822 (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: xFp/fC0gfvIMOmI7vBvnb/E7bYJ+KQUo0FIYPJpwL+5izLfyezbpWLV2dOULogvi3OZ4tjzXsk1jyFP4U4XUdaUputqvmkNzyKixhQFCLJA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB5787 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-02-09_05,2023-02-08_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 bulkscore=0 malwarescore=0 mlxscore=0 mlxlogscore=999 adultscore=0 spamscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302090075 X-Proofpoint-ORIG-GUID: SfcELtKVgk_ECTFlF86UOnk5UOQIldGS X-Proofpoint-GUID: SfcELtKVgk_ECTFlF86UOnk5UOQIldGS 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 e2c542f6dcd4..fbecf54d3b44 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 Thu Feb 9 08:01:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 13134150 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 2D2C6C61DA4 for ; Thu, 9 Feb 2023 08:02:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229596AbjBIICE (ORCPT ); Thu, 9 Feb 2023 03:02:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58464 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229602AbjBIICD (ORCPT ); Thu, 9 Feb 2023 03:02:03 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A2CDA1351B for ; Thu, 9 Feb 2023 00:02:01 -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 3197QeWD012323 for ; Thu, 9 Feb 2023 08:02: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=qaNGI5HY7M26yc6xXQ6HQ5L8rSDjtUAzjw+adU2Iewk=; b=RGtgv+jWNQyIM5QIWWdavb/Hx7z+zWd/Clw3XqaVsloRatGi6XrJW1yqD11z5/zisd3d 8jVBDQ6fe3Jrmx1f1G56JsgmdEgTBxi91+wbozOgl6TrFnnSADqF1/JtiFO1Of21UqUr T2UUJPIqe9j9NJ1LwYOz9sFGv1R/BFf187+e+ppvXTSVYVmk61UJdQfCPwPGBZWOkWfg uz430Swh6l428xxyfIjNFPKBwaqNEBbYKI+KL2BJRLjR45KHgncdiSBNI25Az2PR9nOO o+QZreWHHepymGe/qN1kCnaTJ+348FTkTD4UB38G79sZiDJh7EL1Jld2ZNwJttxhFdDI tw== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3nhe53j50q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 09 Feb 2023 08:02:00 +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 3196eWWj031525 for ; Thu, 9 Feb 2023 08:01:59 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2102.outbound.protection.outlook.com [104.47.70.102]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3njrbcxu9u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 09 Feb 2023 08:01:59 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WdR3c4wtT+K1Ovpe2D02oC8FAczoDdbuPKQTmNnhzZtRUvTq0b4QcrR9+6qE2N/3P5y7GyqRG7h8+mseWryXnWTi9H2OfstiOceoYiRw8rSICStdeMPmJ5WyELf/1wDVQrlOyzJoOqRi/7Fb90USAvJhaG7ActaKzHm7fozqyKN9tiLVuEgAIC/UOaZaZNnwsYvUqL6rDqrZknvMo2OzziT8YGGtYA462E+H7yr+LhKxWqwW3D7XZQivbX2IZLm9JU1tXb4QN3hncAtGZo2X531Wpmde5tnJF0llATNy5voXINMVqfRBYCvYksOrxMzJwM9/HXjExon0jSiSk6dedg== 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=qaNGI5HY7M26yc6xXQ6HQ5L8rSDjtUAzjw+adU2Iewk=; b=OQf0kJpzHiH63YZcOchxj5Avxgl4iW1/L+dyToTPp0jI1wmubEjejk10BTx7V5iJAc2jEKdZzMBhKzcS5ui3B7cMB8KQqwTD79/mKxGv4rcAEjDwaeRdKr4f9UZtA2dgornNk+8dX08QvG8pIM6xW0ZxkSRWCRxHxQ1uNPwNJZsveOXwQZ+5dEbeMxBERnh8GGuogxgjuoz/kXsGktPxwHaGH3IwsqGMR4kDCp4yKQOBoiwh79J0/bDFC2pfDLpzYNOKHl9Kme43S7Go1Vt7ik1G2fcHTHCYX3JlYXbP/yhDYu2u5nXbA7X/PZ1RlMjYxAZSBrXOrUUrgZjv5S3N8w== 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=qaNGI5HY7M26yc6xXQ6HQ5L8rSDjtUAzjw+adU2Iewk=; b=VUibXXu8lWeli04W53SUUJZhow5/hadaDJ8A1uj35drFXJgGodgtXP/hcLsKtxfV85MJ2QFqRXJGYGFVXOG0wtY4deX7HdX67p1E6R84BVA/98KDrLUjg5yV/4QsKCEbrMtXvAvBrmVYHtJs0MgGRl0LCTjbFm4MKYktz/pNhSk= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by SA3PR10MB7070.namprd10.prod.outlook.com (2603:10b6:806:311::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.14; Thu, 9 Feb 2023 08:01:57 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::eaff:9f55:4641:db38]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::eaff:9f55:4641:db38%4]) with mapi id 15.20.6086.011; Thu, 9 Feb 2023 08:01:56 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v9 05/28] xfs: Hold inode locks in xfs_trans_alloc_dir Date: Thu, 9 Feb 2023 01:01:23 -0700 Message-Id: <20230209080146.378973-6-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230209080146.378973-1-allison.henderson@oracle.com> References: <20230209080146.378973-1-allison.henderson@oracle.com> X-ClientProxiedBy: BYAPR01CA0057.prod.exchangelabs.com (2603:10b6:a03:94::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_|SA3PR10MB7070:EE_ X-MS-Office365-Filtering-Correlation-Id: 3eb0c771-e5cd-4809-9d0e-08db0a73ea0c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9RMlhv3GTpe/ASncetu9dKA5r6GzK8aecZK7p+5InaSXfcUC4pW8G3AJi179z3EL1cv3IFgm2gWXPIeB0nO7dOl/1pSKxPO0SqN4hj/2DTTuDiLmAG48XTCLaYT1Lz44p68fkmQOSNWv1yc3cr44NN53yqm2lk62FEEnb3dhZaeVL/uywZ9TM/FvaphysUTsVFy5rcvG7u6W8fJl6oGwpsbgBkjYdYhJ/ZZLv6RNDRk/UiwQC10RVYo/J/SyfNk1lu0Icj5nHuLetvnFXpAymIltRQwBMSOZ+urX0N2T2EV0JslAI8AXQ7fTi/OFqetKkjA0nUeEE9C9kNcnzJRUnNqL0XaQ6wJFpIBnWnfIyiZcRE/MJ/QyHN1ywmKxzK6hmCOGzRCa26loiw0MJIvd3UubuT/y2OIyzAoBYaHBjno5k2M1gABTgk5hIEUKC53P+h0chiC9gxhXYkNIQQHJxcDZ6N+2xC34lF/uUkfhqmckKOgc9cuf2p202N4NjjPjtRGDOFNVCAk1AhRi6KslbZhKyqVLXRqOyOV4eDygnWJ44Y/mxTo2xPP3ncsvsy9kbbV1dP/pL1C3qk1U0qC7JI7MmWPChFSpydU/JvQQUWgAQFMV4XXNhTmcTomAQ75Shy50ldvm92yyiVsMdZOHnQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(366004)(376002)(346002)(39860400002)(396003)(136003)(451199018)(478600001)(6486002)(8676002)(83380400001)(6916009)(66476007)(66556008)(5660300002)(8936002)(6506007)(1076003)(66946007)(6666004)(2616005)(9686003)(186003)(6512007)(26005)(36756003)(316002)(41300700001)(38100700002)(86362001)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: vL95bg/N21BhixRA/ryyQu9ZHlBZdV5ckixCwnVZRDKfP/fzC43Xo2dd8d88g4L1i1VOSzQyWtLzXpWOUNJ9m35c0Otnvsgxfe7h9BOfz2R9RZIH8d/y08obdBHvx4W0syZ4T2KWKqYa4ZNPj5EUSPq8fYrPl2RQA5brW+QXU0/pzVImeHKRSDdAN3QbQXGj7v0ksjVWdOz3Uctwx7ribHw2tCYaOpqd0eVs/ChAzaNxZw1HJOK5ym7M59/LRlN7+DGSSIV6Bq8x957VzxUwWdiVie0+mSxR4w5n+FUbi/C/tiSMwD3Rv4k8y4WnILXBRlLwqy/2jEBqUCruH4im5Go9M7IWQDlHqvFebLAsGv6qPFX+u6AE47kG2xQ37y5Aas72KyUREsUa7W0aUHETp4gbtEzw5dF+r5TO552anZZpcNyAAfRQMAzcgura7t1uDytZu1xjIetnNZ33UKX/te2S528XECNldN1h1n4NmCddi6vs49OIoPje2iILBMGEhg9uV3TVKV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ax4s89LUOLIK9DWt6J58tw== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: P69qEspkuQWQ0NObqPWb+/FSx6AJSshpj9ZJezMFrhoAPiWWlb3cU1GiLVzuqEVZKS5aeCyhTUsQSiXcCV1+TAt2TAUbmkKmtG3zegrPr8Q03Kul9MyM11/g8zoBZZdKoNc/iSkuQQuv2r+ScBmczsk8HkY96xIz9EOaYqJQfUSM6vNCdxuiuv1SAFMfZYK6VoV/YOTIqUtnIa3HuR78bBGphH6IsHahpsozW5GR6BUvjZet/VTViXMScdtdlhWoBr7RHBxLrZBfjpNVwuCmHdhyeS+ySyGLA721UpZaX9fjKfxK0Rk8dmv8EaEnyE4mxBYotvrvEG5MyhG9wh/7jSYuiik3IOm41Y6VLupEpM4MWz9dmWyi/s9ysziq53Ups5CmSTNkKuJDiX8gvGI6bvFXJHlWr1Y9GrADRHA2Gd1gOIF27KMSila2MxzFW83f+GXfGDQC7ugCKXo7m5AUN+YNE4vmArsF942RwtBsQN7BMmhlcH330Awq8NHPskw3T2ja7UO76BTCvzkquBlou9lWAuuEOmFMgaPsx7r3eUjLd2w3ni85sa8Ntrpad/b7LroDZgEsJWzJN8bKKRNhCMRpEmuguWZSJO8hXoAh4SjakZCXP1mzk2lmrp8LrEiUJT8buqHkZUnbD91cE0jtERhm8nUmTKXNPX7FrlXx+ckXnPkC8+IOs5QgPIc8dRQ5lbiooVSW+I381tNCZOhIUIrntSVvP/7cHCIwq+7uexjHJ1KrPgUeJVKqIeLthuWD X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3eb0c771-e5cd-4809-9d0e-08db0a73ea0c X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Feb 2023 08:01:56.8363 (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: bbm6tTIHjakkoVD+IVKxVLoME6PtuPmgs60NpRbh+Svq8HI3ekEKZFfujcMfpjL82EEmKjgTWA+1BVxw8Zrvkzk1rMTULfeZMP8WTOK9kdw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA3PR10MB7070 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-02-09_05,2023-02-08_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 phishscore=0 spamscore=0 malwarescore=0 suspectscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302090075 X-Proofpoint-ORIG-GUID: xiS7igrpoxow-a8A9RHCNw1qCh8JWQbX X-Proofpoint-GUID: xiS7igrpoxow-a8A9RHCNw1qCh8JWQbX Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Allison Henderson Modify xfs_trans_alloc_dir to hold locks after return. Caller will be responsible for manual unlock. We will need this later to hold locks across parent pointer operations Signed-off-by: Allison Henderson Reviewed-by: Darrick J. Wong Reviewed-by: Catherine Hoang --- fs/xfs/xfs_inode.c | 14 ++++++++++++-- fs/xfs/xfs_trans.c | 9 +++++++-- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index 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..43f4b0943f49 100644 --- a/fs/xfs/xfs_trans.c +++ b/fs/xfs/xfs_trans.c @@ -1356,6 +1356,8 @@ xfs_trans_alloc_ichange( * The caller must ensure that the on-disk dquots attached to this inode have * already been allocated and initialized. The ILOCKs will be dropped when the * transaction is committed or cancelled. + * + * Caller is responsible for unlocking the inodes manually upon return */ int xfs_trans_alloc_dir( @@ -1386,8 +1388,8 @@ xfs_trans_alloc_dir( xfs_lock_two_inodes(dp, XFS_ILOCK_EXCL, ip, XFS_ILOCK_EXCL); - xfs_trans_ijoin(tp, dp, XFS_ILOCK_EXCL); - xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL); + xfs_trans_ijoin(tp, dp, 0); + xfs_trans_ijoin(tp, ip, 0); error = xfs_qm_dqattach_locked(dp, false); if (error) { @@ -1410,6 +1412,9 @@ xfs_trans_alloc_dir( if (error == -EDQUOT || error == -ENOSPC) { if (!retried) { xfs_trans_cancel(tp); + xfs_iunlock(dp, XFS_ILOCK_EXCL); + if (dp != ip) + xfs_iunlock(ip, XFS_ILOCK_EXCL); xfs_blockgc_free_quota(dp, 0); retried = true; goto retry; From patchwork Thu Feb 9 08:01:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 13134152 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 C83F5C61DA4 for ; Thu, 9 Feb 2023 08:02:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229611AbjBIICG (ORCPT ); Thu, 9 Feb 2023 03:02:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58490 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229602AbjBIICF (ORCPT ); Thu, 9 Feb 2023 03:02:05 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D13051351B for ; Thu, 9 Feb 2023 00:02:03 -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 3197QHS5023505 for ; Thu, 9 Feb 2023 08:02:03 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2022-7-12; bh=dQvLZOogNQQ17Eu9k8jhxLtyxVP8S0cseb4hxja3+38=; b=X2TLNMmcgHx3DktE4FpQ7SST08LDMCifKlmETxKasiDelg7T9aovjnjRZ5Q0dyr10zps M3Kb8tOjY0lqXY7Ryvy7XW1/gUca0euXapq2o8Ok2ewc1bbnKK8GltohEECPGuU7TSdE igmEtqW3if4QM5xkfDAPFk9z7Z2QyT+sxswZx6+FDucaTKuRiK8ZCy353OmHMGX0LQS2 PhwWOQ3h19Z755RemAGJxbPCJ5Py9ZiHem8N8NhFarnMNfOYFFIfVo9EsdBAby9RkV3K +a8YMO291LQJxLwyZGdUx+3lE2FtkhP3cQInEsKQT18UtdpyACxC5KX/LI2fhTfGy7XF dQ== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3nhfdcj6ch-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 09 Feb 2023 08:02:02 +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 3196ZHTU021288 for ; Thu, 9 Feb 2023 08:02:02 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2101.outbound.protection.outlook.com [104.47.70.101]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3nhdt8duya-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 09 Feb 2023 08:02:01 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EQpTPXShvAk5dU9WEI9d5+ZM0knFu7i8lMLHaceSLo6DxSkv75V7VgFqDFyYYkcMTON/hhJ083Y6goGhriIj/W5KhEb0HpkLwyARHPvxzyi/XTm+9b9FP37LwowVaWxCckTOT1EwAFRHQKltRLoL10+F2ggoxo6VRb7kHgc21OoXkD4Hs8Wzl6ss0t5a238Pudh7PgZXGXq/e6XIPicWhBQkiTP1MK1ENx+aPjtbDEJvUT2iMv4QqsRVj5HU8i4fURQQ6g1w72hLqTXZlQiYiuaOYFFHdsdnmOCwu3w7LC6UXRCpxOHZYQnxtp3tTPqCWdYYjytI68O/r6pVVXjuGA== 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=dQvLZOogNQQ17Eu9k8jhxLtyxVP8S0cseb4hxja3+38=; b=OJ3tNrOc+PIvI1qCYlUgKRsVofUtMiER9J1U2uWc1upJJOOrV8cGP93jhNUHgespOHbBbv64q+Q427E64ZRhO6EDr5IJDshzA/alJRWR6fQIGSaGQ0ZXDKAD/dBqUM48UBGTbguj+cAckuPEUCA3DN0Lnsm1N8vlseYQg1baBuOnHO5CdFmxlnIG5CHqArLpQIgmNvif4MZrgaECVTEWpgkhq8C9AxCV/ySsF/fYKDIdBXKIT3lhMmnaTS1UvxGUeVt5JU6yPQF6BSVrEx1StGGHtnBeF2/hHZod4mzJNDDec3zv/LqmmZbkfm7FkAtKTOUv+52IeXSQqlScxtc16A== 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=dQvLZOogNQQ17Eu9k8jhxLtyxVP8S0cseb4hxja3+38=; b=ik579Bnse2ON+Ssma7DDmOJUU/g9fgOzvv/5XkyUaXPdHLYj28y9BYSiVnG5K2UH/GdER/YhNxH2Hvit1M2YRPowgQKF3K1Jn7pHCc18Fe51n5a4d/3ZuGIBcgBtHzFPe1T6/hDDcl6Kju2oAcHNG8bXOf+L4Q1c5VFMpQC/X6s= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by SA3PR10MB7070.namprd10.prod.outlook.com (2603:10b6:806:311::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.14; Thu, 9 Feb 2023 08:01:59 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::eaff:9f55:4641:db38]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::eaff:9f55:4641:db38%4]) with mapi id 15.20.6086.011; Thu, 9 Feb 2023 08:01:59 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v9 06/28] xfs: Hold inode locks in xfs_rename Date: Thu, 9 Feb 2023 01:01:24 -0700 Message-Id: <20230209080146.378973-7-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230209080146.378973-1-allison.henderson@oracle.com> References: <20230209080146.378973-1-allison.henderson@oracle.com> X-ClientProxiedBy: SJ0PR03CA0375.namprd03.prod.outlook.com (2603:10b6:a03:3a1::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_|SA3PR10MB7070:EE_ X-MS-Office365-Filtering-Correlation-Id: fbc5be99-4770-4bf5-4cdc-08db0a73eb5f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: c2hgBxskdSnM/zAFW6Aq+o1HDyShhNOClH04ZKTJN+glOTfLQ+jYyKKTKOWQXUODE2DyeQiVJ8TRjwaorA2D4v3oo3gum5zCKp05H89LS98VzUOJHIpybmRvHAeYnt/fmnuTZtQjMpn7veFeCikqK8aBJCyvBRA6lxOjXqq2E/HDQeidx/X0lTpDYhHpq4iA+zgJcxt7ifJtcFTfYtioQodxDjJSuvjU6i1jZ4ePHjjxZNo3fqpSC8AMgQTizRHUlezIQ1XbNHVHnAo6Rv+UGovA/FyqGB5Fl2PHgsO0dpeiqRr7AnZiuyLmaEWjs/pquuAbLWQWoNopqPQYPkUqqs5GK90GwfmDO99r6YKn5JFol9+UxofuDkY7vLGRaTWUaMHPpb8iHY+J31eHhEyCJocmT9W4w8LDQDIPA1NSqmQvJuCZ+BCa6Pql5qRmLSWVHyiPPuJFtwJQ2f6PoWDykth1qWOcZW8O0nYQn6RK76FTqytaQJ3OmAukua4PiNfHU3TLXHI20+XzjS9WxJnHSQAfvQM+h88kRszSZQDcMEaLClBQaHV9MN+dgltQ3fDFUAu/LAsoTnMIqpdxcEHDkRNaAvlUqBrws0LIzdIyn4DgY68Fw3SEyZDCUUdr8H7PbEpEVg/SuAf+EAyKz8qSSA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(366004)(376002)(346002)(39860400002)(396003)(136003)(451199018)(478600001)(6486002)(8676002)(83380400001)(6916009)(66476007)(66556008)(5660300002)(8936002)(6506007)(1076003)(66946007)(6666004)(2616005)(9686003)(186003)(6512007)(26005)(36756003)(316002)(41300700001)(38100700002)(86362001)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: RX1c8TIJmO06DzwB2laZG5tCV1SmBEJYLXGHFXzBdevjDfWTn+hbM4q4kggUgMZp7oGRhTnETMquL0nYXrNk3Kh/0kyxCm+7j5w61LwM/S64+dBDdU6aZ+FPzk22lLkrcsZf7ATvWzW6n3oIhAAO+x4klNZKnzPeZtuNp+JzSlyeCEaN+ylMZMeliYs9iavs45Dg+9lexyDh1t9+lpNHGEA+zp1Gga6+ZSVoGvzrwGXNIYZlfMzPeurdVYMjW0ZJCM9D6LZVK3Ji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hdd/pnOcjCipJllkDu8PTP0D7Wa/6mPuKNbt5yB9ZwpN/fV+pMq6s5Jq+5tzGdj21MNo X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: fbc5be99-4770-4bf5-4cdc-08db0a73eb5f X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Feb 2023 08:01:59.4776 (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: 52yv6dRqTFeZ8fXYHmaHzYzMAhUN4nOPwOOfGLUWNFvz/g6+9u1W4R1IusAva2AQLNDUyuQlVzatnuh3Ip7+UGi65kqd2QehUQFZqidkQKM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA3PR10MB7070 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-02-09_05,2023-02-08_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 bulkscore=0 malwarescore=0 mlxscore=0 mlxlogscore=999 adultscore=0 spamscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302090075 X-Proofpoint-GUID: lI8P0wDMh3iLCppzYdTPQMbbumjfAxp9 X-Proofpoint-ORIG-GUID: lI8P0wDMh3iLCppzYdTPQMbbumjfAxp9 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 | 43 ++++++++++++++++++++++++++++++------------- 1 file changed, 30 insertions(+), 13 deletions(-) diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index e292688ee608..131abf84ea87 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_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. @@ -2881,6 +2896,7 @@ xfs_rename( if (error == -EDQUOT || error == -ENOSPC) { if (!retried) { xfs_trans_cancel(tp); + xfs_iunlock_rename(inodes, num_inodes); xfs_blockgc_free_quota(target_dp, 0); retried = true; goto retry; @@ -3092,12 +3108,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_rename(inodes, num_inodes); out_release_wip: if (wip) xfs_irele(wip); From patchwork Thu Feb 9 08:01:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 13134153 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 557AFC636D4 for ; Thu, 9 Feb 2023 08:02:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229602AbjBIICI (ORCPT ); Thu, 9 Feb 2023 03:02:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58508 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229612AbjBIICG (ORCPT ); Thu, 9 Feb 2023 03:02:06 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BAB292DE75 for ; Thu, 9 Feb 2023 00:02:04 -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 3197Pibn024484 for ; Thu, 9 Feb 2023 08:02:04 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2022-7-12; bh=6V8jvoFTXiqb5KGxOUdyTpyXBvusz0Drjv+6VgVQpKY=; b=dP1H9UUFhSCQjlZLyvFwzWsur8QJon2fjpD1N70+csyrFiDchSTVOJeTTSUqHpGOXdjQ zQm/F26e2mUDA3EBLNJGiLzP7+8TjQJw8zgfeeqsBOu00n6NRXUB4gZHColoBLMDbANp bsV30yygfYXjiI+opKlud9+Q84JIplmm91g1eOPq8DhDnvyxaPpp0UU1aPK+lAilnhfn czni70Qa+k03IP1rYUu9BIiZ76CiqNGgv2w4iDZgIGnl9CPrQkNF2gwWcj0M7e0Hvkul gp8RTToEkxw4oKGhLO7bGYNunOVPxvsX6WL3jgdGdN1pvZbkU4YSadTbbf0c9ktq1beT 5A== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3nhfwua2kq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 09 Feb 2023 08:02:04 +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 3196MXbj036346 for ; Thu, 9 Feb 2023 08:02:02 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2104.outbound.protection.outlook.com [104.47.70.104]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3nhdtfg3t7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 09 Feb 2023 08:02:02 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JCrDMw13j8OoKNxSvCL0A4W3EVmYs88jS/MAaRyPumpiao4v5Dw/hzWLy+sfPE95GBypQmZL0n4MDSNWJGnwT7GEIe7fvX2k3ZyOR7PO8tJAl5Xf+t0Noccr4xh/JUWiEYos569j9g2oBPmNUyFiY1ENqZ7hSgrcq291Z+BXvYFc3ZQ4JJzes4hMJq0kG9jBNhYDeKDXdm4y8BQbUIMDqwXVckHx/v0f9RwiaMLNFM8kZChhBLlV8rpS0opEcg8/zBluRspt2uJPHqwtYhgJIVO8ShatdbRe+bV0nzdXlStXchqgO4BWdHfd2ocQYHSc9SanvqLLjRGiAVyWbCcz2w== 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=6V8jvoFTXiqb5KGxOUdyTpyXBvusz0Drjv+6VgVQpKY=; b=Y6x+Jp9JwZmtV+EocTP/uliIYbtZPSkG3Yvi0lTjjWR/hYRIWJe+kgbfzloTemYQgm421OTCmsw7vBPBYLpvxeSr32+2nue0pjbHRgl+dSoP0jFL43RhQvBU5Fv1MzHDU5zeULqFVR6miAtfxNxI96wPUGkDp+fuMDO0TaQbYX+jXQgSVqjVEdJxT73ON/jmDk1A6sgXl12Ij6odlmxBI4qi/yuii1aZ/DGy2IfOyGA1ITI35pt7JIlKuosZmB28FVFofoihe4poZUHTh4F7j/xZqnEY8O9fbPyK/n9CPUKKzRynDYQd4KyjPL//wAcT8ozcpA9D7S1FWsCI6Ep3RQ== 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=6V8jvoFTXiqb5KGxOUdyTpyXBvusz0Drjv+6VgVQpKY=; b=FFVGjw+7f5pZgHUvWy4MXhPlbcgRiabBC8Glt4DyHlJryVuanwCMbWH/o8Je3INOQti1gT5+lV/PbkvuTP6GW8YIWejWc94Ecz1DnYrEwiwyF4RwJZdUJx5j4I87+fnxGnngn6lxHJNiL8yeb5gd4QADGdEg9khDKE/GpQ++Yik= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by SA3PR10MB7070.namprd10.prod.outlook.com (2603:10b6:806:311::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.14; Thu, 9 Feb 2023 08:02:01 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::eaff:9f55:4641:db38]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::eaff:9f55:4641:db38%4]) with mapi id 15.20.6086.011; Thu, 9 Feb 2023 08:02:01 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v9 07/28] xfs: Expose init_xattrs in xfs_create_tmpfile Date: Thu, 9 Feb 2023 01:01:25 -0700 Message-Id: <20230209080146.378973-8-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230209080146.378973-1-allison.henderson@oracle.com> References: <20230209080146.378973-1-allison.henderson@oracle.com> X-ClientProxiedBy: PH0PR07CA0031.namprd07.prod.outlook.com (2603:10b6:510:e::6) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY5PR10MB4306:EE_|SA3PR10MB7070:EE_ X-MS-Office365-Filtering-Correlation-Id: 9bbeeb98-5d4f-4063-2f7f-08db0a73ecbb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: f6wyH2O/81p3Qy9lshVKm1R9Jarf7jU8Zt2cov6HiQWRHrygiM1tYPHhYUks1UJ4wPE7rH+azrowZXe5F4heDI30TKpmhiA5xvdUtGWHFbJl+Ut+E6Sn3zbuIV++9EuvWTLEYByBCaPT6MaAN+59ALqqzJ3X/vbkqJ/Zh3kPzQcznbm/o3Lq8U0ETmE7ZZd8+FZyJOjA/vFQcgDe8iFNtIijFauwVJDJa2GZwnMOIWL0WBSz+QQowMEGP9SbP7Xw+ryXvxd0IUvnaN3iz3NgEuPy3QiJDWsf3gmTHqxMuK4xscokLWO47nMj0eqCSzzAqJPMsgYWlx3ijoWV4nA1bAQCtX54s7uGqXnx9OGm5lxAKzxQK682Q4Yw2RboHMZTh8496g9YkxsVnZDLPMlc0DRqINOqgA2KiPN0+IMGHzCQNtcQN3sbomZvNREwZi5uS3ATqXyYHCwythIfmOFyNQcc+Jtw3xBmDJztKh2McUgKeNSRzLfzTGnPg0z1wMbm5Qh08kGPyv2zjiuGmYve694H4/jgVyuWOzPH8bpKE3/8y00LGUw8WBORnDTebvNTJ2B1wBQaMYrmY3FNVDYoP8ExgH4avs0NDve10QtRyT0c5O7wcjseT1Dly02UHUBc1yXMnLvdtsSGh+kIcyatBw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(366004)(376002)(346002)(39860400002)(396003)(136003)(451199018)(478600001)(6486002)(8676002)(83380400001)(6916009)(66476007)(66556008)(5660300002)(8936002)(6506007)(1076003)(66946007)(6666004)(2616005)(9686003)(186003)(6512007)(26005)(36756003)(316002)(41300700001)(38100700002)(86362001)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam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Z7YFmKSw/UoC/RmlXmFgJeDP+grka2RPyovBK73N5c4PnTD7t2DSgsEKOVDSV9Usq9OlLj4wVRHDMtGrhgIfnoKkag6RiYaPbGyd3OAu8JMNe0JvW1a+0fg1hKwIi25uZ3QWHmgvzPX6qer9hzgDuQleWAeKE3swdVINDypjzilPsXgWphm97BqUnRHL87Nx5f84ot9c63FF2GdUHWs0g2ZtFCBe/IIIUuh3FTRytuhqQ+WKKettv9uNJeWuevnAeloouxgbfKS8R4uMPQAvxorRUAZS+rNj3Sb5LInugkDOQI3JJJVPsC+RZkfMbYOtdTMhVQZphWBGE4bMn+5Wby3yu0A6beoFajwEJDfcrSii5FO9zlqLN7lXKh2yHxoXhu80UkRRwx71FAjwdi53j5XHtiwLRmCIJPATy4sEQUPnyjX31yi4WyzT/qvyvEMNWMwIxDR/yKbHsnGZW5D6oow8Cto0MVY7ncSb6AgIFrzDbqlzCqy75xQP0fKQbg1CL+pK4VrC1slQ7B4uvB2u92fbo3u21uwGkSjKXMLWk6xArHr05vWG1r2mfBVF9JvI2DVt/c/5gAgYPQWEbYgg== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: eMhRG+02in5OGtJDnRvu39flJtQRx3N+vH3u1gdusiWNXoqGZgCD9vQYIF4GJxxDL5YTAVJmEbvVwPkufU5khdMcEb53/Rbgtu7BZnkuPu+9Ln15ZaRBvbk4joThm85Fjgmcfr1fZ14fi0qPh1VF9sISzZ4ixT0l/v6u6kTmmAzdzDm9/T8zF5Ysnis35B9u8kmoJW1yNYLAYIWutC9JcXIQnyCWJIhix9Hp45PteHxIpIDiQepktZpxDwRitHnH1s2bQFUww4iPK+HQYFKgEkFz05fQO9XqcvVE0Tiy1WlwlDpr7xvKQCJSW6sgtaGGEo+Y/teV5itwuEwva98yHDimlO1Te3oikA3dXxIit9RMh4LbJdrqaMMe9rveM9N48F03wHEuLhE1GdyqIcRdnhT8+niVUKSWyAXQWGpMAHr1GsOpr7x1KrrL0e0VeiQzF55aQ8Ard2zqgKNBDu+eKSfVcQquyjMsKaNjWLrwuRKg5Y7Hr+Hvi3wAO7oUoM5pSBn1x0dhjxFVKzPj16oe8HbZn7gL0e399QFSOr99Gxr/hr5D6rfMb0b/5m+IQAcEfCtP6rMnUKkjZXnVlBSdbNeC3pO+uYO6Qq80hcW/NtJ5DlG6OulhPKyvj1ZhGsEowMfxHBsGJgDe77hzmmPX5KMtrtkf2h1SpdiAvFeAyAN3o3sJ2nyL+93V/6jbo7jublXKbs6STBvMb/L6MsHIRFiA1rLJXdDaH31AGbmYCrLgy+E0Q3r1t7oh+gugHNbt X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9bbeeb98-5d4f-4063-2f7f-08db0a73ecbb X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Feb 2023 08:02:01.3982 (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: f/1lGvlDLuCQdXZ0oLxKfr8OxnSozA/ySMsTHeKR23eQqjdfc9hkIjcbZuusdgI3Ewjd4e+dqc3Xb9uauCgQai9AFsRTsH7jafZ+LnapDTE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA3PR10MB7070 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-02-09_05,2023-02-08_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 mlxlogscore=999 malwarescore=0 adultscore=0 phishscore=0 suspectscore=0 mlxscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302090075 X-Proofpoint-GUID: 8PhwIzMnD7Rc91gTVNcRXEvzPufKV84x X-Proofpoint-ORIG-GUID: 8PhwIzMnD7Rc91gTVNcRXEvzPufKV84x 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 131abf84ea87..267d629a33d9 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 515318dfbc38..45e66c961829 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, true, + &ip); } if (unlikely(error)) goto out_free_acl; From patchwork Thu Feb 9 08:01:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 13134154 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 616C2C05027 for ; Thu, 9 Feb 2023 08:02:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229612AbjBIICK (ORCPT ); Thu, 9 Feb 2023 03:02:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58522 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229608AbjBIICJ (ORCPT ); Thu, 9 Feb 2023 03:02:09 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9F3B526867 for ; Thu, 9 Feb 2023 00:02:06 -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 3197QKZQ012373 for ; Thu, 9 Feb 2023 08:02:05 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=2mD/+w/gIEcqSKEpz/PYuGTNBS+UC4p44L++8n5sVQ4=; b=TR/cPW/RK0UAkoNooabojAw6PALFiJbvEnhK/GwBmaDxPhLYPlrS5fg9oOVwwEs6OLQT tmMqtiKSvmsw7kcXQnFRKD6Pm0xnDD0SZCVedL5mGbZT0AAPExDGqQMN87YsYq79mLzF kK7Ycnjg8c0g2iiJglbfO5J+8tfDXw07OGGoVMPM4auC7M6TTbnSEyJPMw+fGyaE7/F/ riTsJFFMh/oQ+j3JxFsKHBWltUyGisR31Gmd9WnnIYYAZH/2IvoItpuxzxWqJEmmK7tD wdrCq8sY/xJ+WmDFuO6i0xc9tqVp1wkpYlFhuVoNkUflUIoAfoe/eKv/JOLymHo2WRmk iQ== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3nhdsdt4a7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 09 Feb 2023 08:02:05 +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 3196eRNY035966 for ; Thu, 9 Feb 2023 08:02:05 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2109.outbound.protection.outlook.com [104.47.70.109]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3nhdter8ut-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 09 Feb 2023 08:02:04 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ILdgbvoettXSUziwJj0ISGeGUCUVeUoz5BQVepbJS4dxefrKjY2ncQrcYejn0uzRffcRGfcg30ySerBajxjP6f3nKVDanKpxDj6bLVbLTRukjP4WvxWg9q0sLnY9HcLarbxCxTy01hnR8OJ+STUiR6a+39+aY/zgdA8DjF0vGDOdDsEYSsSiIRv7cpRdFfjliBP87/BByo26Dg9CwsA7k8mCoTU+uUliLbgCP5mFOdzo3r5n3KU4zjRzSKy3aOZUy8HqMWyHteC9J4O9s7pm9LhqTQfqgucf+MkeY3sUJ8ZSgm9/uN6ZohxfZcM/CMCYKJH3DxVf8oReXTg4Xk9BGQ== 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=2mD/+w/gIEcqSKEpz/PYuGTNBS+UC4p44L++8n5sVQ4=; b=n6wzecPqYlSnAJVFlz8JdimfEUlg4LWkD0NYyHnspR2kyEKeuAXe8b16QmjjZT6NmVC2ETMcPZaZ2Kx80ILFvjLrtpKP/2C3tBpS/Z6MW6MhLKjkgm8tXER6oEqFJm2av6tJmOjngs5gJgaaC5KqBWI32dz0U07xfAIxDKQcMikhbzgX8zGSRmmFkWCIS8d+NzxXCIeYgEmpBQJqHFRMRALEOf2Q94VxuIkY+GNiu2897hGj2N5HRB77cCrAIkuLNWqcQ8bcu2Vm3EVLNGOL1jbrAnLFtws1ZB0fCv6h8FKOU5Jaj9BBRxYnChfl8xDWIoWHYoFFrXHa/WzsROkR0Q== 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=2mD/+w/gIEcqSKEpz/PYuGTNBS+UC4p44L++8n5sVQ4=; b=ly+VAS/GrzRekGrUYO98kv26i7RO9sVQsyEGeQFav9e6teDT16H4wXYBTf8QWm3apXag6wm58CyVadtm77zNaFACR00evtqOt5RTbiX/kPq9UAsdlcwTN5G+w4AnQb0eL2VtA39aVOdRCh+0LZ0uBlynuukDkA2QITCY+iOAZCA= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by SA3PR10MB7070.namprd10.prod.outlook.com (2603:10b6:806:311::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.14; Thu, 9 Feb 2023 08:02:03 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::eaff:9f55:4641:db38]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::eaff:9f55:4641:db38%4]) with mapi id 15.20.6086.011; Thu, 9 Feb 2023 08:02:03 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v9 08/28] xfs: get directory offset when adding directory name Date: Thu, 9 Feb 2023 01:01:26 -0700 Message-Id: <20230209080146.378973-9-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230209080146.378973-1-allison.henderson@oracle.com> References: <20230209080146.378973-1-allison.henderson@oracle.com> X-ClientProxiedBy: SJ0PR03CA0383.namprd03.prod.outlook.com (2603:10b6:a03:3a1::28) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY5PR10MB4306:EE_|SA3PR10MB7070:EE_ X-MS-Office365-Filtering-Correlation-Id: ba504d60-fd9c-4fad-071d-08db0a73eddc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: D4E5cLmXWldPJOMWfR5eQ65L1V1QTBwutQmRV3qdkTY7LzaIzNBfSfcOv+dzHEs9TNiZAyn7GwkEM8oXNkJOUzoSBHTRB65RKduAQF1jMw9uRytVTWlzJ1SgDK3xAxBEpk7d4SRfJeJgofgKIKziqElayKY7vjDYcKUXvN5IKeliOYv6Rz24Me+ttrjOR9DR4ou0ZQmWiAgZ9/878c8T5dUYlGFSgRIMwFFeJyRZivb4hn7ddtxYtWCEbsuP3q+5PPDEFpNzePS+UeFfQMPydsnEzCV0IDSLU7zsjj6jUOa9MW0MKA4EgebDI70zrvNGd6Wx/fwDCZd5KeDDxFapVzZl/TXdAAlcNWpOclUfXJlpqnZGTnK4X66NPfe4gWmVq/wRT7z6GXJYXM8U1iW16BQS/rTNH4U4ZUbGxmA+IG+TjSE9Zd1oEHNNeAcjb61drUe1HUnmFiZgqbUA8OENLnffgsyuFDJ848JGy+hdpUu3YS+XCgw66vi5bA1cpjbssUNghfF+3Q0DAJL8vD+Q+9lhR208fDP+dSuADrGE8BHDcpe4KD/+buSwmlgMulsdxwifLaUceZVm0Ncl0VW2Uk0R6lhrYkGxoEJ7+v+Ei2kBAy2Q72HGkZLPc4aqUDoDtCGHLmpojUNMwXSTFD3Q/g== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(366004)(376002)(346002)(39860400002)(396003)(136003)(451199018)(478600001)(6486002)(8676002)(83380400001)(6916009)(66476007)(66556008)(5660300002)(8936002)(6506007)(1076003)(66946007)(6666004)(2616005)(9686003)(186003)(6512007)(26005)(36756003)(316002)(41300700001)(38100700002)(86362001)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IBLh0H3DZYYinalPiWMl7jLQMREZgXhawibppLBDMaGQA2IYGQC/NaMftMQfIQIrbJwA7VHfbCkDe5o1d8fdRJYC9ap+pdm8aRC5MWv9DZ7WuCxYfSOC/0Sglrxz+1Jsr0apQ3OL5eAPS3g2cbb1+Kz5YNW/ZLbeNbI56wau82IBhVm0lm19nKqvm8HUmJenAfQHI1ozU95IIhnAnh0bvWK0iCwW1DmJ8Zj00Tyl1F9P/tUonhV9dHd/dCO2mQKQUQKYsuOY4/CIsfXVJxwskNYQB13fennGqaKQqhpbPKMIwA7IUZL2ewwDF5BIBDwDn0vBctdy5JJrltoE0U5ZNPlwrDe+wp4WaG3oHi2eki4VfcXTjdnSJCaZw66ZYLmD3EsqH15shc X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: ba504d60-fd9c-4fad-071d-08db0a73eddc X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Feb 2023 08:02:03.3536 (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: GYdLtHIK7j5Qm7XjFrNuM2OZwi7Zpw7QVFLV3xuTpWsgFn7zf9HFfZd3T0+g+nN9cJfogEPCDBM8yxLl/0LwoAGvdmwOS5ppUG7Wui0acv4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA3PR10MB7070 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-02-09_05,2023-02-08_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 suspectscore=0 adultscore=0 malwarescore=0 mlxscore=0 phishscore=0 spamscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302090075 X-Proofpoint-ORIG-GUID: 8bn4ZqrKF3fM_WaJswi0EzzMXfNBZsre X-Proofpoint-GUID: 8bn4ZqrKF3fM_WaJswi0EzzMXfNBZsre 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 267d629a33d9..143de4202cf4 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); @@ -3001,7 +3001,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 Thu Feb 9 08:01:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 13134156 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 32849C636D4 for ; Thu, 9 Feb 2023 08:02:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229608AbjBIICO (ORCPT ); Thu, 9 Feb 2023 03:02:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58566 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229629AbjBIICM (ORCPT ); Thu, 9 Feb 2023 03:02:12 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C19B12DE75 for ; Thu, 9 Feb 2023 00:02:08 -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 3197Phsm003371 for ; Thu, 9 Feb 2023 08:02:08 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=j1UphUgrLxNzSWpMB/bI7vBqQ2f2Hy1w5Wg7M7MEFKI=; b=UC+BQQbVGmYyn9ZGaCKuAoD0w98QjfvMCcnxztYLpJ9zsR0SP8McW2PAm3M/eP//X3jP JsGpZtv/8d04lRtQjPIEJxVPOI3CSQG3HsOHbGyFTK6VnSfeH/QBs5yIjwzTzIW4mA1i t1O3nu/xLCg/LQWyLJMc6ibIpvLTdY/t85M/1/+WXVsOzK4Mk9j+Qzh2r5VcLPPsxcfg XXI6kqaVNNTEtu40BiEFST/+G5mRiJWE1iNIUOnEmzKfHVsuBg75yPKb7dS54smuFR/m XNgJhSB1JZrDv4E3iQeovFQFSGpsOKHfGAxWc5ACsGSfi520393WScOBXjkumoIrF75U 0Q== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3nhf8aa441-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 09 Feb 2023 08:02:08 +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 31981xCr030986 for ; Thu, 9 Feb 2023 08:02:07 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2109.outbound.protection.outlook.com [104.47.70.109]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3njrbcxuh8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 09 Feb 2023 08:02:07 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jbP5XlURL2ocDs9nWGgaWBeGHDfgO+PPgAzPR8U9nm/aEF8y+gZzNa+/r8C6qNnlQnJ9qRZm+ypyPLOEzL9FgD4awziwK99tp4BeDYy7Zq5Z82CJJjVwLzUZunnaFdAQ+XCdW954Nr+8q57LH4UGsGDReZNaV+i0o2s0ZOCN0OhmmgbTr7aDCv+8pT5eaqhQIwwy186YwFaXcBORqYyDjyAsnid/47N3LD7p1RNy6QWQYE6bcVAXWLgsPEuOpDkrUKv8DHEVGMDcaYE7N+dDNs3ANauY0LnWX0LXZlavLvTg9JccFLYUKhDOa/tzNTKbPxbob22NYQgmWgDHb94Vhg== 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=j1UphUgrLxNzSWpMB/bI7vBqQ2f2Hy1w5Wg7M7MEFKI=; b=JIU66uat09LdeS4mZoBN0mOBK4ZM61Nya6yDUv2fPrPSO5Dkl5BCf1tI89PAW0kHEw/zkvAPQWdLJp0LRjcCWSYUyfH/WJK3sFZfR2Es7x1/3KtDcGyy+0PdR22YasUoxaHo9x1lwSMOKqEaeuP2IU5jd2samS4D2iYdcVOLNfrnCxzlLbAliClvewHpeVlac6R38uGru4XsHOtbHdj0ZXhZdw9v4snonyKZlhp9a5vRLHrCfmzwBNaRb8Zbanty3+dJAJ+nXYwayt7DFPi3ZNBl67izand+poVtGx8YdibCI9+Ne+fmWXiLicHDBedjCIH2gqQh3+NvIBgXYCix8Q== 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=j1UphUgrLxNzSWpMB/bI7vBqQ2f2Hy1w5Wg7M7MEFKI=; b=SKtS7QPdDP2JLvsFHOlF2urAB9AYJ4K8KhKEN7cZG9LoE9cXXUQqmOe0Eutde7/w287oC185L48wPvsRlOowy0UlFBkuUnQutMyvbsQiet6WVmqxi2Bh8sHAH/8Bu4HaO+y/kjmdoRwGL21vPxetx+XKCBQsbb2U5D2EvXLOVPg= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by SA3PR10MB7070.namprd10.prod.outlook.com (2603:10b6:806:311::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.14; Thu, 9 Feb 2023 08:02:05 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::eaff:9f55:4641:db38]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::eaff:9f55:4641:db38%4]) with mapi id 15.20.6086.011; Thu, 9 Feb 2023 08:02:05 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v9 09/28] xfs: get directory offset when removing directory name Date: Thu, 9 Feb 2023 01:01:27 -0700 Message-Id: <20230209080146.378973-10-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230209080146.378973-1-allison.henderson@oracle.com> References: <20230209080146.378973-1-allison.henderson@oracle.com> X-ClientProxiedBy: PH0PR07CA0058.namprd07.prod.outlook.com (2603:10b6:510:e::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_|SA3PR10MB7070:EE_ X-MS-Office365-Filtering-Correlation-Id: f2ca114d-342e-42f6-f2eb-08db0a73ef0a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: JdFvkkgrlnm4Yii1TwHKzgv8DsQFXC8ERDbJUhdQRtMbBf2FDG7oDGmIIWjqjpHKpCcZDi07toSVEketEJr31Xp/sLTxEylGd5McfXU16tU89lQGdZRIOHtl5xHjWGmpZoZr2Hj/fru3OdYNhj9ijxXzyEydZRxH0aHlPWsfgdV4h3ogQOlif3nbb/Q+XOX4mtdAABW7EIwwkTBwebm/tpCLlhfeoe0tI22084zKrLrUV3elNZ7G/Yv0uIwf0So/F3oSxs41M7kRWS9E0W1HtfswQpVI0+eqTCgLXHYU0/Iy2EYV2hPHHF+CHwBUxjyQo93mnHTXqej/SUNBAGD+4Jl1pARYRLgN8eAGdFyvq7mEqc5mSZ9zlLsTSprMyD9Nu4KOkArISex3UabXJ24W1wE5YnjDrOrITFuV0oFP+oezqWAwHhUEmGY7tJ+q6MubP3tWnDjIrtdGmukXc8QD+h7eDKi1He+h9/3CczObZmeOsBGMb90w/i3vZT4JddUBKTxa5iQVteMq2QBFVxnchuW9+GkWMwG1R2F+EiV4LLizck4JCmwQO/M6esR7EIy+ZNlqTl05bnERySwD/q+lGowtvZaBMV9CjhR1ug6pJnXKtiWqDkYhCo5xkeawW9q7vSP6sLGGn4TlyfIcd+tmhQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(366004)(376002)(346002)(39860400002)(396003)(136003)(451199018)(478600001)(6486002)(8676002)(83380400001)(6916009)(66476007)(66556008)(5660300002)(8936002)(6506007)(1076003)(66946007)(6666004)(2616005)(9686003)(186003)(6512007)(26005)(36756003)(316002)(41300700001)(38100700002)(86362001)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Cy5OzNP7CbiUYb78NQ/5hvIx0UMjIZS3v6OqGMrLQ4FTs0Y/8PBrEhW38z919ypOwKGf0PvgY8ziGn/vjq3ghf9xEslcqDyFHRcbaCUBO31Zq24evqdM6WnmDrpyZfknFo54jYCqaVHx5LefIgLp2q9/YjtbZhtL6NPurfRl5Gji6IEaMkprW//gj+oSto50KfLe/R+kPdCHqLrIrLXFkDygmsP8Y+VJlBCnShCKBVs6IS/xStbmFgdvu4oWtrXK1olLZ5MBColNyXtxH3umf2t6lpNJBqlhIhzItp3+T+pt2/ZP/bBLJKohGOzi4/tHdoBUROagb2HeSB+9d6VXz9HstEWfVwJZ4TW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XeRILOUHJpfmSOaIC6IUvXtfU0+7CKVCOymKl0RVUowrSOqpYUXktsFcz73oSkER+w6sQ99ogko256DFzyafXARcvM44p0TUg/PMswUq3gbisY3I+JhsCEVClV3tetPg9P9Dn6Qe0XwlNyy42ZO0XYpTCKuXXxehvXR4q34A== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: ldZKQh0v04/7NF9NNkf6u4gf2cqRgFl5fwtDUR9A6/y/XrNRpJ01Ye7RBEzP+0/aNiopx9d3wxjeARxK4RsxO7v0jutlcJkrlMXAnOUtdpIBkj9GX2aGIGhPEQ8yrC5a4hg7empCYr4NGJlEpMjYsTaVu0psUCsQqGsKcctB/Y4O8sOYStORByzj0ji9hReSnka83u6/7CEjWt0oLG47NAFw+RUoOaFD9QQMmUc/Op9d97Chdmq1ev/ykO4v/l4jYSR+e0HUOh41z1RR5KbpnHH6xIGQz4Ky0sF6n1qtR/+NMvDcUHVKFFb7tCekGGUO35dAlCL9s61azd28VbXEduLtOGvDNUFjKhjWE2j7oxpfxBITUadd7G/jpQ4qKqEPsKT7vYM6Tdx+gMZKObFhWsYFcmejXeTI6KQ6cmqJk7VyQ/wThsA1VCga9nbAx6iA2RvbcvW+34p6i6Q0JhrMbb5NF3vz+EhPHcsiwlzTgCAjzH7R8OvmIRyimB7WiVwyKLMd5T38c71Og107gMgfFsfdj4uyTx+MpuvLD2cbyZtFk/VeCNATiYlzKhfzJbXfQlEur0dNcnerAv8AqBFT+Wy92Im0yrb1v7G5arObf+LxKb0I7ZZtu0AfC5Fewyhlzo3/GizQI9KirRVxpYguch7vBx5qZgSxqTkVyjfG6q+BUkFGGizs4i7fYrMfMu2b8MlFTMQ35I4l0bS0veDvpo7jGO1ShOiDEG/Y5DWh6kHQtEYLq+3VWs3USS7D7oSc X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: f2ca114d-342e-42f6-f2eb-08db0a73ef0a X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Feb 2023 08:02:05.2899 (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: QgkXbEXF7cIPZ+5BwW1Zhkx4FfkOCKTI/GYkDJD5syZi8SaEEnfAaER3Ca9/MipAT891xL27nk6Pz9eridOI3HSeAJ/GxqsM8kOTuvEdnkg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA3PR10MB7070 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-02-09_05,2023-02-08_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 phishscore=0 spamscore=0 malwarescore=0 suspectscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302090075 X-Proofpoint-ORIG-GUID: IGFp_FRl5m3uBoRe2iWraQe0qIkpu1HS X-Proofpoint-GUID: IGFp_FRl5m3uBoRe2iWraQe0qIkpu1HS 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 143de4202cf4..e5ed8bdef9fe 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; @@ -3098,7 +3098,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 Thu Feb 9 08:01:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 13134155 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 9C06BC61DA4 for ; Thu, 9 Feb 2023 08:02:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229650AbjBIICN (ORCPT ); Thu, 9 Feb 2023 03:02:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58568 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229632AbjBIICM (ORCPT ); Thu, 9 Feb 2023 03:02:12 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4AAB8265AC for ; Thu, 9 Feb 2023 00:02:09 -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 3197ProA016215 for ; Thu, 9 Feb 2023 08:02:09 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=A7c/ag05lDcclOjw/wtyCnf4/2HW5521laIEYPVOD18=; b=fNKnQ6ZYZZiMCtDEqPiGdbURkoj1co/cnKLJ4Deslr+zmPwqz7e+RriinKA8mW44eh6Q 8utSpWVe6GEz2CXSL+MXTxYqSoUD/4j9AADtd9NVlGETfqiY49iNC+2e3GD30g2QC13Y Rj1x6mG497s/5ufUJJb0m+s+EHvrq1WDiOdKA8hojQW7L/3AeX9k2QOtlBVSHTslRzbD ORQGEl4aXFfTpyxKWb8r35Iyb8j76n8m4lhgk2REcYsjl1O/QW5yAFcohcvqoOIaWrxL co+d6Zevk/yOHwvMpGvWsztI2xvyEXCCpLXHClU44QwlYhLPWxr7bb38UA/+w1x4km4c LQ== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3nhe9nj4dh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 09 Feb 2023 08:02:08 +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 31981xCs030986 for ; Thu, 9 Feb 2023 08:02:08 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2109.outbound.protection.outlook.com [104.47.70.109]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3njrbcxuh8-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 09 Feb 2023 08:02:07 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gXF0ixpX6GA61DEB88udPNsCZo2jZ2QFG0HuDDVOBW8Gtl+nTbPZKYmykotGRdVux+Ev5XWQmT7Jd6EGwOSV4VKz/F7Jh1dfNVSactaWwoYTOO9wh2hMQnKCDZmT98GVnDzVJCq5Xz9QW4PJe0dGiU5/Z8RAwY6tmTbg5m7KB7JHtA73KV0NB5qgLjLYcgK4iHKQa0kQh9oI4Dl26KOY4rapJD3cZQYffqL/7MmXkuc2HlNKakIyZl3Hqr01HbN5WslvGA0vXSnaCrE5bhrUJ9ALxpjvp/YBH6O0cYApZnzjWS1xGSPf0PaT9Jym4LujfNwwjfNatqZ9bYDhyxzRQQ== 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=A7c/ag05lDcclOjw/wtyCnf4/2HW5521laIEYPVOD18=; b=AkRaJH6o1HNvmUAobJBlE+pCVmNFkrPP+QuuPCQT1pcyP4lhuE8/IxDUq2tCJEVQc85QJLWEUas+qRv6gMAE3gdbJ9LlojwcKiFq5QyN+hjqj3dDfhtVmrtVhzvDUXan2esfrvoSnrnS54nSQ3s+BR3JFxKwjuBKe4+ZUkmFbWWYJ/pMMzpwK3q8OZWbwHIZkTei8loiwNY8cbOnSU/86eHqpkFV1p1i8l7bVJbzAxjORHXaatb9dax32muRorliM6Qr3sHGvIxEEMVtYXGLxZI+KNLUdTbP9PWTwiHjC/saMgCMGPB4Nmas71vl0LQAuN3ktFzW2HuKreUnIBlYMg== 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=A7c/ag05lDcclOjw/wtyCnf4/2HW5521laIEYPVOD18=; b=lrmTB6kuxQHdGWsAiMI0RiOMq/F3RjXEG5jFkYHveseJwd2NshJNDkJRcgfBAy0OCwhE68IunXBvwMFmWPq1Z5PYwdG9Qop7a3X6x4Lt6O1g9TUAsX1ypZr6lB8Z8QTxB9gw5aBDXnH250Bapet1czQHO8qIERm+AMHzObLclh8= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by SA3PR10MB7070.namprd10.prod.outlook.com (2603:10b6:806:311::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.14; Thu, 9 Feb 2023 08:02:06 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::eaff:9f55:4641:db38]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::eaff:9f55:4641:db38%4]) with mapi id 15.20.6086.011; Thu, 9 Feb 2023 08:02:06 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v9 10/28] xfs: get directory offset when replacing a directory name Date: Thu, 9 Feb 2023 01:01:28 -0700 Message-Id: <20230209080146.378973-11-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230209080146.378973-1-allison.henderson@oracle.com> References: <20230209080146.378973-1-allison.henderson@oracle.com> X-ClientProxiedBy: SJ0PR13CA0093.namprd13.prod.outlook.com (2603:10b6:a03:2c5::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_|SA3PR10MB7070:EE_ X-MS-Office365-Filtering-Correlation-Id: 5cbd06e3-2285-446a-ab0b-08db0a73efef X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: hcLUjaY1WLmj+pepYoCDfCTf19Pr9bT8owFtktW5SiI8/yBkM/UvBGaWm79MCmOlgL9So7exuWM8+99SQsXFfn7ZIsT2hLlKymQkFgQ9NIT2R2IGO4cWtj5Vl04vUdpV2iE8GgkYjIksuESgAaytT9nhsYddIiIHeIqcJKZUKKCAss5g+4+rzNRjT0tUGBs8VlWhoFNltm9JGYm7tjw9d19UxqGclXAeQLoVAm5bgqexuU00ZWFvtWR2DJAFChLZPUeqVUrGoW7phB5xLgdg0mrdTBNrwrehpGQ1Ze+LgYFwCy2zMSzHC1e30QVCBWhyi9S0IX6peUacjenPwOfCdihrY9ZKYrVpQLMb+LVhIWw+LXFVC5Nj7uDwgWEneO7TBWr8pZ9sUM5yw4TngT7dV/0rzFgezId9APNBBmF6O/6Kjug/7ne3ARvYtYSvEbJAjnyN6dR53XA9F0dKPbu1EwtSeQHupHJjDqi22fuVBOoeQYm7w4GIn1Jw3B/H1RRveNJhMAStmrA77gWyDJqXK53aI0qSWNpJZia2EehVE3zHK0AfAuAKa75H++wXB/uPMx3A/Qp9y40driP3iueI0jrwcJVJ29pYPB91KWTRuJ7V/waOAc7hhXZ4Xjsz1aaiZrFUyu7dlw67wsm4AXK9HQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(366004)(376002)(346002)(39860400002)(396003)(136003)(451199018)(478600001)(6486002)(8676002)(83380400001)(6916009)(66476007)(66556008)(5660300002)(8936002)(6506007)(1076003)(66946007)(6666004)(2616005)(9686003)(186003)(6512007)(26005)(36756003)(316002)(41300700001)(38100700002)(86362001)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: IgbG21jS1LF8TzzLj+05swkQ68IoXX9YK4LOBxmi9aqL7R8WAKL5ECkcpIlJGTMe8PG+xCvo672n4oVYPn0gysDHL7v90BtBDts9PrfM5gsyFZ28uUqd0OMXmP/Ww5NIAn3HyJTbTCKDenXkmsyexuJE94h4M7EBPJuLz4QHNDIiSsHSV6c4l4/IKJPRknN813pC6Ce1Gff9StY1QXlwVXV3QqNFZmhsj36N6sMrJqX3YhfWF/uIQUF7jX4VGK+79w9vVnbVxcGJE3rvvx/Iy9lzoUArtC3sEXyfn4K/MuogJivEiuuR2dK2yxPdxKtWFzCvMBdzXf8aaMOXDJDevLfqi1Op8HN9iKqZNaW/Xl2MxPglNXu0ht4aoAu+asheIJ0TqT4IvmjdwCRiIIixLXzMjFar8uG7h7NJGGMGxK7HZDVlIoNCyP5bXBVOc2EdKnuVPuiOYvO05rQ5jv2aQVanNwFHYcInLrHTEhllZChqkTkqFgj/blfRmhZYBhxx5BSAgRdw78mQ9OcNVVyrk7tZc5NYjvbupKm4kLvYw5WWwv98O9AP810QVzbDoZONggNjp/kjo+vY9QRTHw2+j1LeV3DQbdFqdtoGfZUDGkk0YA+zQrqDRr4Kx+JG2E+TqtB5ORO5rS3X2xQNZ6LHcXsrGXOhHXlKaIk5iGS5mQjCCti8aGny0axai2/815DYrA3NCgrrw2PJB7vK9fvkThIFUBAXMXYyOI9WILcpNuRIP3H4CxrGUY2gi84Gz3AgLf6JPGWfWPh+oTTE2ZwDV5xhkVFK3HoRvIncC82mmWo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j6ccvYjLn6kq+mLDJ1kr1LPMzTkCL5hzcvGKd1iKGJuUY2PX8+ueVL+MhOgVROjgCCEAs4SVy3Y44Tpv8r0Tln5rhEODW40HNxUXI4vKnRaFwttXcSxnXN4V1o1N+FtQnOUXNbq9QJ1jVHjjmrTsZCPYJmfXc55Hr2IM9kTV+ng5T3MdzAFRznXEqSytLCWkwOj/lZ7yoijMb2rgeVqPs3ghyjI6GKJWqIpQsw5fFvnDNWQvpzKOZeoiukhS9It4tKdlHqn29L7bWvZDuY4WxtI8yjOSk6n3SBzdwH6iF6Xy4Aj9BDp1v5OHbdfc0ewrl4E6drKaV6viMZbz1iADqhwt50SBKUknT40H/5g7CtqOVfSPxEOgCyRv9t4e048Vyb7KmUQKqAC9p4mgtWJJVHqy3HpN8lFggy/7pjZ1+T9kPO3CoPnqwQb0NBix5os28136gSVIJTh6kC63kjXRMJSixvR77J6L9wduH1mcVlUM/lLQQ2bNQHOlMVVWYJF7oasndLoPCe4RSzcCl23kF6aDgY43aiLs03zhJnQG4t81jdJYe1LiyMIPR X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5cbd06e3-2285-446a-ab0b-08db0a73efef X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Feb 2023 08:02:06.7910 (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: MwExKGtSuuiKpbOh+VWvas7FgVC0s3uRbdq0LsuQPhsXL4Y8/LeWbmUM1+Yu9iogM80vyRLcQAKtc4128gH7FD/OzF46yuL+D7fEimH4Z50= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA3PR10MB7070 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-02-09_05,2023-02-08_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 phishscore=0 spamscore=0 malwarescore=0 suspectscore=0 mlxscore=0 mlxlogscore=968 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302090075 X-Proofpoint-ORIG-GUID: ZlAgGKonkj7blFtUKPO23R_tD3tQrADe X-Proofpoint-GUID: ZlAgGKonkj7blFtUKPO23R_tD3tQrADe 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 e5ed8bdef9fe..a896ee4c9680 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; @@ -3022,7 +3022,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; @@ -3056,7 +3056,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; @@ -3095,7 +3095,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 Thu Feb 9 08:01:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 13134157 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 C5859C05027 for ; Thu, 9 Feb 2023 08:02:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229629AbjBIICP (ORCPT ); Thu, 9 Feb 2023 03:02:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58578 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229634AbjBIICN (ORCPT ); Thu, 9 Feb 2023 03:02:13 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AF2692D15C for ; Thu, 9 Feb 2023 00:02:11 -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 3197QBcb012239 for ; Thu, 9 Feb 2023 08:02:11 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=hVjRnCfspL4P7YZo4v7somjYUjK7m/v7/aZdoU4F3ps=; b=r6Ef9bt/l1BveTg44pWT0WtCgtVs8+t4AXWbggIstC26iodZTnCQ6bzvVIYkya9a40iH OSqCQwAYhS3cAGcmc+0FsMm519taP2g9r4bHn1wAgOumQEbj9lXadw6Kl06oZVAQBlS0 YqOa5K7Av4bmSymAxGuyxfuVVg0JkQYA7ifuzPK2vRfEOLiHMzX12pJr4Ks/LfxoA0Ig f47mAal2ccViJKnHZl+gmshxvCTVtKtOZa8MDX44ObyEuSyvI8mkK1yCXh8ZKA6zbxTb C+SDQwg/jW74FjzFx0dRqs3daQJ83CUE4DQEc0RJr5ECUh3HzaxVJ2JmhUP88rwdg3s4 mw== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3nhdsdt4a8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 09 Feb 2023 08:02:10 +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 3196c67s036270 for ; Thu, 9 Feb 2023 08:02:10 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2108.outbound.protection.outlook.com [104.47.70.108]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3nhdtfg40q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 09 Feb 2023 08:02:10 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=O7djBiiRsQlEmz5ZKct+POFZv6YojVQtvff9W6asnXsFONIRymmHAJmj0wP+qJyCHIJGjOg/oNcOjttTSzhYcYM+oRmxv74C8gm9L8RmhPB4owYcMcDd+T6h8c/9rOs3WYqbieJFJ7H3ZoITTCoAcUP1VvJJqctU7FQgLnq4afqK87oVQA+J3yhLflZ8T5dzRLHjjObjB7YRbZnme0E+LvRuUE8HAJLNaiFd9rnz0G1v2Io6pJZqjTaU4zNxqFSwh2yLoCCvwfp5so+/7V6tLmTa7vrkgnssx6gs5i6ZDrwtaorvf4ThYoyC5D3vYbJl3d39Ii1mvwZDv2fITA+XMw== 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=hVjRnCfspL4P7YZo4v7somjYUjK7m/v7/aZdoU4F3ps=; b=GVB76aXqM2n5SVFeP36X+NqG2ju2+rO/fCC6FvOmaMAzvk2ELah97KSdeMtojiaLRQp1VDGJLAkxc3UP9LMiEU+MaXS0zQ06RCpebqpe2hkUZ/emP0VB/SS2Oyuqjn8Zuyyptv5D24O7zLGNoW9cXlcYKBLbot/FRDF3/Q6oAFKA9TqSjPbNGh5yHMSTcF+CaVmjiMwP+L88UuMOnSYoiYEv8l0xXCmqHNSlWxPsQWiKrrZWpy4xB7iqaBXXQaFG/GTlQAiJme4FENhnOhqFTRtwoXKuhLT3jDZV0e4j7OkFzBdHzl/RBl87W6SLc6ah9i8ok5W2u+P0ErhDSzCjOQ== 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=hVjRnCfspL4P7YZo4v7somjYUjK7m/v7/aZdoU4F3ps=; b=q8rZSZ5JPVFNyH+ZrC0XoEjrjghdmobwHkKVQRB/9ij7L6E+PPaKiQcYy6B0wKI0fRUNNADGT1850go1B6JsGMYhEGtkkCZ2xlgWEgq4Fo2s5I3H/pMruGiEaIFRM0sSaSDAJ2H7A7/KHXgeEhU9EhsKrnkLlCPgxebdBS+IoQY= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by SA3PR10MB7070.namprd10.prod.outlook.com (2603:10b6:806:311::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.14; Thu, 9 Feb 2023 08:02:08 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::eaff:9f55:4641:db38]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::eaff:9f55:4641:db38%4]) with mapi id 15.20.6086.011; Thu, 9 Feb 2023 08:02:08 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v9 11/28] xfs: add parent pointer support to attribute code Date: Thu, 9 Feb 2023 01:01:29 -0700 Message-Id: <20230209080146.378973-12-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230209080146.378973-1-allison.henderson@oracle.com> References: <20230209080146.378973-1-allison.henderson@oracle.com> X-ClientProxiedBy: SJ0PR13CA0023.namprd13.prod.outlook.com (2603:10b6:a03:2c0::28) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY5PR10MB4306:EE_|SA3PR10MB7070:EE_ X-MS-Office365-Filtering-Correlation-Id: 372f48e6-aa17-4cec-dd27-08db0a73f0fa X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: FS5yd9qO8/Q/3oRe16TlqMWz3Q4f+rnjOJPa+ig9jmpELjMM9sAoQ+p3I7pBZXOCFpmh5cHPubsitGWJvbhn++Qo4hEOvXXReZtmmXdJ9h2ISFCm0tTKMWUdWI1JnB5G8lIdaT80yKNLiTZ8UsFUsFbOVfuhJ3I0yMM+18slv5KE5LKu54WqohrGCcY15bZnoLOF1eAm3WiYkaWSHF5yR+rEFsTChC2wZJkT7KvIGJP9Sg7vNAJ+u23bM53x/gO/2kt7AyzeLrzHQjIVFAUBnH7VaDFJSQ5sasKt3twGy2pGXmnilO58QOgwnqxkTsl5YYekzp/f73pwN+nSPLtaGzoOrzDo1zrJKuRXgsULlZmDO2G3ZuGfIstQOLQzKgUNEKqnSX+yYQZ5FQSvlnyETmBqVTVD4v4Tn4tHoWkyOWlZV/yz8/YD2qVpC10/O0czKruGQEa7t91gnc/DA83d7IHRZT82N3CkmQRrZRKhlJS2BPVCDC+JAtjJHbnCcYjw2smcoBq4S25gbdy2xSd/sCVktxZGCdF8M5WURIdlpprEqC0jsEOnHu1nTyHmwGStvRi5VQtt48dbDgJvj1JS7egJS2a5bvhYyaTi5I0jOIZGfYLKo54JbQn8rVoJkGl6zxNMb9n3NFD2Y5OR0ro+ZQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(366004)(376002)(346002)(39860400002)(396003)(136003)(451199018)(478600001)(6486002)(8676002)(83380400001)(6916009)(66476007)(66556008)(5660300002)(8936002)(6506007)(1076003)(66946007)(6666004)(2616005)(9686003)(186003)(6512007)(26005)(36756003)(316002)(41300700001)(38100700002)(86362001)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: bRbcoN3UxYN4b4KeshwB9/qvvosNiJRWXUSx6WVNOySFEZRD87lP6oLE+bSIYvNSrqp9zPt3cPwDer102W7SfL+HssWXscYKKye+F+OcpCSR7jLJ9/FUUYyF9bM6qTMIDl0l4K722zo6eSAlrNXlHGKrVJk1dOInA1eCv7du51Xi360tA+Y8eFrp91Wk6AkNIVSHGOlvPj5JAXoIPw+Cr8zBO8Lwo3/NOmd4bKiKeDAHD2ZnQF13KmqG4DgpDUIZt+f3CquOvpD0wxlNfXC6tkuIXWRbAPGKigqbGquVak4OpRMn8Lz3wBO//b4i0tAGL7tQT+I6aBXodfoRU012ElJ/LEvN+nWh5k3oMPWNba2VeCk1x9flCaKltQeJmxBb7hkOsvFTUvuVfg3E5pUVHlX6jUTrnLFzw2xPLeY4Ji/tPhzMA7EbLuM5ZH9ikcrJMaaTes7RkbGwGBbQd1AwyrIu2zWvL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/pyJroDf7JQVSZNIl9aQXH2nlSkK4NeqAHFnS+KYbX4epSoo0TKhHliu8nlbZnKw== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: Z0LG5dhyWINPKZACeAr2906GD3jtvQoLhEADlYN193vG71WAaFI8Qq3krU/EiTkt1jFGWXez8WRgIe9p/TZI67r5q2/FWvkSWgs/AOdSaoG4iePuJSCxUoBl64qU8ceZ1HnVLO2NR7rLPn4eVJ4C/PGd9XXBeovH1EQjYG+17YnW5WC6xfdQiZ4Eif0Rj37aUdTASgarKKh+tY+3VCrSM1IggspLjWDjrw/74MQi/sP+jPf8ee67TzuEJI1Q7yEcIRW6F215plnRVJsiSPpClGh8KX3WYwIUfvZZgvoJ0tuGTHq4cdZ4n137pt0+DygILVUny0F3+Wpm/OyF24kZsF7BaJE+Y/Jgw0+nbe5s0QO3gMLGQufRU+fSVi5d/fCH/dyuxFYFw6kzmuNh1VlQi1AzhsKfK6sGeHZEeH1IvRbwZtXnUtK61nA7N14Lp9tIm5VA3jxViemaJHEMxIoxT4893sq/MGMLm22lh4SPr2n0TLmuhDdJ07FV9EzBHGoKUZ5JwHCvT5Jc0pPN1b/X3fLXxfvwkIyv32etcCHKo7VxnCNBbkd7wmcyxQp7T3ZpCtXXGuPWHcRhb+UKfAX6IcIpeTexbznE71R8jNqRrD4xRJJhchjwAPg5hY4VuJ7rsxA8TBnb8E40VIAYYMFZDAas8MxGdQKOV5xmJVTFe5nkQXCCHKPS0h7BsbzJLjlLHUAGqoXSuCXVQUO09OSzqEOpqiLud6EkxP2tHT8cDuxyX06zXsg0jWng3bxMleCs X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 372f48e6-aa17-4cec-dd27-08db0a73f0fa X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Feb 2023 08:02:08.5577 (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: 7A4kUx8fbZXqKnA8ZkbTnTCyc6/+yOsYUusNF9RoiFZLPqaKtVERVafwFRU/Mc3xjDBIjl13Ngr6a1+VZkmcg1sKOP+3hDtq1MhdpArEQ00= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA3PR10MB7070 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-02-09_05,2023-02-08_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 mlxlogscore=999 malwarescore=0 adultscore=0 phishscore=0 suspectscore=0 mlxscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302090075 X-Proofpoint-ORIG-GUID: zS9U4Y-x9EJOPOuoXpmn_olo91HZx_Vv X-Proofpoint-GUID: zS9U4Y-x9EJOPOuoXpmn_olo91HZx_Vv 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 + fs/xfs/scrub/attr.c | 2 +- 4 files changed, 9 insertions(+), 3 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) /* diff --git a/fs/xfs/scrub/attr.c b/fs/xfs/scrub/attr.c index 31529b9bf389..9d2e33743ecd 100644 --- a/fs/xfs/scrub/attr.c +++ b/fs/xfs/scrub/attr.c @@ -441,7 +441,7 @@ xchk_xattr_rec( /* Retrieve the entry and check it. */ hash = be32_to_cpu(ent->hashval); badflags = ~(XFS_ATTR_LOCAL | XFS_ATTR_ROOT | XFS_ATTR_SECURE | - XFS_ATTR_INCOMPLETE); + XFS_ATTR_INCOMPLETE | XFS_ATTR_PARENT); if ((ent->flags & badflags) != 0) xchk_da_set_corrupt(ds, level); if (ent->flags & XFS_ATTR_LOCAL) { From patchwork Thu Feb 9 08:01:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 13134158 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 4CA93C05027 for ; Thu, 9 Feb 2023 08:02:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229722AbjBIICV (ORCPT ); Thu, 9 Feb 2023 03:02:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58638 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229632AbjBIICS (ORCPT ); Thu, 9 Feb 2023 03:02:18 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB10F26867 for ; Thu, 9 Feb 2023 00:02:17 -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 3197Pfpb003363 for ; Thu, 9 Feb 2023 08:02:17 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=XtWI1EIcxYzAAlrvI3LZLUi4XGR6A1SB/+X000AMgD9f8xswQJ0y4wIw2OEUBLRhoxGo 6xZqcEJDDqbKgLwiyh2kPgtm/W/vCPkgeWmeREOwHdL1j/ceEPFBCoTbjWGHKUikXqcK nvLg80p49vCmtu9+YcjRsbrqnMEQ7UCIiDJ3OjzFfDFhkFZmCdcNiJxRXum9povzs4qB x4cMqZRfcdW40FX1DHTVQGyNFXfe3C3GBd1ZJFIioqujiic8eQLxRomStGMNi70+5x1E eoqkF2hzR8TuLsbFC4FkUkmAfReH+iErI/WnHihWUfBusbJEBBsfDEyS+PmFSBlNtbZA lg== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3nhf8aa44b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 09 Feb 2023 08:02:17 +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 3196eBvF021294 for ; Thu, 9 Feb 2023 08:02:16 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2108.outbound.protection.outlook.com [104.47.70.108]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3nhdt8dv71-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 09 Feb 2023 08:02:16 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NVS0Fn5t/10oSNsmxWbMuXU12iC9FFz2Mi0+8+ry1gxOawJi+Ux3XkU7fVvCs+6TEEYNx+eFsmjAbPi5Rs+PeJmSROZhtcUAcAm2Sw5OvEv+aXOs7lBJ2SJOkblpA6tyQYZD1SDYd9jUlBa6OPoNMXBw+5kdV78hoWrMESdGeoqlcxBENjRDfh8ikI+Xosi5E+DzfI5vMEm08g2aMAL283Kn7HWKpAq0wammbnFnWfV5GsODJVV+WYZXCqbiaIPLx7bF0AVlGpcgAokBQqLNO+U2maKLX+zpHlhMlBoJUJdzG2w4lGOe+vwPjNK8ZaiQbTzGlVtX+SRlNRyCDVqV1g== 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=S/8DZa+rzCFY5Xlcb0K7wZBYZv348BNOqsWYVWwPPw2OZDPr0km2ct4KtLGacqyUpYN1VvexdkADTiJWRGo3rwS2ijJob3ta1V5ORK2qOhKZMX1K2g/84IxeOyB3IBK+8P36Oc1eH7ow0dXNYLFvuC5gcNCg4VYAA8LR6F8VQt7xbveUVlQqR+3qEeOZkf5ui5n7GP8LHh+EH68rWsFAnhONRcO1dIJ5MqblnM2/5sMI0byiXHY+ZDebdIGSgEkSPDK8vr2XYSX2gzJCtYsT2iUWjnAPDoARm93Y4xGN4JMTxDGmgAwylmw84fFdOh4uhz/z+hJxnLh6vkjDe1cjAw== 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=qrAyB5TaesIJMeLu0C5pIGBV8PRhqmfN4jJsuL7HzcXramd9I5XFyK/TcA7hDu3d0tIfoPjdwLE1ZOVaIfU2NvyMFyyfHZpwibGT+6xpPni0ALNEbYUw2XWcgu/wOYqxSCORtjMw7+PaqLtSQDbbxyY82PMSta6TDwTb0xPov+w= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by SA3PR10MB7070.namprd10.prod.outlook.com (2603:10b6:806:311::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.14; Thu, 9 Feb 2023 08:02:09 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::eaff:9f55:4641:db38]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::eaff:9f55:4641:db38%4]) with mapi id 15.20.6086.011; Thu, 9 Feb 2023 08:02:09 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v9 12/28] xfs: define parent pointer xattr format Date: Thu, 9 Feb 2023 01:01:30 -0700 Message-Id: <20230209080146.378973-13-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230209080146.378973-1-allison.henderson@oracle.com> References: <20230209080146.378973-1-allison.henderson@oracle.com> X-ClientProxiedBy: SJ0PR13CA0028.namprd13.prod.outlook.com (2603:10b6:a03:2c0::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_|SA3PR10MB7070:EE_ X-MS-Office365-Filtering-Correlation-Id: 8a6b22ee-5178-448c-de49-08db0a73f1a8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: GjPuia6MaqzBnZmhxtCPJxG5JjbzH/Pybfn1IALp3HB9Szu5gOSCmH7xFUkJnsq7izbp3pby+VWs7KRNd/YLLxP9ubhHFv5Ve1Xrh8pn/UvYiAMNNymHMld9Kz44SXlYCIPT8RhGsYn1qyuNsf2waAjfbxSMWkDDvfAj6VvTZ96d4tF7hKd5WeT5ptaiTMOkg5yFUqoGIp1lpNdXSxzvQwnrM2LHj9pfg2oRhudXVXE37imMxhw1hGAEbxhUbHPI8+l4StZDBaSe+INAk8kUcU1dt8IO06Dk2X8fDYDEnkciNGP6Tm60hJaLTgvcHnwrEJPT142Usoh19Za8qVGRKz4pbf3auXNYOgLKcyLjUKsXjG7yxMuvKav/fMgipNg+Xx8NfQHgg7WvJrrAbcF4eREjI1mlYcSlgYUVTXx2hKqay9kl1Ah/Yp46MvmL2TGmSVNqRTbjVPOxkdWRpS6zaiumts47PY8ABGAfpKiemome9mpN0P9LSpElu278nv/YGmSaDef5C/EpYrI2ZeKHtUjJ1kIijFo3LzTiLiWk+QLlsQ9sa1G7xcOrqE3V3D5IibEIj46aYhnyQyKM9+KLOl04jcCyxNhLAvgRBfgCFsEaWlHL9BWTAY3rSXDuGYD1hF9hpUm/p5M/O0vNJZ8VMg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(366004)(376002)(346002)(39860400002)(396003)(136003)(451199018)(478600001)(6486002)(8676002)(83380400001)(6916009)(66476007)(66556008)(5660300002)(8936002)(6506007)(1076003)(66946007)(6666004)(2616005)(9686003)(186003)(6512007)(26005)(36756003)(316002)(41300700001)(38100700002)(86362001)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: r1a3oJobhZfY1sVG5afnSQXaANgqzqcfRRQNURvNNHr+VDSGA7VGm5I2/3UFXvZlENnFsWglPJfFb72xIXAI6Ex9//0NQN02JCworv0JwOu2tX/tsp2EX9gfl1eqhcCjl8RL4AhKwKFwv0vNaFclJqmhRE1io8nKU3mNI5UlQ/qvVlZfaAx4w1qenngXYV5OxjuPmmEZpeX6mr0xeYVrhI1X51yti5Tn5wKac5F6Mq9jEhon+c2elLhP/F82scnivUosa7ENgYBiKQHCLoO9GBLHrc6z8BSvxHFhCe1NLeXnQxBDzL+9zdtVTSkcpmgISv8iomo0p554xtQ/ZpKhfK5dFhjkoKJbeyHMR2+mEBKhnhygt08Sd1/dPU16wA+s/eckAQrAjPjBZ7YmYPrMsNvXMnrv9vtrzwvuR1zPb2Bk74xS2L1yfNl2o87Ds70zNparNxoYe8W2x2lnl7FHPYDaIxBIRgkyQwIQssIwVYdp3SY2nEV9UNZ9rGe5TlsicUMeFGCDUx7GHgDhb9+6CfrzMLycGXXgAkQMo9uoMVXlR0JqdyYqK6Yh0YsV0SAV4Q6jcrgvwfVqbCPFZlwfsWGOEVtJNbWY0fejBJQxDI+wDuysRBVaumyaCWw8yiKoZzExjfzqB+xrzdum8mNjTJgm8fal6VUTIEs14cK2cIb2RWKFmyC1wopC8jS1tgdGZ/cFH0EDvqxHEg8c07GTTH2iqq2GHt0TR3ZHGfEc4zTrKSExLMBudvT7P07rK4Siy05Vyxqnj2XwAXNlpMxOxMaekylszBd1N1ucqWUKiAOr4NyC7Oet1VUHiQINzpHiQG95ZsFN6cA+JanxY7J0ArQfmQUi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Vvk8bttx8RwAPsDxKpjmaSZCQF3osGIlnu1ALLZkBqZLKraRyMhzkTDSt9ZR1bZpuWCROFo1iOmmL6ZaCNJN6v275XeiogHVsUSKaGmp8+ImZAVp7pAUDvT7ZRv5Ky67PKDy23FtrvaI/2yu0Zd/nRBGb6760lvp4MB9Vu6yMAbtLGLg7AtCV+2r9UA1v1kuiVc3I4UllV8dhcVhhmTHK9N5EDTc5+ytRDwxIRtyB9cXOlDBAfqAWBT46rfUwjgOz/QB6Ba6Dh173Lyw1Ww5c1jYeqfWmH55x+v3/1Bz8OqxwxuqXOayXjXh9O70wcIeiyIZwny4UKKCpskX2YdCdHr1GGxkoc4+fIcLeJ8x2ggncMxtyPGhDj7/4Y5gKRDXkJ8qiOZcfKnhSU54RkqFQgVYupJjE3wgpn28i+gmAcfhJNtiPOJaPNeF8kdUyuD5IQX1kZuzV6Rvk7TPYBdBoXboHOPjhp/o4DXuqQf+lpevgK9MAV/F1o3WecQIKn0nf9cOgPVGXyzXpxTam X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8a6b22ee-5178-448c-de49-08db0a73f1a8 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Feb 2023 08:02:09.6824 (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: 7vnKMXJVTCztkaUQmvdn8urlh+Y2dxkwiDi0phwar9HHj6mRXZES0k1W2N8h8xhZUW2oDgfzezBqJGG7CDhzgrScxZO6QXSThEF8m1DBxzs= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA3PR10MB7070 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-02-09_05,2023-02-08_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 bulkscore=0 malwarescore=0 mlxscore=0 mlxlogscore=999 adultscore=0 spamscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302090075 X-Proofpoint-ORIG-GUID: jOsqXyLg4YfRS8myWDnA1tU3yl0E0qLR X-Proofpoint-GUID: jOsqXyLg4YfRS8myWDnA1tU3yl0E0qLR 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 Thu Feb 9 08:01:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 13134159 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 ACBC5C636D4 for ; Thu, 9 Feb 2023 08:02:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229482AbjBIICY (ORCPT ); Thu, 9 Feb 2023 03:02:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58660 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229657AbjBIICT (ORCPT ); Thu, 9 Feb 2023 03:02:19 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 48170265AC for ; Thu, 9 Feb 2023 00:02:18 -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 3197PgdP024435 for ; Thu, 9 Feb 2023 08:02: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=6GP8mJBw+M/AN5gzsRzuXZkkeJob7qVdrYUi7TC2yiA=; b=lxvY9viKEy2ArbqJqa6VCwdhZoAuZNbYYHp3cwl7fphB1Fhk4sqvj7M8fmR7lu20UYOL 5nI0on/yTtCqwIO9ENw/jslvcTKyF4Tp8W7ytN9/boQfDYUx2DQmAegagKbHRPZDxO7a HY2KpVf3x51ZjnpvSOTIo5sv+h5RcrWpnkQO3XzhKRQWeZ6ZABRqYY/FwmltB1Mhq/ys xIrDAZjME17g+vrrg26Jfy22lK4iZXAh8MbI2Jdeqo+lqx4hXMGW3p5wzsXcwtMEBUoI p78juJW+I+f+RMqdHUwtwOOVkop5hzFPvDj5FT8AkjNUwQu1boQVKniCHe0YLB0GLxOf JQ== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3nhfwua2m7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 09 Feb 2023 08:02:17 +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 3196eBvG021294 for ; Thu, 9 Feb 2023 08:02:17 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2108.outbound.protection.outlook.com [104.47.70.108]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3nhdt8dv71-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 09 Feb 2023 08:02:17 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=j2o2rbQ1ZpTBT0IlYxhJQ6cO/LdVDWiYWzu6Y4k1dDAiBGcMFhggjNLWlIQOXI6QIJ8G+S5eAi7TFCi0avBTdPm0w5CNc/q8VBqrKT/fJvayWoLuiHTDCMa3t5aVLuWvijQ+KSPtvXGdE9kDD6TF3J2nYJRRClnf78Jaz3EP1c5n+ugeoFbqmjKLVqLV03qT094nzxiEiQEWC/2wKmo6hqqasHrFItGd4BHD9SLeEOYwHJH2LJqqhXtA6KbaJQhcEVw3ZkMj7LoJ+/KYoPAC2ZUN8QajJuI/H4wQrC4XbuW9Z7ICFqlDpomXr9hKwyapW4AKiGUg0vBAYSkr1t2Yeg== 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=6GP8mJBw+M/AN5gzsRzuXZkkeJob7qVdrYUi7TC2yiA=; b=IQ3qO1lRZSimXqSPPGqffJNCxL/bktHsXGJaThCGY7OZnOodXmKHp9KN8PKHohUOTPc1kQt1Ec58jxw+vyBW10oQY9c3o8Zb/Ux3xf4Yqek7G+A2DLQ+B5GVF/Z9uBKC/pbDTWdPFnFq2i8VcpAg38fmTxhiRooxGHkOpE5rrUA8Sv4+vyiR7g5+WbD+FpPsHu3TJlkM9cOwNHIBlYDLolhY2s6ChZgrhh8MrBFJwC7dtM8JxAIpR91ginm5Shpudu9jjwRV4ZEILn813lI8eIFaASt/WUVACr8U+Nnr9masasTCdss9MS5A4r5wafZnKdW4MyNx9sWkx5D+XZSG1A== 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=6GP8mJBw+M/AN5gzsRzuXZkkeJob7qVdrYUi7TC2yiA=; b=aspmw0SFyeVO6LtbUw0f/xxR/nbyIjPsSZVDMiqobsM3l97EbHuqO0TDPEbAzmBtBSFZq0YY0NLiY+UHl6WRmOpX2WpBX6auWcqdd3jl8s98uASDg/ZPBgT6P2WNE0b2GXZ3ifF9jg9G3wiDEqdDmUFZq2Vx3TolKYg10ee4RTo= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by SA3PR10MB7070.namprd10.prod.outlook.com (2603:10b6:806:311::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.14; Thu, 9 Feb 2023 08:02:11 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::eaff:9f55:4641:db38]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::eaff:9f55:4641:db38%4]) with mapi id 15.20.6086.011; Thu, 9 Feb 2023 08:02:11 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v9 13/28] xfs: Add xfs_verify_pptr Date: Thu, 9 Feb 2023 01:01:31 -0700 Message-Id: <20230209080146.378973-14-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230209080146.378973-1-allison.henderson@oracle.com> References: <20230209080146.378973-1-allison.henderson@oracle.com> X-ClientProxiedBy: SJ0PR13CA0008.namprd13.prod.outlook.com (2603:10b6:a03:2c0::13) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY5PR10MB4306:EE_|SA3PR10MB7070:EE_ X-MS-Office365-Filtering-Correlation-Id: aae65cc1-4123-41d0-987c-08db0a73f28d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: q5AC+x8HGKnQekBVWe81WGnjeopnyRvg9cI3GMVn0bDD3iIzf3nu1Cv1U9mqPBFYw4LJk6WUNpeZnJE9GglS3U93seC/PB6RpkJygALnvQ7kb6net3WEcIlxC0zWaYta6ed67WqjIuPX+uVbgCmlDjxpFuLI+8NOVGXT79MmNUpvrc6kL70Y13PNrPIc7qV0ofutn5jmQM3/wJgGUvxKoHXMXyYu3MKsenDlyZuCnqb8uhsQunCMcj7m45wJMJthGtHEGtUnprYKd7rE003JCAIZNMtTnGAh9/8apyHZsUqqATYFVCHhHyuPlWN5bbFqfT9DJqM5a1vzH08SK9G9VHoafzU9EEm61L9T4PPaeGdeAltLuS/jLESrwiIrJqnz3pqHVt1K83LOI29QVfh93t14Tyaj3l3tKnc/T28jZtlOehqHVIc/eScNreCsZKuHbpmO38ON8lCwL3nNCy68SRODaoKgMq8OaN2wMVBhiOHZG6tIgESDcAnXwK24VkqKbyprcyF7yhRieWfKpDwfx+diEaP4mfeLRH3wZeTo3j3VdfGbk+j3j0Q96jF7RkDF+Vs7GKNzU7cpgDAMrsM5Jfs4B74r0WQUnzoqpXdlEHy3jnguLy8XvEoH9xTMkir2aQhw2jo/oWpsiojat6iZZw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(366004)(376002)(346002)(39860400002)(396003)(136003)(451199018)(478600001)(6486002)(8676002)(83380400001)(6916009)(66476007)(66556008)(5660300002)(8936002)(6506007)(1076003)(66946007)(6666004)(2616005)(9686003)(186003)(6512007)(26005)(36756003)(316002)(41300700001)(38100700002)(86362001)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSp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sx0SJSUNEgEtLRdIuTGidU4ahp3USldSVleZbjXtisY7+XYE7WTRSbf+6Jbi7DOMsqLyhbG63Meij+qH2O9BiuYGKb5Wc/AkNg7H37ItJxanQdNSGCzMBETIomxc4IV5alQLc4h5SGymwj2Wx/bRBXkUizPNVHYbDQHGff3R+VJUs6I7KoHquzb9oSc8Pq79zKSEA/VeAJkIQzsOfJC+cDMO+doYk1gkqNgldLAkJRrdTtYrIx+5YMPkCGh1tPlMSswI1uMlfRum6rBUknx7Ka8rjlbXd00q0zA5uUw4bOc3SBLczGqARKF9C8OXBgDavmB8/Wvq3TlcKJEkLE5kximU6yDDROXTAQFUx9QbIRJnQma5IsdhQGsa+EYShsdROw698fYRBew7ISDfQNXhyY1KIZ3zQ3/IxGt25omTd2YM8UOSMionEi9K0pDi9cHrKNXbKCXiZTCEToKT0W0dvnHLa7ViyWVK0oz/1jzzPSPI20yYkpbDHAbQJAY2TJZV75joeZv0tuxo5v9C5/T9parGnpiByviaRuKHs50RIWIEDutXQ5cE56f2/9Y8p73dCGlkwz0Qiisng== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: ordu6Jsr1SF8gZJwRuq5TWyy6SnPouqRgL7u3eqajFFdC5a2Kzldyse3wozNoElNdkXrwguv9IcP3qlEurS2izikYJY6tK4V9/RmbLlgsXG1OI6EhtCVlGgTqQQfjze06b+5CNsuPWWxAU0j/S2E82Xl3HufiB8myzPu9d/lKPtU2Cy9/H4zQ/M/q9yOS8U2y8qCyjt3OqOxcKX5OZ5lvUtMTwzcniD6cxjlwwElqFt+pHpELqWt9srHC8dY/F1ThQQVNIKqJ6sWFlZeyQpnlWqWCSzlUDHzz3aqscwTpch3XbB4irquF6NWiiClDhj8v2XoQC6Iu7aSHpd2kJ7fhjB85o11sJLtRB7d9L9XJ2R39JDWFwUSLcNWkmCFyTeKfdbmONLDT1nSGWAdDySguMMjvJgnIbHgIcIYH/09h398HpG0TqQfELF23JRk47gxAZd0RvbUgSf4LataJ+Uxw4dSGH2VNMX6CIpjtRZL/niGsnVAKKaRd5VZtcTVudPalHvswNsc15chp0dmgtaSJf8fgTu8Y6Gs0V4bW8TMD+ACgWjQZhDcUOvILQoFZ1eIi9pSn0KgP/ejTWaZdHv+jP7XPE1p3yxPcJvLnNoPN8cBGXFtmI+jcIDzPJpm8kH/HPxbmAkioMbtEYCcLvCveEmtRDS9eWcGpyznAD1k/To9bUooYaqAXiv9tSkU9DY/h1qBar7MkkqeKxT7qEyE/ch8lr2+ESf2AiJNSq086H4zkruAQas5fiQmD5eAaSce X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: aae65cc1-4123-41d0-987c-08db0a73f28d X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Feb 2023 08:02:11.2126 (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: zDngsYmV7gQ1u/+Tlm+jSsI4UCth7aFm1Hs7h6rzywSdqdc8zDaLWfZpuz9BsOtYmNft0PZuULVFd26tuUj2jK5K94iqBslXQmzLpxhoJvo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA3PR10MB7070 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-02-09_05,2023-02-08_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 bulkscore=0 malwarescore=0 mlxscore=0 mlxlogscore=999 adultscore=0 spamscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302090075 X-Proofpoint-GUID: fFUKXOeMpQyvfwJogL5toU2on01xSfE2 X-Proofpoint-ORIG-GUID: fFUKXOeMpQyvfwJogL5toU2on01xSfE2 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 9d2e33743ecd..2a79a13cb600 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 Thu Feb 9 08:01:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 13134161 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 6D63BC636D4 for ; Thu, 9 Feb 2023 08:02:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229516AbjBIIC2 (ORCPT ); Thu, 9 Feb 2023 03:02:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58674 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229677AbjBIICU (ORCPT ); Thu, 9 Feb 2023 03:02:20 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E10481352E for ; Thu, 9 Feb 2023 00:02:18 -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 3197ProD016215 for ; Thu, 9 Feb 2023 08:02: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=6tYSEWWb1wiKYWw2+XP6sFmWvJlNNBn4jDtZsPv6VNo=; b=xbFkwo+zBUSz7MXZmDpmql+4vIa04RNqs3jayeN8qfwS9TnxhhtIqGAZgfbdOFlg1cpz 3BM+4AexM4U/kWHojlcogORaC4u6h3JVLmgo1c0AHBhx8JJ29ASB2NG1zqnpYcgqZZ2w Cbnf8NdMXzdgpZqkm9bR2IGxMms6rFFNhWqtYXJa6vkITs6/d1ZBlbGuotl+qE7DjJzA /bFAZzOL0FLDRqz3IVMCtUgdfFVLw/tuJiEbn8bmMesgxzEgewEHP/llwkOB2ELfBRVP pABNQYAE0B+en6gTQBSHnD+tIe1Zf50i4Hsge2zErY7McnOVdMVkeX927XOlBPivR1Vu 9g== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3nhe9nj4du-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 09 Feb 2023 08:02:18 +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 3196eBvH021294 for ; Thu, 9 Feb 2023 08:02:17 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2108.outbound.protection.outlook.com [104.47.70.108]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3nhdt8dv71-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 09 Feb 2023 08:02:17 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Fpu66uOXbJQn4eZexV5bPmNJh3G34Feu1FOXJxjVYX0ZngwFNc2s5P6PgQ+3oNaso5FeGsumFb2zYDwUg1gzNhEp4cVbQqwd4SZ0ECETGLr+djqdPmIle4+5Kp7z+eXW+LARv+g+BQ339iicvjQZ27KgWsA5tQOEvup77zQ+RZbU16RedjAbmpmp9wKS+I31Pt41hTBiIIi7PenFChCVSlsrtYuWSox66HuH6a4ubYobIk9wwoBUWKIOvd3YsKDjUjVfLqD5zowDL93v5cwqDhFENMFFUHX0/PsQWoRWw3ErwK87t4wWPT007HvkAP+D/jRdXQlxWHdi0H2NDxXyqQ== 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=gdgH22st9VCNkAR7KKadWhuz7YAzcLnjOOKMt64R6p1B4595mmJQNX9b5k+UBvVm55zNiDVFX7NZnPzwfHS+K08XU/euWaBOvfs0mvXAVDYQDSov+zXb/CyYqBQ5hT1baipvzADVAUtc4nWTte+tqBL4p4dGMUujOUbzSRDmk7st00uiP99n5AwthNq33TjfgE+P1DyrUhhSftbT+WliWSy+wGhzveyErObyuYgxbWd4kL9DNRCqQuOSAR+Ke5/2e2UE58idMSHZER0OMAtC41ighkVEsWgURgDg9w+7eZkmAkt7HoIlDJ8lFwGdiT2ttgrDlj+uaoi6ZkG5R/Ylhg== 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=cAidFhvzGxosuRIcwFQXap93/R2QB6h4u1rmtUKwe61NVsH2rlI6WLTfyVu1lSVthQcYP3QhBwluG3qTXcVVG1BcJYiDDGcFEedKpxS/MsM+ddfEfkyXQH0vC5fn3V0ZAvXSzUX6ztVZuHOEKUkV5aFiTflfpdt3k92K1w6eqc4= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by SA3PR10MB7070.namprd10.prod.outlook.com (2603:10b6:806:311::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.14; Thu, 9 Feb 2023 08:02:13 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::eaff:9f55:4641:db38]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::eaff:9f55:4641:db38%4]) with mapi id 15.20.6086.011; Thu, 9 Feb 2023 08:02:13 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v9 14/28] xfs: extend transaction reservations for parent attributes Date: Thu, 9 Feb 2023 01:01:32 -0700 Message-Id: <20230209080146.378973-15-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230209080146.378973-1-allison.henderson@oracle.com> References: <20230209080146.378973-1-allison.henderson@oracle.com> X-ClientProxiedBy: SJ0PR13CA0015.namprd13.prod.outlook.com (2603:10b6:a03:2c0::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_|SA3PR10MB7070:EE_ X-MS-Office365-Filtering-Correlation-Id: 12cc31cb-6b14-4082-f2e4-08db0a73f398 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1t9T4CCI2MgBXJZCSTdjPe2r3qraehg5cw7lKv5dM+ZAKwAQpIwKdsudVlR2QQIWRlBVR7tiKT2vw9x3I2Tqu8fPJM6UvKfl/enFcbs8pypyxP48V9rvdozDjPFi7dRqehJy568EVumU8qROQSIQhpqWuaf4zn10KqryYqsc2X+xPzRR6g65e7MFsaASHtgKBdj5zlM/EuBm9pzy7NrR7H9pIAtyIz0L7gZG8M76woomWiT6LLyD5WrQQ5oQ/+5eVnycIzOyn8a6obRVoKjB0UmfZXob0nxLY+Yb8ltRjwEtBrcRjo3v0XGPec890jZ1WBGvHhlo/deAY5eGiydKKYIx85f+xsUeZAG6tdYJT6fj8LxUpnzuP8oHIk+keseGBYsPsjZbp1M1zoomNZE1TU0zU3m1UWcCsZw5vMLosARkRhTDtNLjiEd22WXs3oYJx8nJDw5Xq2vgyJiVZ2EnaXO+qvNGG7e8EHauW/nRt2thZRtnUd2RY3f5awFj7r8ctXec8b+LU3E62RKrURlzPrez6K41Zibb7FFB10n+ZDj7N91MOFmrKJMihKFUYfpKLo/aGU2DMSsWg6UZVIaxxmkKetweK8sSCXehcTcrnKGw4GywwrqatE1vFfffoe6C+hsYHpyFUFukRTgdVuZSeQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(366004)(376002)(346002)(39860400002)(396003)(136003)(451199018)(478600001)(6486002)(8676002)(83380400001)(6916009)(66476007)(66556008)(5660300002)(8936002)(6506007)(1076003)(66946007)(6666004)(2616005)(9686003)(186003)(6512007)(26005)(36756003)(316002)(41300700001)(38100700002)(86362001)(30864003)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: MCiWva96aPnc0szPjVxJurEdaaKoqjb7/2TE1Ic01eJ/MJEAeBk2Ca8H8IrFy9wpog4p9xW92JYz0GVnXnWf9ySVf1QlSLpmt0C+cYdOby8DFsY+9iNxp8OWLp6DDIwO3Efp1Ksw8kp0OGKN8kP3GU10mqhU8u92iwijqCACnlZ1ALCDP++Cec9Tb7hvdMJoSNO858tQFCIJ6bLJdfI1CCb9oNnBwG08pxPmftiGS5yISjhyVZiLoLs3BQXiLNiZxTpNVMGgzyf15RIss8MfUr6O5RNMB3vybvwIjP5i3lfEwSQ9dGmr3gb+yQUf2tFMg881cfQ6cmBHBat5HNAPgas8yZd74ksnZGjnGLevBO40LA5lXeKnfKeO7KVTKruAlr8i0j/Gd7bqDsPernWzph3I6XXfavxCnSWMngPfpu2T0syQYSlvA2XS8DsW1H1s7T8kR8r5HRa+ahvzfA9G7Vv3vbUn2poUgKJOKC7BcrRFDKzn//6M6yHzK8AyrwsiSoqZYsfuhX4xCAGE6mB+BjiMNxAw850WMO1ATybjYzqwxKaMUsAZma/v7Z2tLiYZEFSQEKcC+alW/1nMJvsegWwa9Mb8qzua+XcJvUQZN8zoXlU4poy2a/FKKedVZTAf+0oIsM9eAlTvFIyYQ1m3IRuqBVEx5T7sG+5M3o9uS92qxzGfrno7ZqJ0pY7JMym8w3bT4yReVGOQBO54MsKYW5gQWApBUgC6/YWU2mkcS9A+oPVmzTEowofAiQEeFvllODHHXlcNBPHsmOFs2cK4y6cQFQU3LcWPCgnA+DJD2uPzXglyEUWM6sv2u4bAW1VTwyNhT483siEQopGN4ptVPxQSnUt0QPdT6uLmyRxKgS0PGPT6KEWGRW0eexOJ09DBTPSbREdy2C4JWPQkaWo1L5MVY0E8oNVa8U+5rNiJGsdP48QtZJhDPUNiw9jYpENieynKU5NJ8Z3z62gmQZODnXy21Hwm0fxNmkBWxsTlcY9sMIZQtwYX+ykXrDwky3fLDh562WY3tWLdsg92MUuK8knOtKN341w+JjuNol7+0urvPgr5Z2CDC5jwhrrnbigYtZfM+Db3idNG9pLPwkOAjgQsvtj5RGhbqBukGCzcBZKWeHVc5huIeUsXMs5f54kOx/nr43E7NVlU4H1P1f/gqnuD3zNqaKPuD6T+KVWvkXOvI10NihBRmrTyMCMO4Ys7GUAJIBHwwaWkFpWaK1egegnQ95mjhTT8qB3N4Ez6ituYOduSYEoG+uZSBjBPP/MDreo3DBrI99iiCJPAb5bOFGw+YZKlKkUIHE8GluRSmbEELgBylZdzbNpT6bfq9vxq+46x/DVDCW26fktcV7/1UZZZwkq01MjcqIqkB9q0yhDmXohf6OIpSo/dx9do41j+MuLucxahjTPTVeb5G3NdZeSglNM8+apGGws2Rb93QPt/BD5SlViLIt/bn00gac5QMNQZmIN8FWeluORmglAUo4omu/FDfxnFw3iSWx7vpenBdaP+hTrJUAOKTVvebSYUCPCF3ZhWONm8dt25vUAc3+GrTWvfip94OBaQQyvzed1D+ztWOI0JkT2q8mAwGgMXMipxYzGoZy7dZtmpHX5zSQ== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: NiSDBsRETpaRkI/bbxV+knyTtoapZTrvsoS5YNTd19mezin1FeqyuQ+rufn66syH/yA3Tm/dVS3+ZHLJ+sk/T72f6FWfJNLVJYLfQTE5oJsT2ztzr6lTEfNzfzVR23FxSL0ZnbHi5/2YXa92t0B73T1tpV8cLao7iVvateKB7M1q00XD6xeUaNoIB23EwlA5OI8OX3L/Wcn1yeZNbfj9PVdHXh/zlRIQPjL45U4ZHccigZ+NW7g0dfxzb45/d5WUEORIvRpIXGpgVwsynhmxMxGmwZiWBt58JtiGOcbUe2QOy15vTIwOlW52A2pDYRuwSdmOThAIqgWHz94CaaqY1DEzV42F7YheOzi3g73To9nPpdLttKN2UBWGNusNUew4dU738fVQXyaFERQGLxAGUl5FLoxRmMIA5vY7Z37s48tOT+Vvk/XeqOokglQ2BWyUoiO4EgsQ+Opbm0VM00uLu1EabZYB8Trug/px52Ap03rayeH2N9aNiXFZumdTpx7LLI90D/a+SAUOvgM2DHOLryB0CSAz3fq/lU5txL161FkzimFWE4qIrsiLc4O0J7Ahu/Jo0TaKpcu70hKQEfJe3jabyMIuQA1YliWriuE5bLfiMAvjaCSxSLz7ySimogHzdmIfdbekNu+LJCgrbvUk5H149f+OAcPTCOdUAPgjC2IV2DLaIoznRGOt9329t2S/eyiCiCvmgUQ5gk40rz4GUpfZKZN307KPFVpUhAWUhfOLj+/kBHuid+piEuRglSnK X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 12cc31cb-6b14-4082-f2e4-08db0a73f398 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Feb 2023 08:02:12.9804 (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: 0bWo4JkOZ9SkCN+R+u7kZ7hppVeZpWCto70PVRG8JHXcpABC+0iFpR3H0FjE0xCl2kNXZUUWsgVYN9rLM/EZk35cOgM6YFglQCx5qi3vr2k= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA3PR10MB7070 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-02-09_05,2023-02-08_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 bulkscore=0 malwarescore=0 mlxscore=0 mlxlogscore=999 adultscore=0 spamscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302090075 X-Proofpoint-ORIG-GUID: 2RZCLRKJRKhIveypMEc1X1jeat1lz04b X-Proofpoint-GUID: 2RZCLRKJRKhIveypMEc1X1jeat1lz04b 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 Thu Feb 9 08:01:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 13134162 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 E8A03C61DA4 for ; Thu, 9 Feb 2023 08:02:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229634AbjBIIC1 (ORCPT ); Thu, 9 Feb 2023 03:02:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58680 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229701AbjBIICV (ORCPT ); Thu, 9 Feb 2023 03:02:21 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E1C32CFDE for ; Thu, 9 Feb 2023 00:02:19 -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 3197PkhO003380 for ; Thu, 9 Feb 2023 08:02:19 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=lxvfLUw4TO5TFIw19Rc9Ae41y50Ia4JlxYiv+rJVvrw=; b=FxsAfxfA3z8WBrKLact8fsFduW0NLb5fhrCaNyAn+5kkMLZpRIrCKhIRt4lkuEK5rSXa Jz6Jclh7S6b99Z4ZB1o4O7Q0EAGshmpLJFSaDP3AjWja8BjFmt1SWFxFk448Xk0VfDOT pVpW8TIyqOrR04C74jf8SkVukmzqcG1wr1XV70R0hFLaBG+EqbM1PKUPzdUBqsygxxgS BBmnpB/fqf/XLJtTT1XamMMvm/BeiXIfFoppgQGbOjfDwN8XQjOpdvKxeCAQsI6rE2uU 4DSS/URDP7ZmbNJXk8irc9seOvCrYH5KyMWSmqi+nLwXcHw/V/igwcVjyEEqzknAF3x2 Mg== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3nhf8aa44d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 09 Feb 2023 08:02:18 +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 3196eBvI021294 for ; Thu, 9 Feb 2023 08:02:18 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2108.outbound.protection.outlook.com [104.47.70.108]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3nhdt8dv71-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 09 Feb 2023 08:02:17 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=APWVWlE1//u03JKhhqha4tRzGEDhcqEsQ4RhHJdu8Bk3T8s3KzPVJri0g23voXDbUI0j1VjirI5lISXW5k3vGJkl8UStQVNjfUnRoKSrZg6hf+NDAN+U+draB+1HhIhWaAEwcYGmptWr79s4hjjuP+gME+f99iF9IIJP/hVxRnMWv8QUjv2yPLKT1sdJjihhDEo8aT2nFUlndaRHpOKFCtabgxaXxASUcxpeITDEH9X8WFV+uAQ2EJXAczswqoaTf3Nx3zGYuowVOhgeNRuvi/iS0Fx8cxmTLlg90GEsan0EdBYeUv8Tca0WBOdkArnHCxpgqw+5GdhX6AAjbMcIVg== 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=lxvfLUw4TO5TFIw19Rc9Ae41y50Ia4JlxYiv+rJVvrw=; b=f0dIuQXlDp5woc9GG4q8uJ6Ac+LG4I/7FKonpA1HpTaBIm8pH7QTYNBvpSvx8WfcUqHQ6uSuIZgIVi6WqtYfhr7uOldjLua72w/lHBYqHhntInGiSwYofB5U+M85i7Kg/aIEmpET/T5JQRABRacDsp2TN2WEzNFe3MQt3ssvVM+O+fLh0hxGz+dDGYkdMvRVPlr0VPhjC5caZ7OIWsxnLgI7jP1MlE6GFdhGgh6RkNEKhpLBLfxO/hG/9zPJGHR9sMwtnZwcnYcxtX8/MylmGtEWVhEqJb3UfSzmZEaS8M2mrHxBurujeu1klILwIXqkWh4I2w6GB/9NCyLd8f2oPg== 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=lxvfLUw4TO5TFIw19Rc9Ae41y50Ia4JlxYiv+rJVvrw=; b=IR+2/Ngxpk2zG1uOYjGwhs8c10BhJzztDfvnENxX/5nMCP4FfQ18KzymgcQvboSuwyPUzlsL7ekRyIG+/sFftNo5j3Xo/0MMPP8hGooCk1qV9jlI2rPHXbkZMLVtrJyiU0uMdGoGsf3I62/tBlnE8BOjacXSRaAOp9O9g9tRAlM= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by SA3PR10MB7070.namprd10.prod.outlook.com (2603:10b6:806:311::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.14; Thu, 9 Feb 2023 08:02:14 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::eaff:9f55:4641:db38]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::eaff:9f55:4641:db38%4]) with mapi id 15.20.6086.011; Thu, 9 Feb 2023 08:02:14 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v9 15/28] xfs: parent pointer attribute creation Date: Thu, 9 Feb 2023 01:01:33 -0700 Message-Id: <20230209080146.378973-16-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230209080146.378973-1-allison.henderson@oracle.com> References: <20230209080146.378973-1-allison.henderson@oracle.com> X-ClientProxiedBy: SJ0PR13CA0091.namprd13.prod.outlook.com (2603:10b6:a03:2c5::6) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY5PR10MB4306:EE_|SA3PR10MB7070:EE_ X-MS-Office365-Filtering-Correlation-Id: d21ab1c6-18bb-4092-6a5e-08db0a73f493 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: t5jNZInnWCxFNVE3Tut9UPMbQ20ortIJhPDvMonKRBw0UMLNuycWZccYG+cmojj0fiAoJA2EnDWzFlLuD3koR9pTWeFmuA4qlpVgcmSTrtTEtMINRIKsVudKqH0Spu2GFd6P7mzsqs6pecyywkEEXmgypyOoqF6onuErjWfTfGI8/kbLrvTxZKT0+pS075Ik+mGpeOC+/Xuu8wbBH+EkiFgF0OzzjIp4OKZm99G/+z8+eiqbjE0x1fVVV5Df80D1mnsI1v+nET+MFEJKR+OLnISkfHxS6B++e3dKTqhpNQ0sEWNEGMgA914nE4/Tgh2BnI+kN+a0UnqyyBap6UG38uU1p0KPmhiZW6hBx0a55xfLlL0SP9uu8Q2gKnskqCMa22l/vESAhKfF4gxoPwICPoEG6+se+Y7h1kPS6sQ6hcnhc4Ocow1KnTwzrUO9n6XkN6CY6gQH7ZwF9Rv+bPppDo4FThBZy2owLQn/rgnE/kttgJED2Sbc8UxndIXnVqHV2RaSk4nApoSH8+v4VkaYIP1Se9gH+diDqJKiqVPnQ2ftqxyK4HdX8/+j4K2UrKHHjWjeOfmYIA8us7oes4XBPF0lniZyqxR6xhrD4EjgvJgXthq21Nic+wQ6/YMR1TGAmtYp0uHruYlpdnpEX/PLvA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(366004)(376002)(346002)(39860400002)(396003)(136003)(451199018)(478600001)(6486002)(8676002)(83380400001)(6916009)(66476007)(66556008)(5660300002)(8936002)(6506007)(1076003)(66946007)(6666004)(2616005)(9686003)(186003)(6512007)(26005)(36756003)(316002)(41300700001)(38100700002)(86362001)(30864003)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: MndwmCXE9w3nY3UEmU7PCQWouizRIT3btYu1kPJSReJzA3+VsTfTcWvArwbnalN6ykCoCJqpxycaJxoKUqb6ls6CHXUVXJ4LfTkq+yifWubvMYQnM03Tkai79Wyfj6umnNPCt58L0sK4aiHiKQnUkP6/Es6WjaltqBUgVk3SeU+lhLti0CHTh5iPFGqsbdPT4qBiLf/DGhf6Go/gNt1ItjRXz5/w61S2qc9ABmFCXdzvOUHy13GmB6WdW5okox4K9PPK8MlVSq9CNFJwS5nVUMKOjPRCrJlNNc8dWCvqxpVFzivv4pscdDViZo6iTwb+X040c38jdf1PrlgSEFbTAn6Izh5jM4KOFDMGB+1XvX+8O+J+Oiwm/6bwzdOwdiq7Zq+RVs/9AG26s1/aFd9QvUNvnMAoceNGk7NVUdW4TkjcUb8Y19ldVuMRR9a4wXuS5FQXWBLFkYR/eAfOgUykIvLkHWz1h3/Gjm8sLSqdIXH0952qW/il86rWwFhCsPwFilE1xwB8nbh9HgWQo4KkZJpBY9vbLV+rmycWAy6Kkzm5iu5LFM1KEyPN7xQfQBCO7I0+yJPWMWzPXBdhvHFq45Vvu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Exchange-AntiSpam-ExternalHop-MessageData-0: vY8MuvA5F6NbJuDXZElrTZpLNWJKzk81XpKjGm6ba3om4FwIuEJqy2/JnNYVicRkepBWVkaip7J+CrNjNiFD7GgzvaZ9SWgshPaXCCPW8acnbLmfXfbRwV/XvAMh37rmJZjlPJbBHSc6Pc6FnSkeuZjl/X7RJRdj5kJyMwu46967g1IMkDQFFFlh2xPqsmT+3lxf3sKu+JK6zfaB7DGCefzf31+MqxbEHjjHpqUG/s/jkOotlPPqj0cbJtMf9eZ9SzBVLv0VR9xHliCTRcoz8NPB1aB3ML9eN7ffQGt1AGOFP1JLPc1iGGIEYB2ed/tevzo/qgWZm7u5B0rmADb65EJlMnY/4WXi03iCSmfQXcRBdJZDsqia2bz9Gc+qQafB75sb6eaWkheDE/8GGnhRhmlHXmMncFWM0hvcfzEJxIZHtNkyPiS33PrIe0DvUuROUyjkVO7TVoxE2u7pCS7wytSs0rhz85t5R9s52fPSmrQAewaDm+6vOIPmMPZrTzVSboUw3bFpkeCnIvNKK6Kmrdw9ZfnOkKaeP3LeqkYwH4DeMeSree2PPw8PKlBTlOzcqsjjUVdl84eAPhs2WFQxQPunwEmNWzJKrN4gm3Ded51v3pV6wKz2sIrE9jUXMyKnUq4FqgjulDMaw9tBdTOQWpdwbjNOSNOW7iOUc8K1KC0A2cmKBnUJtPvZZ4Ldxd6t1Z9d9m9eBp/DCQLLAhiO8KrttnK436Ai/9AGUQnRnm4nyTJs0CHbQtv7dCSeOdj9 X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: d21ab1c6-18bb-4092-6a5e-08db0a73f493 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Feb 2023 08:02:14.5751 (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: JHHEwyOq6zosgdqL4B5nuTVwWaHcxSBBV6HVdHvi1eqQP02ktWIY5V8KMUPH89t9+9W9Xw4WOmB5U/T5AxM4RJRmAL5d5ZEicm+NkmidLt0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA3PR10MB7070 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-02-09_05,2023-02-08_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 bulkscore=0 malwarescore=0 mlxscore=0 mlxlogscore=999 adultscore=0 spamscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302090075 X-Proofpoint-ORIG-GUID: 1I4sKtyvAcSxaF9wFMVGuvQ6RTEjgsfh X-Proofpoint-GUID: 1I4sKtyvAcSxaF9wFMVGuvQ6RTEjgsfh 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_da_format.h | 12 --- fs/xfs/libxfs/xfs_parent.c | 139 ++++++++++++++++++++++++++++++++++ fs/xfs/libxfs/xfs_parent.h | 57 ++++++++++++++ fs/xfs/xfs_inode.c | 64 +++++++++++++--- fs/xfs/xfs_super.c | 10 +++ fs/xfs/xfs_xattr.c | 4 +- fs/xfs/xfs_xattr.h | 2 + 10 files changed, 271 insertions(+), 26 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_da_format.h b/fs/xfs/libxfs/xfs_da_format.h index 75b13807145d..2db1cf97b2c8 100644 --- a/fs/xfs/libxfs/xfs_da_format.h +++ b/fs/xfs/libxfs/xfs_da_format.h @@ -826,16 +826,4 @@ struct xfs_parent_name_rec { __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__ */ diff --git a/fs/xfs/libxfs/xfs_parent.c b/fs/xfs/libxfs/xfs_parent.c new file mode 100644 index 000000000000..6b6d415319e6 --- /dev/null +++ b/fs/xfs/libxfs/xfs_parent.c @@ -0,0 +1,139 @@ +// 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" + +struct kmem_cache *xfs_parent_intent_cache; + +/* + * 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); +} + +int +__xfs_parent_init( + struct xfs_mount *mp, + struct xfs_parent_defer **parentp) +{ + struct xfs_parent_defer *parent; + int error; + + error = xfs_attr_grab_log_assist(mp); + if (error) + return error; + + parent = kmem_cache_zalloc(xfs_parent_intent_cache, GFP_KERNEL); + if (!parent) { + xfs_attr_rele_log_assist(mp); + 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); + kmem_cache_free(xfs_parent_intent_cache, 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..d5a8c8e52cb5 --- /dev/null +++ b/fs/xfs/libxfs/xfs_parent.h @@ -0,0 +1,57 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2022 Oracle, Inc. + * All Rights Reserved. + */ +#ifndef __XFS_PARENT_H__ +#define __XFS_PARENT_H__ + +extern struct kmem_cache *xfs_parent_intent_cache; + +/* + * 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); +int __xfs_parent_init(struct xfs_mount *mp, struct xfs_parent_defer **parentp); + +static inline int +xfs_parent_start( + struct xfs_mount *mp, + struct xfs_parent_defer **pp) +{ + *pp = NULL; + + if (xfs_has_parent(mp)) + return __xfs_parent_init(mp, pp); + 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); +void __xfs_parent_cancel(struct xfs_mount *mp, struct xfs_parent_defer *parent); + +static inline void +xfs_parent_finish( + struct xfs_mount *mp, + struct xfs_parent_defer *p) +{ + if (p) + __xfs_parent_cancel(mp, p); +} + +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 a896ee4c9680..ba488310ea9c 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; trace_xfs_create(dp, name); @@ -988,13 +1014,17 @@ 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; } + error = xfs_parent_start(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 +1040,7 @@ xfs_create( resblks, &tp); } if (error) - goto out_release_dquots; + goto out_parent; xfs_ilock(dp, XFS_ILOCK_EXCL | XFS_ILOCK_PARENT); unlock_dp_on_error = true; @@ -1020,6 +1050,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 +1065,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 +1085,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 +1121,8 @@ xfs_create( *ipp = ip; xfs_iunlock(ip, XFS_ILOCK_EXCL); + xfs_iunlock(dp, XFS_ILOCK_EXCL); + xfs_parent_finish(mp, parent); return 0; out_trans_cancel: @@ -1090,10 +1134,12 @@ xfs_create( * transactions and deadlocks from xfs_inactive. */ if (ip) { + xfs_iunlock(ip, XFS_ILOCK_EXCL); xfs_finish_inode_setup(ip); xfs_irele(ip); - xfs_iunlock(ip, XFS_ILOCK_EXCL); } + out_parent: + xfs_parent_finish(mp, parent); out_release_dquots: xfs_qm_dqrele(udqp); xfs_qm_dqrele(gdqp); diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c index 0c4b73e9b29d..6795761c31e0 100644 --- a/fs/xfs/xfs_super.c +++ b/fs/xfs/xfs_super.c @@ -41,6 +41,7 @@ #include "xfs_attr_item.h" #include "xfs_xattr.h" #include "xfs_iunlink_item.h" +#include "xfs_parent.h" #include #include @@ -2115,8 +2116,16 @@ xfs_init_caches(void) if (!xfs_iunlink_cache) goto out_destroy_attri_cache; + xfs_parent_intent_cache = kmem_cache_create("xfs_parent_intent", + sizeof(struct xfs_parent_defer), + 0, 0, NULL); + if (!xfs_parent_intent_cache) + goto out_destroy_iul_cache; + return 0; + out_destroy_iul_cache: + kmem_cache_destroy(xfs_iunlink_cache); out_destroy_attri_cache: kmem_cache_destroy(xfs_attri_cache); out_destroy_attrd_cache: @@ -2171,6 +2180,7 @@ xfs_destroy_caches(void) * destroy caches. */ rcu_barrier(); + kmem_cache_destroy(xfs_parent_intent_cache); kmem_cache_destroy(xfs_iunlink_cache); kmem_cache_destroy(xfs_attri_cache); kmem_cache_destroy(xfs_attrd_cache); diff --git a/fs/xfs/xfs_xattr.c b/fs/xfs/xfs_xattr.c index 913c1794bc2f..c1f4bfd71e73 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) { @@ -61,7 +61,7 @@ xfs_attr_grab_log_assist( return error; } -static inline void +void xfs_attr_rele_log_assist( struct xfs_mount *mp) { diff --git a/fs/xfs/xfs_xattr.h b/fs/xfs/xfs_xattr.h index 2b09133b1b9b..7e0a2f3bb7f8 100644 --- a/fs/xfs/xfs_xattr.h +++ b/fs/xfs/xfs_xattr.h @@ -7,6 +7,8 @@ #define __XFS_XATTR_H__ int xfs_attr_change(struct xfs_da_args *args); +int xfs_attr_grab_log_assist(struct xfs_mount *mp); +void xfs_attr_rele_log_assist(struct xfs_mount *mp); extern const struct xattr_handler *xfs_xattr_handlers[]; From patchwork Thu Feb 9 08:01:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 13134160 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 2744FC05027 for ; Thu, 9 Feb 2023 08:02:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229632AbjBIIC1 (ORCPT ); Thu, 9 Feb 2023 03:02:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58664 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229671AbjBIICU (ORCPT ); Thu, 9 Feb 2023 03:02:20 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8A6942CFE4 for ; Thu, 9 Feb 2023 00:02:19 -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 3197PjsL011365 for ; Thu, 9 Feb 2023 08:02:19 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=/hWCYAx1t6DfdQn5Xdy+zxzq9asIGmH4jM4dOZNlpP0=; b=Iy+tBVU/JFGpu7JPLJUo7EKwtfbRX7FZoFROO6JLO5P8qtLumGCmTps5YIG4dQndgnjp vepQ/OebzlCHYRNk2hIBwL0Msn/uOmN4aAei83e13nOuJPkLGOv4EwnSA/qibwnldeeb K/hC9AMswngz8Vwli+vNe81kYxBBa6TGDWnyRHWhxEVSsA/WWD/lSVr2kgsJCJA11iJr +vRkltnFTzFxierDYEzcazNXc2SWoOieZTTg0j0YXPba/IhOcd2TZlJ/aT8F4CFSTn5U PIANxk1XIRe5aLvwfqhNja9TxbuR1LHVOJLWg3Oct8o4Y3xz1gCmLE+bR3g1U8ScObsN EA== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3nhdy1a76a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 09 Feb 2023 08:02:19 +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 3196eBvJ021294 for ; Thu, 9 Feb 2023 08:02:18 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2108.outbound.protection.outlook.com [104.47.70.108]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3nhdt8dv71-5 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 09 Feb 2023 08:02:18 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CyklEXgu0PXpP1EDF4HcEtqpFIQKbUsSYcG8+dAGbwWLqlfXzAyotf02MUrli7LKIIEkn35csMPqik5kOjHsDZCdAZMz2m9561khPp03QXecVJCADA5tSnJeeOah6fz+93ziFa3IpRY7BIAufAtogTtjde+EaF7cVtQalanW1XSL29LGbWGIyYYgynPCsErCEN0CjsPwSTdwr3sdZNISYpLbi3VxE3yWcEtQgc/7RQy8kOnyzXjlGZy7l6gHNzvg0rdl2BmfJ6lnq5rmfdTNo+kEQr5FYKZKuHkt6+n60Z9AN0MyeWdugv3c0nPoHHuTnHH3XPdy9WcXbwbyVW264w== 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=/hWCYAx1t6DfdQn5Xdy+zxzq9asIGmH4jM4dOZNlpP0=; b=aXGXAV6KXRE7DX6nEsvrIzLYvU8AA59GidDOt7JuoNcZ6Kq2NvE7lgnywDA0yZ4YnHE/1ipwJN/X4WXLmhUwCsZ34gbH800VNrvj+kdn6L9WYJLcc+LmwCD8wVPv8fLeVPm7ieNFt1SN9lwNNHAe0jF4snBiCGGZMizcEow6xzhRzZnDhT0F82QaFWMIuRWsy55ZGn9ABdBCpxYURCKk2r2DfDcKvPP17lRfLscCq9Hib8wzju6eoRCcHhQ/AJDNFD1dvE8q/7hr9fUHAm9oc3g9VYPK9sEAomPcrds4ULeZoCdjGz/Hqus4clhECNnSth4E9rSIw2xRTKuv0TrmtQ== 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=/hWCYAx1t6DfdQn5Xdy+zxzq9asIGmH4jM4dOZNlpP0=; b=qsRSjfDMR/VYoMQlr0StV/kzNgusrG7a8nNbtLkLozFE++ZTCx6DnkVHCF5cdWVOpyRfcFOkhUV6v9NNizlzhv/9GVMJWfEICKB8+rrdV+YmatiJgiAI9XG95xWzhVfiC4aAI+CSh5woPN5qHEyfEs3bQ3PC9Fe68vU1w9ZQCa0= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by SA3PR10MB7070.namprd10.prod.outlook.com (2603:10b6:806:311::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.14; Thu, 9 Feb 2023 08:02:16 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::eaff:9f55:4641:db38]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::eaff:9f55:4641:db38%4]) with mapi id 15.20.6086.011; Thu, 9 Feb 2023 08:02:16 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v9 16/28] xfs: add parent attributes to link Date: Thu, 9 Feb 2023 01:01:34 -0700 Message-Id: <20230209080146.378973-17-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230209080146.378973-1-allison.henderson@oracle.com> References: <20230209080146.378973-1-allison.henderson@oracle.com> X-ClientProxiedBy: BY3PR05CA0009.namprd05.prod.outlook.com (2603:10b6:a03:254::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_|SA3PR10MB7070:EE_ X-MS-Office365-Filtering-Correlation-Id: 249ffa53-16af-41e9-9161-08db0a73f5cb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: o0tzxrQOoXhnr3uK7wDlqo48dX5gK83m+s+bobe4l26Borsdx3ruVitC7Kc4w9Z1wsN1Zcmm9VAt0FGP1TFmI+f/wValsfYFf4Y23wq5N5MLq+foQcyo9d1bZLsYbszaAxqwaOrH7AqY/mZtPLhk/EtG2LCJ/UwHXpUcaiKE4KvM9M4u4q3pX6g9vBxyGvvv34Zl+WUF7APIx81CDFyNAPkmZFrCaEsmYiw23SXEIuB57ctCyAyLWuARHRPMyzfq+mVgxo8bEXNMOO42NyCY4daDOmMGs+dG0DOhLqVSNoW9zZXl7uHFoIoaWr57ONuZWN+MF6984Z2yRonwhRNE3dVA61ATbW6fLP9MuGnu9kWuvIHVlVOgkKS/HCK36vMck+a1iQKQjMmxXxmO04f0j+5hUo3Oqiauis/d+5Xeg02iv+DbDHSKz8BmU4RA5q+qXn/slJiqhrh3EBBdG3ONh9raQqOXOchVEIVSK4QHeYSgjBBGu5ic0A4YaaBa9bJmXnEFBMPxdPE2SGgYMW8Jxv5hO9KUhAljEvepOfR7fSNMMZ24F0OPMoLx4zrvct0wrHdaUtRXyGH5zln5OlKJyo9HjDf8PR9FlL2t27iyvvn/uhtoQfjbR+RBpBwpRJWX+9MnlJ2PU4At8spQ3xdUBA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(366004)(376002)(346002)(39860400002)(396003)(136003)(451199018)(478600001)(6486002)(8676002)(83380400001)(6916009)(66476007)(66556008)(5660300002)(8936002)(6506007)(1076003)(66946007)(6666004)(2616005)(9686003)(186003)(6512007)(26005)(36756003)(316002)(41300700001)(38100700002)(86362001)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: CUEEZ3FUjebS3ODKOv5EiQp1A1VHnCNYE7DsonSsxtNvjCdHaZ0YLezrgzqqnMRi7/egpeuxu5CR59SBRYXc4mi2eHPjloM2LMKCjbixk2hntY0AfWoBuNDCuIqIhGZKPD+Sd6gNM7akAEAFloiUSm6wP23F1/wHz1Pq3UNU9s1wYjovoh0A2QmZRW7ZmUMcz+GXV4gskw3Rr1Y8WtcTY+rEq7fnsmFZYqHeWdQWf1iYYlvlX/vMJLrOY7BtZux0uw/GioRU7TcnFmhqo3a1ueuxqv3tHLiozxMCxjUxiTp98G8OYeU1o2Dfn2UTjwnXOT0hmkuzBdcxnHrFm6yws2PJ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-CrossTenant-Network-Message-Id: 249ffa53-16af-41e9-9161-08db0a73f5cb X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Feb 2023 08:02:16.6363 (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: 5EktTAbzIB1gb5A+Othy4/FFrtWH9FPBj0lbuMcIdqJ7JHdZH2/6+OXH9JDA6nPqjW9dE1IoayfE0KPmfcb5ch0oIuE9O+yfWFpNTjJrBao= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA3PR10MB7070 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-02-09_05,2023-02-08_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 bulkscore=0 malwarescore=0 mlxscore=0 mlxlogscore=999 adultscore=0 spamscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302090075 X-Proofpoint-GUID: IDYIaXsAc9AWCuN7C0XrM5Uhycmw6VTe X-Proofpoint-ORIG-GUID: IDYIaXsAc9AWCuN7C0XrM5Uhycmw6VTe 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 | 60 +++++++++++++++++++++++++++++---- 2 files changed, 53 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 ba488310ea9c..b4318df03b5c 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -1247,16 +1247,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); @@ -1273,11 +1289,25 @@ xfs_link( if (error) goto std_return; - resblks = XFS_LINK_SPACE_RES(mp, target_name->len); + error = xfs_parent_start(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 out_parent; + + /* + * We don't allow reservationless or quotaless hardlinking when parent + * pointers are enabled because we can't back out if the xattrs must + * grow. + */ + if (parent && nospace_error) { + error = nospace_error; + goto error_return; + } /* * If we are using project inheritance, we only allow hard link @@ -1310,7 +1340,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); @@ -1318,6 +1348,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 @@ -1329,12 +1372,15 @@ xfs_link( error = xfs_trans_commit(tp); xfs_iunlock(tdp, XFS_ILOCK_EXCL); xfs_iunlock(sip, XFS_ILOCK_EXCL); + xfs_parent_finish(mp, parent); return error; error_return: xfs_trans_cancel(tp); xfs_iunlock(tdp, XFS_ILOCK_EXCL); xfs_iunlock(sip, XFS_ILOCK_EXCL); + out_parent: + xfs_parent_finish(mp, parent); std_return: if (error == -ENOSPC && nospace_error) error = nospace_error; From patchwork Thu Feb 9 08:01:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 13134163 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 00081C6379F for ; Thu, 9 Feb 2023 08:02:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229518AbjBIIC3 (ORCPT ); Thu, 9 Feb 2023 03:02:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58662 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229738AbjBIICZ (ORCPT ); Thu, 9 Feb 2023 03:02:25 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 817632E0ED for ; Thu, 9 Feb 2023 00:02:24 -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 3197PePF003345 for ; Thu, 9 Feb 2023 08:02: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=Ubv9KfwwPBg00mJ7DbZY/cTUoJeDp8HC1BJELHqsjwg=; b=qaFUBtKhZ+5suFeEiXqWd5qzNAwRUXytMqefz7x6AO8OKfeLy/LVeTMacM6mabWp1OZw MZ2xDAsbzv+mngnaaUlsqJE+rAMJu+cG88RDIWH3zneVMv9Sz7oQdLFzGxnnEPu8Lk5K sxdoGcRQ5g7JNcgRZFqD1n5Qs/pV6nyp6yM/P3Ks5KLCdJra1REqIjFaA8lmWQN8TR1C HHnnQLPK/JcG71ZswT7NdXVTRZta+szTarIZQRghgpm2Vx5HIimMvj0jsYj0V6QmIzLf mHsptjchw0IscopXZ259lsfjJXhx9VJDE2c1u6fH0o1dxgOKyNFcQLXgut7yGGTmvGc9 YA== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3nhf8aa44j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 09 Feb 2023 08:02:24 +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 3196VLoi028396 for ; Thu, 9 Feb 2023 08:02:22 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2108.outbound.protection.outlook.com [104.47.70.108]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3nhdteyg2h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 09 Feb 2023 08:02:22 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=L8+alAKFt4hYCScqS3YJXujfnaK8BlZeshEZ8QYQ9knc8Iw2YM+1Pf4ESnHBI12m5xnfospazkYEa+RQVhKGfYd/ldHyk+9giiflYXl9JCI/Gux2k6+oZn7vgS2CwPAQxxyO0wSbh1mHIblSZ/oHhk2cbj6844ZoWNml4oKHHOlMuC8jvWJHxLF/FwgzjCpCsuADQ5vsm1Ie8hobf1WXw4hN4w1HThon/jG5Xj8jvM5RoVHCz61tt0aTWrKv8V7fFVbka1YGF779bPbIeKMDZAinTXbWnEC7AR/ERCah8GLP6VjQVB7KtLJFiZcYfkif9PoC3Ft0mxguYUPjhFxGbA== 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=Ubv9KfwwPBg00mJ7DbZY/cTUoJeDp8HC1BJELHqsjwg=; b=fcwCkbW+oilhue+oZ/B4hCa1iExfC86yQkkaAoueKqLxT/KFvSXuKfKde8qFGKqleP0+edVAtkwOceSO45oGDFlN5TOkW+xDpeWgSu/gRk8ZxAlOa1fODGoG/yp9ELKcKzTSJNpIYlaChGVBEYArYPHgLvEmwRNg4RJd5UyjjahN0Cm7sc1fEngdmqd+FDbiCtqSip2dd+vx7/LBeMnZCFLrB05qjYvr7nzK7QYrc5teRhD79l6u3MzGFSt7WQJs3bLSsFRvxXqHl/Jgu1C6enExN+aUO7rUdY/mkw/FC9bAQtKdsbrpcpoaUj4ROP2dAPhHIfOB4OQpOb/9mIDEkw== 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=Ubv9KfwwPBg00mJ7DbZY/cTUoJeDp8HC1BJELHqsjwg=; b=uim4lwSvhCvP0j295MozWKzVUwR3qqQ03aNoskPLL+uL4jis52jqGkCo1BmwKFFqs2y+n9YG3HXt2raQw3BzLOCksi3V5zCmuelfp9GYttdrE3+d1D/CmPLz+GCs10G2p66SuUSIdLML9JFhFjs6fAH8Abp1VBzaWu7OxXKBB7A= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by SA3PR10MB7070.namprd10.prod.outlook.com (2603:10b6:806:311::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.14; Thu, 9 Feb 2023 08:02:21 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::eaff:9f55:4641:db38]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::eaff:9f55:4641:db38%4]) with mapi id 15.20.6086.011; Thu, 9 Feb 2023 08:02:21 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v9 17/28] xfs: add parent attributes to symlink Date: Thu, 9 Feb 2023 01:01:35 -0700 Message-Id: <20230209080146.378973-18-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230209080146.378973-1-allison.henderson@oracle.com> References: <20230209080146.378973-1-allison.henderson@oracle.com> X-ClientProxiedBy: BY3PR05CA0007.namprd05.prod.outlook.com (2603:10b6:a03:254::12) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY5PR10MB4306:EE_|SA3PR10MB7070:EE_ X-MS-Office365-Filtering-Correlation-Id: d5038ed0-cb99-4886-d20f-08db0a73f88a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 98HoU3wJRvIlHFfQklOQh6WVc1mutvzN7aTm37jLhXvqpxHh/YbMl0a6T7hwGrFICpGOcIZwM6acWB+f2h6TnYOGHV4K6HYynaGhF6fF0ro+OoPiE1fItFg7P0npfBqcbDyClR1bgROPlvhUFHF3StW7dQ953byqvmPowGQZS0WgKKdgJyPM45wBaMRbbrPCCGfz0VUEMLzXUUZz1H9AefgMaienJYDRNAt0PHe+poWFsOWexmdeT0aB9Jun1dWVoV+1vCdZyxZfol775net0NmFkI1wdbE3JkoT2XQi62GOcJrjQ4PUU5GfnwQwIlma9WvfddFmNKzzb+eNyWhmETXqwAh9G759XKvucmdWSqeMdEh2PJJHG4s5OAQMDXBcGQHAU+k6EjB3S+Wgl8rzi9fLcrlhMbU0M2yA/LNmcrfRMHZ44s4IpLwEg9Jv5opUyiOeAWBZfohenqhbcONEbcSx8qgED+2pLg3pDcBXJgecj8iAvwVJOBh9O5loUUcnDZnXq4ljC3gXUK8XO4/npwTXJBseNEXKYkW5g34KbyjegYZfdBCpmjb1mvkfQWVTgzJA4mQqKOV+PB5ktA/BZTHvh/7onxVXuxrZvYyBs1TUL85hu8KImVGyHZJ7kDPUI/nAMUa6rVYGxXQMT8xlrw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(366004)(376002)(346002)(39860400002)(396003)(136003)(451199018)(478600001)(6486002)(8676002)(83380400001)(6916009)(66476007)(66556008)(5660300002)(8936002)(6506007)(1076003)(66946007)(6666004)(2616005)(9686003)(186003)(6512007)(26005)(36756003)(316002)(41300700001)(38100700002)(86362001)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: zgyqRQ67tFtqBno/m+3zp7HMhxkucLX6lpUDfFTl8PqADeU3Io7MZENZdeMZuCXt6Vy3jVYi2LDZHmEcUfFZ9NB3swZ1kXskwXSt7MRGa7VZ3nLffUoEaQSKppz/2jNsBDIZTch6EksQkyIDWqNgMF1FPS7fjRxEhZMFNU6kPkKeOH/MVDTGPojqQ1QEBWhkPP3PcGhyOypJxQVx7y+qqet7wRobGN3udnnxxcyqQ+tQe3Q/M62VpZLkEW1DPxMB2uUI54O4XW+Rqz+QKHf6VzTt4BOQ6V+i08OCdPxlT/VNsoogCEIoSA3ERqbACS841lEURLegWpda6Z0d25aDtkVts53GGg8cuiw9eskMeAjI8F1h9nriAnN0ojTOrxfYw42/qKN2AaePoH9ymD5pINvELfUTYcDSI/wT2XH6tQYUz4zZ+sHrVhNgeyPwqyjtKFzHqqJc+nTJmDpFPq9U8/7B4o0gPl1ED+kAz0Uh5rSfJ1SKy5Jp926mK8BTEQRmUu8V5PYz2+yYK9X4NOJKXtMDiqaq1mA9VklHjMcEx7x2qGr6Dnm8g84g4tuusB0m8wPSQlya+a0uqIpzZbxlYli7+rzix31z74xMSX2iQ3m/VjOYpkI4+IZqsp0G3c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qB6kuHN17L7bOkubfidhU8DaD58E418svsM6c61pcWhUOPtcdVLUUiV3F5p9aBY2iCrDwfcsMgDEhUxP9XAGDLeSc8hs2ZRjeQIJM+RN/n46wFfJdC+zs4gnBv/CpTs3V6RBinofK3STxRsx4eWDfZJPXx2b3nQIfUW9Dw4GL5Kgvn+XeKP5A8/Sx9ZSW/iDUJObqCgs4BEhIb+KmxplZmm7p/Ivt7XzU4f8ThoqSsgCvnf5HnFgTK1I2/1olgwdT1EUUSoJ/LeRbr2cemRMZh9+WxDt6gsd0XEVZugLen1Ra2FQYpknQKZZJ+8uJLq3YTM5MK61JChdh1zvTxRANV/fzF6yIAjbG6YYbtBaI8L2ovx24gq3iWR5BzYLb0tPUvdYu7Kqodd5Aymo3DWoXKJf4YDKKk91eN9vXfljRiX5xWhzwWtqrtp05zj84A5rAiWSKfMfiw2aQ636XGF+eT10EojjAY6dhcL0dGWTrOpw1IAhCpGQzpkI6YK73lvo4sUTO6mbelwB2EBkczuq8GZ/Tr7eX9SFo/AMqOkyQYF9seuAm9RNL3dyISheXvJ0wFKHrBhfG6PTcUITJKBYya2Jz/i7b1QgQCdzUlnfXQ5KvqZMpERveZYT+WsiX7vZWZQ8/FX1HQW1y3939LH3MiZrC4uHr4csU/q4NOcbna1uOsBp4pkezNIcu2JEP6DGOLXSaxxWvJBkxiV2G8W0bCG79Oqjxzl7Y/b7TUwM X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: d5038ed0-cb99-4886-d20f-08db0a73f88a X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Feb 2023 08:02:21.2608 (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: 1aAgQmfj8TxOuWYvVgNtIsVj+DM4L/VKxGoaK02mpUpevADIhjM7csZmoLgv7ppKFAzVNDqgR3xTk+o64qBerWFkeAJR6nIGCsmwkCy0vCM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA3PR10MB7070 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-02-09_05,2023-02-08_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 mlxlogscore=999 mlxscore=0 adultscore=0 phishscore=0 suspectscore=0 malwarescore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302090075 X-Proofpoint-ORIG-GUID: v11u1n0yMqT0RcSDZ4tJ4KHSvseVVl3J X-Proofpoint-GUID: v11u1n0yMqT0RcSDZ4tJ4KHSvseVVl3J 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 | 58 +++++++++++++++++++++++++++------ 2 files changed, 48 insertions(+), 12 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..f305226109f0 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; *ipp = NULL; @@ -202,18 +223,24 @@ 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); + + error = xfs_parent_start(mp, &parent); + if (error) + goto out_release_dquots; error = xfs_trans_alloc_icreate(mp, &M_RES(mp)->tr_symlink, udqp, gdqp, pdqp, resblks, &tp); if (error) - goto out_release_dquots; + goto out_parent; xfs_ilock(dp, XFS_ILOCK_EXCL | XFS_ILOCK_PARENT); unlock_dp_on_error = true; @@ -233,7 +260,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 +271,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 +341,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 +373,8 @@ xfs_symlink( *ipp = ip; xfs_iunlock(ip, XFS_ILOCK_EXCL); + xfs_iunlock(dp, XFS_ILOCK_EXCL); + xfs_parent_finish(mp, parent); return 0; out_trans_cancel: @@ -350,9 +386,12 @@ xfs_symlink( * transactions and deadlocks from xfs_inactive. */ if (ip) { + xfs_iunlock(ip, XFS_ILOCK_EXCL); xfs_finish_inode_setup(ip); xfs_irele(ip); } +out_parent: + xfs_parent_finish(mp, parent); out_release_dquots: xfs_qm_dqrele(udqp); xfs_qm_dqrele(gdqp); @@ -360,8 +399,7 @@ 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 Thu Feb 9 08:01:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 13134164 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 B4433C61DA4 for ; Thu, 9 Feb 2023 08:02:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229631AbjBIICd (ORCPT ); Thu, 9 Feb 2023 03:02:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58764 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229653AbjBIICc (ORCPT ); Thu, 9 Feb 2023 03:02:32 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 39ACF2D17B for ; Thu, 9 Feb 2023 00:02:31 -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 3197PjUb011362 for ; Thu, 9 Feb 2023 08:02: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=hjKom0jYenTDKGaVxb9xSuclU1m1nWbc8z4FAPcPXj0=; b=rlrYEw3Ko+RrpOw0mrwZqCgOSdJ5BJ9qkWHlZlScQTH0IDKse6dputCcVDAXtdC99tJY fbzqiskL1+G0FOo5jGtsS64NRWwuub5GkHuCPWXhRZQn0Qlt3Pp2zoEswcP6t5NWP0+E HZf2bNckwZHUtw6BvkML2NA/xVZOfEL1aOwY8DaVVOytskr4++nL5q3M6wTvXCojFCnc Zs/0K9zLEPuAIwxHE4sUXVud4N5rwhnp7YRkmQ/IWff3MbSszW7B3SDc6kgxZZ0eeOUt EoJLWeZNGUNqwNY366KMs1d3Lb3KEbQzlP+X/fY2N9ngy5Cd1RUDWYFNVSKt/+/6eYFi Qg== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3nhdy1a76n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 09 Feb 2023 08:02:30 +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 3196KLvj021320 for ; Thu, 9 Feb 2023 08:02:30 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2102.outbound.protection.outlook.com [104.47.70.102]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3nhdt8dvja-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 09 Feb 2023 08:02:30 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KgnTdPDA74Cnx64RwTPjCRXe0cfCJ429oZW8nBvJpjBK5Jq5qTFNg5Q5TZ8o5zAW2UqO+lVg9dpeLgJ/4mhJ0hJ4rpR5P8C74d4Fhy0tDUbPpBAmOKIjS9bMbmQcU4H0d4C7zJDdlYwD3Nx3Y8ktYKrIQfZC233Y6owlls3V5EepAOjr+oVZXMfSAdjCGQpae1g+1UdeuHJY5S55eG0M7cFTQybw0t8dpHlWGmRV6cF6dDvcz9gFFT1ROErQKiXjXbhiYwcn/402FVUDO0I1lhDyYQ4Y/UjRlyQgsg8Q7LkvWzJ6C+1IJpjVQCfqZlSuo+eaHmWNnN7c7f+eiEwtOw== 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=hjKom0jYenTDKGaVxb9xSuclU1m1nWbc8z4FAPcPXj0=; b=Sda5E8+2hp3+Jn7szCgJqBKhvKMfaIPnfpKeGBs57+A6wWwA9nHJZeWzB+1JN+X0mvSvxtaW/mN+kwSUUtTkIlcXVp4DGeq4HXba24iWZRMflq9xx42zRpd0C7ldc4prLPbH12jTMJdpfuTz4OPFFmX37G+JEOMTHe6IWuS/xa6VptGuyz7Q+A6popKMFGmRzaevw9ojPd1WY6NfaxaW3BrFyrXJVcDDIvNvRb/J/UzexBPbbs+Qu+WsA72PM4yZbKrT8pcXy3m8WNLjskh4cb0RKPhlHTpjjsv1QnDIFKE09DeOVnFN+h1TXEpYj4G2avjR05bkpHcfKlkFxVXYvg== 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=hjKom0jYenTDKGaVxb9xSuclU1m1nWbc8z4FAPcPXj0=; b=GnjmhZtm16e5m0TSfyKSZ37tdBeqJAM+ex35X1DwAsfS84hiuxbvZG15Dvb7sSTeVgZpwtUUMLXm3isULyVhW7q7NPvONofLuMhEH+GyT3lqTgkQKfL+lfrXaGGCTnQs+Ty9utoupESs/iYo9itI2x5FTiXEVIIyBC1WNy0GN7g= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by SA3PR10MB7070.namprd10.prod.outlook.com (2603:10b6:806:311::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.14; Thu, 9 Feb 2023 08:02:23 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::eaff:9f55:4641:db38]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::eaff:9f55:4641:db38%4]) with mapi id 15.20.6086.011; Thu, 9 Feb 2023 08:02:22 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v9 18/28] xfs: remove parent pointers in unlink Date: Thu, 9 Feb 2023 01:01:36 -0700 Message-Id: <20230209080146.378973-19-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230209080146.378973-1-allison.henderson@oracle.com> References: <20230209080146.378973-1-allison.henderson@oracle.com> X-ClientProxiedBy: SJ0PR03CA0199.namprd03.prod.outlook.com (2603:10b6:a03:2ef::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_|SA3PR10MB7070:EE_ X-MS-Office365-Filtering-Correlation-Id: 3966acc0-873f-4f81-1e58-08db0a73f983 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: vb11JETZRDaaKIvVzwYPZYkD86fEdtLQQYLh2RpbRPUZT2WoSyLtG1z17WZnFyQ+sDO16/ZsopFTUPChoJ0P16xjx+Qdpkw4ECoCsN8oMUXynVKiRKR+TZSXvboeZEWlCr+RlItv+d7jIQmLQQU805PsZuAVKQwbSUPVN4lItfcddlm56ttnr20OfIcApuX1mP8Jk0FE6djIW4lve+LVvXlrc7mRr8bmJ0KSTK9SbiJYdllK6ZwVlXp70c6jsGoGiH2a8A7yAnbWelvf5i4MeHQdSXDau8ODdA91OWCI5hpwJ/8K9q8M6ccvuCuxE76JRInm0fRfbqfqaUhlPqKydwTGI7dlY5sddVMWYmIoyAuCprIdJpJW6vSwAbKwx4OFQNyg7xnYfgLY4x6fWsx2aevfRAdJdwUvabqAyy6X66eDOtLlgpSB82yLZH7F5/0ouKyeuK1ms3AS1luGFbYswptYgq6b0VJaSPYeuUjhUU2HKj7ITDC/GNlDwidYLQ24sblJkN1npD/eHnXcbKBviwcLtyQM10IfNPpXMfALRHv3InU1wqXm/e6RdfeVrjjn/2COj74byazLtnXeAyFU6TaprLk0BsUU0B5/aCBTDXPZ8N+7Y86bEymahxx+izo1oL0KbTIKSEviqoQ5zQALwg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(366004)(376002)(346002)(39860400002)(396003)(136003)(451199018)(478600001)(6486002)(8676002)(83380400001)(6916009)(66476007)(66556008)(5660300002)(8936002)(6506007)(1076003)(66946007)(6666004)(2616005)(9686003)(186003)(6512007)(26005)(36756003)(316002)(41300700001)(38100700002)(86362001)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: xeLkZnMzmA7IHrlXmovB5fNXDtIPdtfW/LFX2hxS6SqGpg3FCYfl73khgJ20RESu5ToBSjFq0zmiRbc76Nu0y0Np9jgicMxJU0xDjZsEWg4HmqW3xljxvxlvHeTfSCwCpi5jwbcqzJozLrI9ZFoJiOdtB5OGt/YPUibR74bpOuQqQMCR9kjaDkivp5KXi1JgOE2N6uCHGOaLI7wqUU54yAT5ff3pl3uTFY0RaqVjwEY+oORsCIwGAaAXExQXTm617THVRxeUGoGhYD9vverS3XUcaUVfrY/hV2QNqNa7JMdGsfFmYlHT3cV+0lqrEIz9ilTtyaW8GLI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orOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3966acc0-873f-4f81-1e58-08db0a73f983 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Feb 2023 08:02:22.8580 (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: VaYtuIGdZwok6QBDSeXQjolLiaAw82j0dqlDqRzlWGS1UtfaYs8sXs3ZrmKGt12v5lTk/NgP43ph9hFx7aTaDD3C7bQTU+UWeXKeemlM3N4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA3PR10MB7070 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-02-09_05,2023-02-08_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 bulkscore=0 malwarescore=0 mlxscore=0 mlxlogscore=999 adultscore=0 spamscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302090075 X-Proofpoint-GUID: 3UP4inmGMPHlqWE8-XK3qR5CxVzlpCX1 X-Proofpoint-ORIG-GUID: 3UP4inmGMPHlqWE8-XK3qR5CxVzlpCX1 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 | 5 ++++ fs/xfs/libxfs/xfs_trans_space.h | 2 -- fs/xfs/xfs_inode.c | 42 +++++++++++++++++++++++++++------ 6 files changed, 59 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 6b6d415319e6..245855a5f969 100644 --- a/fs/xfs/libxfs/xfs_parent.c +++ b/fs/xfs/libxfs/xfs_parent.c @@ -115,6 +115,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 d5a8c8e52cb5..0f39d033d84e 100644 --- a/fs/xfs/libxfs/xfs_parent.h +++ b/fs/xfs/libxfs/xfs_parent.h @@ -40,6 +40,11 @@ xfs_parent_start( 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(struct xfs_mount *mp, struct xfs_parent_defer *parent); static inline void 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 b4318df03b5c..7b34ca2de569 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -2477,6 +2477,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 @@ -2506,16 +2519,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); @@ -2530,6 +2545,10 @@ xfs_remove( if (error) goto std_return; + error = xfs_parent_start(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 @@ -2541,12 +2560,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 out_parent; } /* @@ -2600,12 +2619,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 @@ -2623,6 +2648,7 @@ xfs_remove( xfs_iunlock(ip, XFS_ILOCK_EXCL); xfs_iunlock(dp, XFS_ILOCK_EXCL); + xfs_parent_finish(mp, parent); return 0; out_trans_cancel: @@ -2630,6 +2656,8 @@ xfs_remove( out_unlock: xfs_iunlock(ip, XFS_ILOCK_EXCL); xfs_iunlock(dp, XFS_ILOCK_EXCL); + out_parent: + xfs_parent_finish(mp, parent); std_return: return error; } From patchwork Thu Feb 9 08:01:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 13134165 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 9525AC05027 for ; Thu, 9 Feb 2023 08:02:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229671AbjBIICe (ORCPT ); Thu, 9 Feb 2023 03:02:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58766 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229657AbjBIICc (ORCPT ); Thu, 9 Feb 2023 03:02:32 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A181326867 for ; Thu, 9 Feb 2023 00:02:31 -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 3197PjsN011365 for ; Thu, 9 Feb 2023 08:02: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=l2LPlF+Pn17Z5N4hWYkbckj8AjPsKx6nZSIa/oLWK34=; b=xbsZXE0Np5/TEwNTmM++PRxEp903foYBlzt5o2Ig/8qWeHD1v2kHHHQ3nvKPPifsbWcp 8VNtOYm0+8Wdw0Bv4OH/R6f6om078qKNinPKccuMftVibVuqVC3WcdnvMIxdzHzFFd18 fr/iSRpIcq8QYuezIky/55MVevtXLtCa5/g0Cy44+//+acwHsEsE/eUo7IVjD1TNAm3e bZ2pKfrx3SJubkUcVBqOgKULCUBJmkQ0H/RPZlLlj1BEHpUVixKmFQBjmXeVxisWkC6F OfihJy7XukLpK2FzTmdp6nHOane6eTcwkjkkPcG4Lk/LBJSZzAx8bjDt3L+WipCsIDk9 pQ== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3nhdy1a76r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 09 Feb 2023 08:02:31 +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 3196KLvk021320 for ; Thu, 9 Feb 2023 08:02:30 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2102.outbound.protection.outlook.com [104.47.70.102]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3nhdt8dvja-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 09 Feb 2023 08:02:30 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kk/KxjbChBf6e35QBlHqWPZLuj74St2FSSd5Qpd/KNRHkxaFNYSoGUdUlO7KMD5QcJ3qHwQPlNd2qSa1Th/e1nR2/bEXfLugmUpTabsjn+5yPEPJwxubsUzoMVR4J9cNRKQ6xWWvichNlmU+3HytqnKBLwaXf6vIa79qOsRrlUHyymLvaD0VeMso6LFgJT3oiHnZujohoKk4WLN6LwDTb7jeCPqm4d/VwX9pXaOv2j8Gaxm7zr0W1cC8dYiUanlsa7DkbmcRwqyYHureB33TwzrjlVYK5yjXFwnlZK8UMvkuXWpim8Xzh7Mj9+kEEyxrLBimRyJiRKBJSAf41z0YGg== 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=l2LPlF+Pn17Z5N4hWYkbckj8AjPsKx6nZSIa/oLWK34=; b=GJeV3AmgqKHr3Jxy/uxDMgjHEcD21334aJFVkDv/h4AgNw19hyRPa6ehW6WEZP+uHzzvILdcsr8jf+6ZwI3xM7DoURHvg1k2H3TdcDfxzG4BtMi2Yfp5TBn0AkvhJCA1NnnmBfDBTTO9hDNAzVyrBS9jJK5jP85FjqPfkO29jRzuVCvA/ROIN6bIwQI1iEisoCQbie9t6GFePBY/oS69qX6ssPv+ORXRy+kEhP2lB4+0ZCMOhrXSetO9pq8QMnq2/QjNPCkTyp1Zy9A77BlMBUOX8e5ZvMS6ZSqs+MhNAHzEXQl2QJr2bAX3yCIVq/YVgKWiMUxosujuuNO7d5duLQ== 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=l2LPlF+Pn17Z5N4hWYkbckj8AjPsKx6nZSIa/oLWK34=; b=A5mCM+LCh6Z9/EQhom5B/5yL7YCdfkiuVrHyaXe2xQmRg03foSMiITrWvX4HoMBzFWetjc2ZoUz5sasaMzxH5YGbICIRlQ1Q6CJ27bdVuUAbsk5ymL2FDqzmKs/DCHOW0inwUn4H9U61b0wHsk3CN0N91z5smSqtCetVGmWPFTs= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by SA3PR10MB7070.namprd10.prod.outlook.com (2603:10b6:806:311::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.14; Thu, 9 Feb 2023 08:02:24 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::eaff:9f55:4641:db38]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::eaff:9f55:4641:db38%4]) with mapi id 15.20.6086.011; Thu, 9 Feb 2023 08:02:24 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v9 19/28] xfs: Indent xfs_rename Date: Thu, 9 Feb 2023 01:01:37 -0700 Message-Id: <20230209080146.378973-20-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230209080146.378973-1-allison.henderson@oracle.com> References: <20230209080146.378973-1-allison.henderson@oracle.com> X-ClientProxiedBy: PH0PR07CA0042.namprd07.prod.outlook.com (2603:10b6:510:e::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_|SA3PR10MB7070:EE_ X-MS-Office365-Filtering-Correlation-Id: 2178b6ef-3f23-4a54-a5fe-08db0a73fa76 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: dFPxOp+kMFS4nZLDznZW2v9t+pqDYH6s1ulnWM1wt/cTT3bDBHqzFOtaep9Q8UTE3KfsgnObIWkbf9lzCIjE/rxgMz3w5GiO94yOVHBKLiyIPEMg5m6bkb4U05MWYgkMmlR1bo81nRNAGgnpjZevlheMxPy+rva4oZS6dUNaEEyq0k9AjJqghN40RKr5N+Zx/A8RZK6DtgyNd0UW1pHuMALCbkxtQQ53CbIdh6Ks0b3UrsS27HyirdJuVxsSPJ6v4FP4PYRSKp5kvqQpANwZB51sJuhUKC/feZLCpttHHcZiMEtM5hyDgdWUiznO+1gqCjG2vf36HfmO7Pgw2kw7c5H6IJltnpdd6oUg/udOTiLuzvblfw6X4NY8eOuri28fmofyLMmc5jDgFsq1wWf8gQLfKiEd4hLFQZGBgnWXEoLLSpsUC+5o4PlYFmULp/lE9WceUnSKIlj5EmRt9XuFbKAgleWkw822A5nwIgDNiu4ll0ME9qmSyogXQgrzbG5bmpMvC2Itf8ulLCjdH+l4cc8GwCRBqSKpgD6k/kSg2HS15GSb/tzhxtQu6c1JCxf0Y8bRrt26wc5TWlnQT5HUFCni1LFK/1X3NimLLYiyEmVyfCx0loLF4JJSGZT8/XORPmMz58IIws2PWXmrzmOg4Q== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(366004)(376002)(346002)(39860400002)(396003)(136003)(451199018)(478600001)(6486002)(8676002)(83380400001)(6916009)(66476007)(66556008)(5660300002)(8936002)(6506007)(1076003)(66946007)(6666004)(2616005)(9686003)(186003)(6512007)(26005)(36756003)(316002)(41300700001)(38100700002)(86362001)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: N/uGeStHtsCyY7KymjAUYdeYDFsBrL+5JbTVB3hnQEOyJvGm/ODw2hVb0rScmfLGJqGdk+0cIPZvJTIeYVEXwsIFl0oHR6zHatwOIzOdiunZjqlbBMCXFQFS3qUsWkk+oEZxgfc8vJn/ogI6W6GbKO28cVYKH5JTwDmJBXhkVupGLhLCDEdM9W+5SrYyj6qbLARgguYA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wyLKxpg/iGtGnt3MdTjWrsTNpvAkYVA1+uXFvw08Gqn5i+TmdAOtcEvxXFgA3S4zHCNM/axixany8AvLPXGTpgEobL2IJrR0if3Na7h6E+S5pZDpBwxHWRkDi X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2178b6ef-3f23-4a54-a5fe-08db0a73fa76 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Feb 2023 08:02:24.4528 (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: sXiIe9dn3jlyJKaXMVrmTICuKV+mipw/WBGhCA2zSn4YhBkPoKB1Ce4hRzAj9O7fkPIwsxcBsvS203ywlI5z9m2rMshuOPwsHEMEtu/swvk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA3PR10MB7070 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-02-09_05,2023-02-08_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 bulkscore=0 malwarescore=0 mlxscore=0 mlxlogscore=999 adultscore=0 spamscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302090075 X-Proofpoint-GUID: fNWpt7UuBAO8cWstwDrEXH_ya0x2vmOD X-Proofpoint-ORIG-GUID: fNWpt7UuBAO8cWstwDrEXH_ya0x2vmOD 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 7b34ca2de569..2d8f225cb57d 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -2902,26 +2902,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 Thu Feb 9 08:01:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 13134167 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 56ADDC636D7 for ; Thu, 9 Feb 2023 08:02:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229519AbjBIICf (ORCPT ); Thu, 9 Feb 2023 03:02:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58790 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229660AbjBIICd (ORCPT ); Thu, 9 Feb 2023 03:02:33 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 24B9C2DE77 for ; Thu, 9 Feb 2023 00:02:32 -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 3197Pr4V011751 for ; Thu, 9 Feb 2023 08:02:32 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=0+eyhh3tfjPJPNr1iqM+fdcCGTKJN/EJNiTp++deJGw=; b=B13ut8QK5ttmn4CFFDugqX7YNJ4bJCLoVisRi6LjQVlASwo3ijSs73Ey/fJ29k96qo/h ORSYdkpcraotyrCRSkuMdIytDw8PVP75wak0trQo1LlELU+HJ/RRsiHgQohi2+PSgbWH 8OQChTB8E43JW2D/Qg0kwGwE9I5VVUHJNZUrB3mkhOLmQEe8w3gs9VP2259zb6yzNvsl 4THEiqgdI213AYE8d/uxQOK1RrkLzweaXUc+TPeKydodKamBLhP+IGuHVl2xCyhCFIlC O5wMVq6VvGvgYESUcN1g8rIdKgK9Zc7NmsfKg5Yr3jGDR3gKoXY36W9hbr/DCTQb1k/o 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 3nhdy1a76s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 09 Feb 2023 08:02:31 +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 3196KLvm021320 for ; Thu, 9 Feb 2023 08:02:31 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2102.outbound.protection.outlook.com [104.47.70.102]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3nhdt8dvja-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 09 Feb 2023 08:02:30 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OJFUMsOq1jotLpFwEifKw41PC6IeC/5pmf83VSIMZQBnbJGfLA4HDp5OZOazkt8gp3REtb+8fzbXkUiRwjOYI/BG7D11Rkf/RjLLYJDqOCSWp5Eb4Tl9BeAZO25B5xYRjSNR5dQW0tbgolNeGzV6FBwZYuxW85vEv2HsXRzoks6nz9ibtmL//Gzr9xgi4FOdHxxDsSdfkEPFCzo5iHgqEk0h51WWTCcZVl+BCRqEeBjSJqI3wfAPaRLFLqleJnjHxJDsiIg6uIHOcSmo6rec6eV/q9WdAh3xZ9gkSqxx0RQVu0VQly+3XmiNfYcNAcrIPaArAltQAjdBwZI5YifD9Q== 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=0+eyhh3tfjPJPNr1iqM+fdcCGTKJN/EJNiTp++deJGw=; b=gQV7VwYEkwHJj0jgHIqLlW62W01C+eUjs030yLKaJ8WYqvLkZhGiUbTzq6cUeVEb2vquz9s1aNt2J3rIayA1YCl3WQRT9MLLhnhne+UwEDMqBiuwHxxg+iES5lkP6QHFfUNDVy4bv5ZOoPfLxqJg5w/p1veWMMg+XzZjyy5qEcAfOI1eRI63YJ5qKPrDIoeu4Y/osmi0AkP9L+uM0v5lSJwwprmsQDbuemSz44FNFpW/wGI5anv60f4W+Ks/Q1Ffr+1Uf7DsiCRlk78KG+RL5fyxzQg1yGNCNL8TirI4QH+Rmk8LEIAEIzjRg6sD237rHdQ1y0HCXqmllCfc/SjXWA== 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=0+eyhh3tfjPJPNr1iqM+fdcCGTKJN/EJNiTp++deJGw=; b=dRJK70dNq36ZIOuN4lJ2CgLAqYj1OOEZCMpxsgBFzoQ7DD+/rQomtSkSx2tJM2O3ual0Sry5TA69NNfYfR7JbMyAhCFfSrsfV/cSppwUTJFQKLO0iYpAlNTVHluZaqlQAB7Lzf6ahCf0SQQNkc3/ocyd75VtHaT+g+2zO5L0rmY= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by SA3PR10MB7070.namprd10.prod.outlook.com (2603:10b6:806:311::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.14; Thu, 9 Feb 2023 08:02:26 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::eaff:9f55:4641:db38]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::eaff:9f55:4641:db38%4]) with mapi id 15.20.6086.011; Thu, 9 Feb 2023 08:02:26 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v9 20/28] xfs: Add parent pointers to rename Date: Thu, 9 Feb 2023 01:01:38 -0700 Message-Id: <20230209080146.378973-21-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230209080146.378973-1-allison.henderson@oracle.com> References: <20230209080146.378973-1-allison.henderson@oracle.com> X-ClientProxiedBy: SJ0PR03CA0038.namprd03.prod.outlook.com (2603:10b6:a03:33e::13) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY5PR10MB4306:EE_|SA3PR10MB7070:EE_ X-MS-Office365-Filtering-Correlation-Id: 9230d3e6-2498-48e8-d0b2-08db0a73fb58 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: OkRZJ9PY9QY9rCarwwb5leDalD6dcGY7TL9PIl1HrjlUIhy6gR1nNWx/F7sgrd2b3rhwEheX/+sSqKECtHcg4n8Vapy2EwDZ2ZmCBbTjR1N7c0ulwdYuZPqc4KRYu6uDQwT8OmRPLFqFSXHFShTuxAsNDOiwV9XcIva3wkro6PuNKoSiT4LPbu9PNRFylvPo+7nfZiaP3TqSPv+mdaanYYdcIyVujL8wV5UxdL0G3Z7liJD38MZTYPbOwGmDLDHf2EBiALOnZCF1k1ofHfrxzaUVqlCZ/cLLuiyBEYmMN6fVE3/TxWkFJCh9dX/Y02P2MsPClAaHHnd9yovyofz+npRPRRaWOLeZ/oQ+8ssATn8AyK0uoHWA5zwxCd8eMSblKJqcv//M/gvXql/FqwnQq1/YyFYiLkFkDxv34tRig4QYBqT7da1g6U4nDwO5A0BDpUrWJCIlScDk5x9extuF9XvcRQdvUWg0eYRasO0zYHeNm6kz2GnwuQsSo0G1hr/WXkcaIQuj2U8ytHsV7lPdTSgwpp8qAqSH3HApuScvYEv1Xfvebqrq66QDunDXB9HyCmHEAFQF58PomRXy7bzzK5oMmzEEvb+FpGWD8UI8zg+A99DJnodw/Px4/oqqZ58//CTfoG2ttLg2p8FpV0qexw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(366004)(376002)(346002)(39860400002)(396003)(136003)(451199018)(478600001)(6486002)(8676002)(83380400001)(6916009)(66476007)(66556008)(5660300002)(8936002)(6506007)(1076003)(66946007)(6666004)(2616005)(9686003)(186003)(6512007)(26005)(36756003)(316002)(41300700001)(38100700002)(86362001)(30864003)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Q/CjYaRGZXzu2e9lVGDJnvHdAXYRraacpbuiGsnzRsBaEgTATHU5BMNc5o/b7TyiFU84SvXdLkKDEPs75mLcm8BqFZmrRZOCKWMicBeHGqLwM6GBBfU+ksm3m7BhC3NPtVhLw6wL5iVJhZoIBtLxKiyEOOPkq4yY6hDhgxsm+BWQEHab4vYdqYO6Y0IrGYysT9wajRRGObRzo+ETaGwYmLI+CRqePoCJ94yVPMM2U7ppPDGJO3KdAAM6HWovi7XnuEITaDZu7cKZD4gDFa1Jj0EHDHd5waB6S/GEKHRXxqoc9rrFK3nIz/5lBda4QmzPtklL8miU2uhISCa5FD9asXjGf/TR+XMBw+GySh7sD9LKSJJRkjjdhacRGFoAzqPEYy7Jn1AOS5qg0rjFugPHmdTpKxlJbMi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7ECcNKBAs+nZtHDJms1f35P8mlgi1XLCmICOZ2vr2TyYZu9BUGrmkrELRuXauOv0l0Bq2ik1dlfdKr9nxTHLVWly2qnB3U9ARMNo9nLju3r5V4IPtvO+Pafv6sF5BA== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: ux6KL3eYPPZg46A2PmZGlXhd2lyo7xJjM1P87APHJ5CBn/hTFlDd15NoEHZ35CO0cqitXG2Ol7Q8t+rP8uzwUG/k7ksqMkxOKZACyDL2o5xfubUgQ86biVYBRC4C1gcd423OhY/9ss0lSiT4yvN/AMFpxlLXT+3kbDaZblgERABergfRdJ1/dSr2UdV1jLKjzfFcSozk9QLJXww8M7IVm+dsN0RhhUeGmNpp6GpY+P6rMG0Kx7c8DieljLROkuBKRlzD1C3+TefnkGChmESVapZo2WeC8NAmU2DUcrXJJF9AarUDZwO6WgNqFtyfp0ThF1NDg0eDXRLHQv78ABys2gJCbH7w8r0COqc7eHXv/apHZUU6vfasdQVe5SZlc0FHrTKdLlbaBrgo+N3dXfDbKdg2KLWtmdaUF7zHF0z6uItrxadlyeszvhd6C7FuTZX+VLeAqG0s+A+1v2jkCLh4dyYlYwJPWqqHyFEyiFZdYyxKChG1nRSsS6dk3+mLLpHvhlviAsZWDSnZe2W8aPOgskVQvRWotVZ6uBqn12XPBE1WRK8fsHI48MDgCW4D8C2FjOHss8xt6QiP/lWqasCu4B4rLwMVLWCf8gH4cETQD0nsEsmjCkdDkpaVR3U9z5z9COWPtOuiEOymQ5rbwYdj2s1iLtd/3uFbjeSqQAw54VmYdFISkKBE6cNKORgrRphIhAz4HoEXtl4BRPhATwzm0hs7p5WPGPpF7tgAihXXR5QCF3CQIb56wIixOrARqMKD X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9230d3e6-2498-48e8-d0b2-08db0a73fb58 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Feb 2023 08:02:25.9519 (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: wUl5+4JRSAvYBDzxkDyZXyWI0zUk+xHDGH3W0afA8AEZWtzGQZrZlL5rfU3wWGz4d1Wu3Dol+0+zmln8NBTAyvjEnS3sqmmNyy93XMhKeyA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA3PR10MB7070 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-02-09_05,2023-02-08_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 bulkscore=0 malwarescore=0 mlxscore=0 mlxlogscore=999 adultscore=0 spamscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302090075 X-Proofpoint-GUID: oOSab8-osx6bNXaOSTeoJJyzbE7Nnm82 X-Proofpoint-ORIG-GUID: oOSab8-osx6bNXaOSTeoJJyzbE7Nnm82 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. 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 | 47 +++++++++++-- fs/xfs/libxfs/xfs_parent.h | 24 ++++++- fs/xfs/libxfs/xfs_trans_space.h | 2 - fs/xfs/xfs_inode.c | 117 +++++++++++++++++++++++++++++--- 6 files changed, 174 insertions(+), 19 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 245855a5f969..629762701952 100644 --- a/fs/xfs/libxfs/xfs_parent.c +++ b/fs/xfs/libxfs/xfs_parent.c @@ -64,22 +64,27 @@ xfs_init_parent_name_rec( int __xfs_parent_init( struct xfs_mount *mp, + bool grab_log, struct xfs_parent_defer **parentp) { struct xfs_parent_defer *parent; int error; - error = xfs_attr_grab_log_assist(mp); - if (error) - return error; + if (grab_log) { + error = xfs_attr_grab_log_assist(mp); + if (error) + return error; + } parent = kmem_cache_zalloc(xfs_parent_intent_cache, GFP_KERNEL); if (!parent) { - xfs_attr_rele_log_assist(mp); + if (grab_log) + xfs_attr_rele_log_assist(mp); return -ENOMEM; } /* init parent da_args */ + parent->have_log = grab_log; parent->args.geo = mp->m_attr_geo; parent->args.whichfork = XFS_ATTR_FORK; parent->args.attr_filter = XFS_ATTR_PARENT; @@ -132,12 +137,44 @@ 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, struct xfs_parent_defer *parent) { - xlog_drop_incompat_feat(mp->m_log); + if (parent->have_log) + xlog_drop_incompat_feat(mp->m_log); kmem_cache_free(xfs_parent_intent_cache, parent); } diff --git a/fs/xfs/libxfs/xfs_parent.h b/fs/xfs/libxfs/xfs_parent.h index 0f39d033d84e..039005883bb6 100644 --- a/fs/xfs/libxfs/xfs_parent.h +++ b/fs/xfs/libxfs/xfs_parent.h @@ -14,7 +14,9 @@ extern struct kmem_cache *xfs_parent_intent_cache; */ struct xfs_parent_defer { struct xfs_parent_name_rec rec; + struct xfs_parent_name_rec old_rec; struct xfs_da_args args; + bool have_log; }; /* @@ -23,7 +25,8 @@ struct xfs_parent_defer { void xfs_init_parent_name_rec(struct xfs_parent_name_rec *rec, struct xfs_inode *ip, uint32_t p_diroffset); -int __xfs_parent_init(struct xfs_mount *mp, struct xfs_parent_defer **parentp); +int __xfs_parent_init(struct xfs_mount *mp, bool grab_log, + struct xfs_parent_defer **parentp); static inline int xfs_parent_start( @@ -33,13 +36,30 @@ xfs_parent_start( *pp = NULL; if (xfs_has_parent(mp)) - return __xfs_parent_init(mp, pp); + return __xfs_parent_init(mp, true, pp); + return 0; +} + +static inline int +xfs_parent_start_locked( + struct xfs_mount *mp, + struct xfs_parent_defer **pp) +{ + *pp = NULL; + + if (xfs_has_parent(mp)) + return __xfs_parent_init(mp, false, pp); 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); +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 2d8f225cb57d..cdbd7df64ff0 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -2871,7 +2871,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; @@ -2897,6 +2897,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 */ @@ -2923,6 +2948,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 *src_ip_pptr = NULL; + struct xfs_parent_defer *tgt_ip_pptr = NULL; + struct xfs_parent_defer *wip_pptr = NULL; trace_xfs_rename(src_dp, target_dp, src_name, target_name); @@ -2947,9 +2977,26 @@ xfs_rename( xfs_sort_for_rename(src_dp, target_dp, src_ip, target_ip, wip, inodes, &num_inodes); + error = xfs_parent_start(mp, &src_ip_pptr); + if (error) + goto out_release_wip; + + if (wip) { + error = xfs_parent_start_locked(mp, &wip_pptr); + if (error) + goto out_src_ip_pptr; + } + + if (target_ip) { + error = xfs_parent_start_locked(mp, &tgt_ip_pptr); + if (error) + goto out_wip_pptr; + } + retry: nospace_error = 0; - spaceres = XFS_RENAME_SPACE_RES(mp, target_name->len); + spaceres = xfs_rename_space_res(mp, src_name, tgt_ip_pptr, + target_name, src_ip_pptr, wip); error = xfs_trans_alloc(mp, &M_RES(mp)->tr_rename, spaceres, 0, 0, &tp); if (error == -ENOSPC) { nospace_error = error; @@ -2958,14 +3005,26 @@ xfs_rename( &tp); } if (error) - goto out_release_wip; + goto out_tgt_ip_pptr; + + /* + * We don't allow reservationless renaming when parent pointers are + * enabled because we can't back out if the xattrs must grow. + */ + if (src_ip_pptr && nospace_error) { + error = nospace_error; + xfs_trans_cancel(tp); + goto out_tgt_ip_pptr; + } /* * Attach the dquots to the inodes */ error = xfs_qm_vop_rename_dqattach(inodes); - if (error) - goto out_trans_cancel; + if (error) { + xfs_trans_cancel(tp); + goto out_tgt_ip_pptr; + } /* * Lock all the participating inodes. Depending upon whether @@ -3032,6 +3091,15 @@ xfs_rename( goto out_trans_cancel; } + /* + * We don't allow quotaless renaming when parent pointers are enabled + * because we can't back out if the xattrs must grow. + */ + if (src_ip_pptr && nospace_error) { + error = nospace_error; + goto out_trans_cancel; + } + /* * Check for expected errors before we dirty the transaction * so we can return an error without a transaction abort. @@ -3122,7 +3190,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; @@ -3143,7 +3211,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; @@ -3216,14 +3284,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 (wip_pptr) { + error = xfs_parent_defer_add(tp, wip_pptr, + src_dp, src_name, + old_diroffset, wip); + if (error) + goto out_trans_cancel; + } + + if (src_ip_pptr) { + error = xfs_parent_defer_replace(tp, src_ip_pptr, src_dp, + old_diroffset, target_name, target_dp, + new_diroffset, src_ip); + if (error) + goto out_trans_cancel; + } + + if (tgt_ip_pptr) { + error = xfs_parent_defer_remove(tp, target_dp, + tgt_ip_pptr, + 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) @@ -3237,6 +3329,13 @@ xfs_rename( xfs_trans_cancel(tp); out_unlock: xfs_iunlock_rename(inodes, num_inodes); +out_tgt_ip_pptr: + xfs_parent_finish(mp, tgt_ip_pptr); +out_wip_pptr: + xfs_parent_finish(mp, wip_pptr); +out_src_ip_pptr: + xfs_parent_finish(mp, src_ip_pptr); + out_release_wip: if (wip) xfs_irele(wip); From patchwork Thu Feb 9 08:01:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 13134166 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 3C512C6379F for ; Thu, 9 Feb 2023 08:02:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229598AbjBIICg (ORCPT ); Thu, 9 Feb 2023 03:02:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58792 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229653AbjBIICe (ORCPT ); Thu, 9 Feb 2023 03:02:34 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 759981351B for ; Thu, 9 Feb 2023 00:02:32 -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 3197PgdT024435 for ; Thu, 9 Feb 2023 08:02:32 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=D8F7qpF6ITLlAtuTJlPsIwlwLTGP2m2hJVcuRUGzdOo=; b=QBQ/uX1tPjxoy2KLj2yupqcC5nxe3cWiYZnPsu2gR8UsBB/1cSMFzoIGzs74x02rxyLJ 7cvCyoQKsUXz+/ozsfoFveC3jylWhdqd9CjkgyACffM9MfXQo10v4zl+w22PexPnCTxK 7r5/0EJQxRvn5EcpUV5IvaUMDGzMhOBL9NRmoQatn70+T2QbfgiHZX5s1otlc2v6+yxQ qUkzK2DXGM4oMwgWVDzlm0nN/tOmscuvlS1mVnrLGCypBC6gP8Rv3YY1agQNLUQrMzv8 EKBXKg3gGLpM4AMl1DQ6jVvxOTfq/P+Bb00xcycIcaUYrCwKry95yVOOkSSIhEuGp9uE EQ== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3nhfwua2mr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 09 Feb 2023 08:02:32 +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 3196KLvn021320 for ; Thu, 9 Feb 2023 08:02:31 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2102.outbound.protection.outlook.com [104.47.70.102]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3nhdt8dvja-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 09 Feb 2023 08:02:31 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cVMYMv7GGeuQQz2s10cLYHy095+SXuqDDZByRiez9r892eb3+ZDl5QBAfmWRK1YVRTccCn7w4cBtOVmpF/qV4u/AVxV6AN9uEbID11lScGV03J4TSANIKL1qD7jLsJDSwxFPlrBFgRxvQDrjRQiusrEbYBD1LKksIw9m3sZ2ZP3OszNK6R6h9Emfe1NzckuNVJAaZhnVCyaIJ0bybq6r18Li/gWDtktZckhdHxJB463dh1BoJIybnCh24+gGVUkofMB5K3TJ4FP/48mDaR/dDu7Qf9b2fiCQZ+vsjcwNxQlxEJB395BX3YSW72YFnyuisvcLKgD/7HOqgXXRtGQKWQ== 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=D8F7qpF6ITLlAtuTJlPsIwlwLTGP2m2hJVcuRUGzdOo=; b=RFE2s9/TK3YbBOT04vLa+9jM4/nrR7KY6QgwPJjUDE4QAqfT0qhQe/5xP9UIjsPrP2rPufLtAy3nmTQAC8AgS8uKwv64JqNmNw6KUrgBLcqt4NG4rhwWqu4NOE1yX7bRpkpDSvmpNTR9F5nrUeTpFkrwRga+ajoLe/ZSEQSMn36XwSdwKqZo1VDMOj0F2SLYxr+mQFZUkG7wSmFtO/VLaVsrsipJWt5hhYvRHa9sMMpq4HXRGTqOwCRj4RocAmWZuKzq/b2E8DZJ2p/0GapWxGY5K17w6eNLrjxzRYoZ70Bypa/MJ0rPg90KNl9NMvT6YR77r8Ubz3mD2iFz1DOTCQ== 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=D8F7qpF6ITLlAtuTJlPsIwlwLTGP2m2hJVcuRUGzdOo=; b=tSjfZagaDdApNwtA4m8x+PgeKS5GEEGZnSatx2uQbFOJBiNnjW0ebPFRfPbDxR0N0WRSbCpFiop88uTJvWSdi9rT8KUe6iYIfWDttUPnpVZuv3kb3nG8ACjE0d2SxOpxUCwTfL8LEcLHzaXpr+vYB9Jsjb+mypGou/UvJvbklVg= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by SA3PR10MB7070.namprd10.prod.outlook.com (2603:10b6:806:311::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.14; Thu, 9 Feb 2023 08:02:27 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::eaff:9f55:4641:db38]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::eaff:9f55:4641:db38%4]) with mapi id 15.20.6086.011; Thu, 9 Feb 2023 08:02:27 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v9 21/28] xfs: Add parent pointers to xfs_cross_rename Date: Thu, 9 Feb 2023 01:01:39 -0700 Message-Id: <20230209080146.378973-22-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230209080146.378973-1-allison.henderson@oracle.com> References: <20230209080146.378973-1-allison.henderson@oracle.com> X-ClientProxiedBy: BYAPR07CA0017.namprd07.prod.outlook.com (2603:10b6:a02:bc::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_|SA3PR10MB7070:EE_ X-MS-Office365-Filtering-Correlation-Id: 9a580373-543f-40a3-ffd8-08db0a73fc63 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: drSz31hqIFdznzNZFK9WcQs+INrOdiaBG0iec5ne3OBaMYWZLIGDvndeLr1TChA52Rv7WE/NNLBjc6TDXWGui/MAYIptMDyHCkKIXTNjFa6E+4DO0UaNofIPrrHx7JRi+7JMUhiKJX6W71/WGRhZu3wHnsEx+2yhAWgTbDPX22LN3g5RexJ5ViYZnXHQzn7Tv3T1VoFghmPx0hgXv5GIiAEQCiU6TMIH2DWHRpadz3iGzScA99/Hwk//A5Q5iCnFF+B07ioxeZggLC4sWEfn6ovNZI0o2Y0Ij02oiQeKN78b14Vm0ioQcFhyiGpaii803xJIEodd81k3zbq8g2FntqtdN6V9hPZfQYDRiZW3a3j+n55Cwc2HzcvLQor/HNBpQ3AqZrlN5nd3TJaDKr9u6EjDeEqM4+wiJ0Xc3331F3bWjTD7XPEFnVHos1Fz+wlR+naCHJ3GvcmmMKjbujWq5VSQOOUFHpdjP7uDM/h+BjpOp97MW6J3kwu5vdh5eL1ZncVd8SRwlu+Xm0PBQyz5S2EixtY2GhU4grRBytEq+r4Nl8bSHeFXH/dHBIytpnzpnu61rQug6ywXS56AkzFnulcIAwYxpSaAANfp5GinHdvgDCFuHxR+3+S6OrZhG4ZAC0WfdQ4s9hihiMXimNfL9A== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(366004)(376002)(346002)(39860400002)(396003)(136003)(451199018)(478600001)(6486002)(8676002)(83380400001)(6916009)(66476007)(66556008)(5660300002)(8936002)(6506007)(1076003)(66946007)(6666004)(2616005)(9686003)(186003)(6512007)(26005)(36756003)(316002)(41300700001)(38100700002)(86362001)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: N6HJaeZuEg8e2vKa4ImPZ86/oUQ88xo40Nye+vhJEcNPum6SQ6BIt9LBbTGNBCKjfbYt+bZQSa+wP9Q8PsugYg7lJyRRlnZhUEMTMQTl5fG1eddrxqllQaVjIldeK04vcX1qKcGxIbT9Ugak132ihIvPD0GwYXCOLabY+9w5YF+wGcqKZq7/evpHicfzFmViXnW2Fq+7tDJ2Gg9Y2ip5U2769D23FkwBzc5h0rB1EZpOvrB1p78DYhjoUjwuaOpeeWof3Tw9xUnu0HZ4OHODhqcVkqa8KsTl4Yp4l4OP3j5Ow2531V7WApHdps2KQ7EAFmYmljVLlHb1wyx5oaYisGvqGMz3CqrNN+KuvqzMeq6Zk652zhAX4DsqTpN90yStpY+EBRZYPHhE8o3y42JDVuqNAkGTNtDcO1Uk/lEPYBnegHAIjzMMzxI4y1JarE84ThLlOgA16Id02hGNblz00lps7qrSjf4QRgagIj3RbyTPc6VJQYyAcK1hPNsH4/U5qbnH3kpJwbhv3Rv4JIeUzUiBvMKDXo70XCr/KfrIJQrQ42hX87h4IUIjs8u2j9S4PFqNKp3h0N/QMjSq+0Emy3AOI8e356tLOxUs/VjtXBdenwG96t+LZeZQCmpPW78ZsI/ugFlB76uNLXrXw163VZOB6/fdXDEtRlEHuwNU3qZD9gSMw4GP1ALjbGeRbATWC3d+69C88rm3471CpZapAq7DU41bRUvGcvC8/rAy9tEmIdNsSNbgi3lt8l9Yf47Olnfr1MA+DXMYK5RywZ0T3ceWSCr/tFZqoW2lMWACdxpn9jmuPKqaK5tiUkzQwsXmwG5HS/UyEFANQlQYcIk+uTOz8f1iLaFdb+rNMYKHe/32QONv+icV8OPIu7VdeCRq+eQEZd88XbkKsIO4CWs+jICXJElB/IQvsJ/vIUM4V2TInLFhnTQTEYHVS6LMda8iiF5iiB9I/GON1Wazt9o6sP7465seHVh19GAiZMLi0j5vOmNCRVSBpHuYxJgKJF2VUKkcWR+tlihCuP/dlIV8hEfaUFYAXlN+gMvGIdN5WHBFdBpFZy+TT2dArQQ9K7sxw5OsuHxeJkWCfvMblAMrSFCU0IESII+hBL0FkO+zvmG41sVoF4nBTcujB+vogW2Ozg54Z9p+mlmqFtay5xpu39JPSoDBviUbIudHk7CiG0TkR5SfFwssIu8whCG3jm7kXh6m8n5D1NHLBfNrUdArW6KdkMPXvs/qhPU6jMCLUOu7P0XgGLHbPN5KrpBpX9x28J7p4ZrgXG77vh0LmOvh57x2yBMeH9kz3Y8WQjWWKkMag9xIs2vij9tfnzR3V8v34ZruTzxR+sfAMSCUKCNyirxvUbYdTfifzO7MkABDvqajooIoXu4uyssBr/UbG41/l6x1pPbA2ZSTv2WYVAhqj0vGXe+/Jol+tXJ3mEUsAXSr+8txozyPhjf5SKoMnX2hGIoCNCKjDktx/6b/KqNKGwua/fVjx6wTylPzN+K55fgcvl9+D0drn722Mn6ryiH0YuL2qURQkOyFFNZI1eVUHpgBoM3ftD5FQWrVaHTeO1mH9cgHXO1uTjRWNu7V373ZFagKElklvq4K531uAeyzUA== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: Ss4FZRWpXe+tJP0ljqqXXycnQkuAnua0pBROsIr4cwZPBdTF8QNh8/xPOlWmb99j9zeHWHbdjbhHPhrC+jI8adxVBy5sSTrgMKFu08rb/FmL9gybWusoV/SsDautVHXmPkqQVuYFNM1XeNMALMhz+aNFUfncUPpjQywCU7P10wDoawEIYb4+XmDJHguF+oXatTwwdeaKIjHXsA2QH9+LdEGI0VEaJUc8OUWQk6ohjN5x/Qq+9n6+MjQJ4SaJFDBrBRO5qQd/wI3sTayUYqj/wD+/kdZFZoK8EySSk6/5L1HFkwZS8bY3tirIP8KnPBNdd6XEOPQQuRGyGYIyrCk1kvflm5kQ6639anqQgmsTmbatD80K3fiHARIi962pRveFE43xGEOj08ahFBi6ISp+HySrmWRXkD4XO4HPG7fPiinIKA7dBbFR9VIEoA68c671N3eoL2TkrZXZvNTIRy0i1x9HqTqJMcQYOaekvbQVNIRyy5QeBxVQhNYUNKyLHDYQcFy73ccLhoyafMbx3WWWRXsUOE4FGT/Rqg4/8LgEgLP/7picBmrLVu3t8IouxW+baW4fa8jz+kyoCevupDLB7UUBzujmJA455tuwp6kt/3wnHYvJJe1qKokIv7IbdEw1WAYERG5nPc+ANxH1PSEI3pxaRxPNkguuU0supc+xdQ5Alz8mB45EsKaxDZ5nDUIN2gD/V87vpIXri7odvDdUVFP7n5QqezwEJVUC6neo+lGILBLDbbSmkavfjo/mveNR X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9a580373-543f-40a3-ffd8-08db0a73fc63 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Feb 2023 08:02:27.6704 (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: PPxpWX0i7FL4+9BgH/qh6GCXaWN6gvkCBKvIbhhaaaKGATDovmOMSBAjSxccpw8ChvCZ4xea3QI7frYLRs9M2x5T48bilBZQDEzDTrZa44w= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA3PR10MB7070 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-02-09_05,2023-02-08_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 bulkscore=0 malwarescore=0 mlxscore=0 mlxlogscore=999 adultscore=0 spamscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302090075 X-Proofpoint-GUID: RSiw6_fHwqZFKr7rR7lCi9m2jvXM6SUW X-Proofpoint-ORIG-GUID: RSiw6_fHwqZFKr7rR7lCi9m2jvXM6SUW 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 | 51 ++++++++++++++++++++++++++++++---------------- 1 file changed, 34 insertions(+), 17 deletions(-) diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index cdbd7df64ff0..6626aa7486f1 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -2749,27 +2749,31 @@ 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_parent_defer *ip1_pptr, + struct xfs_inode *dp2, + struct xfs_name *name2, + struct xfs_inode *ip2, + struct xfs_parent_defer *ip2_pptr, + 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; /* 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; @@ -2830,6 +2834,18 @@ xfs_cross_rename( } } + if (xfs_has_parent(mp)) { + error = xfs_parent_defer_replace(tp, ip1_pptr, dp1, + old_diroffset, name2, dp2, new_diroffset, ip1); + if (error) + goto out_trans_abort; + + error = xfs_parent_defer_replace(tp, ip2_pptr, 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); @@ -2844,6 +2860,7 @@ 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); out_trans_abort: @@ -3060,8 +3077,8 @@ xfs_rename( /* RENAME_EXCHANGE is unique from here on. */ if (flags & RENAME_EXCHANGE) { error = xfs_cross_rename(tp, src_dp, src_name, src_ip, - target_dp, target_name, target_ip, - spaceres); + src_ip_pptr, target_dp, target_name, target_ip, + tgt_ip_pptr, spaceres); goto out_unlock; } From patchwork Thu Feb 9 08:01:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 13134168 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 3B6DCC61DA4 for ; Thu, 9 Feb 2023 08:02:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229653AbjBIICh (ORCPT ); Thu, 9 Feb 2023 03:02:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58794 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229672AbjBIICe (ORCPT ); Thu, 9 Feb 2023 03:02:34 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0832F265AC for ; Thu, 9 Feb 2023 00:02:33 -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 3197PePH003345 for ; Thu, 9 Feb 2023 08:02:32 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=42eV6BCZMwlgEoy0Eapx6sPtbfuRIysXlYYK6QuNkXA=; b=0wF2jxeCzROz5LYS+eL3jLkZ46g4aX480I9D+h6slnuGCUzeDsiZjmhBkAuPcDO/BCSm DNcz/KLfd3CLHTyxTg6q9TTzP/roJ3BFVch7szFWa1lSwgQzx8DFZLv29tp64szAevqk r6s98T21AuLxk0/prqqVae6v/1mvfxDzdECisMAiG+B/AVuE1LOTH+4g52zRotsRJqoP CUluhpS3e+dMCU7RCV2Q5mxOd3JiJSd1huHZOck89JAe8S6citUJY8v00Cjb6C+al+ji /XwD8yQd0Wv8hWMHOsqh/QKZrz12iopRAEkjoXx3HiRM1xZd7SxBEOSXrHxRALi34Oro WQ== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3nhf8aa44v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 09 Feb 2023 08:02:32 +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 3196KLvo021320 for ; Thu, 9 Feb 2023 08:02:31 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2102.outbound.protection.outlook.com [104.47.70.102]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3nhdt8dvja-5 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 09 Feb 2023 08:02:31 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LR4ZpiiO6EHUTu9zgLnZZbC1mfXtKIlPBmoqKbwnH15lj8WNO85iFbxqRN1doz/fdXPbvZjWU3o4jO4r+DAcy9NmxJKxzWw9W72FWkRyaw0YfHTu0fJMcEdbsb5D9zwJQA7DvJ6heTwlpKIIcE262cAw1LGbbTWQmjiNMBB9FX7R6MnXdBP6srmDPBF2L5SjlTkb8AepNwWIqH4ea1StxC8gizKjXdcvk+3CikudjVoOzVPOLuIs+sgZC1EnJK+jAkhaOVEE0VkI7qYeAfPvyBGIR5tpkJ/FhKylGDPIAdywZcXvr8cATqD8gY4SCL7CdnTFR0HC1Edzgj6b4eaVFg== 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=42eV6BCZMwlgEoy0Eapx6sPtbfuRIysXlYYK6QuNkXA=; b=ha4IXNlKH5xz6GN6+5b4R1r2uvYX42M1D2QgASd2az/7lQSBE5q8SZkQ3rHLRMoi6B5jL/tKbtFosqRGyMYVZQy+gURi8mu72PtpDjyKz4PPI7GmQB6909gJX7ULTv9Tu31qnxo9eHNzNQOdHWa4ZSZE9ImaOQ5xbVdb2izclZLntpJztNxBf4qRIFOEA/Gi/ikZLCL7Irmoemtt347CdQYvHzfpe0JMORgjdennKG1mE5+3jzdFI9pQycY7DIGEUEq+90sy7itql93GOIMYKH9H2PwqAY0quV4qP/buM4IfQ1iJy6cvrc81YE6EoUB/x1UFej+g6XSIv4RW4Sgtdg== 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=42eV6BCZMwlgEoy0Eapx6sPtbfuRIysXlYYK6QuNkXA=; b=Uo3A0NCsdBUh3fFe71SSFLGOyu5dr29PEIZRXa1NwkBCufddrdshXoiEL+WP0l2cbfpennLc+D9JtsMK8S5/TQv9dRJOXa4aNpLbKUwzzeIZU+KWXxI8oUk3HGi4bg6XK5aJGIM0A3wJckHxmhoiABvS+QPIuvKMqnrAnHa7uKk= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by SA3PR10MB7070.namprd10.prod.outlook.com (2603:10b6:806:311::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.14; Thu, 9 Feb 2023 08:02:29 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::eaff:9f55:4641:db38]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::eaff:9f55:4641:db38%4]) with mapi id 15.20.6086.011; Thu, 9 Feb 2023 08:02:29 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v9 22/28] xfs: Add the parent pointer support to the superblock version 5. Date: Thu, 9 Feb 2023 01:01:40 -0700 Message-Id: <20230209080146.378973-23-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230209080146.378973-1-allison.henderson@oracle.com> References: <20230209080146.378973-1-allison.henderson@oracle.com> X-ClientProxiedBy: SJ0PR13CA0197.namprd13.prod.outlook.com (2603:10b6:a03:2c3::22) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY5PR10MB4306:EE_|SA3PR10MB7070:EE_ X-MS-Office365-Filtering-Correlation-Id: 2efa8c66-0ffa-443c-c437-08db0a73fd6c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: wI7bp4czE7WQGKN1jgMF3s+D7/otGaiMY3wuTYMjSyROGLvZKWtXCs4Qo3hXvESwES/bbikyVXmPZ0WC0EPPQ7e+hiq0qw0+M5ZG1MkdnpfWcp7ucuSv5f1XBB9eDwuNG4JqGnNL0NLOMnW7uai55dKVnP/7bn0PAo5jUfp30zv8DkAw7WbCPmBuyCsRcMSg/deQdUjkABUbwra/DBkrCY9xi9/OL2fXzT+HxQSHrvKcuLI6VP1xRFFjWfdn2qS5WgrBl2PG//u2KLPBuzEiJVOYaRfF7CLEG8p+JL8srEFtS/lN2YSX6FoROM03p7M+XATf7zK6e7cvGF+IleaXNvmrCogk2TOpPafsbPkl1PvjZz3chsEIj4/QeGew3xeq7XYNWyD9Ca4+oU9CUqd6+1vgnbC7I0Jq+viu3PMDsjMubn/Lg3B1CRpqi9U4P9+pwyy38l723ADKIiodMBPiQvBQIFBfcE0UtS5hZm4HlGePzzhpcs5OcYBc54QDCzFZv2E5uwsaiZLx/Y1WC//KmnLM3zwjEWkRda5MUbNkuIhU/VzglSQve4uyt5z2F1FXXoKw68mPgdLjbdeGz9Vnd71MCwZUow3DUaLdtMEQ+xEclsKDiN0fikurBSIfPtcCXhNS8vLKni2emOS4uWEeig== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(366004)(376002)(346002)(39860400002)(396003)(136003)(451199018)(478600001)(6486002)(8676002)(83380400001)(6916009)(66476007)(66556008)(5660300002)(8936002)(6506007)(1076003)(66946007)(6666004)(2616005)(9686003)(186003)(6512007)(26005)(36756003)(316002)(41300700001)(38100700002)(86362001)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: jNpn3YawfS6v6bApGZE7hgYdlYMJTcKXjgvuFNT371krzouDs1H1nMHnnRtekRGdILVpsG0ayw5h6h08te2bVVnwyNS4BEL2fMb9rJLoj2Y/GpbGYYC+lbW+3D6Romp6/QNqBzjsUIFYDVr+GiiWWdK6GgNVL3+piXnG6osEJj/RrI2hUhoJTvsclD8gkC7Z/+6rUMDg05n1qwbbOPudT4jNNuaJN+dsvz8ebNOevLjisU2KrJYrM3E2paxpFfdgZG/v8fUn8oMS7jw4tzP4hR8YSnvVz46cZyWWknMKggx07lTZHyto5oksA+w4FM/Xpig58SrLw99XLvZLtQYQFIx2thHiEdhZ9gmdgzL6TfiyLWzLBke4ne8LkslH8SbEEWgAJvIogJQvyrfjjbau6y/YjyBQHo5kslEg4/446q6QOdZrNa/spZVcpmRe6qaXPrApelmxVDjDLSyPaUxCmgnXcpxl9tWfDEm1Jrxk+bnuONJoHhEdKqgOY+br5Z1JpcLOYVYL03D8xTDgBL8HQV24lw9GxUJ+yWunBk0+aJon2jO+fZjE0RQb175TiQkW4VsEL/Jh160dUo9nxE5gxEJJPFzywEN9IITyGP9JDmkqesIEJgZQTCtXsrwCwD5ZtBfqNvzhQmPxU3FyCRAsVuwU9f6tN2K/U6gXyUzA7UjAS8E3OWUZbwNF7I+kelyJHe2c6/uGzkxqbGaI7LEl+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MmhmZlun8WQtLZ3nNZ1ORKn6HJd7DYe79d+mqJG0uvmmWMlCYs9rHCCRNagabGKXr0xbMATZMJXonL3pONCQQb8kVkW/t4ZTQNrVEXMj+o8n8RbPTBzzRjWtSEcAPdZ8eDFqAvQ4X8AEj+sUpguAoZtQwzC62X7CdYJPYAcgM7lCjFOl4iFmrcwzLJrKOAKkm1c0L2ud0HqQu4GC1Gs3STWsrp6KVaHaAzijIqaiJNcPXTW2RLTBHjEzZCxlpwpUjoVA5Tmh51ameY4JApW3i9wO7sNZIQmECgtp2E/tkFIXQsJHhgJIoaanBrmhPnf4DCxFBTmDGPFblqiEpt9g1buGxhbBFWme/XuGGKfNKI/k4y92v3nBhA3BYdETj9uudGd8s2/V+ZoPudD0vaZHKIKbeCpZ0P0vZC+OeOMQ//bjLPvo78AVs8VieVSSpfkV9YHMAGWDnfyNNHrjmv6uD+55YnLM6whUDA9HM/K/RO1KzHBA+OhsCcjJdTK/hYePb4CCv7YaSv6anApWZLzVHgOoA6Nu3+Od+mzon4qb/dMrRaf+tOtPoVzpF/YNZZFzqgYETejckpmgIYEcoTOgza+UdGDvFid1BR8s0YD0s1ZxxAdDXN0WkrK/unfTBfB11uICMBhiEMHNWQiG7OtC2twDQ195XfUis X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2efa8c66-0ffa-443c-c437-08db0a73fd6c X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Feb 2023 08:02:29.4368 (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: aKdqZ5c25I9u+WoJeyl/200nl5AfZOVFgsrDLxB+VknH8Ii9WD9Cwia3qBXipkK+bAoLdAJMfdCHPDwwMqr1l/pw7cexWqggkp8hpls8n9M= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA3PR10MB7070 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-02-09_05,2023-02-08_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 bulkscore=0 malwarescore=0 mlxscore=0 mlxlogscore=999 adultscore=0 spamscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302090075 X-Proofpoint-ORIG-GUID: apd6hJHMX3Hbmt4T_mcz6i1QCFv5rgp4 X-Proofpoint-GUID: apd6hJHMX3Hbmt4T_mcz6i1QCFv5rgp4 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 6795761c31e0..0ac55d191f1f 100644 --- a/fs/xfs/xfs_super.c +++ b/fs/xfs/xfs_super.c @@ -1664,6 +1664,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 Thu Feb 9 08:01:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 13134169 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 C8CFFC64EC5 for ; Thu, 9 Feb 2023 08:02:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229672AbjBIICh (ORCPT ); Thu, 9 Feb 2023 03:02:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58796 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229677AbjBIICe (ORCPT ); Thu, 9 Feb 2023 03:02:34 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4729026867 for ; Thu, 9 Feb 2023 00:02: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 3197Pru5016231 for ; Thu, 9 Feb 2023 08:02: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=vsMvGLx8okHtK0olwwc7WZqMVdIoOvrBE31gaFSs1aE=; b=bYvJuakvytjmM1UD5EkgiWlGL838Novxtm78AyHXzQA0I4JbK4yi25IsuAGqfEMj/zNR 9NsPIoD3Co/5EJeBooeg5VgGMOqFyyZPf5sOyyKfOMv4VihoieZNtkKdMICHlhSXv1Ja eUDkm/xw2XBt4mUR9dRIMbDVKRfdBev3aj0w0WwrfOlj2n4x6A0NjXbIGOkbZmw/modO lvuLSl8D2SIUXKEwEYSKk+MB4MkJm92iKVfkvzu5W5esCO0g4nbLDv/IeNd2PZs0N9I0 AwzuSKNE2ZKtfhIAkc5f7v0ZyjQgHDv4wMEmXHlq/RhjlbhrYmRDqRjYvAxnGJiRs9KS dg== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3nhe9nj4eb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 09 Feb 2023 08:02:32 +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 3196KLvp021320 for ; Thu, 9 Feb 2023 08:02:32 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2102.outbound.protection.outlook.com [104.47.70.102]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3nhdt8dvja-6 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 09 Feb 2023 08:02:32 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KQgrZ1JDHwHdDGbsTBQh5c5dr6FRGD0pAzOKyNDIP3Mbt2ga43rj1MCsmlqnQyGS0a0rcjy1HoynViRcY0Tk17glIcyF+tkDvNVSNfsaJ+V+e8TWDf5s5YSkOJ8UVQaEyxRyCnNCvgVQ6PME2l3SG3QI+MHuYeJjOut0s1ypvZJB1lI3Fpk93ire7DRcgZSiPNkXmee2LPDqrjWfoK4qqBpeV9Pn+zRkBtY8nHcqU5OjHuZwfbzMymYiKLQVImKSD3SZzSl6Aw/QtkDWF/IokP4lNKDURLMhuTaPGXJAk8k42PJrQsPzguoBCdl4wvyaolMqHvJ6H7syxMt/fufZpA== 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=vsMvGLx8okHtK0olwwc7WZqMVdIoOvrBE31gaFSs1aE=; b=EcYHgdhcfova5PIN5vdGIsr1wpANlk8EN5/Qblcdice4N6xnXJ/9TELSLLfz2GfXeDXV8+z9JgJ49Dk3hq6ugyt1xTdWXbEjCTuc+Fwbe08+9lhMufEnZAUmGbXiICqI6OEkEIDhOAiIR/xvFMKfyBQiSnjau0iVBACUHVrgIWz1noEs8HeYFcSZ0qoTLyJrMqBLmYZZ+A0LF0bE/U9iidcrhwwICCRvHG3NOFCE7zk7dfDHb6UVIiznMYZ6vej3vSBAlHdIGXld81ZxWC7b7rLPLmO/WlmQs9xMcBlGqvU02mZrVq7Km2jnHs6BpAG28t+XAFuDtXICwoO5IcFW7Q== 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=vsMvGLx8okHtK0olwwc7WZqMVdIoOvrBE31gaFSs1aE=; b=UjJkCW3oACOy4rr0NNyt3FLLPX7HuIiUuPk1bNorEx400LZJyb2cxONfvUPtoHV0LSrA9qprVpy9gxjVEM89fFO3Ja0ehwPZooOuCjsPKWr3OiGIfhjOi0RbnbyhsgIZjwMghyBbgC+XyswmoIjikOLz/aWh0Q+R1iXnSVNtrVE= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by SA3PR10MB7070.namprd10.prod.outlook.com (2603:10b6:806:311::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.14; Thu, 9 Feb 2023 08:02:31 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::eaff:9f55:4641:db38]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::eaff:9f55:4641:db38%4]) with mapi id 15.20.6086.011; Thu, 9 Feb 2023 08:02:31 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v9 23/28] xfs: Add helper function xfs_attr_list_context_init Date: Thu, 9 Feb 2023 01:01:41 -0700 Message-Id: <20230209080146.378973-24-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230209080146.378973-1-allison.henderson@oracle.com> References: <20230209080146.378973-1-allison.henderson@oracle.com> X-ClientProxiedBy: BYAPR07CA0017.namprd07.prod.outlook.com (2603:10b6:a02:bc::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_|SA3PR10MB7070:EE_ X-MS-Office365-Filtering-Correlation-Id: 173a9d2b-3012-439f-4839-08db0a73fe56 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: A8o2+lSMK26734WCjbH/AoVJHoDXuk2m7hJIzyErPtw3cpUKBq80GcX509JfDFClP1+IiCOWHH12/kWhFGMzpJLJKZ4fC4kSXGL5EkwMwJRWJQRmpKKmmPzw+HFpiI+zg1/SkvcVCNR1VaRS1DedanKLGy6oU4GO5faGoCEaPa9umVg+I+MwkvtBcjxTucD6x1Cf1yLlZgfjhiAfedB1gqOKUVS4/1olv9viivy80OOmPVud/Rw3xHG3VN4G7prSSnDDl42Ghotk5uTbW8VPk4CRIdpsgoXTSM+/LMhM5syuMu0RNfUcTR/RvwPT8bUmldnWwGG29xC+24xIx3RzjLqWpNen90aQ1H9kQardX92SCKua6moldcKHkPmgWhjhw0l3FsCumiyZDJVGRkHXjIalQxwZmrgcQ04x1Nfy2SvDd6+S9difnuTVRwEPE4t6NCzEcuc6wer5wxmNQGUR/rt2Jy1ZE2UCRBuFsw1Ka5moId/AHmy1kuT6iD6oEHyEyRmg8buqpYXcNbTr8tCvnxsFbuCcrjDkayf2Po8TTmYG5q9s3X956ng/uYVB/VR2X+WFBMvVmDLGcfPqSoqKIESmK3pxXc8ex7MRCZYP84baAhSwYECGRttKXesBujSLXK9P/SZrocYtMy9PU4lMeQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(366004)(376002)(346002)(39860400002)(396003)(136003)(451199018)(478600001)(6486002)(8676002)(83380400001)(6916009)(66476007)(66556008)(5660300002)(8936002)(6506007)(1076003)(66946007)(6666004)(2616005)(9686003)(186003)(6512007)(26005)(36756003)(316002)(41300700001)(38100700002)(86362001)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: b9gKNMyvNqaYfo4ogcgaOYHfM2PTXOAHmlgyfCigKagFCm1JXe0+VuYUyW8Oip6+3rw+RxkoZQ66EUv3IAgyvDxTE2gjA7CyokwgERQhXb7/qK5cIhtLATELhMcO0fVn0Dc2Nz7OVXCgQVVnYt95/c5rfhyBYJ8k7LHrWcAJBxqpFV4nIe/mEnxeZYd6950t/LQNN6xIIFTQtnEMu7zOzKWK9VNqwDhIJdBMuL2QNZ/aPjlj8S1RLLQuDUEyvqPQ/PXnAFWthIJiuQ2BfbBWEr5lsoPDEhRg1rhClCEglNt3sQ6Wn8Sy1VON/+OGzoI66+cBxwgflYyLQxSWdnena0rtaSLyXZxIRbSeq8n/xmkUxMHfmQhRW4H8gTfQo279ZT6klUq9gXZ82AySE8oajWLLnVGAkOmmIOiWcSkBidoipTRKUHm9GejkVkcUMHOQNT+4iIr9CQ5J7u1VYOrgJVUViDWePWhBeDG/3Ve4IfuEupgjB61bVMs8UA7eQp7Ceg/EKhHZGH6paiOX8gfneLRZKvkaOHBnWwVyESE4EojoSHpURShiWdyIqp62hQXsIUSDuHzkcZF1cNTWhOihEBJhM3rHh+7qioY1xRYNLX8ILQQIOOEIZbXeHQpKkN74e4TLSBMZmoILOIxSh+WBPxU7vEQHC+Jz9yL4ZfKbQNOyraMQFUAK1XN1+vRjkVFSOd18NSqR2qj7NLQ+Ppo84kjTuxFACDoOtZgElFl1Hjzni94Fi34YggBn0rvCSBRb4j5ds/5FfWntYyw2GMk/1BZxd7mHkykbbMl4HvUR5Y7OOugzNfGAWgtXVfSXaORJZStk2xkaK5nChtk3EGXxA7j1zorYS7HeQDVQWg2tAmFoplJaiPGztDoFSktAPZDv4xIrElKuGEcY5GFEtUOrcyh9Rct5/jOkqVFwiYj+WNNvEQGGD163Y+oXKrWsGjzaW6+5wISJM2xqkqfpv9l/1zDLcmsFcknbrZJbn3lx++DlvEURCS+DY2NrgDFdI/DeL0wLAG7ofvkzim/C2XZwqZ9lucC5vIrVl27C4KYB0EdZvzvI3Aj9vvtteNXfvgL/irMdp0/NdfwNrcCosrOM5PEqvTjT6zYUCIqltBCiCADZftIsQwWm9S2VdeOOqouz7TLD1hQpFjtPrvEhbkhd7RERpidk7IZ+/K5KoUppYnQiNaREszGw4j7leYB4u177mNB0M2AlueflkJM+fzJ7MvFZqtltdddKlpij7S+zqscG4LVFLUMIi0S3LlrqHIpxpHnB6niljIfYLDx0fsMOG7qyUtqj/kZaQQ0I9edr7dzm5saLAm80ZdcF2qMa2+Y1JBpZHw9sQyd4RHpRVGmH9Hs3RuO9GFwyC78UGAKABA1Vw0Dc90KYz/ofMnLzisemvesUZqpE2KdzIjYmkdOduTaDcXZMcACkFWwN2Df2g94UX4sY9nfqlG3ITU+WwnX4x+lsjrst+NU+YCmmVMXXzypEUtwnC6RB/Sj1xthngrvx9VjI8PGg8FPAPWKDz1NQ3hkXis4rUrHeKGVc/kc5vnRPMAYawL3MUI/fT5G5g8u2yweZs3MU3Jy/i+SPPMnZn4hmbDcruAGfDWNRPSfCcA== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 8XLpDIfkxFgx30Zqzi/4xIFKa221MlEzPVigBbivblft9ujLwG9jKekBhSWBfhtRfgumwxr23vpUvSuWOqXO16CxOtm3ASGC9SZxBvaltssLCx8gO0XUKLG3C7ZYoEGSxiKtGdBW6Cbwc5GnHAw1yMHNElPyABMCG476ZNGqrfj5077t20F9JXJAD704Y70wX0f9Rlq0Rssxv1ThN/c2erro9fXShyGXPsN/vsb2ulN+re0yRp0kpUI81kv1s0mtUXFYsTa7cUHKyV9eCZcwP+1/hp+kKDKricPVFaBqQ2g0zQAF0whchTbVv6vPoUlYDUhDff00GNx2A8e27JHZ3c98ZAvxS3v/896ahOifBpETBNUKRedJ3NXLFjKy71vR+4fRI1sYvkwWdZETt2YOhP7EiIopnihzlDpdlqg9kIFZbhA35FC84bDCkYX0vWIpmAqlOAb7Y+CWgCwQ5WaPQv4+sD4lxBWGgAg/r0rp5IvVBdC6KTghcsAZW4hY45+ErSwb4j8U7Nps3JHua9kP2hGnkRlk+vdEiKHlsNV794wNreRQu19SIQec32O/O5nqG2kjQ/dJNRlXjjWqcq7hekfGpMN73mDToyJwWpqgOccsmZ3ZFY1jQOz/so0slNwVFJEie6VE+zujxkR1WhwU4e1vI1orzKEIQrCnQUi2OOLYg+tYjf0bljhbE/X5exVJ+F/DNegwo1jwcHmbC/3VB0pmWjjBXEcg0B04r2hTL03CNRlDcoqnCt92DSLHcLZJ X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 173a9d2b-3012-439f-4839-08db0a73fe56 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Feb 2023 08:02:30.9515 (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: VsS1+WSdm/xoA6uhbL+kh2F3CDKe1K87CWdTLmdN+nUfmKdHLrqCAzVD+pw5wbrYNvCGlrUQd2q6fUz+HHwIEntkrwFsPfFj6JGgVwpPbso= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA3PR10MB7070 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-02-09_05,2023-02-08_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 bulkscore=0 malwarescore=0 mlxscore=0 mlxlogscore=999 adultscore=0 spamscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302090075 X-Proofpoint-ORIG-GUID: t11qqCInJI0SPcbVhmw31kbV8Vrzyir9 X-Proofpoint-GUID: t11qqCInJI0SPcbVhmw31kbV8Vrzyir9 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 736510bc241b..5cd5154d4d1e 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 Thu Feb 9 08:01:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 13134170 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 DD82EC05027 for ; Thu, 9 Feb 2023 08:02:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229660AbjBIICi (ORCPT ); Thu, 9 Feb 2023 03:02:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58824 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229685AbjBIICg (ORCPT ); Thu, 9 Feb 2023 03:02:36 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B7DDF2DE75 for ; Thu, 9 Feb 2023 00:02:35 -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 3197Pvjp011833 for ; Thu, 9 Feb 2023 08:02: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=9VypDKPA2rlmjm6ThcApsxm6VyfB8HElvx9QBsMNLyw=; b=sQ32bgwbS4lQ5r9LEFVTlvA2bb2Qz1WIM07nQ8kBHMjIScEzL3D3e9WUb4MWqlkH9y5c ElgxCP6aq+B4/HgrwEy8N/t7zMksfIDTU6qLI5q4RU2YYLEarupSqvjhhO9u+cb2Wgqh dkNQC0YjqlVP8twJrxGjSmZqos2rczNXHw7NROGmOIiTRsymlQWcv7Pzwk5OOEQgy5Gj WcrEmZKUHGzQ45QgDXZujyAE4/L15qwDrT2/yXBvKDw/ws+IERnF09j4B4sxdNTNxfzX b0x1bVWR/Bb1qfcaZxlgeX/bdewCPfiPhm3e28Ech/LL1u7q846zB+P4OH5K2o+zkLQK HQ== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3nhdy1a76u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 09 Feb 2023 08:02:35 +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 3196t43f031609 for ; Thu, 9 Feb 2023 08:02:34 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2109.outbound.protection.outlook.com [104.47.70.109]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3njrbcxv8n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 09 Feb 2023 08:02:34 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MYxfkMomWloIG0LxSzrQOYtufbazQthyULjln2HrwUOc3qr8HdFg/1rP1DFj1Lb7SAt/tAZaUG8lFYt7AgPyWJ5gAYv4da5O+TzarZD2E+ODX9bNpTO5cDWFlFHpoBHh1CfIF1iHqf6NOGD1XnyIGjy66oPNYS3dm2NqOTbdcHXXFADUWnbxzeTKjvKh5jRQLukJNNqZfSJLVP2C2H37FbWckpmEhLC6Iv3Lx7BfODZjHF6fdHXi8cUzj80gdLlAIp+utVGW99bNQch6jlfTMTql17jkbjW5pievEXA1sZj4RvdDQCvE4hboXOzo+5UHGxYjR8hpqktm7EG0ylybRA== 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=9VypDKPA2rlmjm6ThcApsxm6VyfB8HElvx9QBsMNLyw=; b=ErMfX0jMA7RMryVF7UQPMZhnSbek7h1+IXVgtC58jOAjtHUdsJKtoWSytPkre+24G/BtZmBY70fOvCTlj5ztpngsCFF4UOzAD7PNu/GC9ExxCCcCkdLEzLrMCr38EDrKzrWei+GDmmA2WiXDyrko0QIA28tZeEQzEhaNHIFtzx5359AHyf625owr46Pwbi5wDL36974lSYBW7l+WjOZnvt6+CpeW3iHZ0RMPUMLb9TWg0kvWkDXmt8xUeRg0RxJQRCL54tkOXfpR1xYUtEGx8AKzvuCcxi4ToKFv6xiPnQarVuycFBg++Ll/9uQnMiDMAZykF2Z57fCl7z23hJZxhQ== 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=9VypDKPA2rlmjm6ThcApsxm6VyfB8HElvx9QBsMNLyw=; b=GEH2EqNsmN94tyRvIJp/T63mHZetQQ1Umgs5EJs4fCtj2qGd5kE+rTJoOLFQlcygCb/MCmGVqhkkJd8tz64UsqYIbrAACr6GSFkFuo+jCG0M8N+7esIpB18WMGGbAZ97kj4JEYfocfKqN84A4uY9JD6OhD/lSvNJnYdoorxLNLM= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by SA3PR10MB7070.namprd10.prod.outlook.com (2603:10b6:806:311::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.14; Thu, 9 Feb 2023 08:02:32 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::eaff:9f55:4641:db38]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::eaff:9f55:4641:db38%4]) with mapi id 15.20.6086.011; Thu, 9 Feb 2023 08:02:32 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v9 24/28] xfs: Filter XFS_ATTR_PARENT for getfattr Date: Thu, 9 Feb 2023 01:01:42 -0700 Message-Id: <20230209080146.378973-25-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230209080146.378973-1-allison.henderson@oracle.com> References: <20230209080146.378973-1-allison.henderson@oracle.com> X-ClientProxiedBy: BYAPR11CA0090.namprd11.prod.outlook.com (2603:10b6:a03:f4::31) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY5PR10MB4306:EE_|SA3PR10MB7070:EE_ X-MS-Office365-Filtering-Correlation-Id: c97c2a66-8642-4821-2449-08db0a73ff53 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: elPmD1JhzOfphkd7TJ8cnnkeElUJxsGQ4a1MAbyL8WaB/XgFPd8xJCePRDuxaiLejf5JBf/+9fYqlAiHaqoSTSXcFkWbTbrq+AfNhSjlrrv4yONa0IBDTt7abzomqakcxDAgV0vDygUdE6nv8TW4us/0kdWVXBDiZqnTdH6GKytIkbdVvRNGYb5kbzb8omwf8h9r/2pLyd8dNLVWgo9h/6zdYxM1MSc7Abwwi1eDgQqPrgfbWZ1GvCiHEKRmQ5RobWnUJEctUGUUX3GpZxj59/L9dxZyzmOXo7Vrcy1N1sduLKWlD1RhrVuZG6Nd3EqCPxOLNrGPh9HuQQQ5urrYp8ftE8VUe9fte0Co+GYgFAYwqwcs791EdxN2sf05oQLjxf/zZtbdtJJ6QZllbIc2PvkzDhgsCYmvT4Fp/lESRZkf3UTwiLmz/3VDx/R3X6pN7cAyAb8zppMrLdU1bQr0PDeVHH24F+wLbWOpVYZJr1xwE61r/BKTAKO6l++LM8abdM/qUFzkf1kKn57mq/fyoHsF9r+bPmMsvn40V7VHpAsstBbAdO0DDSDDC8hWKyu2wkArUkMG1Q0h1/TCCr1LnogLhLP1rjjnk9kxkPgMawzOq3STlWGh+mn7RVl4GOVl5aKO9no4Hu6GEE/4laIBQA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(366004)(376002)(346002)(39860400002)(396003)(136003)(451199018)(478600001)(6486002)(8676002)(6916009)(66476007)(66556008)(5660300002)(8936002)(6506007)(1076003)(66946007)(6666004)(2616005)(9686003)(186003)(6512007)(26005)(36756003)(316002)(41300700001)(38100700002)(86362001)(4744005)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 6ff5CBKPea4WzpVcX0/45P72govJZUcx2bX9blnOlcidLXnLzkD+/KXd182KauYo9qNx3oHiHzG0mGIBaqT7+PdemsHkTK30geDTHy/83kf5X1DXz5/OLQgbJgP4JwzaqVAcL9VhY4SyqEz5AB7ps2tbZwGnbm7j+awjGhuPyXbi7Bi1xmZJpKQ/0z7dpJI7LAXjD5hS4XdAjtJfvVbsgZxeVTN7EogfHiUtve+c6V6sPYPNm4pbZt2vd+WF8PVhC3mpKz/cLh/LpNpyCouCMQABVPcb5bEtyvSXUWv6K82MU4LEVh1wu+dIyhvHabt5TywzHuizT08xgGr9yrVDuLwUoU41MeAnz6YnjL306wF3COoqWG6053QorIMUXoJo5oYLkOvBEnaFvo5xA3ErBFIjJK/DIzAH9jWx9sdDS/YCcpa8wqUhfoB7b74Y8XklXzulVSO9EmCz/d8HTBtCD5NeN9zKCSC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PK5Y9Wn2HISS6tPqh1fS5wEC90udNEErKFIU3UDqQ4IHwZ24ZhFLiGD07MQg0fhu/XE4njNzriiapLvfAQ== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: /7EeopYshQqy56VOfEQtzL1O2XKZGY0q2BAyeQF9QqYAS+IcIVriglV1h6HN+t/Pngmf28LeSf0MnSYPKAn2SGZPH8AmCvqIEycDzr7T1Hmv4ViFA8EEnmA5UFr0srBbUZFNwgQz9sUwTR+MejTC90Vk6qrzAEvXeJtCGZY8963jwQOw0ATYW7JK4S2gj4otUffPlW3LLnI1VxceHPPHzU5W7elNlGYXhNwJrbXCkdbJeQJ2xp8WSmezMLkYacHg5pjq/zTzgOVzqwBn3SkFbuyMmCsvpzfXXbyXoB4Zx87WJnFVuVxwu30mFXHe23Ztt9JXzsn3Egz8Wyt+uWzmagNLNQ87jT0P1kKZnXQbdvH2RS95+TS47Vn+xOzf9e+7OS8GxlWfYkFJQPl1QgiZhHEbueusOKXVfNp/OXCchT+wq9AeNcsMDePSFhCkT+pGcqYuJEUB9uCVDVmPKu+FzoIJBAtZPC9JaVPfCTsnTO3TVtaebn4iR5z/lhX/T94wLBbViDDYUwABa9IFVmMzTbkY93LpSgGTKBFVmweLDd3wIoGlBrEWz33byDmyDicvkMv9v37z+3R+G5jrexIFEMEbicF4F9hfu8+uOA9OfCY7I34FF0HCyW0RmzIehhJKn+RM23lZELayMEj+0isjXRLp7/uLKnzCRfKhW+4H65Z9usEcN8VwZhGDtkyoxTcJdP0xLhdtMSj6fuD7smzfb5t0/Q/X6bT6dgBiUSeUdspDqDArI1E/PJFJ/XlDkRlj X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: c97c2a66-8642-4821-2449-08db0a73ff53 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Feb 2023 08:02:32.6255 (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: V0VeI71/hoP9raSDuRYV/k5FZDXs++XoTxpw0Meue6ayX732I4SWP7b7DyA6k2YFCPctfSm8ZFVek3yH23ToJWsZUbneVR75eme/lnruYII= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA3PR10MB7070 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-02-09_05,2023-02-08_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 phishscore=0 spamscore=0 malwarescore=0 suspectscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302090075 X-Proofpoint-GUID: rs3mr_JlklINtoYDDvCwMin6boPAIdsE X-Proofpoint-ORIG-GUID: rs3mr_JlklINtoYDDvCwMin6boPAIdsE 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 c1f4bfd71e73..ab5c7bdae457 100644 --- a/fs/xfs/xfs_xattr.c +++ b/fs/xfs/xfs_xattr.c @@ -232,6 +232,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 Thu Feb 9 08:01:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 13134171 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 80E32C05027 for ; Thu, 9 Feb 2023 08:02:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229677AbjBIICl (ORCPT ); Thu, 9 Feb 2023 03:02:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58888 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229685AbjBIICk (ORCPT ); Thu, 9 Feb 2023 03:02:40 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 209CE1352E for ; Thu, 9 Feb 2023 00:02:39 -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 3197Qq3B012378 for ; Thu, 9 Feb 2023 08:02: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=ZDhB7XDZUzOyYc8IM+WQlyLtpc28ct/PXUK+kHWloyc=; b=Pm/ujXYL5cq7xR0fdtotAPJLHxVZ9vNNEDGEmQ+shVbBbf+uqdGZqIMvRTWJhHFFVMgr nogBTGBvUVq3eYCeBlqyOsoohUNt3wSJiOEhR53kRoYhxSIcVBCo52sXahVfJ9j/Jh8W Zr5auAs+F3Ug8kbK7kHRXThEVRnhLP7kHQrX60xNTexrW1lu9xGCgaM1yM5RHPXlCWib 14qbhc383HDuARKwQYg19EAv2SUFqHp+4PW076XrR4gPDJJLv6g6Rw+IxkHfydof4Qew H68LUI2gejrS9LKq+y223N3VRMFqsQuq8A6/URGF/LPSZuOCL2lOiY4C6B55ygASEELJ Qw== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3nhe53j517-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 09 Feb 2023 08:02:38 +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 31965ffW028432 for ; Thu, 9 Feb 2023 08:02:37 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2175.outbound.protection.outlook.com [104.47.59.175]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3nhdteyge9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 09 Feb 2023 08:02:37 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HwT//ZsGmeivNTr45y7xwlyjvS4mzFLFscka09SXU0sHR1YcZ180/XJHqgZIJTXngqTJ13ZVMKrOTQd427G/ZXKjOHRT9wZY/915cH0hcgshg5rU0prZDEOTWc/3CIvpHGHnkQVsnaOAZMhGk6WyGmN2AjTFhlQZuJbgxsbdR1cCeUHLefAin5ikJGuHH6ioqCbEG3MSCmd6MFn7HzBnTzbxvETfHkHyXZ/H9jL4zWtvFdUxHbFbZZWMQ+Z0aq2s6rUkeffiZVdZ3Dj/66QxJB+8FPB/M8Y9iV70oKbx2up4IxdycFU8V9LCnWuUSmXSdlQe9QzDzaOTTGQz/8scMg== 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=ZDhB7XDZUzOyYc8IM+WQlyLtpc28ct/PXUK+kHWloyc=; b=nLVBQWEMXONX6H/YYgWulwUnEHri+AZ2Oxb9B8PJbFAejrYwH4uY5tLPp1XWkOPJdd9WX/EwI92IW/31BMrXwTvh3MGBpVhc2tCSp41SRPANeIsGbSxhsPYWCAqKLz7k4ScWAEIkyKOD9LLr06OEIrP7uGXNHeZunpGMe8lLIoz3AI3xo/UIafcEJa9xS6GhEM+9A0yQ4yDlM23SxasxI1get5N9EAxUCC4IQOC6h/hqtEUqLFf5rmOqhEzhBBmYLgR7hz+izYwYnY6y7Dic6LTGYISiQJNmVdoYPYbbAghkqOHko0GRe7EFA3zlq8b0JTar77vhg9hRkqAxuw5MJw== 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=ZDhB7XDZUzOyYc8IM+WQlyLtpc28ct/PXUK+kHWloyc=; b=iFmWqRp8gWmpgxyqR0b/p8etNGryMHC/ptvagtbwyB1No8gI5nHh9KeC8dGqjteXJLSgWPgTrogUmI1um/Az8xFzRcJkKXVoW0wyLDQPxbb0pLobpuDcP0SVInvK6jLu/KwMl1HF0e+uidiMwmSjNZcxJcO072Wkzzo18HwZ8qU= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by BN0PR10MB5095.namprd10.prod.outlook.com (2603:10b6:408:123::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.19; Thu, 9 Feb 2023 08:02:35 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::eaff:9f55:4641:db38]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::eaff:9f55:4641:db38%4]) with mapi id 15.20.6086.011; Thu, 9 Feb 2023 08:02:34 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v9 25/28] xfs: Add parent pointer ioctl Date: Thu, 9 Feb 2023 01:01:43 -0700 Message-Id: <20230209080146.378973-26-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230209080146.378973-1-allison.henderson@oracle.com> References: <20230209080146.378973-1-allison.henderson@oracle.com> X-ClientProxiedBy: PH0PR07CA0080.namprd07.prod.outlook.com (2603:10b6:510:f::25) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY5PR10MB4306:EE_|BN0PR10MB5095:EE_ X-MS-Office365-Filtering-Correlation-Id: 52c45a39-f038-4283-2d03-08db0a74006f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: NOnBFijwgoZHD8hY4KkQ7Otee6FLUsTtwFoA2eOQq7iq9Q2zilpFToV26sZ3oKpHiLugADkA+7K10StqitI37gD3xLDrIAdicy+TgOxvhQLYzqkpzY5pR9Z8zK8gmLafMlRJsImyhIIWhGykuBhBgY/+rv0gMQp6fMQcVvOsU7lfNA2ERWKTamr2HggT4a1AmO7My5SSbm+/S9R7dOZJAlfPC19NY4Iehq7fM6rpBJv1JZi+zQJ5ze3BOEXhdBLLnL5ChR0n7JDziYsnOoRlNXtgINkKFk0Yn/jF96Rk2laQEJQ46ZNAfiCF9kDCElN538hxrnaQhOTe9MhfTW3Lev+FupRNSm66zPMtGxjnniuUyJ3S6kiQ6DyBtTDauW7Oa88A99oMEE5EY23IlShSGhS0LYK/Ao+TKzs9M02Nq4bG3x9q0tf0uHBay9iqvfgbZdV/0fQ1D/rQpGTEoSS2pNx/5jRNJMyzdvc84eQFyaRhC/Gvub2sAbryROohfznm4eGS8w+BeFmTJAk7u0N2Swqkt6FofyUvp8+zeUUSymavngjx2lAHCOk6108WqXRHKrswwPBFzDBIeJsSWen3CQtE6uWrB/IqHa6ts9OYJMDlwrAZcpTUVSZvZJSRPBUAPSoNpisXq7SmtzTnqZzxcA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(396003)(346002)(366004)(136003)(376002)(39860400002)(451199018)(1076003)(6506007)(6512007)(26005)(186003)(6666004)(38100700002)(9686003)(2616005)(2906002)(6486002)(83380400001)(316002)(41300700001)(478600001)(30864003)(8936002)(6916009)(8676002)(66476007)(66556008)(86362001)(66946007)(5660300002)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: YRI/cfAcogIelCfz7dAXqSepWvVHgbBzuD3Kmm9pVentCcqaGuQes4Q4xvU2kxNkxHFEJakWJq8UrJIxCvoD+tVgJEKZONiX5jC0K6rNjCOipr8cxp0Jn7/ptgu2t0WefoPCvZYAqFE0c5LGdK0ivCfs5MkXrKqqZ2qxyoebUIIlVuViASZHunlOCo1HuOHFJXjsqBiqG/rrSleB1YFOtQFxOnY91ZiqFyP5fZegParWBTVvAXnLHO+nd2tVuyEEmpXZoVC3BI1CbLBp6Zy0IMXcSue8Zv6W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w87dzamCC6X3Ryibrp30Mau6l44IoUa2vsNuN7tx4R1/riZBfq6PMeM47nbNIl4uW1IuweC4+P73PxkBqTsznNtLjHqkkZKaE8gpCaCSibPRiqyKFHSHc0fX6Kh+nyLXstP8w6g/panLGdARvwgve2i19jmtKtO1xhIyumAxpU/J2qYs7GkI/fUa0tWBz7+hs8cZFRDTVWm8skEMKVy1FXtKHs9xR5RDM4Wy9pUg== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: ReSslySHGZK5OwDhuUqNzs1ERR1MIbq6Kch3q/FimFWfa/V/BYLgQqin2FP/pl7bOWp3UPCDfsS23cPbnj9AVnCXJhLYgt9uLqxtP3vFJ8w+n+GrLxhrG+7mcdu9xLN6hEr/NVg0nZNuMT3lO3N6aopa4B9SVJ9AKDO2ZNbOx5DItal6C6Tr/v5Fi3/OZm5dLh7EAMO+YKnJY1rAX2tTXDuA6Oj/HSls63fULA+0XqT6pjtN1/UwR5foG3AWpbjA7BG58tKNYhGnHp26J1/Vcvxip4Bhiwv51RmwbFnJhrE44scHz6/ToM12BM8lejlbuSUzG7Ab4elWUaVBpvcVY5Foj0LGcvv80NBgTsRVmAcsh8wolfz2xJXA2gpyiGTDtSq521j9xDTqNVtyDR4eTid0e7kXTY55O8Xz96MEUuAZroyE5OB2UDX29jiE6mVXLXVXcm4MKKVVahKkalWV34tdMIhOlGF6RcoY9UtlqeTM03Eue8rCKtJFFp5aHjzw+A8yC7UCA9p/7og9iWFW5IqpHQnzFCyBmDSpNdPfp1v87exTCawyxG49YSrvcAV240a3SV6u4eqjn9TZ4BmIA/zD4Tup5v0tcehcGHxuhOtpblkk3CobTHvQxpt/OfeqtjrRRS9zp5vRenLE1pWbLCdZMafAFIOlp+A/OVLG6+7JWRCfKZwH28IWNb3jZLOuqEMR71zRrh7goAuIMYDj4oFbe3GJRSAiDhMvpTBUt3BcKHeDp5cwQUrsd1wavnFk X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 52c45a39-f038-4283-2d03-08db0a74006f X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Feb 2023 08:02:34.5107 (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: /uMySRo2IjAwrRibdFItJXXqNrR3tumku24lLGLd/OVa4Lzg0SZQ/4Z1ffM2DybuSKXm+SznbtoDno5VzK/hfVISmNtrK5fDxIynuoUBODc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN0PR10MB5095 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-02-09_05,2023-02-08_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 mlxlogscore=999 mlxscore=0 adultscore=0 phishscore=0 suspectscore=0 malwarescore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302090075 X-Proofpoint-ORIG-GUID: RqE6pjk9vpon25M7a_-nUHCXNcaGbgup X-Proofpoint-GUID: RqE6pjk9vpon25M7a_-nUHCXNcaGbgup 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 | 126 +++++++++++++++++++++++++++++++++++++ fs/xfs/xfs_parent_utils.h | 11 ++++ 8 files changed, 321 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 629762701952..9176adfaa9e8 100644 --- a/fs/xfs/libxfs/xfs_parent.c +++ b/fs/xfs/libxfs/xfs_parent.c @@ -29,6 +29,16 @@ struct kmem_cache *xfs_parent_intent_cache; +/* 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 039005883bb6..13040b9d8b08 100644 --- a/fs/xfs/libxfs/xfs_parent.h +++ b/fs/xfs/libxfs/xfs_parent.h @@ -25,6 +25,8 @@ struct xfs_parent_defer { void xfs_init_parent_name_rec(struct xfs_parent_name_rec *rec, struct xfs_inode *ip, uint32_t p_diroffset); +void xfs_init_parent_ptr(struct xfs_parent_ptr *xpp, + const struct xfs_parent_name_rec *rec); int __xfs_parent_init(struct xfs_mount *mp, bool grab_log, struct xfs_parent_defer **parentp); diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c index 5cd5154d4d1e..df5a45b97f8f 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..771279731d42 --- /dev/null +++ b/fs/xfs/xfs_parent_utils.c @@ -0,0 +1,126 @@ +// 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" +#include "xfs_parent_utils.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 Thu Feb 9 08:01:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 13134172 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 854D4C61DA4 for ; Thu, 9 Feb 2023 08:02:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229685AbjBIICm (ORCPT ); Thu, 9 Feb 2023 03:02:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58894 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229657AbjBIICl (ORCPT ); Thu, 9 Feb 2023 03:02:41 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8AA2D2684E for ; Thu, 9 Feb 2023 00:02:39 -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 3197QNgX015211 for ; Thu, 9 Feb 2023 08:02: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=0HDc5oSRZUZiwCZrUG1G6lMOEEvHfQHLGVwhC+kxeKs=; b=c/jHOlarffzTAg0tgMDnBoCTeNdAP/SJTZWYnXon+tkDcnZ51PYUW+peRe9zbZhBnM9g CAVvkG/bPg6sZIoEgF9gU1ljXOPXP5N2zcOjAELQp3Tcd/93OB3B5DVk56vizzyJPi1v WEIHqGzuFVFBps1ot9nC2U99tQTbOg8ABfTi8m5SEyDCJrj//ira+Wlgg//bsWfa0Kck yISG+6NGAOui8mHLNMbpOqC5VYMDc4Rgv0fvusTfH9Ad3YCEaKurvzX8YTCf1NvU5aq2 f/KrjykqFfRFFwMrvZ8P2oEF03afgMs+FaSxqXETOTm9auH88CszaY50T13N13PmzXck 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 3nheyu26cs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 09 Feb 2023 08:02:38 +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 31965ffY028432 for ; Thu, 9 Feb 2023 08:02:38 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2175.outbound.protection.outlook.com [104.47.59.175]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3nhdteyge9-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 09 Feb 2023 08:02:37 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lf1citTcDlXgwiWX0ACiuRS9Ud+CdeT7U9Issrv1ZdmABdW2wpNVFvl5l9f+1Q+aeNDE1UKdKgl6x8V+8EAlHr+NoljJOEA76BU1OZ1aAaTJfl/FBOra3htgjpPmfZdTuEwUUOLdL2zTw+s7fD3MX2DWi3StgsxGCryg0eGW7zeb3eNJkfgJ3+50NhcUGf8msSF5fgYs6yQ+f+FGgJ+LDKzkUSQpGQwSie6pT2cvvogOrr6Llk2KuTKEQ/Ptpr7X+XaYeN9tCDpj0ifLkit3GWRd1dgQB+bTxQPRFRGlja6jrr20HOheYu0nzW6Bqoajd/089eooN5JP+uj3EXQZPw== 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=a4NVkuiKQfi2lLkDt0NWPAnyU9xIbhBOY4XiIz59R3Yqb3KtZJo1yy56OjqPSDTW9UnqZz9tCDsWxH6O8akx875qKxIVSOCnSI4oQHa7nsbJV3Hqj8WmPUhWAxWGyhofxNNnrcUSUZ8h1zLent/haoD+hCgUobws5uVtHwlI4xIi+sIQ4UIV914geMkcxVD0NaV3XwdOGN6i0HJ6YOGFJS8SmIvlO0lid4RcVPjREjzf5p/pmg8t2+oCuBBdiugVPGHA3fjGtrXrHRaoirBytjjjwS78R04xLSuJJU+HZRd58CVd1JaEtq/eAkUVqXZJ1fDe7Y/VnVk+UwNJ7OquFg== 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=DkJ3OjucVZP8ZbCAqphey4tx6LfgzN3PCKDJQJTDzZfsPAFR9fEGqpegfb7MA2GvAkPFlbdBmwauT2zifdqEAByvVSH2GRGRRnzBhh5JeraUeNSN3wjKJhqOcIY0gzsIC2aUKRMOD+rs0O3zRRqzWBSCSC13TkPRWk89OTa1J20= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by BN0PR10MB5095.namprd10.prod.outlook.com (2603:10b6:408:123::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.19; Thu, 9 Feb 2023 08:02:36 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::eaff:9f55:4641:db38]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::eaff:9f55:4641:db38%4]) with mapi id 15.20.6086.011; Thu, 9 Feb 2023 08:02:36 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v9 26/28] xfs: fix unit conversion error in xfs_log_calc_max_attrsetm_res Date: Thu, 9 Feb 2023 01:01:44 -0700 Message-Id: <20230209080146.378973-27-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230209080146.378973-1-allison.henderson@oracle.com> References: <20230209080146.378973-1-allison.henderson@oracle.com> X-ClientProxiedBy: PH0PR07CA0076.namprd07.prod.outlook.com (2603:10b6:510:f::21) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY5PR10MB4306:EE_|BN0PR10MB5095:EE_ X-MS-Office365-Filtering-Correlation-Id: 8b770294-b693-4fa9-81cb-08db0a7401cc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: HfINjNeu15Y/1G+MddirzRhDwqCHWCw2oSdcuom6tTixW6tv9/58zkq3v8pFcAqAmfC1BFLf5pACwZoCBgzW+5uokcYwCQfPjgGkutktaImKkqnmeBVuzeYC6ujP54z9Pm6tbWPNz/81CAWfMG8RernkHDnJImIa147lkFDqWufkCZsB3wic6GNOxoxNPbmUOKfXZ31CH08RCRdpYCu3hzV596nfxB3s9ahh8QzA0Ux/8jqChIVsIwzp5SZq5Rx/tIklgaznaR9x2NdGTyQMRYL02Sk8JzIzZGjZL7InDG9tn+1efQz0huJ3GvKqXYRsLyd7SWLMZA8qVpQW4a9nyYIePpRZW+Rk5+D8N7zcmimLPv6g+MT70Xnv2vsn1fQp1t/nAWXBRv/iXRuRfjNPr9gdzAKJ/0Z6KECT11TCr9uxrg+rm+T7fH9U3cyKYBY9AMRTSbCx4ZVrF5YuFWJc2OS54++6dYyBPmbg9h9mHU3CZneibgJ5RVzAID8b1Z5Itgqcb8yypjcVRcbA8OX66/mVl6panpPew8g9HI2jA+kg3gPT7vGOi4CqSEtk404Zg3n88Nm3OfmaaftUC5IrlcYsRwlBXIhW+K9Y4xQGFwHL71ufIdP6gqBaCowRv+GmIRFXGJ5OTXmPI9K/Eee4Lg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(396003)(346002)(366004)(136003)(376002)(39860400002)(451199018)(1076003)(6506007)(6512007)(26005)(186003)(6666004)(38100700002)(9686003)(2616005)(2906002)(6486002)(83380400001)(316002)(41300700001)(478600001)(8936002)(6916009)(8676002)(66476007)(66556008)(86362001)(66946007)(5660300002)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-A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EXt+s8kTHeajFq9FAcHrXVwMCkL0jOC9QkOKvjDzmAxennluNTMZIw/FA6p+dQMbL0bpaHnTZbqFtW4N6PMB1qF+XiT710SxsbOWlUOVlkQLw6yYNSTaMx5lo84fw4shghjJn3Hgb8OtNPst7iP4ZL4QBVYUgzbO8VCr30QjosYAJvnH1I1h8zIWy36o8mrVBDV8+AErXtCzt4qkOlsiE0ke6Tb0sCh4wxn8ZLLk94Zx0+sjWkRUwQUekILMNK/57wcHFvfE6a/BaHBfbTmhVhucVw0xHIIsGioQ9VtHacWPsIPA/aNwyUBJP/yTQMXPr70QRpFmmHeOUgEnLxsY/cg+l9GlKTOjVNiLUTsvD+KlgL3kvSQhB X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8b770294-b693-4fa9-81cb-08db0a7401cc X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Feb 2023 08:02:36.7595 (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: +mdmX02ZIsqjnEZMDb5I8JGUqwfs3PIKuKamcFL02InnDtfnpyyfB5KPpAIL8BsLwhUhACAgeSC9UCbz/ywqTFFD5r7Uw+tpDhfo2ZAW6iI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN0PR10MB5095 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-02-09_05,2023-02-08_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 mlxlogscore=999 mlxscore=0 adultscore=0 phishscore=0 suspectscore=0 malwarescore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302090075 X-Proofpoint-GUID: ItIZ1LTgWUePyGQHK_fuqRACQQHAMJEz X-Proofpoint-ORIG-GUID: ItIZ1LTgWUePyGQHK_fuqRACQQHAMJEz 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 Thu Feb 9 08:01:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 13134173 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 93238C636D4 for ; Thu, 9 Feb 2023 08:02:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229726AbjBIICo (ORCPT ); Thu, 9 Feb 2023 03:02:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58912 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229701AbjBIICn (ORCPT ); Thu, 9 Feb 2023 03:02:43 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A87AE265AC for ; Thu, 9 Feb 2023 00:02:41 -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 3197Pm37024495 for ; Thu, 9 Feb 2023 08:02: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=QnZjoGgIcEUP40CqmQBJYUuAmBfobRJOlbitbtUwDrQ=; b=MtL+sgDSiaRgXMVWLe1vR0oSY9yeIBJITrBb1F0FN0zB6JBJ/878FlYMshiOzZA8gk5y 6jrovqIqdTorYBGijeNiP6fS4HKiIXJBwIkHNv2t7eoTwxR1R7vf1fi2tjvllyzvid7s sqCTgq0Z+79018pZOTeZJjUmT3SWylubch8DCBxL4qYFMe2nFtAItnWzX9ltsEBqu30P BqT9hB1EbKe0NqVzkkiqod5G1E5d/pDjiYRUxxDEgUVRuTRw0e0gXYoNzyptT9lv984h ebYHsh3PgGLKTYVjWiXyEJLlil/Hz0G4EbZlSZqYR/I9byzM6i+whw4zRCVf2qvOzPZs FA== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3nhfwua2n0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 09 Feb 2023 08:02:41 +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 3196fNet005776 for ; Thu, 9 Feb 2023 08:02:40 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2171.outbound.protection.outlook.com [104.47.59.171]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3nhdt8wr6y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 09 Feb 2023 08:02:40 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AbMPCIEeZVS+oB0DiXcl/RMgUAHheqs7TZlHtg/mMdzSQJ9ywbyY0QgId7mwts/BZCV7XPOwQZeN6mAagxb4XXlyu7EdQgd+k1JYnnsUreHf3X3tWSypO/XvB8+WeplvSHnDvjV+DfO1KluVen/6ahF0aRWLGg0NaCg6BPSO4178EUYgbJd2lu85w0fol7zeR2Cl2WkzWmeH+EZUWp+R7Tn3hCnkfRLjwRUyzZexriTfrx1xOTyQihAMnBE0j2TROVvQnBBIJA8LP2mHyKJv30fX3qm3MYiPHOhnZaL72NYLyPLYqvr3n2I38HS4VWhjE8C9Dz43VlLMv829XglLzw== 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=nFIsNsRAbRLO9BG+4q6sJdHcB3fbszCbsv/CiY76zgcwOFA56DATK4m4liqWE9m/mtyrRrJB+UmNx1qRXLmWJ8Ewwjnd1zzXwSnXaYUZ0YroZB3gGEygUTlZh8TyNyM4xDUfP0yBXsxnxEHoWUs9XzY1fZOwBzCVRZvbWwQLr4xe0DubMC1neQMi5wlr35IA56BfTb/BtiELgz/cJq1TDPWxcxsvzhYgmSr4Mv5EGztFnlBMHMlDjx3+sfgOh98cXHPaAZ3Zv7OZMo0+khYZVJkfCBav+uMWrZQnbkltrXoONyVeUBuQpLTURCKKcNBAZyJoIJ2MRdIUVCUFC8N8HA== 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=toQDVBWWOEVHTt6oEvBdmozpSbg6Ft6UGGSnMdhC+L/WBeTKaWDiW1mJdrnJc9sRb8DsYUzQKyxx12G1DnYdpGm/Pm36v4T1ePYWmqPWxd9LCRt9KY6t+UM3eXDFPHRMkVD7uhZBNxgFbdjqGqrFUre7lZK81cwS8Ud1ijbj5Zk= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by BN0PR10MB5095.namprd10.prod.outlook.com (2603:10b6:408:123::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.19; Thu, 9 Feb 2023 08:02:38 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::eaff:9f55:4641:db38]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::eaff:9f55:4641:db38%4]) with mapi id 15.20.6086.011; Thu, 9 Feb 2023 08:02:38 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v9 27/28] xfs: drop compatibility minimum log size computations for reflink Date: Thu, 9 Feb 2023 01:01:45 -0700 Message-Id: <20230209080146.378973-28-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230209080146.378973-1-allison.henderson@oracle.com> References: <20230209080146.378973-1-allison.henderson@oracle.com> X-ClientProxiedBy: SJ0PR13CA0158.namprd13.prod.outlook.com (2603:10b6:a03:2c7::13) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY5PR10MB4306:EE_|BN0PR10MB5095:EE_ X-MS-Office365-Filtering-Correlation-Id: d7aae42a-f3fd-4fb3-d4af-08db0a7402de X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: H8g3+yk9z173xZdQsCKkcGhHJcusJGw48sseH8VjmV+Kwm8zf0iCCXAmgjdrw75fShpxeNzI7OU/NqtPRnvZxIjebdbNXTtgcg2R93Ud+Yv0xNd+9BBoGZck3/qi98QQP8L7wBfiSzMuCwO9ZkA262gl3Yh7rpSq0KL17DEeZi0XIJOoSpT7xwgelXoQK55nyfbtpfFKyUoe+UWY/DOnp06IvV+OC3uf8E5tTcpxy/IBkJARgCxa3EGHCIokz5w8t2Qhno3RW9m5nanE4Hr+rGajwWye8kQAAs7VNMCY4G9j7IYmlfT/LNWc0ppW0bIrKZdJ6a5bxd4Bg2WGO4skPopGd/bhyGh3VE48D9xUGeZla3/zGWAZdcY93NSOnuFX43UWIY3BEpT931890H3uGT5Gb/anJoatmF9fqT6Elir1kAIQzU6KxwVcTyduXLZAeHY1Ffb0+rpAK9jN5C7wyWIvtz22om8ZG1T66orlSmgCItYrQuJjzRhGU/rUDjprqNOmhgxhosVD7hEAt0KjEzZzCAHUaqAC3JaFeROWI8Mu0DTMFrrLLRcgk97BNuAkg1Rz9dpWcIPIdGx9CvTOxfLzLCfRAnQdQeIMwq1NCV1cvFbM7HceKLgDY0B0iHfFF4EnYBBV7GXJVcoGecUIGA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(396003)(346002)(366004)(136003)(376002)(39860400002)(451199018)(1076003)(6506007)(6512007)(26005)(186003)(6666004)(38100700002)(9686003)(2616005)(2906002)(6486002)(83380400001)(316002)(41300700001)(478600001)(8936002)(6916009)(8676002)(66476007)(66556008)(86362001)(66946007)(5660300002)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: BzisVKAZKFIdj34OD+BvoG1xT8J2YESEc5BHZbTaAN14z+Jnk73j+VdjWq8I/l2RNHdMYFnl94cOlXKUta8flPzp8RdeG3Lo1fsZ13pxEGjCwkAZi9LDDXi9EqC417jGw2KCZD0DnZEFzqkq5icM/bZf/bEFs8Gc88UzzKLYlACQQlgiyTSbn/dYnRK5/zw5zmF8UdMWzZ3Ukw/1lGsdsQXaY/9GJP+LJ+H9J4SWnKJ+NH05yqFAZRyB3dR+4L0Zh+Y7RfFeWZe/fV/CDJwkQ7mXwWEDi/hCGbpGoEjrtAs1Zsqs1GFRy0wf+Nt0SN8GSuetKj5pxXykUzdcaAixSTJfIBv8tl42ibRF2A8yXqXNJmt19XljezZBsICQuIhJlT1mEOf+3ui+YsZEqe0X7zotKcxHGIqEWfMk7qTb7rfsctcIeFF0wNBAuh8wVA+osGQeCxd/kDYcrbr4/WhJ0+6s/f163p1w6RrXbCbsOKS4UgmwdgspNxllS7gn5BqqICBTvwWZsCXT2VBe58Nt5BUVlIiN37lSykbOGScd4UDqwSWiX+2NUr14GVojkaL9uJoJ3KoiQgIBzikzha90ksVJVVH42GUAvJ871HaSC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: x7TXU+d3Uv6wRQQbh28SMM7TBuL/HgNJDfbkzDV4qbFycVVEGJyGJhg0NIsH4LjCiD7lKXjO3ho7t7/YbsAHXmHnVkqKlFImwYaPY1mllKITFC99uJF/k2rznSkFQmazubbSEbpnd3r/KBaN9fTrVQMtH6K2pKY3KHfM1l4iwEYvTDoxtBDWOEqo1sMumsltiqhefpw1eNYSi36ZBiq/0lvtBz2g9MXExBoNmuaPqr+8MNv/ylTOLcUcJPAOfziK7EBGIKPzvfCU513rULRlzW83MtHYEEIKrnfN1KxQk1qAYY4qx6Sy4HeX2eF6kyjNCFljNVbdz3WKAtpZwnbkv2lzbPYG8Bv6Kh29i7OBqLGUWhb5KlTg5Zl2LTTMHS+rgRPC1T0uwkiCiCHwTUY5S+gLlcUMDK+cS6evKKjtk5AIte/c5+8VKZrnhc7JdzybNImdWYim4/wxQPoolyk7EeAoXECVfdy76qeTXJD6M+/RBJvm8Ruy/qSuhnfFZ+GerTvPw4qCNu123WGKbDMNzLXMQoRA5gYi9058iojy+iiaAk5h3e5EjbaYx9aj9B2Xa7ZPFiTjCJCmLN93Ert1ge8aJ+qVuC3nq3lzyQR/fUYl249GqhJPanwhE3YpXtKMXmm9X0l+ZtThUKKZRe3sYbqKIl2agkBNANQFpqTXY8qnWk9MGBzWhx/G+C2UoHCMLRNJFtORA9TjNE/ng+EpByuHrubv7ayI02l5Jk06QWRaFMJRGLwqolXlwvw2ayry X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: d7aae42a-f3fd-4fb3-d4af-08db0a7402de X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Feb 2023 08:02:38.5573 (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: TfmGuZO9SzS2NkrwKNgOWxQDZGqgwcydNkWrcVjvi+QwJHiGe3WGUbD/yIZXHShnLIqGRkVv5XFNQ9jA6tla2117KyH2htmK4m2q3nIbKhU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN0PR10MB5095 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-02-09_05,2023-02-08_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 suspectscore=0 mlxlogscore=999 adultscore=0 phishscore=0 mlxscore=0 malwarescore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302090075 X-Proofpoint-GUID: Vn_ROGFXFA8jnor1h8AFZf27NLwTEvpd X-Proofpoint-ORIG-GUID: Vn_ROGFXFA8jnor1h8AFZf27NLwTEvpd 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 From patchwork Thu Feb 9 08:01:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 13134174 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 261D2C61DA4 for ; Thu, 9 Feb 2023 08:02:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229701AbjBIICq (ORCPT ); Thu, 9 Feb 2023 03:02:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58932 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229657AbjBIICo (ORCPT ); Thu, 9 Feb 2023 03:02:44 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A356B2E0C5 for ; Thu, 9 Feb 2023 00:02:43 -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 3197PxV3016268 for ; Thu, 9 Feb 2023 08:02: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=VwiWWfWXG177Gwi0Y5OEGfnBjOP1g5QYuW9dKH3bVjA=; b=kAZVntFqNy5rQRgKMJ6MhPN5lNCNVZX1W0cwmdKp8egfx+gVLu2yt31PFsR3VcbvYpYM 8tQkIjjWTLT6PZO2I7pqQRhTT1CvhNNRSd6KWqe7eXRCWOQ1dGEnAGCXNgc3xKMELJMK bl1gHhjMQ45/ROA6Bd6TT1AXaL/S4deUqe8bN7qHosrpppd8Fiq5Fj9+36euxVB9Qp1s XBDQgJF1RZNa3eNmB0x3nIuUwLJQSJbcAxYTHE1Ln55IKSKJgnj5wEDUw3oyhxxw3tza WMrujTO3akiJZ2yqXrNh1NF1lnp7OA9TjM4vMGmRRT+cR7q7X/Ongmb8nh5DUWNn70FM ww== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3nhe9nj4em-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 09 Feb 2023 08:02:43 +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 3196jIut035773 for ; Thu, 9 Feb 2023 08:02:41 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2172.outbound.protection.outlook.com [104.47.59.172]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3nhdter9va-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 09 Feb 2023 08:02:41 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SGKaIxXHgM0p0wVvHUSa7/5/hhgLZOu08ykaAyskIHH6awHeY5rLr5/XyoDApZ3+hgC12cCxhReLfGxjcTf7yUdZveLLWo2w+eSQyx/qb9p3SD/DW+WQz58TY9vUf7b9wolIXJ4vuVfXtwGUAYhe09TrHrWbqSZCKCwsXCsskFy6xxozr9mdbqifoAjwywTbbJ5xx7K0M48dNEjRjt1pMiDMh4P2or2tiJu7X6wQKCA/Nfj6CDGNumchEumA6BvMHku4C/jacUj860VyP0gJVZR0PcAvKOisjalAviGKfl6YzkAEmEbcJGgn4wb+/OKDqhFefGGKl6aM+OXLtZE9Zg== 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=VwiWWfWXG177Gwi0Y5OEGfnBjOP1g5QYuW9dKH3bVjA=; b=nV2b4o8B11d4mFTQujvZ7kfN6gi9VlWUpJaLEK+YLMXmQWu+0i6Q9WNTmUYC7TUbG7t8vKSa0ZPIUj4INkzOgN92GB7vO89WuJbuumoI4KPicT/xSY0n+SzfzdzyGYCM1Y//SnzoMzorjgBviEMeCzbBn7izE0Xw0Z0tD3I5OCHAj0m4UZMZRP9PpNubraIZsxvjEpVrmCmIMJGT59phPXPHfNWvW+ngI+JL7SVa1qbR8muNjaDrdHKZYrwiv45VDpXHOju1GBr8H0BMcxwp1yeLCcN4kJXQniNr+pmHSeaSQrMKH+XAMrdN+MH90nmeLd+pKBHxfYoEiTBZKsNmvA== 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=VwiWWfWXG177Gwi0Y5OEGfnBjOP1g5QYuW9dKH3bVjA=; b=P5NepUey07ixObgWyJJCkc/CqbA/10NEcge3JwmHv07kzkfN3QneF/o3gt5RR92hrdZt5o4OsYq8lwaHU9ZaCsbLQfwPjOzUT+olzG1Y9KyrPCn0p1sbH7ngU6BBszOOuMwJvnuuYfz3Ot9awvPUUZfMtbWJh9RpXU/I4C6uWa8= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by BN0PR10MB5095.namprd10.prod.outlook.com (2603:10b6:408:123::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.19; Thu, 9 Feb 2023 08:02:40 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::eaff:9f55:4641:db38]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::eaff:9f55:4641:db38%4]) with mapi id 15.20.6086.011; Thu, 9 Feb 2023 08:02:40 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v9 28/28] xfs: add xfs_trans_mod_sb tracing Date: Thu, 9 Feb 2023 01:01:46 -0700 Message-Id: <20230209080146.378973-29-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230209080146.378973-1-allison.henderson@oracle.com> References: <20230209080146.378973-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_|BN0PR10MB5095:EE_ X-MS-Office365-Filtering-Correlation-Id: 318ff12a-b990-40e2-20b9-08db0a7403ba X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: JpL+VEI+pBO0x+m262kkGRJbKPwI6Mlo9kiKifaFkB40QmzHVl05Gi/M8LkPsvA8NWpgWBCX8PAwOL58U2RJfwx0gNiGHACVLLG5F7uYNMegfQZsKY0yc6wZHbrXxMAn0LfSUHxvBdCzHYTl0zbHIq3E2qQK8p7ATfZbV6xiuJLngFa1nihDbQbeB8FE6BMl9SIXvLA/WPsUr/EktHglT/nhMNj5zLZbo2rkge7+DiO3wmFGn+lawBh647Lw/6fsbDdu3QbCC2IAhkaNXtEvdL+RZzDajTinXFKNMfcUq05nTCsRaLvkkh3kuxRDJVQk8fxdiveCLQBQ3mVxBPcVC9fQwH8S3wuVz7t5HZ29cwhHpec4H1ViM3MTW8YkTnqWNG/Aq6RFWpLuiuDphj5HuNzhW5FfeBaYaAPsmZ6auNBNWa8hbUrSzVzaKiVK1XgWrOIrzOss4hcFPz9RodOiQIKG36Vt7n5zxpwFrr5+MGmFWpoYB67Tck2ve/Gk9pVfTYuVDOZewcSuSMocrOIwYhpTOZYQWHvH0U1EG6syUJGqc2twCP/U0qpt4ZBJzjj+fV6mdwqzHm+FSybbSFkI7khYD+0Dt4zC9INqTDzgkXJ6dw+QGYGwiIZvK3QqW/K3gaqO1p45CyIP5hVDf2pNwA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(396003)(346002)(366004)(136003)(376002)(39860400002)(451199018)(1076003)(6506007)(6512007)(26005)(186003)(38100700002)(9686003)(2616005)(2906002)(6486002)(83380400001)(316002)(41300700001)(478600001)(8936002)(6916009)(8676002)(66476007)(66556008)(86362001)(66946007)(5660300002)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: h64fbX4BtLNjQe5b9hf2Sg9h26cExdDJWEX9/GKv106TQWDh7Jhnm9UpQd1LSE1nzfoHLQybLm8KA8FqmjQv7mjfkluUTjQgXUj9//HTkpVsJuhQc8+ysGiS52NK04w4w8taUWOZLI5cffuSrSWxZR5BpPdZY+FA3hO40tbB6C9dX38K40+zveco/UB52kbt8TzQFKdd2ecWy2G6x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EtjqMb4vFeKhDIHEg3531hrYXaGNpd+I/YgZVSWF2/zzkT/GkKR6hiCR46fzNyYPV5qhX1nkNhf7+fxmVDx0tY3eHiBMgh0aJCcBAmOiK X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 318ff12a-b990-40e2-20b9-08db0a7403ba X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Feb 2023 08:02:39.9957 (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: nOsYaC3SGlIJFnwfLdbpyQ//y/7MgidBTHCHwuX1Fd2T+nLnII0pSJg+u+y653mz4Lr6NQ5M1UIHCvA+oNCv1tYpTw5YVJ3HSUsTJf1txHw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN0PR10MB5095 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-02-09_05,2023-02-08_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 suspectscore=0 adultscore=0 malwarescore=0 mlxscore=0 phishscore=0 spamscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302090075 X-Proofpoint-ORIG-GUID: fmk8-lkFkHuXiifdAhXNJXkyW3OqPXsr X-Proofpoint-GUID: fmk8-lkFkHuXiifdAhXNJXkyW3OqPXsr Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Allison Henderson Reservationless operations are not allowed with parent pointers because the attr expansion may cause a shutdown if an operation is retried without reservation and succeeds without enough space for the parent pointer. Add tracing to detect if this shutdown occurs. Signed-off-by: Allison Henderson --- fs/xfs/xfs_trans.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fs/xfs/xfs_trans.c b/fs/xfs/xfs_trans.c index 43f4b0943f49..bfb7e87e7794 100644 --- a/fs/xfs/xfs_trans.c +++ b/fs/xfs/xfs_trans.c @@ -375,8 +375,10 @@ xfs_trans_mod_sb( */ if (delta < 0) { tp->t_blk_res_used += (uint)-delta; - if (tp->t_blk_res_used > tp->t_blk_res) + if (tp->t_blk_res_used > tp->t_blk_res) { + xfs_err(mp, "URK blkres 0x%x used 0x%x", tp->t_blk_res, tp->t_blk_res_used); xfs_force_shutdown(mp, SHUTDOWN_CORRUPT_INCORE); + } } else if (delta > 0 && (tp->t_flags & XFS_TRANS_RES_FDBLKS)) { int64_t blkres_delta;