From patchwork Wed Mar 8 22:37: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: 13166520 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 ECE84C64EC4 for ; Wed, 8 Mar 2023 22:38:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230140AbjCHWiT (ORCPT ); Wed, 8 Mar 2023 17:38:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33810 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229905AbjCHWiO (ORCPT ); Wed, 8 Mar 2023 17:38:14 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 879A92C66A for ; Wed, 8 Mar 2023 14:38: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 328JwoiY020849 for ; Wed, 8 Mar 2023 22:38:10 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=x8OwePzbBza8gqf5sZTqSvIWBTl+sSleeliCQwQ2aW4=; b=sIkyCz+8s6boBLqMjLonPzZqVk9RVLZpBTQ2QE8UJnEwh4BStv5PbvJ/LjCJuhpt67hA oQcN9UMQFdawC7vAgbynFf+srFJvfCuqhrKufE5dq5DWw/LvhvbwNj4MLx9qeS/rG9+2 g0luwtT7kMg3YVhZ9SQvgmtS1ZK5pTOwGf3mEEWObjL8IaaZS75eA3KinwAgwtMcMMGO zdDPTm3k7vajUKZ5HJR0uNr6IGC4eNPJ1x9iYaJqXieFU5CZ+ALSVr6ryC6M2jPGxDaL cHxSEs10j+nalqOZ7ydFn6dLDW+YnEwNwt2gC8ojrgAUyxgTURuytSj7QjwJkZLnU+80 QA== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3p41811a29-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 08 Mar 2023 22:38:10 +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 328MAF4l036499 for ; Wed, 8 Mar 2023 22:38:09 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2106.outbound.protection.outlook.com [104.47.70.106]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3p6g464w1m-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 08 Mar 2023 22:38:09 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FtURCQuomKSm8Pe2kf11DVx21C0GcHGRDdJNxujZswzuaisSQysvwsKfvc3dWRv0aQb/rV7kBgGX1T0+E//0sZ5r3Lr6ieB8faMObUpqV2qcHfk3Ae1PCzvCtGhUfYhy2IuZKWvUGVp4+b+PyjSYChatG5VAlOoOrTAa+AGkObtJ9tYApvVCPERUx/GZJEg2AGH423wxAAE3htkQM25pHdAJaxnJQ0TRV0OPPpggA9B+goW4+T9zLR0OH1JZpGMoT//H37pwTs/fYYVkjObVhnPQn70eqIjeGNKaPIm4wX3DKdBpGjMY0rmqqW1EcUlhK6oBeFGwz/dhAP8JAFW+jQ== 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=x8OwePzbBza8gqf5sZTqSvIWBTl+sSleeliCQwQ2aW4=; b=SSoxvoXnAZP+5XKuTP4aqvogSHJInR15po6eAgT/RlAqyAAygYXWFEuCHOkgbjHjO0A4oS2yzxLFuV2tEW4ynLowrBvzD1uzpuZL6cUvVOaDRfUfm1RgrX6waLLKgG/0bLJ/iz6PDhVLS8UPbWEdTBOf7tqVWTI4TEVC3fTruMDgsjLPq5/ro9+vtkc6TyORohIv1sxSHimLrYX1JvOqK0+7FY4xnrfVZyLdx4rNq6pLYNdJRJu17Lvif//fTZsGfB3BHZT2AqF05t75YauxoeZCwRyMCBbiNLUBtP7MS9wvqLyKoaSkBohcoCha/GisdQbMJmPFhwEm9Of7gh9dJQ== 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=x8OwePzbBza8gqf5sZTqSvIWBTl+sSleeliCQwQ2aW4=; b=N90ncFYLDXE7epVLXaX7EihAs548Ho/tebBwIgZCBq6RMjQKH2LJd/32SZEtKrH3giSyktxCAO8Nc8fAKKE3BpgMd8J/8rzwqmhEioZJ3my9TwsHY0R17WN70jLOXs+3v5UEof10RyNmSDkV+WbL51/Qxg+U0eu0qlpbDhA+yUk= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by SN7PR10MB7102.namprd10.prod.outlook.com (2603:10b6:806:348::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.29; Wed, 8 Mar 2023 22:37:58 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::2a7c:497e:b785:dc06]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::2a7c:497e:b785:dc06%8]) with mapi id 15.20.6178.017; Wed, 8 Mar 2023 22:37:58 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v10 01/32] xfs: Add new name to attri/d Date: Wed, 8 Mar 2023 15:37:23 -0700 Message-Id: <20230308223754.1455051-2-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230308223754.1455051-1-allison.henderson@oracle.com> References: <20230308223754.1455051-1-allison.henderson@oracle.com> X-ClientProxiedBy: SJ0PR03CA0028.namprd03.prod.outlook.com (2603:10b6:a03:33a::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_|SN7PR10MB7102:EE_ X-MS-Office365-Filtering-Correlation-Id: f8b7f25c-3e67-4b6d-9dbe-08db2025c47a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: TeSYGZjiifn6ChC7CNLbm5QeV42uxG8qex5RtbehCZYqkxAL+gMi3vpdzEIssrg9I6Sa6Udl1v72JYUdUSpQtM7GG/uQ0nkxNY+O6/TjIBcRZRJa0Kwu3uffkE16ie/GyuczE0P0PFQRAk6JWOqUPYdZsUXrd7xEf5ErEv7wp9VrQI5sGficSCOoqqjfHGBW8st+5XXr4OCOk9oEb6cjjjRN/LlNhSqIXMLUXSGr40A6kgW76mOprT19OVf2aNoB3rbvoIKaUlbMF5Xi+V7xPxfKHj41RPpdt7eJW7d3/pTkDujGH8WHFVBkW8MZxmEtw2jYuVOVeoH+NSQgBNNadtzs/X5oYxTVrxwysBC2VORIcd/6G4e+ItCAqx9jiGyfBAUlNwl9QXsKaQh8Di2RoBSJrYxzew8n3ssAF8a+Swq+jMK98WBIgk60V6bgTSNgV6X/ksP6BzyzEGImb171f23eWtwCptnJkpjda2YR+tzQN/fKbrrB1ki3uvto6t7RZs/ie7D0Z/DWk+voVVa98lNi7f9JEPMiE+es7ajqfhU7j2HScSwRraw+8kH4K1Y0jjLLfVSAUm8oowo5ga6gaUAxuVkWXKhh2KNVduvlZJ65xa6Ok5kbJVvGxsYOHa91Q9LIEvIg/bESriyxr74BPQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(376002)(39860400002)(366004)(346002)(136003)(396003)(451199018)(36756003)(6666004)(8936002)(6916009)(41300700001)(8676002)(66476007)(66946007)(5660300002)(66556008)(30864003)(6506007)(2906002)(38100700002)(86362001)(6486002)(1076003)(6512007)(316002)(478600001)(83380400001)(9686003)(186003)(26005)(2616005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: DxaosgYfI3jJokcOu3FS/xED4ntoHc/NmEMrQ5KS9Kcja7zud2niQ+52cdS9D8yOgVCAQ08kMl9c1m6PMeTkXshIKeUlDfECVr1Ug8yM9OSfET0SzYqmE8+vhr2TuXe4syonFVpMM5plOS9L9CMcNhIk09VSs2okmVcHqewYWQjXpZWtptsLN8CifGKZXtngV29M99ms5FTPjzhxOAdpYiKxMX1iVjfpFQe09bQcruyKQ0vcPcm3wnpljBHaodO2jcbzbZpG4aumHT7NjGFh+yr1qmW3taV3YXn3gC0dCERpJURFB312/yHQG8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OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: f8b7f25c-3e67-4b6d-9dbe-08db2025c47a X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Mar 2023 22:37:58.8118 (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: 567DItcb35y/U2Vm566EcjaHUP/GYv7Jj9F4eYnn6HtuX1VqXW7ApOacse7Gd+XU2ik8TE3tS6T9rIWAl8hq3JFsUbaXrY0K/sZreHrB6ZI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR10MB7102 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-08_15,2023-03-08_03,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 malwarescore=0 mlxscore=0 mlxlogscore=999 adultscore=0 suspectscore=0 phishscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2303080190 X-Proofpoint-ORIG-GUID: sIPoX0P7KpSVYek-MNvgu7e4ng5-cw16 X-Proofpoint-GUID: sIPoX0P7KpSVYek-MNvgu7e4ng5-cw16 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 Reviewed-by: Darrick J. Wong --- 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 Wed Mar 8 22:37: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: 13166518 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 02735C678D5 for ; Wed, 8 Mar 2023 22:38:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229529AbjCHWiQ (ORCPT ); Wed, 8 Mar 2023 17:38:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33712 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229708AbjCHWiN (ORCPT ); Wed, 8 Mar 2023 17:38:13 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2AE402DE7A for ; Wed, 8 Mar 2023 14:38:12 -0800 (PST) Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 328JxvCF026722 for ; Wed, 8 Mar 2023 22:38:12 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2022-7-12; bh=MFDtTRhyv01ZEygnq385U+/6cagFIueYX8bTrpBpPBY=; b=uczWSQPTYG3C2abUIczm3hQMHM1z8wb51NYU9S04h3BEj33XnUfRWndYu4YVGJ1HV/vf moh8Y+CZb423UZDygKucskrJet64WpK8be4HcdxLVAsG+fi8f4UbfpvA5Dh897eyK/Up g7cf7JNdF3fIcYRFsqosMqh/2SfNTdKyffcOQW9tzq7LpTOeXurIZHl4NUzc3ucWARW4 4XdSeqGefPWcVYVYKhIFaifww02vHTHH4JFggcGfEDDd6wrt94HGPaKH6Ta+Q6/ERwSn pRgH3FRAxRYu/RqPc1N2JiuSR8aaMB9DdQqj07Hmyj/05Kp1UF51nKf9nUD+7vceBmBp /A== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3p5nn95qe6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 08 Mar 2023 22:38:11 +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 328MAF4n036499 for ; Wed, 8 Mar 2023 22:38:10 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2106.outbound.protection.outlook.com [104.47.70.106]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3p6g464w1m-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 08 Mar 2023 22:38:10 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Jufo7AcWlXi357jM3EwFRV+TZjmMM8oCExDFDQFRbAZIIn/q9TZWKXC6s0Ymfky75XR+M6Jgd3Tsugwty4MvF8DQ0dE8Jkj4D6xoU31/4ELyptU04s5xQEqPIfJ1eyB0I6PZwHZwlkVVi4cp3glwNHhvcceLjGqV1reDfCBsyiSsnPcEpkqEEk0kVm4HllLWVI73XvpkAXjF/XLhhgERMgLnPmIBv5vPGstV+djmKdXf1cpDExT6Zumh/mKPIg0GoNQaGDdF559RD6HakXWqRCf5NuIfFJZRncKLUVuhPtVn8/zjrM+PKYMkTwY2nRCAqH2fQD31BqklDtPf65/QzQ== 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=MFDtTRhyv01ZEygnq385U+/6cagFIueYX8bTrpBpPBY=; b=Ql3kyq8ohsmPJ+dr8qONy0r0JLF2OkMRLirpGjf+uFQT1U2yrpI3zbaI4QG8N+c/HhmCLNPnS9x044R357ZSMrA+c9EJELiaI3JQyvhaAWFYAf9C2bFSgysCzUVIn3GffiVjD8BZGoiDthXTuejuh0to4S0FE8pHAIGOm+YzALze1sJck6SXxuzfkRFjqxbY4Sg9fr7VaRueO6vWhAWFvHr28gTSKQ9SlCFvvYH3DvPXhzJwUz3ulJAqGkxBUu8aBryYFYYzA4NFAV1uzJTMhwDN+I4b+KoTzbme8f6RmzBmOUPzp+Bcl7rVGVauvWz7W2qPD/+yssE6utXeQdwCcg== 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=MFDtTRhyv01ZEygnq385U+/6cagFIueYX8bTrpBpPBY=; b=q1agP6ogtx5vUziHeB+8zr4AwP48SgDJ8IWLZKjGvg1tE9Z+tLfmEK1tVecJDWA1aq4P0+YLZXHreVa+MpVcuqXoMRkwYAAWVjnOwEKcJTogEEp2Clva5ZRZqDpHwNjirLXnDUXnMQvW6uzNa75Rc0VXSXsAXpYwW42urPe8bJw= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by SN7PR10MB7102.namprd10.prod.outlook.com (2603:10b6:806:348::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.29; Wed, 8 Mar 2023 22:38:00 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::2a7c:497e:b785:dc06]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::2a7c:497e:b785:dc06%8]) with mapi id 15.20.6178.017; Wed, 8 Mar 2023 22:38:00 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v10 02/32] xfs: Hold inode locks in xfs_ialloc Date: Wed, 8 Mar 2023 15:37:24 -0700 Message-Id: <20230308223754.1455051-3-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230308223754.1455051-1-allison.henderson@oracle.com> References: <20230308223754.1455051-1-allison.henderson@oracle.com> X-ClientProxiedBy: BYAPR02CA0011.namprd02.prod.outlook.com (2603:10b6:a02:ee::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_|SN7PR10MB7102:EE_ X-MS-Office365-Filtering-Correlation-Id: bbcdfb90-b1e6-408d-1f15-08db2025c583 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: CmFkcTs6ObmLxo83PHyC3IpRIafTTaQMretEkc1Gd1elcGWEubYsi+azNErDK+eWaVKikecEoJJxfY3aNrl6/7k0GZNa4IHesovUn3REFvhfaH6h2m2E8X1Glogpph64kKGejZltG++6D9yrTrluTv5wBnixXCRVFydTLwszQH0jmrLysxvk/Be37grvthxvIA9jUxVSxYDxSZjAblzRfCyScAO3sOOsfmXjDYOudCK5QR0l2Q9VFqQHK397u2I3yjkrTa2GM4Ge40ly8CJjmwK3JLD3nuOuNT9vTrJLfpvDvcpUidJGgC8Jjr4waeWYzLj84ca52b2JwOzya62N9ZWugKihDp/X0KPKk3rlMZQ/cqB0JMUkjvcvlXaukQZaCjVEW5QH5IgfCIGSCKwdrsHjf0URF5EH1jeyaD0MWgxea4JcyIUaalmiWRtt7lQOPRC3l0X3tDnAHEC7H5jZ/S8h6k/NCQNMsVqN6Zz8o64TcoLkn43u2vRiAisshV7G3z2O9o+6xqMMPmnYgtoQi7NLKeZzkveD43MgItYedehIxiGICpf+9L9N5NBNZhM+pt/Tl3G1ryt6Anf/JZLdbA7Leqd7Q+6hbrT9VGVncjNpZ6l0B//IKb1oe9rUV1iYijYZCQgIHqOXC3pJZBFcXw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(376002)(39860400002)(366004)(346002)(136003)(396003)(451199018)(36756003)(6666004)(8936002)(6916009)(41300700001)(8676002)(66476007)(66946007)(5660300002)(66556008)(6506007)(2906002)(38100700002)(86362001)(6486002)(1076003)(6512007)(316002)(478600001)(83380400001)(9686003)(186003)(26005)(2616005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: nEFkY63HfG59B6NfbbkjyOXde5QeHB4hhdE2HAtUpdwo8J1OIKbEkVmHp90PNSB2ByIc69JUUBcwGDxUaAANIkJJDd+O2YWd4G8/S+YIaVqmllAjmVWaOYl0SB0riEDboWmGlgEI6BqquLQByQ9YzG7TxYa4Gr+cSCW00vYS+Yg3DOKQn6L2QQ6DDHwWYxKvtiEDJvBBy9FjTIfN5OeE3/9ptyvtDNyWrS/zvYK497ebh15TUIz3OO8lnjUEmELZmGAphho0Ko4qhiXAeHQU3h7KkRsN8trYP9b392XcB8pybjJRTYnrkF7PNIYPzo9zJ6FOOnjSiHuBOjZdbQvNAHvRDwI+69e8TPvyI3wvS9AmaAwX5q1pRdqzFZ6yGJcSJaDyJuOvjKFa3csZLaNjSE8t1mWoewlcJakQk4iy3WWcPX3JANfD2cK+6aKgyfJB/NJ5bCIKIPO5Zdy8U2J/rB952YSpeyGIZ8BDkUziagEB0wYXGwpXzk9JiI7E2ugNKbGdG8VR45a31j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JW1/75mj2hRbLGjPYA== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: jfEC1Q+HW4l6q7Cf3sSDDVuV1oy/A3cHYharchB0xVwShdAOtfdekbXB2zpmYvESNMCfZWW7QZAIUa1LSIhDq4PiNlRmesr4W6SslnJ8IYS91MnYbHA5M7bf+uZ9o9Lrw2lPGz2O3XOXmcqT6O8R1UB3jGAK6AXPdVLBpwYUemqt7eFYW8ZjmxFVJznUG+t03vQh/lHeR8dPp9yyPIwJwvxLpulctXwBO5hpf4PJWX+S922++WU7oqKue9MBf0R5FJYS9s2/9PXKT28I/uuiMbIaJRqaPjLGt3BpHD4fa5HCml8iGNO2MCzbQ9R3L43vNvbO33w5uSbjLv9DxzA/5biT9TfMEZaB+8Xdj94q73ctlO3PEurG/JdgFIrfeG0jpekwNqOF+dW045u8KHnuh4TDhW6InAcakMh9X9OhvpN2MxFTMs3W0YlLOeB9U1e0DU0FOZTq2Enm7/aqvQJ2ZBJP/OOGhwMhZtk15b9Y/mK5TlfNZIxSxKFQG0DlynD1p5cZLh7iyOX0C/MfhnCqvhWLCdTCNd29J3Vk7JYAPZRP+7jqN4occ0QysL9or882EmjvzoF4RaPOgQp8kwYilqBZjOOP16PWNNTudlZzVpebx4Ys5yEm3L1yrF5mIkNbBZmV05/VEdVfPETs4i4GVjsYuB8a0glqnzZRht5rSDPl0Iy9zxjmI2drYCF0mgOuQttHoAg8XCJHgKXca6G969ra+bx7PNnw7O5OuMb36UhK/11WexoL/5JILr31sXm5MSuzAlyrFQfu+QUtYuWUmg== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: bbcdfb90-b1e6-408d-1f15-08db2025c583 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Mar 2023 22:38:00.4359 (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: OioLBggOivBzZrzfyB6WgVaXO25ycpMC0yrHBOo26fBVC6OTJrFJ4gvzpAui+IeJsxOlz3YdJXpRMVXLwovYChyR+9RH+MPA1biwpc5BcnM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR10MB7102 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-08_15,2023-03-08_03,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 malwarescore=0 mlxscore=0 mlxlogscore=999 adultscore=0 suspectscore=0 phishscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2303080190 X-Proofpoint-GUID: fwD4Qddk7zl8Ahvy0zLH2q9P-1whEGfB X-Proofpoint-ORIG-GUID: fwD4Qddk7zl8Ahvy0zLH2q9P-1whEGfB 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 5808abab786c..16ebe144687c 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 6abcc34fafd8..0e19ad8719af 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 85e433df6a3f..b96d493b5903 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 Wed Mar 8 22:37:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 13166517 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 29B0FC74A44 for ; Wed, 8 Mar 2023 22:38:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229708AbjCHWiR (ORCPT ); Wed, 8 Mar 2023 17:38:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33794 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229801AbjCHWiN (ORCPT ); Wed, 8 Mar 2023 17:38:13 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8BF9F34F78 for ; Wed, 8 Mar 2023 14:38:12 -0800 (PST) Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 328Jxuqe026675 for ; Wed, 8 Mar 2023 22:38:12 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2022-7-12; bh=c2vpJvOtq9qJvLcor06pWWGrAIAYm1ZeINLc4MN6fEA=; b=Do/y7YHQCrADpuM27+PmcdDfvyhKWbsQ5G9Fq/OPsDRYGaL5DtdEYfxbM4I92E7voFWY gsgejYqIjevTUo0UQ5a25me0LSA7uDzfPmBELjWmN4G0/b/q9AnMFkHepdnWrcld3tVh OLWhYq9naliVE8MUbaZt1OrPtdi1yMpYpErP/y2BB4sxUf5Ke2Tif6gjq9leIpS4XKCR oEDeEm33sTWPjDOfCD4JsfZXZgt+q+UIWz+zwppbdjoGWvce4uEI6JUJHjAY9JFLp1A4 hMr+voE+xMGiM3cKJ4DSHQOjFeq8lkPpPk2we3fupKGl1bYJYDxEv5cz967GolSPX6Bx PA== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3p5nn95qe7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 08 Mar 2023 22:38:12 +0000 Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 328MAF4o036499 for ; Wed, 8 Mar 2023 22:38:10 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2106.outbound.protection.outlook.com [104.47.70.106]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3p6g464w1m-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 08 Mar 2023 22:38:10 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=acvvAXNdoamshUGv5sLgLYOrylmadzqh0xh6IMsv3ZPM5I37Uhlv8pUy0UMtaJrxO89vA1lZBmkjRQ5nJaL4s2DZOvGUR9gfcEYNfpOxOb9Ctww+bO+9C9vJo/v6EgGXf5wegQi7XKkXxZfG8oSSCMTThhUiDF2z1PBHLZd4HR6+AyEampVDRLto9kg9kCLuS8JrasvTC4+O8qAON5iMqYgw7ZvuoIBIPKLfupXBwX/MizxI6UifodykgIreCF2TmX/QTEwljtLsgZpVSEC4khlboh5H0o7JTs5XupfXda8X3nJPl0gevEsRcYm+G6wNs8s1Wcv/3Geux1HKynfe/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=c2vpJvOtq9qJvLcor06pWWGrAIAYm1ZeINLc4MN6fEA=; b=ReGYP+CrLl2zvazmR4QhXCVAp7FbiCtdyksGTI2aR+fhXmC4hYD/5Doa4CJbIMGGX+CQ1QL9otSBmCSabS8WDJBijpq2I+Op7WGzxgJri8arAe+AGfT3NH0qV5OgHjIJfQdZNRUOmMlRxHRhAws+xmlkLmmmGYhspcny9kLoWDnhguhglvmYMqr/8x9ERSP29mUNnjaxzaJevy9VMmLlnmnZrOufpmgeLu0XvriKmexT4EqWUcvYh29et+byF+byiFMP4ckuLKRfF1jI+XqktqeBKthW0BN1SkFs+nYakq0kWBLnzFLt+P7edV4/Qvo6jEmHY2uKYXhXwrD6xeToIw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=c2vpJvOtq9qJvLcor06pWWGrAIAYm1ZeINLc4MN6fEA=; b=qUtQu//pnZvs3r5xXZEEpQNrI9IYc9kQXRVbG8oSlo7N6ZSXodAUWeglWg9q3TBbZ/PsbjoxpAt7vLtVE2jo62//+lazfQ3w9i+K4T9mHNkW30o5cGigte9ni++9+fPynKN4+K0J1513Kr4U5p9WHoqEB/nDjg6+g43pF3j1qDc= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by SN7PR10MB7102.namprd10.prod.outlook.com (2603:10b6:806:348::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.29; Wed, 8 Mar 2023 22:38:02 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::2a7c:497e:b785:dc06]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::2a7c:497e:b785:dc06%8]) with mapi id 15.20.6178.017; Wed, 8 Mar 2023 22:38:02 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v10 03/32] xfs: Hold inode locks in xfs_trans_alloc_dir Date: Wed, 8 Mar 2023 15:37:25 -0700 Message-Id: <20230308223754.1455051-4-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230308223754.1455051-1-allison.henderson@oracle.com> References: <20230308223754.1455051-1-allison.henderson@oracle.com> X-ClientProxiedBy: BYAPR04CA0004.namprd04.prod.outlook.com (2603:10b6:a03:40::17) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY5PR10MB4306:EE_|SN7PR10MB7102:EE_ X-MS-Office365-Filtering-Correlation-Id: 66a6ccf2-ede7-4bf5-99e6-08db2025c6a1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: EDUlBDicFDoBdA0DrfjxEs9mCslwwHwg75tH0qete1JgS2kbwlH9gOuMcGPpqL7uD1OHklhXNSUNnW4U87ClD1t9KP7XQ99AJbhnud/StvHvjicRA+rklwgiDlAuJjmSbhk2vLrouBDbjwpVmcwbW6FdBHYjsJrx+wfQ3FYmPrt/3GKDYmXLsKhPqK8Aayvj16P0q4mrPYE4nwMAkeBIpu18oSGhf21UTuzcFmx1E3Mqb39AJ/ufJe6Ptd4v2j1gFh72bPGipueXfzLix3iY9VUOWqV8LGekUQ/tli59dQp8RnADSaaZZlYigXSPOzTZOclOr+1ktB63bY55acFSESovdIG5kLCwQgfgvw49EaF+xYB2hr6v3M6MZn6l3sUJmW9mbPGX3b8weZSk9DCz2jnHNTZ6M1ksrU90WosqGO4lZc0EBMrBpSdijaGGtzL+txxDifO4jgTbtqnAgn2I4Ti8okdZ/Y+VB3Or/YveDOY7ZB4iqSKa6pJ5yM/lRvlsv+7QndiBQcj3HKRTyvTPtzAv7ngAvrUuOrQwcXRXJOlGTnbngAjH8GWpHwU9CY4m2JUMMLy779U8DeZf3WzXH50mfNecN0OHoB3lEM1eS/3yQ8dB6XPcT6XkSLcVkdhOiRvOdszYHsZujrLzuZYNVQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(376002)(39860400002)(366004)(346002)(136003)(396003)(451199018)(36756003)(6666004)(8936002)(6916009)(41300700001)(8676002)(66476007)(66946007)(5660300002)(66556008)(6506007)(2906002)(38100700002)(86362001)(6486002)(1076003)(6512007)(316002)(478600001)(83380400001)(9686003)(186003)(26005)(2616005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: VJxBhiUCZMZcmXG0NIWxtwt9aGwUpJ/XcU5UTY6VUpbEXWSPicOA+mVezU7WExXF1u5J4dCXEGgexTthr0HHzGJ5/T5UmvroTUEdSwH0RT5Af+70jNbJ7RohG9PtWO7OlMhXT6eDNtvP8TIYo7s9ZP4rr0O5nIiKqPdQat5m0BTE3Q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CiCrXaSfe/uBVn6u7pXL1AnqVO08n3bqx8jzYJKky6TeQ7hQnRct1gMPJeUt1pjqStK42kTWL6UynkGKSodQg19WFmie3HU/n0xRr45IuEFqkfTxtpvKZlJ2YTJ/xEnlD29l4Xf5lrnMC5jbTMda+lo7Gx3YkrZEw== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 66a6ccf2-ede7-4bf5-99e6-08db2025c6a1 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Mar 2023 22:38:02.2991 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: mO370knk0nFr1AMFwfUSU/g/AdhWsAz9R7JwANykE0Y60HuAhZl1uM41yVrHRtRffovQtiBdTgNJc4N5zOmKUsB5IfbHVOwM58TxT4ctGjE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR10MB7102 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-08_15,2023-03-08_03,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 malwarescore=0 mlxscore=0 mlxlogscore=999 adultscore=0 suspectscore=0 phishscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2303080190 X-Proofpoint-GUID: q_uBHbDzXl-OF2JHVkruDh5GELO11THB X-Proofpoint-ORIG-GUID: q_uBHbDzXl-OF2JHVkruDh5GELO11THB Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Allison Henderson Modify xfs_trans_alloc_dir to hold locks after return. Caller will be responsible for manual unlock. We will need this later to hold locks across parent pointer operations Signed-off-by: Allison Henderson Reviewed-by: Darrick J. Wong Reviewed-by: Catherine Hoang --- fs/xfs/xfs_inode.c | 14 ++++++++++++-- fs/xfs/xfs_trans.c | 9 +++++++-- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index 16ebe144687c..fc730c573eca 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -1279,10 +1279,15 @@ xfs_link( if (xfs_has_wsync(mp) || xfs_has_dirsync(mp)) xfs_trans_set_sync(tp); - return xfs_trans_commit(tp); + error = xfs_trans_commit(tp); + xfs_iunlock(tdp, XFS_ILOCK_EXCL); + xfs_iunlock(sip, XFS_ILOCK_EXCL); + return error; error_return: xfs_trans_cancel(tp); + xfs_iunlock(tdp, XFS_ILOCK_EXCL); + xfs_iunlock(sip, XFS_ILOCK_EXCL); std_return: if (error == -ENOSPC && nospace_error) error = nospace_error; @@ -2518,15 +2523,20 @@ xfs_remove( error = xfs_trans_commit(tp); if (error) - goto std_return; + goto out_unlock; if (is_dir && xfs_inode_is_filestream(ip)) xfs_filestream_deassociate(ip); + xfs_iunlock(ip, XFS_ILOCK_EXCL); + xfs_iunlock(dp, XFS_ILOCK_EXCL); return 0; out_trans_cancel: xfs_trans_cancel(tp); + out_unlock: + xfs_iunlock(ip, XFS_ILOCK_EXCL); + xfs_iunlock(dp, XFS_ILOCK_EXCL); std_return: return error; } diff --git a/fs/xfs/xfs_trans.c b/fs/xfs/xfs_trans.c index 8afc0c080861..7e656dd42362 100644 --- a/fs/xfs/xfs_trans.c +++ b/fs/xfs/xfs_trans.c @@ -1356,6 +1356,8 @@ xfs_trans_alloc_ichange( * The caller must ensure that the on-disk dquots attached to this inode have * already been allocated and initialized. The ILOCKs will be dropped when the * transaction is committed or cancelled. + * + * Caller is responsible for unlocking the inodes manually upon return */ int xfs_trans_alloc_dir( @@ -1386,8 +1388,8 @@ xfs_trans_alloc_dir( xfs_lock_two_inodes(dp, XFS_ILOCK_EXCL, ip, XFS_ILOCK_EXCL); - xfs_trans_ijoin(tp, dp, XFS_ILOCK_EXCL); - xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL); + xfs_trans_ijoin(tp, dp, 0); + xfs_trans_ijoin(tp, ip, 0); error = xfs_qm_dqattach_locked(dp, false); if (error) { @@ -1410,6 +1412,9 @@ xfs_trans_alloc_dir( if (error == -EDQUOT || error == -ENOSPC) { if (!retried) { xfs_trans_cancel(tp); + xfs_iunlock(dp, XFS_ILOCK_EXCL); + if (dp != ip) + xfs_iunlock(ip, XFS_ILOCK_EXCL); xfs_blockgc_free_quota(dp, 0); retried = true; goto retry; From patchwork Wed Mar 8 22:37: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: 13166516 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 D2C85C64EC4 for ; Wed, 8 Mar 2023 22:38:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230101AbjCHWiP (ORCPT ); Wed, 8 Mar 2023 17:38:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33720 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229778AbjCHWiN (ORCPT ); Wed, 8 Mar 2023 17:38:13 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 636323251E for ; Wed, 8 Mar 2023 14:38:12 -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 328Jwkds018341 for ; Wed, 8 Mar 2023 22:38: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=P5j7BgTQAGPsNo5QbGjw47KSh+ZHu1/KgUNMIr02vNI=; b=JzK5LqCjpAzE9Vx8iBFj2ilRjVc+WNfjR7UzihHx+uszRZH7Ct4swE/FbiSIcH2vOmxg S3KUREIWOSulPwATTUNDFgqyLZoX5pb3bYt/1ZclneuE8+iuGMOsZfJupSohGfbI3fHT gzvFtGDykAZ9VNf9IPcYOl5Lb5b64LIise435OQxSvQRwy/nkp28ilGBaNObmMRLKIfq 0Rd/r/s6G/CGNoUya/rmyyvUWeubSLXptZdUzAwey0Q4qI+wXr5bwv1Dr/5vyDpSYCEa 6TEi26v7B38G4KmOdqO/VjZNUosWC8kkZzdz6D7R3a5bDNNRxFPzVR7whiQ3HyJIXZ3E Jw== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3p417chcww-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 08 Mar 2023 22:38:11 +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 328MAF4p036499 for ; Wed, 8 Mar 2023 22:38:10 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2106.outbound.protection.outlook.com [104.47.70.106]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3p6g464w1m-5 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 08 Mar 2023 22:38:10 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Yw19OkiBcs/2x7WCoHf8QoLFkgn9ndwDnHL5ZL+qU+p0nQMvlTWg1EZhFShtD60cZ49c7LscXzY++8T4Xe6I/ik3A3TJ/agQzEv6EgXofaQsMFaq89X+Ovv3yj7IRhe5yWQpP/SQT6//OEB4zTmd8YmPBTKu11m4wnNQtRNHttsezdJCM07ybabor/1nnLfY9+En4YGK3GCAHOU5gqlM17CbjQN8cTIhGZwdC3McKqCZDHwygDZGlIOVCffi69uAVp/aCfStyoi1hGjd7b1E224cIlHQ5/N8kTBlkBPYQ98ApJvmffYl6CiPqmwyE5ZeL7NrUCyHY8XxJra5veehVA== 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=P5j7BgTQAGPsNo5QbGjw47KSh+ZHu1/KgUNMIr02vNI=; b=TyuqbGSgR6+ymvsXinRAp6lqcMsCr+xXP61+Ag2WAEaglf3yTEaANQUVgYq63qu7GafE8Hn7JVmV9c9MrI9AFUPKd4ccm72sf7BFIvis0WuL97NmaXvWrpcmGc5PwIgtuC6wwsVWJHVtDAYqQm+0Qz0GoFyg/ALdTEfxjNLRS8bvdav2Wk+A/bntzYf62Ag9dtYtqdv0f4HxCmmV5M/wxcMiHOkdT/8QpW8SE00CULR//Rqow4FuKfGv9AsTEiHCCvrFkp5RRiu9/jXDrJc67hYKgkmyLx+MitrxPcZJRkcNgNF/7W4WeGCNzqLoakLPIAYVYh0cIx6Lluld8K+hZw== 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=P5j7BgTQAGPsNo5QbGjw47KSh+ZHu1/KgUNMIr02vNI=; b=xxvEO0vJ0BwuKcS0MMaTDSQqldCymcdK0XhJkHxYZU615QRwVWWPCrk4G9tEkVsSNTl8stGOMCthrkl7W9UELp5u9XMm0cZF5POKPvaOW7mpOeSzhaC5q7D7sJO1sfHl4z+H8cqGEHQEukh0XjojReVRXEQolynid9nMpoOoIrI= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by SN7PR10MB7102.namprd10.prod.outlook.com (2603:10b6:806:348::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.29; Wed, 8 Mar 2023 22:38:03 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::2a7c:497e:b785:dc06]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::2a7c:497e:b785:dc06%8]) with mapi id 15.20.6178.017; Wed, 8 Mar 2023 22:38:03 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v10 04/32] xfs: Hold inode locks in xfs_rename Date: Wed, 8 Mar 2023 15:37:26 -0700 Message-Id: <20230308223754.1455051-5-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230308223754.1455051-1-allison.henderson@oracle.com> References: <20230308223754.1455051-1-allison.henderson@oracle.com> X-ClientProxiedBy: BYAPR02CA0005.namprd02.prod.outlook.com (2603:10b6:a02:ee::18) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY5PR10MB4306:EE_|SN7PR10MB7102:EE_ X-MS-Office365-Filtering-Correlation-Id: f9baa40c-2b17-41f3-6c03-08db2025c78b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: gxCioSksLgL7G2jaxyXOYzG2op2DQvi8rktkGjG/CdOAhA6v65hI0vxh9mPJDI1FAXDVm+O4gMvHFP2NjgXAYQ731gCajHt4XErd/7hIlyQ08Gh7jk+jTlbpPmlju6LPCdzufGTe7aMpOvLq6ANBrZnf+pwOYlYVHcXIHD4IReEC6Yeyvdl8WGVkL1MBSnHkbdZ0nEJoIWs0iQp0jhB/iF8GkrHqqWg8OdFkoEO/ZWaZxavQs4tJ0Jjl1N971b9WgZa6KnF9bx+/BEn7qPfoI9a2I6ZvhxXWRZl7nWoIxUF11WuhabqGfVgbwsW2nH9tIdUNisAfGRTaQCKbEa89WhLUHskcAikES4M/H8hOWtLDOfCfx0aYcLT+YCrV6VodMr7Rm5TOhLo0oeM0ErXjfWscCJN+KU/Gujdx1I7PhmI+zI9ycA25YYG8NDdLzejOWRXKS4qhtytaXNuv0q0AmsL1AZ7RmQ5A/jGLUFy8muqiLQgXWDT8ZLeULAcpo4CSIMRXMY885+6qzGXUudDx/uA1xICyyKX8T+67/AXBjUOULo8wj5QIM+Tq0BZ8vofyU2GM6Azequse6IACaNtLsy+8aRgSJ/scOtEUnmXUP9Yv9g/KW3mVzh++7XqwkkJJ+5F5zSdX6umyjZjBrZBiIg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(376002)(39860400002)(366004)(346002)(136003)(396003)(451199018)(36756003)(6666004)(8936002)(6916009)(41300700001)(8676002)(66476007)(66946007)(5660300002)(66556008)(6506007)(2906002)(38100700002)(86362001)(6486002)(1076003)(6512007)(316002)(478600001)(83380400001)(9686003)(186003)(26005)(2616005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: fR+ECWr3br7CgO6Yk33VEEAvuMknk/Exblbbk30bd5dVBDplrQc/ZudeyCaQdEO2MAUgPUOeX3EW+lIiWcW143G+9DrKxJ80jzedmifjlawgJKjSHvnlnEH+uEm8T7V/k7hTZH322UxK7zqXWzchqHnty17+omqNvfHr8nEuD62iKl3+wkLi8J6lpub/H6Jz/wCyypl3vuWkvMGXEc/gKPsRqjhrJbNFSahKpqtdhjD0YcZJfAMBYqiRZDvHBpEY5iJt3ajuAW/J0EspYLZTDHVP7yFsbS3nVjmDFPxq+5YLFjmJEXB61MBHLE07Tn8sBR8Gn3U2exq/JJra1DhutO/Gx/8Dkzb3Z2RQEwj6pyZR17cYHqWF9kdT0z96OtTNYu6Hdq5BKP4dK11cop+yzyOoc12ANWFlNO4pvWvq5nUYO69+LiacqdQrfKl1Ja/1foDOt0tsfkfmTdnoI1aBari5RgBoPi0uRRzQdo8oXtgXzsU8bPO1cCDhP8mgzsMvpxz2XLUDW2tDB3AEpNU+DvRxmDIZGomL3fn/tITtsvij4XPWlACBwTdAI90kbu+Nlakq1O3VMzh5CVWl5kdgsgyHbRAIqcVgUVrQUNiUx1hyL5+NL+c3ZZFS/kkgtBQ6oC+8nrLTmq90YwupBcIqyT1dVmo/nDVGvKO952X/omDRZmlRyy65rZoqMUhFL+jbiyLNsgUF8oP05bZogqHyQzklwyb7RX+9teOiR5bX9hzvKY2zcJYO5tSEXQnc2wD0RXM5wNoCMkg30GZhnivqQ5NsbiW310khz2c1wVISJMJyeXJf/GIpFIalRCUlxYD++iTKDJBuO9A+jiGdR9zmcEK5VgUJ/IdUlKZoT70hwjq8sPOhd9FzWn1UzQ3fBix7MU21L1zKT+971axA1qm6NCG5+dLqPk12npKQCEkSjz5SWCc37iHmF455i1uScfF+XDTeiwADk52o2KBdNmhllS8d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v0pt4jH9rU9NKv6aiZBzFo6+1OLLMZLBeSyLkqwujZNgnc72ek2r8uUSEfkvMfiSCV4OZPydWAmWcVNLnCriJlLo7bhi4519mM88gCJagJMRynt95ayHy9fv6WS05ivpi9W+LsHZQQyJqrPLh6Av+wXpq1TA+6FSF7ikMUAKCgvcw6+6idkCtxF6VYQfH1LsXt2X0n32H9NuMTdKqLEvoEIJQP6JmooxpSjSWdOB2Q3tFVlYEMwaZ+8I+0GQTZnjIEva60EwLOe2PrSnP5+j+DKpG0RbYS3Gi4GF/BWh/L5eo73WWFB9BXmSXkb8W1ptoaGWHNueFWVRAeGiKDjDVsJir4u0tDKFwfaTo9zVfrgCak+2xzPC7O49b/8B8pklqTqCEtchiojuPgKnMBFrnmMENCjR63it6SOvw== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: f9baa40c-2b17-41f3-6c03-08db2025c78b X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Mar 2023 22:38:03.8301 (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: 79VSBMk7oRGPGjUwtbywTRgfvg2REPaow3uSMYcMvSyPjoOKXHVHWrZZ5ZCwpYdSKhgwAoKYAClSIy0IxjE4uK6s1Ai5LjgYBJNqjEWJPmk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR10MB7102 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-08_15,2023-03-08_03,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 malwarescore=0 mlxscore=0 mlxlogscore=999 adultscore=0 suspectscore=0 phishscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2303080190 X-Proofpoint-GUID: BUz0ZVDDP1Kr_Hw0f0wJosNduxitXK59 X-Proofpoint-ORIG-GUID: BUz0ZVDDP1Kr_Hw0f0wJosNduxitXK59 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 fc730c573eca..0ca2f9230afc 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 Wed Mar 8 22:37: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: 13166521 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 F10C3C6FD19 for ; Wed, 8 Mar 2023 22:38:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230170AbjCHWiV (ORCPT ); Wed, 8 Mar 2023 17:38:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34140 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230135AbjCHWiT (ORCPT ); Wed, 8 Mar 2023 17:38:19 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1737A6150A for ; Wed, 8 Mar 2023 14:38:18 -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 328JwgdQ007284 for ; Wed, 8 Mar 2023 22:38: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=iWom3jx4wcywWJgX+9XH3WoN+TfLOur+VdCgW2ffFso=; b=M0xBWu4Ay4Gk6GkdGGa8/oI2cMI9GdeQyEEqcm2ZlcywsobNTyG9RYhUxVsJ2GxNybs3 gbbkYt/5RyLb1iwbPf+SI18aW5OuRNZCuUrB/Hcq2pUu9z4GrQG3+46sgB8Yj+lX0Ulg 74cf2zDAAd1LHa9Gt3RbHkFNOk2YMOlbqEsVgZ1MSqjomlPGn8iJdvtoczXchkbZPqjM WMfFrb1K6513ojIlSBrA/MXzhRnvcSK84awIopQTA0U6O7jPKSyEy8+xulokmlieBdP0 m7xPraauf1LY/5/IwchOgGVX2eYl9SgU15+B3olEIxU5dYdtL6lLQbwryS/fWcQw0kX6 Gg== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3p415j1faw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 08 Mar 2023 22:38:17 +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 328LVM0g015688 for ; Wed, 8 Mar 2023 22:38:15 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2172.outbound.protection.outlook.com [104.47.57.172]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3p6femx3av-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 08 Mar 2023 22:38:15 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ws+bDqmfm4iB4jBkqvJSaVB/yA3WOvL2C0SuB+w12AeBvb/7kcFUJCFksqjPYlfJlUDNeBH7GmCBrkpBds8DZt6nAPXNWMidN47ExIY02YobXxi1SUGTQB5FS2SWl4m1UQRxxt+sO5xJJtEkm/O9oBOigfNsogmIqZzxQWUMdg3s1VTaYxN1B0U4aU6m81RVq2SB6B6TkzRS2SfO8U+CucQg+tN1IwwCLyNauzt3HdgtrjxMklTPhCkTGWl1mKZKFDCCaYRUbEaKWQ+MKpoNgM2rRZhvt7IGKlTPkwIYV7ENXvpswcwmcNr4N9KDlj2hwX1VQMaWNU5y4KkApqRXpw== 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=iWom3jx4wcywWJgX+9XH3WoN+TfLOur+VdCgW2ffFso=; b=XH8yT+jEqsFG2Vvf/E98RfSVhJQQWC8FD8eeIVB2HUtSbw1HZ/qlpKYRD4UwNUhk19AA6Nk0twuutLU6qcovlBTKl0KkbzsxGIQv35xlGB7R7N07r9nMLYGxRbjRNdban9OWZsaCNG/37J7YJ7gkIGSXg434pNnC3NpC6PgzxNdTtlEbVhX+yeuNqSQ9uIlMyvpRGmeDt+Sru5/ufVFJYcmJevz/akby0CjXq0o0D9F4qGAG8kZWRUUfF7f1aXc+z3CRvoJJMq4kEB8lg07p65vhmYAaIlpbKaUFnT5emu4D4i8Nu/kYIu2ySlZRKm1E29uteuFncBa0RpvoIKPDqg== 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=iWom3jx4wcywWJgX+9XH3WoN+TfLOur+VdCgW2ffFso=; b=aqIxERN4kuE981QrqE1Unats3R8NRkQcLMg0ZIz+Rnssv/h30fbGcOSKOLAvYZNfzteOMWBJ7Hbt05+iuB4WOHGkMvJte05lsZP00YwpNu/jCbORG0BrzSbafg46Wn6s6ZJGnVEiBSObRsjblouQ9FcDrg1D5yUL2MPj0B9q2Ds= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by PH0PR10MB5708.namprd10.prod.outlook.com (2603:10b6:510:146::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.27; Wed, 8 Mar 2023 22:38:05 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::2a7c:497e:b785:dc06]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::2a7c:497e:b785:dc06%8]) with mapi id 15.20.6178.017; Wed, 8 Mar 2023 22:38:05 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v10 05/32] xfs: Expose init_xattrs in xfs_create_tmpfile Date: Wed, 8 Mar 2023 15:37:27 -0700 Message-Id: <20230308223754.1455051-6-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230308223754.1455051-1-allison.henderson@oracle.com> References: <20230308223754.1455051-1-allison.henderson@oracle.com> X-ClientProxiedBy: BYAPR02CA0036.namprd02.prod.outlook.com (2603:10b6:a02:ee::49) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY5PR10MB4306:EE_|PH0PR10MB5708:EE_ X-MS-Office365-Filtering-Correlation-Id: 999e1813-d854-45c7-e842-08db2025c874 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: I8vza+XELJUWOGr6f0NRighTLYgRojsU5pGZ7ZV7IdIqk0joyJRjPGquSRyfiVTlsL4ZiLEAMVmyEBhxO25rtLVgmHp6LBu3idg4Hah3okx0CbJPQeLOZ6MHpYvtlG491BMMRpol/gchwhtZyqVetKTGPGZENc8RjYQHOUJ5vjBo3SqiLI/ehamm1mm10OuQX9wFZBH7HheBtolOr00GaZAD9WukV5psX6z9OpBL9Vp5JCzj5C/rZhdxS+T9BxL1yFYStXMKnaSOVXcBpcs5QU/IJ9WQX3kFF+nA3GY4cdyH3XgvN32hCmikTrzg92ZX+60XCOfA4IjO/JsGCoMRNXzOa6oEr4BpsUTs7Ns4aBHwp2evBmmwWELdwojlW/wm/MsHJmEARNsJYlMEjlR9TYA7RgjSojKSeNWREt30/se1xMPzPa2Js8QFYBeRD89JRqFT5WuN0fn0vZJCL8KXbrz0gTzGvpmHJmV+rQm2Dl6hFBW1vYDEsE3bSHJCE6sQjrDokjbMGYtQqE+cfyrcizNd+b6wKg/4Fe9wFsFxmGS7FeV1+rmFWi/5snAOwnWmgaID5gaW57vqW6B97uv58dDHX8mBDR1Cu2QZxbBB0TeSebUrOSRPK1Epmnol2GNgc0P271LvG39F9VjM3xuxZw== 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)(366004)(346002)(136003)(39860400002)(376002)(451199018)(36756003)(6666004)(478600001)(83380400001)(6486002)(6506007)(186003)(9686003)(1076003)(2616005)(6916009)(6512007)(8936002)(66476007)(66946007)(2906002)(66556008)(41300700001)(8676002)(86362001)(5660300002)(26005)(316002)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: vFPPd0YHi7N74Z74Mhg9FYYNOnjowVXKaXvUCw1n/cSh7xIiCMrjXJ7fPcXOpC7Ebq9jMJDLp+QBEq5u8idOQlO9r/KY5vTI80XpMT5lWxJJDp47wA2IFTrxXdPY2Kzj4u4TYF77WsPmkFS2erbvt8gJyBtwOiEyHwCaR7HK5S2M8yDGw3jjHrg8Iw7sjaVTdvNHyDVaSRBiEJWkMHJnFmkfc2yeSDDKlh5tdd3GJAgvufpX/wSJRa2iJY79je0Ld4YVRYUNAzFhkceXLOsbGK1MFBv9l+hkjDmbvW0V4AzM5tVh+QWqjV3sSksxtj1U6ogQUJufKO56O9HuZP71RHYQN5GvMvpClBG5XP4D6zEFj338xNHdodJBsHengSKbd2CcvK5z2/WWTAR+62OIVDxjlfCDPv9wcQDpD1aGa46zwdM/eymvaxpqPTFjCheS0yzURMTug4s709dnK36KL02y53fjKr2mMuWdRSiWvCqCDmEVM9VdrJxccf+j32oKRgagHxaEl4mkWzGSaF7cktLEFD6eyp4tpbYBBqs5fAtLGWDxU2v03TugglSMb6N5o4vqpchifAmb6t4svtmbAzU7ce2tMwrPg6zYxVV1iDAKHd1S3suMr6yRolRClqnNsqqpjM91TavjmrlYOeOaPrdoXUz81c3Vz5yu1jrVvnGQuTPhD4tXsS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JxN+Sx5oR8iLxYywWKWdupi1SojrjdYMh0GtKz4Nni03Fh4XEix9hZRbxAZ/1byO+cnYqaghd5QDW3Hklp7RjJWOHc5BhYWrs3qMuPqWqlr3h3H01jU86JbGEIKBrzZVPDwOi8+uZSPZiJtUdQRkCBbAvR5/RfkPEBqVFWLhb+S7cb+85tKnj1L6t76P22YC3rzFhFeBJHDrB/vFjWh1PQhg1QWB9barZwhrSUcJQVT3Qa5sSG4xU7MCxVzITnBIAXqngZ993/288+WB/YHIpEjiyX0L/uJ2edWJJiMI7s2W69Se+kvY4sfXoEcRCJrUuSEVhXn9idhXvCprcF6APGHSo931FjROX+dBXFbQe/3niOqFmn14MtW8s1pMjjeIo75B888+nM40VYRaZzhBvMVpZDqoVhznFsJQgj85gJfZ4wNG6HeTCLaKWyfiOVRKMqj7tQdEP2SqT99zifTAJWdAnGIZicI1CvbiNmtMR0HoK5RoWBRBo9xl8ytqbxurhju4j8jnGiMKKqnzJ1CkKsBPHK/KKMOCS2DFEfaL9P1oIP0AG1jRoP1YBKpH/mTMeMJq5unsRQdED3IGLKLWiGlexLBULIwd0PZWTuT/zjN4vHdhKgMmL2U1iFCM9e4m6UTzvTeFRJNtJZ1IVef9ydNayUZWVuF2w5WH66hZYSMH6JTjAhOx5nw4VRdM6I+ej05g== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 999e1813-d854-45c7-e842-08db2025c874 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Mar 2023 22:38:05.3603 (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: 0lagv9z2YXjA/J4iuZnhn0wJUY8VMgH8yDU/pzpOmJfSaSGMgbV5ClnMfhNqfV7NCm/BfoUXwm7Nmj1nhlt5WLh5dmtY+GzAwjw/10/fm00= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB5708 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-08_15,2023-03-08_03,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 spamscore=0 bulkscore=0 mlxlogscore=999 suspectscore=0 malwarescore=0 mlxscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2303080190 X-Proofpoint-GUID: Ww0E-85iEtSygwKLP9Lkt5kWej3t3_Dm X-Proofpoint-ORIG-GUID: Ww0E-85iEtSygwKLP9Lkt5kWej3t3_Dm 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 | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index 0ca2f9230afc..8aa8a8e17a5e 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -1109,6 +1109,7 @@ xfs_create_tmpfile( struct mnt_idmap *idmap, 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(idmap, 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(idmap, 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 69d21e42c10a..112fb5767233 100644 --- a/fs/xfs/xfs_inode.h +++ b/fs/xfs/xfs_inode.h @@ -478,7 +478,7 @@ int xfs_create(struct mnt_idmap *idmap, umode_t mode, dev_t rdev, bool need_xattr, struct xfs_inode **ipp); int xfs_create_tmpfile(struct mnt_idmap *idmap, - 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 24718adb3c16..afc3cff11cf9 100644 --- a/fs/xfs/xfs_iops.c +++ b/fs/xfs/xfs_iops.c @@ -200,7 +200,7 @@ xfs_generic_create( xfs_create_need_xattr(dir, default_acl, acl), &ip); } else { - error = xfs_create_tmpfile(idmap, XFS_I(dir), mode, &ip); + error = xfs_create_tmpfile(idmap, XFS_I(dir), mode, true, &ip); } if (unlikely(error)) goto out_free_acl; From patchwork Wed Mar 8 22:37: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: 13166525 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 6F03AC64EC4 for ; Wed, 8 Mar 2023 22:38:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230240AbjCHWiW (ORCPT ); Wed, 8 Mar 2023 17:38:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34258 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229801AbjCHWiU (ORCPT ); Wed, 8 Mar 2023 17:38:20 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7351962301 for ; Wed, 8 Mar 2023 14:38:18 -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 328Jwo4S020813 for ; Wed, 8 Mar 2023 22:38: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=/+M/2pVy95P3FvfxzBaUksYhRBWZtbJ9UxEofJ5atrs=; b=uIo+fY1E55J+MiD6hwCThPxS3pj7cz9t8uqgF+PLrdu3yLAwaEcdL3rNxPGCv2C7i2tL 6nZMs6t9lIeVRQObmQeY6MTn5YpUFx1h0Bm377JgxwYT0gTsEPszDYAIBgbRBvdFrPuW wFfPJ0nqoB91GqBYIYgYyt5LLQWAjHsyLTX9ftHalRKV+aC34PA31hpU49N0HP6bH4Ll rhObHVL0SQKgQob+cor4UZ1e7WLoq42b6pZ9r94M4XkyjQBuFa8YxwPDXsi5+YOfdW9f 8HuhkWzOknI6kO4f34PTDmJCexzuNF5KAVtmFjSXAmGUuUt4TRB+cbjwbgmlVT6t/TaC 4Q== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3p41811a2k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 08 Mar 2023 22:38:17 +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 328LVM0h015688 for ; Wed, 8 Mar 2023 22:38:16 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2172.outbound.protection.outlook.com [104.47.57.172]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3p6femx3av-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 08 Mar 2023 22:38:15 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=C1uNxTb9Cm+Cs4a9KeqJVcxhusmYx33SC5cIbWPs3L+2Nmg8cDPt5ER8DvlcRjXLtqOhfL5lM9qs8hvFizL8h9d0aaiYEQH6BdCMVEaEDRPtSLtKayNtlxkKYhReX9vI0e/JlwvGDDSH3p9I+bQTO7JOk2TvepwVT5VEgtbXiBeDu8FCxLZrI7FRR2fotI+vErCYeiXjQCjaNMqDCxdxdoAgCSTP/YP1BDnpl9wOQT+m/jYLEDOOPrzj0LfMhQ0dJAXonbzrW9ZURO02/nWVdPJKh+1XY0PqNQu4fIEPfN9n8uAdZf+uvcPET/CeyPhr2GmXF+K5ELw196414G+iUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=/+M/2pVy95P3FvfxzBaUksYhRBWZtbJ9UxEofJ5atrs=; b=fXHbK48N8nbGv89mbVBGTt57Hh2qvl8xlkGLKq2Y05XvpaQMC0ofV2ZTZP9Uk40sIit5JXmjVHJkqqk3CpdOwR21lr1P2Fa1YvnWMfko0JGH5MnIFiCfGZ7RocIffSODmGhbjBkvv4gDgCbjcaKKwmq4NZVQEzW63K78AC6OTln5fpLZbwYNzMm0BrYqCVLHmBSj+T1i9r9h6KwFAv6uZX74tcJTSpkf3DTr0oI5DAeUbh2ZZUmy71oRFmGx2J0GUbVAtzWIVIolNprIaQLGLHbR0AtB5ZMzmkBD0GLxnqVrrRUDf/2oPUtalpeR4vg5Rsid92R11p+aQKv+A2Tcng== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=/+M/2pVy95P3FvfxzBaUksYhRBWZtbJ9UxEofJ5atrs=; b=adrW427pmhCGvivf7683YZXryV2aWW4QxBoox4Q1knF2Q6qRsP2EmPdPkxL1SpBy9gPbgfA24mO7vLHzOm5HjvGIZizZBM8doPPRkgC45d2n4qRdy3EomSEFPXWmZ4wuqI2M6Hr37YErr7JzTXH4IC0yQlBn4Y78J5GE3+RIrac= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by PH0PR10MB5708.namprd10.prod.outlook.com (2603:10b6:510:146::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.27; Wed, 8 Mar 2023 22:38:07 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::2a7c:497e:b785:dc06]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::2a7c:497e:b785:dc06%8]) with mapi id 15.20.6178.017; Wed, 8 Mar 2023 22:38:07 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v10 06/32] xfs: Increase XFS_DEFER_OPS_NR_INODES to 5 Date: Wed, 8 Mar 2023 15:37:28 -0700 Message-Id: <20230308223754.1455051-7-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230308223754.1455051-1-allison.henderson@oracle.com> References: <20230308223754.1455051-1-allison.henderson@oracle.com> X-ClientProxiedBy: BYAPR02CA0026.namprd02.prod.outlook.com (2603:10b6:a02:ee::39) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY5PR10MB4306:EE_|PH0PR10MB5708:EE_ X-MS-Office365-Filtering-Correlation-Id: fc6bfa87-c710-4029-4959-08db2025c9b9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: kTFiTvKvqTvjSVuQ2+o1xrqxf/OCFPSQKXQwo78d+LVYEWCxV9JlkwghJRIOO+cIpYulsJpvHucIRZ5CANME5I1I8CfQ0YCDedKYZxNzBqKIJ4z+HXOIg31rsoz1zArze236LLfiX9s0UXURDvN51bPm6Ju6FKuQgfmUYtzA66jgqgbcChKl0IiIYaeqm9iUvdN//dXfXzbsX1WzjClrVNNjznEDtEjnCiHUM4O4k/93C8b0k0ZNXTG78k13tQo8MAmE1uTfgvI5tKBAuJAk1P5uPPDvfzDlwCRT6BX79nYZ7IXrGaGU8r0+K46LwGezUE6H+z5w3nYyjTbOFNhbG44lpbINHXLYEUIXzM8ZGJsFQdz6hIPzu2uPMOb/WXQgSqshwWNNRklk3S1ae+vIjwZwoN/y5ACRD3IX46Kwphngu4sBdqDwgo43PVPn1mGZYXzJGhSHxfuQhatDXYiLjGeXCcVLWQsTwmuVWKZHBnf7ZSnNGz5ZtkNmAGIMZmGo/pHJ7s68xmGsISMs/efieMZgUNqrhXPOjee7lmUMjxpxhh4u7BfIiAxPp5zfgx/7osT9DWoi7eTXb4V9Edp/GOi4ZOok7u5LWjXfXiH3CBR3LgppDptUN6g4q+1iJC/v0HY/cWz8iDibOWXo1V3kJg== 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)(366004)(346002)(136003)(39860400002)(376002)(451199018)(36756003)(6666004)(478600001)(83380400001)(6486002)(6506007)(186003)(9686003)(1076003)(2616005)(6916009)(6512007)(8936002)(66476007)(66946007)(2906002)(66556008)(41300700001)(8676002)(86362001)(5660300002)(26005)(316002)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: DAkjJBqz85uXkoFzn+gYq8OzQv94WUFHOPDbiGXdGVpxrMpFWdDlU4S+wAQKWVB2BGnnYTshRMxQS4ejmIfI0Q5XLir3Qg1HI6CgsIMRRzTPkIczY0zIoZo0//q9rqK56QLUGnlvPEaq1CZQXZ986bytYp9cbB16RPgnx2ZfGO+lvuHXWpxZ/3qqqN3vml+OzVZIyGZbmWdfdYdXXRkl6n45HoF0gmqYSKykSmb40WEYYMtvyw4CedjITwWu6ZmfR/DHzTtrVRUuSGsxsSzrcx/mnWOSGfM03fKCg0ECJHhYw5MIa5nPIiUrNuraa8tQ6J/AnbipyoHx9eRzEpBITj0Ssz+2W+Y03ZJG9jyH6QNQUbuSwsdYZbPenWQ4Kc1YnLLIUJBVuox36fKmTy/3mO9ScNUjPU8Un1AhhXZUimR1gJicdivY1l+1sg1tdsyHEwSmZlRlmfo9AJ0zQzO4XeEvBAlrjcHaEaaciflwP1a4BkS42AEMIl1U4QYFcdEahKUMUIs6zRFuHpiIr8hSO/Q2i1FTZWHjFQtf/YuicbkvGkhuV8O4W5YSWIy3mxafOxAkjMkw0+b9SGj3K3DOkwuLoqK8BDnwscC+k6zsFUtU0z/dXc/DS64K3ZIbzSN22/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jGLuL9cMo37COv0eejg8UoORc2aYaOaTt8Od0rrBRCjACffIgu/St382ZLI6lD+EZQKGpPxDqCEkUGmTzRr1j+Od1diIj++CXguzVqYZ6NNWvckrbWC1k8ZqGTeeLFx+sf/p06/XRfprAe0y7jUV2e4o/Y1QN+U/CklDw7AJQrUGi9cx/ck+/F7hYM6rMAtDyOjev2dcdD4Ci44AGVrUtK7Sej2fXo5DvA162qIh5JHj00ClhZ0hUQv3oG54EvWlVKPKqrFzYT5B8Zt1gJRMo/X1mXnzVS7Bje9IIUSEBDzkSXyRFEwLJ7Co7V+QtYbPHOslSslJJVhc5dVMQ1KwMi1PMGSDKlBceEG5pcvbcnOBjFK2DImyRxy5krtzerMKCWx7pO4ZfAFXZERjIfrm9ucSutYKWdeV+C2sI7B3e9wTj9rH2KwSg9vIejM+tvVdfTPi7doXl+Uy3oj0GOSDy6p6MsTY6KxgulKxksk1Gh9JsCke3zBIsFs+b41pPGhp+CdCXoWJCLA3AR73R9fCmmanhvl7TVtn8wsnuHbqCfrG1OawfsN2cQPbqg8U0Uz/QfL/EFF/Agj4i0QWExqY2QoSkaslQsOy0xAQvXCIKpNi1UL/ur9qkpYmrbikUXxLW3sh03yi57PDQM3xJiCq8voYQh1agmE0mn3eLLhGEySjGnr8TSPbpnXbhNDdhlqcirDKPm6Xth3BeBL6oWGSNmmDNEHzuC9r54t6Sq15/pP49iyw2RWTrI6Uon63xVtrChWCKQkohXN2wQ== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: fc6bfa87-c710-4029-4959-08db2025c9b9 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Mar 2023 22:38:07.5017 (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: 3Uta8mY1W8qO5vCgEGM8zO96pwBKweBhJdD0eQ3ISDl1AqtUVlEOWOhKNRIMbROKnA6+jLvWBmI7BdJmELRVbcIshVDtsEDoVpSTeiWegUQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB5708 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-08_15,2023-03-08_03,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 spamscore=0 bulkscore=0 mlxlogscore=999 suspectscore=0 malwarescore=0 mlxscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2303080190 X-Proofpoint-ORIG-GUID: jpf00oR_Uu2FVXgzWzZ5uMEwSwWVLqSB X-Proofpoint-GUID: jpf00oR_Uu2FVXgzWzZ5uMEwSwWVLqSB 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 8aa8a8e17a5e..166ad86ac938 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 112fb5767233..ee09aefa6088 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 Wed Mar 8 22:37: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: 13166522 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 8B605C742A7 for ; Wed, 8 Mar 2023 22:38:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230241AbjCHWiX (ORCPT ); Wed, 8 Mar 2023 17:38:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34120 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229905AbjCHWiU (ORCPT ); Wed, 8 Mar 2023 17:38:20 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0D14E62856 for ; Wed, 8 Mar 2023 14:38:18 -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 328JwfA1021962 for ; Wed, 8 Mar 2023 22:38: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=RphG63hYNnC4bzASBxuytRlm0jX14DR9pFbHBErpnkM=; b=WBdu/E6mZ2E5IWC9+NrYHltWsiBfbZ2wv1d0cW0z0rpElfdl22Pt6otQOPjc9CpSSAuY fCrSnnv7aeSDvbUl9SMKuxOYAtq7W6myt9y/MiSTG8ralcQvhFITUQoW4FCBErn5bjhI Uj6/d+P+vJL2v4sJJ0mgHHDlq/u69rBNObR/J3v1Pt1CMlUSdxr1l+Czt6EcRaN7y4M7 0H6C8DxiZHt0O3Y18NyucEBtKE85OL7X6HPGjL0EsKW+WjaYwBLpHm7RiBeHXd4hRooK XmUn7E7AUgLDWyPiLAw4l0xZeTbooe2CS5cko9rxuTDYrGHamHnFcI8viu2sijk+h5LR 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 3p4168se04-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 08 Mar 2023 22:38:17 +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 328LVM0i015688 for ; Wed, 8 Mar 2023 22:38:16 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2172.outbound.protection.outlook.com [104.47.57.172]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3p6femx3av-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 08 Mar 2023 22:38:16 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=I4/1QCvm01fDYWjABklyiFSepvcoyioBbVODWx79qNHmuxVjy+tnA+WoBd7MkrK6KJV+bmNpCVyOW7GX5M0Y16bKCXv++jK8ZmHWJOOzTggQFieL0QR3bTe20I4ozlHj/v7GvOiv3JQ9FMNsdwuKdYfd3TQH/MkWt0vxwvEXorhvUzD+OxjRSum4SHFFu34PyfDfIZmbGFHxupgaNJt29iIHcitWpqnUcCV2B5xDNrnhOSYCv2Fq5QJM0WvOYdHJ1oTlo4gS9v9tCSj8p0zTrWBX7/SU8lfdKoY681FZuTnQH/r5+vPb948P+PyGVVykq/LFADiDbLImNp7JHxU0LA== 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=RphG63hYNnC4bzASBxuytRlm0jX14DR9pFbHBErpnkM=; b=dXZwI8lZc1kseZpRugfDn1/x73nL8ZQdJOdYo5orY0YvjM57nfhlTQ6Vcq1g1GdbCbohSpNh7iz80/TEPc8mxKIERiEJF/zqpisxK1D49h66FmDq+FHmqbyIzoDTTYXThCkLL/MnEbwByL1RBWlr7Hc2bCEIa/+gUlkqQQvV5a/ZpboJ3VqVo7pO8ocdZsWfF3wukyKxP38TtEUenta/xlJ7eEFwrhFmPUcmy7rCRi7hKegEQyE397NzSsomoC/7gbhvsPXFrP/RsI6arcmpftETpNtrOEBI1adSGjyESpsGw21IJWYxIF6ppkpAtwYXGAGOu4myt1zj4nogLc+CuA== 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=RphG63hYNnC4bzASBxuytRlm0jX14DR9pFbHBErpnkM=; b=O+7CcpVdhzNYAR+0dVXBC1TymBMvLLDlLskyPDFnOK6BhRZzVQLcaUik8WXGnzPuApEcE6VQYLwQhZ0gkweOPFewIfHT8ZqHsYp3NBg7RPRqKx6u4nehwNw0uVLaqyfTUQyFJu5xpuD1ySoVNU2XJDqmxgM4VQfPpLYZa6/TMD8= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by PH0PR10MB5708.namprd10.prod.outlook.com (2603:10b6:510:146::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.27; Wed, 8 Mar 2023 22:38:09 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::2a7c:497e:b785:dc06]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::2a7c:497e:b785:dc06%8]) with mapi id 15.20.6178.017; Wed, 8 Mar 2023 22:38:09 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v10 07/32] xfs: Increase XFS_QM_TRANS_MAXDQS to 5 Date: Wed, 8 Mar 2023 15:37:29 -0700 Message-Id: <20230308223754.1455051-8-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230308223754.1455051-1-allison.henderson@oracle.com> References: <20230308223754.1455051-1-allison.henderson@oracle.com> X-ClientProxiedBy: SJ0PR03CA0240.namprd03.prod.outlook.com (2603:10b6:a03:39f::35) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY5PR10MB4306:EE_|PH0PR10MB5708:EE_ X-MS-Office365-Filtering-Correlation-Id: e2c2a1bd-9c14-4728-c693-08db2025cab3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: WL8V35F+SL4OyMwYFg5G8EdiXPNwtcwXUHzSsTDVumw4l/NDbpELUij1gJPgMyMz5CoClD0E5eRdcFr9t6Z+HFZDrEn6mBn/RffnUpSZOHQFFmarx1odxwBFe47s5RYf6hb3fZJMUKOtfef6yX6K26PLlxPo3kFLgoKg22j/i6LTJZLNB4ThIEefEOd6GrIWSS+alg0FWP3Zj2XY3UQ/qtuqkYVd7mQxRAPxdAg5ftEHV/MLEyAYiHaag2dQJN26qtf7hpN9NHcJSQaRKZksI1QrXlQ5jTzBONMNMCdIo+MfPvu9umGsdeGcZ98LMH2rna9xn5Nx5OYXhdIz5ERtxgEjGOkYnnYClgOGRW3dH9OCc9+xGK69dln7s8S9Av4v+5lW/TP5JrCLms7LgMuHDvCIGP3yNNd7QzPaHgAydJanE4zaUqIJ4kpqm+WsYPXqNDYs1Y2GvmxuGDwaGwA71CjF4xlTROvHv64nqWRR5zxET7cZcQDnURDGB+qcwnMHXnlHypQz4oqlKSMIW7hh19NswSXNldctki6iXKONPMrbUM+i46d00nFSTgRd7GvzFbx4UqeHfxzNSKrvI1aA/VGAHjNGvmkvV3t3yBAR6o0ZlytfapDEBI3YmGv6iTxktoAakIw/QnwTHQexE1iT9A== 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)(366004)(346002)(136003)(39860400002)(376002)(451199018)(36756003)(6666004)(478600001)(83380400001)(6486002)(6506007)(186003)(9686003)(1076003)(2616005)(6916009)(6512007)(8936002)(66476007)(66946007)(2906002)(66556008)(41300700001)(8676002)(86362001)(5660300002)(26005)(316002)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 4A2Mr3djx7N51tYPkcjAsOEzftEYYGPCUi9xYde4VdhSEFZrApIw2OxkMZu+RVUX/luJcumAq/d79O1Hk+dbmK4EUEOWGYnXHTtHqV0m7FjSsaKiv3JGEyQELsBMjXWMQx8tbkJtNMbCSfTE0kC+Z1FDmaXX68A+TlU6If3Kms3t6D6LoaYnQaCMtPoDS6B0vdW2ooEAI13+m+VPOITSA979yScEzGpOPtkBHD1uW5gZEgkNBOvUs2r7D4CWNavKg5OOS/h19R38ilxjzWpbNgzFXQyNSydgO/GxzCqo4UybJrHIH+0PdDT3LZEYGg6jtsBiJTgXZavvia8/cHKL6/kus3NSYygg8ccPONYMZz1CxXYlHnj8eFVi5Djya2Uhl1CoDmBuuLbKI2/JCOrDca/BFfB6iwYzsFxiEr8KwZyAY2cm8MRd95t3EpHc5T9hQdz6e71o0lCFTeqduKNs/FuyCp3cCCprX2vHafTANTfbG7smp6xPRz/TpADaAWFjdUoEf0FG7eyxJydA/8fEJJdTYhAh750yuKgWGXc0yb2IgysmjyDoxbFFw058iZHAn8Xvpz/ea/04o4Vgtb21OMPW4MHQT66jo/ag0RuD4VHK5AuJtULrdpvY3FY3CH8p19r5Vh4SKxz2FRV+AqY0fuAp7VC2hDl7JfKEPx2JqgxZ1tVPuwh83p3+dhcrIyu7V4HUKmEF9KaFC3rUuWCfBbkumBHtPeeD0IdbB+fqcsmsyRpGW9nRIBqq9XIb8IluR0DJ/sW6jWBYXqtXpk/HH/rrFi6RXb78Gos+e7FjLulpyx6VFLGey2YmuY+cm2KVH8dXmT++2qxdIK6YRmNn6C5kLqEh76UoN716fjaBgRw6NZCMFkwYoTEOWc3HCymHm6/Lg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IF6QkB6tScu1vxgk2zCMS6nGEOwa3psqmP/QKKqcEZljhQGr8n5lgLsYk+1gXzZZ4quUzAkYBcsk9MbFJiDFHtaw8T3GGbqYADtoG+9tjdvC1JbAEB989a330wI56cta9fyzd2QkfbUe+tR0807h369C2iffaLQZT6n3MJwPrrn3J0zpEDB2Iy5WR6E3OzeM6zNaEkSmSTVTQNDN2HusJtSu50+K/jPkU/ArphhJOE2p+Gck7Wq9MSzwXTTJ3zk6YWbnMntqnbYoVG4FZkV0ZcMECyMmg+Oe4Ne2Ks4lmGVurN/05BENcosOfSHvqJ9hAT9C5R10xiruG7lRRCZEiewg6zvmd3h9BEgQ5V2JPJonx0CXVEpKhVMG/JCIeT5PrO8HTOmZ9/lj2/AQKpXZ3/P4b505KzRydo1kA1FoHDq1mQztSajLGvYUzS2c8hzuYhSp2+87T0aVdOmhttzUihgS7bI7D+O6+jtEbUBmTZXmmoNykV+DjSVQ== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: e2c2a1bd-9c14-4728-c693-08db2025cab3 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Mar 2023 22:38:09.1121 (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: DRaHQfZI51FnkgcIkFcPDpWpGrOAcyuPZQMddqyVwi8+pnrVQiA/DKtotbGU0Z05x4sMi4VhxxkpX/t1BezhmwmLPEOlPju7Z8Qv0uT1duk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB5708 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-08_15,2023-03-08_03,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 spamscore=0 bulkscore=0 mlxlogscore=999 suspectscore=0 malwarescore=0 mlxscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2303080190 X-Proofpoint-GUID: b90vVSNLOT4Zlji-OthrSD0MDnzAESQk X-Proofpoint-ORIG-GUID: b90vVSNLOT4Zlji-OthrSD0MDnzAESQk 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 Reviewed-by: Darrick J. Wong --- 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 Wed Mar 8 22:37: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: 13166523 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 29003C678D5 for ; Wed, 8 Mar 2023 22:38:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229905AbjCHWiY (ORCPT ); Wed, 8 Mar 2023 17:38:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34138 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230164AbjCHWiV (ORCPT ); Wed, 8 Mar 2023 17:38:21 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 923E262867 for ; Wed, 8 Mar 2023 14:38:19 -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 328Jwg2C021992 for ; Wed, 8 Mar 2023 22:38: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=NV1OPxdYF4wW+3kB/mlg51uZWPML14DAQgv/jsV3WQA=; b=pQ9GZ4aze+JeqALfskLu25H2Wf15nwkSoPYvzhIh78VkQlkBHJIsTB/DRsiYPDzhcwiF tbVXIHp/xeQFVyyw0WGfgc24NAd0QHc/byQ5Vs/bNH8KjpgRNXfuv2RigcfLL4+EwCs4 k5Yvs1HAuEFhnynSaFt147/7Fz9/UtKo5XoqxipWovCS6qeCjb00whZlWtqiu7LD0Kbh D3GEh9NxE+8xXSKvtZ7RusZ+JAMZb/iyS7zVcebLiSzuK6Tmi/7TXSJcNxyKR1Uzctdk t3lGCorrgi7fudyRf3UXveOw6igaC+MuCFRX353UU5GnhJGW9MVZaWZBaS2r/ZhFb3PL Sw== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3p4168se05-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 08 Mar 2023 22:38:18 +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 328LVM0l015688 for ; Wed, 8 Mar 2023 22:38:17 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2172.outbound.protection.outlook.com [104.47.57.172]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3p6femx3av-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 08 Mar 2023 22:38:17 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=h5qkCwdhjgAAxnmb7tGJ68S7tTI/oZyPfyUPMUYJr7tws/ytQFwK2IJNYc0AqBc3ISvQt51dBjqeraZ4NbWon/CLfeToEAe4HbwByVeZXf9Y/oVcJs7c5PBPXuBDAAIJQzb4oalWS0wrO0G5AMOCh656WzxmbfD+7yiasY/BcjX1guKras0tC6uX5D15RAhDc0xhxm4bbD9l5vPR9hMP0PHVWQzrsTpwa0Qaxy8yVS7y91nA7sVk63YiQzctwiFKAC+Bu385T5j5oQubS4zJ4TWogVt7IOkXZ1/gwEToUR+8+OS+LQ73J5lLD9rOrhXwWn+vasjdnOphVVuKd0n9tg== 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=NV1OPxdYF4wW+3kB/mlg51uZWPML14DAQgv/jsV3WQA=; b=PXiJHmyS0kXD4gPsEovu1V9H9kT2tnozaG3TLc4p+ZoEUJa1Iu/jIRiyGfK+jS1ZHHLniL+UoOiJpsRRb6WIoXAFggwEhAQt9MwIf3jetqTAnA70GHj1TZIquzmXc/WnReqCfFRUs0yEGstCssSrcppfFUl5X8NdsBq+oTnV40hf/A/rzsMqTgc44B5xYN6uSPG5PTk/rBMlxUzBL2Pa/TXWAXjUmA7yYXKR12vuKo3VZrRYOisZEFsgHp9W1BKxveUbdJ81jZwDxzRBjtJQL4oovCnv9qNLUI6Kuw1SS52q5S33I4a6v8iXkBLvfOGVzVNDSTIRJWToyZM+NCRSUw== 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=NV1OPxdYF4wW+3kB/mlg51uZWPML14DAQgv/jsV3WQA=; b=TTfxwE1rG0DVpwL0E5LV1zS+yL/qmuSGPDwhyAyQzxL041+/sz080Oa3BVJ+4w1b8bcubuGv3VnktUwtkOaQn4/U87jI9FpoTL9d0W1mJzZ4BIm2sw7Z6xWLQN9t9dxjzExoZ8nU7uU1tSGuCGrkulJlHcKVksFnp+4YBd9gPOg= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by PH0PR10MB5708.namprd10.prod.outlook.com (2603:10b6:510:146::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.27; Wed, 8 Mar 2023 22:38:11 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::2a7c:497e:b785:dc06]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::2a7c:497e:b785:dc06%8]) with mapi id 15.20.6178.017; Wed, 8 Mar 2023 22:38:11 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v10 08/32] xfs: get directory offset when adding directory name Date: Wed, 8 Mar 2023 15:37:30 -0700 Message-Id: <20230308223754.1455051-9-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230308223754.1455051-1-allison.henderson@oracle.com> References: <20230308223754.1455051-1-allison.henderson@oracle.com> X-ClientProxiedBy: BYAPR04CA0010.namprd04.prod.outlook.com (2603:10b6:a03:40::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_|PH0PR10MB5708:EE_ X-MS-Office365-Filtering-Correlation-Id: 35e32524-b5cc-461e-2e04-08db2025cbec X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: NYFCMdKIkf8hDavl/rHEJWId+IE8ZjypfnU2cMSiul8vNMWl/j+1aVK9MWDBlqpzhOVGYD8tTsZRw4P486M3ySKsibVaWX+39E6xZ8h9J3L7tbKbnFNAvPg/10XqBTz+Vr+DWs1VeulSv13FzzIcb8VQpl5gMuZqx4Tm4LPavKXI9NBgODDFZ8foIlBJhppzPCdPkTrF5hwFbftK5Qz52svilM++whdtz0u6s2w34TKahylHN8b7j5gkEN7PtnPs5WtrUUXXH4M8xy9rcszYdGckzPsPbKLexqVaMYUecgoJUAxtykZ30g5mug3bwYOxCARYIfclrN8QhExXHWeAvRdhp+zeQXlV/bVwK3fItcSFzbkOfrSodTxSDlm3iJLW9RXzfu1zWg1R4glRrHEKfxeJBavlqz0Ss628UanjG60DPRYt/bSPEGJbDFpyx63vsJogIlIFcwWXcFvH4dRyrT+/fndGMQOgDCE22IssKw/57mfcfNsuHIRLafRoQObwukQn90n+pXEj6J6R/wPcqmeuWqP8gbwj8gWsIWlZWrCYqeGlOoN79mf78ACmfofFDJ2t8xB6lqoDcdnJbWQLq4CWWqY8Vv/g64AyujIcLRBCJCCbJCKjBZ9EBSPmU5k8nUk3O2T22tjiuKv4a+4hQg== 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)(366004)(346002)(136003)(39860400002)(376002)(451199018)(36756003)(6666004)(478600001)(83380400001)(6486002)(6506007)(186003)(9686003)(1076003)(2616005)(6916009)(6512007)(8936002)(66476007)(66946007)(2906002)(66556008)(41300700001)(8676002)(86362001)(5660300002)(26005)(316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c7O08lINCD77Lo+tNT17qqGIKfYPcliUAtBt+N4r98TCoU7e9gToCsNDolph9wXqxXrJciz8bicd8KztjOus3fb11jNO9wa1i3Cn11M/oIVabR3QnlxbNklolxMsrJz6OFj2PsFMgLxQAq+QSbZ5JVG2EUTXN2qMh5EJ4vA5qJMGP82W0gMp3pIlnq2ziuw4a4VGJUZT8re1uyOMpPk8yJuKUDP8cBbmO01zaOL6XKOnpS8tGnEzlk2uLiCAnNDVRK1lYsjsv9P9lYltsF7pGFd/6A80fU7hJXLHCIKQRLn7mtMAvkCUyyFbcpYPqVuWKI3M4rnjjOl26paz1TpUexPPSO3tPWkFNDt423p1b+cr78fWbzbvx5j17E3y+/hwvq4W9fQiXpWj9JoXcjW4tAlgOZ6w== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 35e32524-b5cc-461e-2e04-08db2025cbec X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Mar 2023 22:38:11.2376 (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: L2QRMNss/K6zQ6QPX5AZcM1hJ5g8R1xas5V6BTbRXq9Ym/64CfL9v5cnKmywmtZSBswV1xY4QbWUCqMDG0gvBWSE/64IfaG8aFycR9tiueI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB5708 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-08_15,2023-03-08_03,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 spamscore=0 bulkscore=0 mlxlogscore=999 suspectscore=0 malwarescore=0 mlxscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2303080190 X-Proofpoint-GUID: 5sXMTqYveWhomoIwqdGrXOV_hPMeLBtG X-Proofpoint-ORIG-GUID: 5sXMTqYveWhomoIwqdGrXOV_hPMeLBtG 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 166ad86ac938..f76e73db62da 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 b96d493b5903..4d5f38936a20 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 Wed Mar 8 22:37: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: 13166526 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 47732C742A7 for ; Wed, 8 Mar 2023 22:38:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229850AbjCHWi1 (ORCPT ); Wed, 8 Mar 2023 17:38:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34260 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230185AbjCHWiW (ORCPT ); Wed, 8 Mar 2023 17:38:22 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9C67D62FC7 for ; Wed, 8 Mar 2023 14:38:20 -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 328Jxtd9028463 for ; Wed, 8 Mar 2023 22:38:20 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2022-7-12; bh=GM5EA2IEsly3XIAzp+xeaVY/Stv47UmPKKPymqi60/0=; b=eeAKaDD5Qt8QjLKAAbMZwiFLQu+kIc0m0LRPWuNeibDuHtaBIgfkZ5eoo15S16YSKHIP 1Blnmi9dVsTmlFI6N1P+95cu41oFrGVCa7RwM87uWCKQwmj425mQJ9m+n2f9FTq+1U1F 9cez9yp9GYwQFllRomuA3rOUYXfLoNV/WVTO3XhZbrt7BB4g+/bpGsxIf777Y3u0WXBP VRYV+mAg4XGzLhRmAYUVSRRZxNn/D+Gow/BjTu5k4wo38aYcZh2C83N0IY5cMBZfVlh2 xcAfE8yRObvlXrb+neaAZfqAnkZeYfsipcyLtw5riRjOxPGUKjTQZFdrJr4heQBdwrmj pw== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3p418y1ef6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 08 Mar 2023 22:38:20 +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 328LM2BM021689 for ; Wed, 8 Mar 2023 22:38:18 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2172.outbound.protection.outlook.com [104.47.57.172]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3p6fr9dws9-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 08 Mar 2023 22:38:18 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RlAF12jl831pWbwjXb2hwmqmSg7bjTxjXgZFBuwP3psJnVPzX5sA/VNdEsjVga09mukZyJUe9QZ3wqRyF692wFutgUetD85b7ywXbGhhm89eL6fvLdLEO0tZpXaT9GNbrEGbolMaFCr5d1CiF8k4CEkrXcJUcB3jBlqCUUPM+UllWhtrW6mvLmlysn+ar91y9VvnNVbanQdOpf++9k/LPIB8pa5+nEUkUT76X1yzfMMYxX9NRtMoyGBdFZnUmpWQOj8YndAmUtcqeiMIWBvfeX1xwUm4zVV/xTV1jREd0WKwUUhxHN/HkPPGrGThIaYJXHBLtqiz9DzaNgGR5ae4xg== 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=GM5EA2IEsly3XIAzp+xeaVY/Stv47UmPKKPymqi60/0=; b=aw16LfEqpEY71JWKykfBlIzpZoR/hOVr9tk8bXwVdIcxBhocTyVqHRKcvkUckD3mXWqqg2rAcC3IWpqzbAkQizkuitevgx+e9uY+ycJP0ld2iNzg7h8uRQ9RaU5axUxh2oE1RVgWGTF2VpMAlOtRp5cFDyKl+USZL1NciHVX1Dwev0pkDJ/MctDTnisgohhv0wPNOvROExDUFTNC87NBl3qylAfqo+eFIALGzkwuapEjGybg/nCKmwj/Y3mVYZBIIe1G9GLokxmre8uph4DBn8qST6F9J/oe74FIz6ODWsDS9Z5FOe7o533nAX/cOlU4RBOiUrAy9UcsKkTMIkJiMA== 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=GM5EA2IEsly3XIAzp+xeaVY/Stv47UmPKKPymqi60/0=; b=plDHr8uR+lNfZYqkGxwlxW2C09FxlCLOtXJN94B1sFICRBUI7cGP9neXlo8BGWVUO0KgpWxPzYBdByjGHJXAFAkOfX8K6zku2v4dcRD7JWR08TZBo3F0Vz4mst/HEDD21FB/k5+C89x1oFE7jA6SmeB9xqVtBG/V5sP69O9j6jU= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by PH0PR10MB5708.namprd10.prod.outlook.com (2603:10b6:510:146::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.27; Wed, 8 Mar 2023 22:38:13 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::2a7c:497e:b785:dc06]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::2a7c:497e:b785:dc06%8]) with mapi id 15.20.6178.017; Wed, 8 Mar 2023 22:38:13 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v10 09/32] xfs: get directory offset when removing directory name Date: Wed, 8 Mar 2023 15:37:31 -0700 Message-Id: <20230308223754.1455051-10-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230308223754.1455051-1-allison.henderson@oracle.com> References: <20230308223754.1455051-1-allison.henderson@oracle.com> X-ClientProxiedBy: BYAPR04CA0013.namprd04.prod.outlook.com (2603:10b6:a03:40::26) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY5PR10MB4306:EE_|PH0PR10MB5708:EE_ X-MS-Office365-Filtering-Correlation-Id: 8e154043-c18d-4f40-56be-08db2025cd35 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: fh1BtLxjDea6s/Ev9Y+kgwQ29Lq17NqQ45wW4ff9dNW9/sFogfvK2f+epFrvPgmgDZI3HkMs+q0DWBOOUcErnlHTccOUtUI7BMeqFNcDtCdUtMOz1FSVsDPeX1zRpVXs5qDbIpG60DMVcD0Jc1T+qBLBe2t2bGOk8f8vi+/Sl5iRGGRZSZ7WURh8GWmhNNJh/uTkSwRSB23XvkemI3dS7p29jiPvVfvZoaeq4kgjKKdaL9HGb/3zrbK3s+f6TBoQxHowy1VslEe+MxeNebBC0sWTc6dgVbkccdXWKIXNqJwjhpsV/ZExf98Bm8cwxKh0+9hmCeGzXA5ZrnUXVz3yVjeU4Q9Pt+IIW7++QVgeQoOeW/tseHWo2KmX6zxO2iM4vyUHUgjZUV+mnvTNSyXkbbq1Idukur5B6Dh/Irg0dnenQ2GZ0eS2ZqZQThgV0Pi8+QN6tW7O+V0+EWB9xwEcMxHUW5vkRXVLqqBLjczt+REoqywQxYJ0Q3fnL6pXU3zYFKvyVbfu9FzABEtDnhCRFPiVDcaECiPDbz6k8JAP5C2GVPdygjs/20DEZCMizQDdi0cUev4N8rkUBbVG/2pVZqs0jAAzjpxa35qWD6MVlR5vth1wtTpxceM3Ji2BrlatObZvRNkv8JjXnx7MwQ+CGw== 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)(366004)(346002)(136003)(39860400002)(376002)(451199018)(36756003)(6666004)(478600001)(83380400001)(6486002)(6506007)(186003)(9686003)(1076003)(2616005)(6916009)(6512007)(8936002)(66476007)(66946007)(2906002)(66556008)(41300700001)(8676002)(86362001)(5660300002)(26005)(316002)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: udy2ZDbTa820kwt8gf3lsMXfqY5oxc9uQd8tQPUW0JG+yZQbBsfTZJCuF4WDX6qSuQB/eaw4ZDN9G5c5n/qvieVHjQz1Z5/u0e4piss9HQVolwq+mgQl0MJvkNMUTFV6EInIR/TKiDGQeDFLH6HAhGVjgSZ058s4Ce11vs9KvL9e/jNtqnvJn8G3vosDsWpxqwIHbpazIwVyp8L182d1jvHDl91HloZLk8C3laC6QEzeWrTs6oMbkOteanOtoSeH+AXxeZAIhbcUvng5ErFwEC0DKr0JtJ2QKp8dVqagXCUM5tp7EEtCBb/UJeRIFI9geD479dK2TA0/5YDgbLwjbODafHn3MTMolCp4R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le.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8e154043-c18d-4f40-56be-08db2025cd35 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Mar 2023 22:38:13.3323 (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: q2fw8dx94rIn5RIj6iO7lq1MFuycsPMc3Sr4vg+3iD7NU1LWDvtfHHgUO4kiKABY0q8Po58Jb6ayrc8j949NsxJB21Nn/g8H22+05SLTe7w= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB5708 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-08_15,2023-03-08_03,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 adultscore=0 bulkscore=0 suspectscore=0 mlxlogscore=999 phishscore=0 spamscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2303080190 X-Proofpoint-GUID: f8tCCzaiKu-ljXLqfnuLQLsth7uH5Spu X-Proofpoint-ORIG-GUID: f8tCCzaiKu-ljXLqfnuLQLsth7uH5Spu 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 f76e73db62da..ec5ebbc4d52f 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 Wed Mar 8 22:37: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: 13166524 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 D926BC6FD19 for ; Wed, 8 Mar 2023 22:38:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230110AbjCHWi0 (ORCPT ); Wed, 8 Mar 2023 17:38:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34140 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229525AbjCHWiV (ORCPT ); Wed, 8 Mar 2023 17:38:21 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4995960423 for ; Wed, 8 Mar 2023 14:38:20 -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 328JxfQA001632 for ; Wed, 8 Mar 2023 22:38:20 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2022-7-12; bh=cWzKpC4JeeUtDEmxa4jbTgEim+CrQ7MaR2cG7+iHYHM=; b=UszGo1FI9S71s9XkuoK3TKU9BuW2qZhdvp7+YVY1jAjuBibU9P4ExdBrOpSFpaUaul2a MZENPo+1Go4cyBQ8un0oyKXb1VZ1jZY8dASfKklMduCqsn7n+Z4cLFZ75XSD9Fg0EewC puoUI3iDnF4mImeQhMOuvpRcOKXsIOgV083IithQ6TO5mBxEfnanlaSF7GuolN+HwpkN cTqpzgLvmxEJcgQG7iT33WId3OGquao65MomaytFM3P9/GwftSvuFgBUg7UlSRS5mOMx pCi3EMJSbixfxFTL7rGQQPNTHLCu5EhNwSIkzyVGXDvYIUMNlTzOZeWV9Yr//rDbOJER 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 3p416wsd29-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 08 Mar 2023 22:38:19 +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 328LM2BL021689 for ; Wed, 8 Mar 2023 22:38:18 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2172.outbound.protection.outlook.com [104.47.57.172]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3p6fr9dws9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 08 Mar 2023 22:38:18 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZyIhzDPjlv4rDHS+9MjniqWZKOU1mA6MPmz3k6RjQ3S7XxEwuUpiJ6/CrRI8ADKtZiVedRfrCTpxJObpC3C7nTPX81gNebuRuGrXO0/uXN6kt5mWqIwEWmX4yMOs395jcoCUp7zx8FE3CQ3xbmhxkVLqieOMTzG9VOt9pXaFAH+i2nHGtLp1h/+vMnNPboJbtYeBkqcPB2d3CTA8mn7wZ8CfKd+zqE8XDrjrJzJnGqd4t2zS2CwhEeN2aPzF7P5UBfwevTxGkvnWQSTIrOubi38XnRBT7mpYRfrZmDaizltrTvtqjtE0JekYSxHS8aygqeHWrfhnuTtA4h9dGt081w== 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=cWzKpC4JeeUtDEmxa4jbTgEim+CrQ7MaR2cG7+iHYHM=; b=B/Q+ehES8K77w+vskXNUdHf6+OdogH/F4OAaG37OexYyfjIgKRGxZ9m6+1K1usCvCn4kIflPLsKISjtT6Y4xNW1xCeEtWZ0PclhVC/jGPDyKOh0nrb99hJ9f4wa0rJqJHhOQs7aWiM4ZQoIk5CCod/MV4CzWWaxy4fw8VRY1YY1rVqo69iJPHp5zyiJuq4BMtsT2S7qOi8n6gyyHCl6GX05qlUaBJHSveAU5/F5/f3ashxzl2TuONGErFZBP0heHrg2yymsed+XDNTVetgJgoKEJGJsj0gMtJmI5eh1UmUsL0CsqtWxsJ2EUruZU1TOe4bHIREWnIHcMhaOMl60vog== 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=cWzKpC4JeeUtDEmxa4jbTgEim+CrQ7MaR2cG7+iHYHM=; b=f1bDPNZR2/iP5JZDvi4bn3ByZo/9o1WcVH0WBIyQzoZaQmmOQN6zxzYAKCOkqVxBlDZld6TIAupq9KrsFf3h9s80NhhYgdOcIB9OylT5tawC5RR9gTCynGHO5P6p9QeMFVzzvOBEvzsRLQC1Adcl1a+jmf0tW9v+jRz63cQjFDo= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by PH0PR10MB5708.namprd10.prod.outlook.com (2603:10b6:510:146::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.27; Wed, 8 Mar 2023 22:38:15 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::2a7c:497e:b785:dc06]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::2a7c:497e:b785:dc06%8]) with mapi id 15.20.6178.017; Wed, 8 Mar 2023 22:38:15 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v10 10/32] xfs: get directory offset when replacing a directory name Date: Wed, 8 Mar 2023 15:37:32 -0700 Message-Id: <20230308223754.1455051-11-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230308223754.1455051-1-allison.henderson@oracle.com> References: <20230308223754.1455051-1-allison.henderson@oracle.com> X-ClientProxiedBy: SJ0PR03CA0234.namprd03.prod.outlook.com (2603:10b6:a03:39f::29) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY5PR10MB4306:EE_|PH0PR10MB5708:EE_ X-MS-Office365-Filtering-Correlation-Id: 6f775693-ec24-4069-47fd-08db2025ce4c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: uPNCFiYFKR+Ri5/tcN2hZ0gFebEGDovJBsT9s//MC1aLqSuVFAuinUGWIaPRIq2QEvtjdfakGOUsJVCiHln+j25v7Eu1qDle9B/8gBEd2Qvqneqy1enOAoq+Rhy04WqbzKNPfFeUOeZUBcnDKOiCFF/t8nbrZnzRmftbxMvJ/cw6w3/7Q6NrZpSp+UOQ/FHECCTSZpmxysh/x1cfu1RgKzSQYcRbmxZYXtUNusH7NGG9Ym9hrtlVKBn9O2Bemr/CjpEIuJliImbdv7P66tVZIGzUOThcClVoWsSEy3OEqKiwKtD8Kh+Li80Wl8JR9a/0xq2qo1a8ReOD9lC4DvlKmAlZI7pIoOYOnUVldB1g6S04e0OPECmOizXzzGgZ+ptRKRlB8WqevBkLLN9LJGdtHciZYSo0A2fRxThilbb3a6cBDYzus/lV56P79MwkE9+UFxGbi7/YYNMisDEod3MQbp6I5BC/Kvpml873Ls4DiCFn9auXLz1/4IB+L7uytw9kVjEVitTFaqGRwJNbtFt+Wb+p5G0fvhlzFn24AgaaT6TQGXQdqTXeyRBwMhyMMJDII4XvtrdRC8jbkwLqs8Pcu67gleLSTODVIIExAzEWj+HKrowtVXX7b9Nf3djiSD5Jnyxhi4Yb22E4HPBtY7n5ag== 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)(366004)(346002)(136003)(39860400002)(376002)(451199018)(36756003)(6666004)(478600001)(83380400001)(6486002)(6506007)(186003)(9686003)(1076003)(2616005)(6916009)(6512007)(8936002)(66476007)(66946007)(2906002)(66556008)(41300700001)(8676002)(86362001)(5660300002)(26005)(316002)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: NWJ5atVW0JXeIU3EQTkkYdsBJokuQzUdsSQpKbRZ5+sLhk3KSoNCYQecDUB6i8ziXd8HWQ19zMtH5pNIQcC9IFhrXxpsn0r9iW5U2C/GCsrE9F158/TVcAAA3qXB+VmAgvhIV8NPQsmRecokTGdBhbBAxng9GiB6ddKtFEo0+tmMgWTatJJ6kRHuvmwC/Mp++hceuS7sgfWHjBT61bOFDXJZ1GXh1ncp40Kfhekqho7RHxlzBzSJTSS57VmAUEto0mNCnzj26cQ/EtUsGauDrZ4LDHLrS+Bhn1+Ec9rRfbQGY3LD4uSL+Tylv7Ir3D+ea8EqvI1oT5xB8NVvCHaWc4syv1tYuM9mGPRFT/B2b04kn6ODhLWFTOHP8l31zBNp8Avo5tAI3IvlHiEeK1jG+MW2ak4WP1kGpATD5N5lSvNqh50bBCfJb1eeg3tlSFjZhQu3A8dxE0NS3QOdQhsjFgeNVbVu3E7X4HaJ7TDwgjNTG7f0jORoG9Jn+aESOX314eZ2lpCesMgXREHIqFYloDKzpkB/Pi03h8cEEI1Rx7uhpHhLXBmULz4vmtcWmybsYweyar277a7XHQU5rKl0eQN8Ha0G90Szn73EmgYerI9E0K3zZ277MBAHl7SQbr4k8b9n8BKEo81VRGxxep/AGyBkuIzVMb8hNHX2+Ucu3adrNhldl7YGO1Ev7S+sWnEaqkcZDFu/2zY2MEgTjf9eKdzwGF9pEOcYE2hpqAyiVR8S+d9qpNztSVGXWU3dT1MB/P9LgcGTNOrcY5dvw0ykfLUxW4I6DJrzIHapJTPQ8DmEbp9hvTI6+oF2YLXlB7uqoISH8Af0oMC7Exw/s5UmSTWqQBO6WA1aNn4GvfcGggV/SAM5HKkzDI7T/80EN36qJLaYqmBIcpUNKmFQfCDAUrYcMtQ5TBwa6JaHhHB1w5AO7bjZtM1HWEmrpOvOf5yLpQR31xWsucgAtBi3O26S64awydSM4Kh0g7e+7erIN2RqDoZwb6vM038U511YxcpDoD0CNtkgldwD18eHakzekZB7Vz7/N22JWOCTEeZrPmJs/Rimh88jgdds11z36ggJXZMSJhluqYQITm2PcLYiKAyBudTB89babbYa8RLoX7SMxY6Pc9BL/mx5gH1c+fieW+a+SrM4NQD8Cop5UN3/o1Wm+o7wSpnQLGvdjXc3+AqkEF9QO7CgxAhlmyG5imTEwxruarsczjdoShTo1S8tE2vvenjDVL/yfUnygbDj0MfZ5LtLqEdaXT4s/SQ4YshAE2NI3twfatLoyVlAHGSSjFyc2p1x7LVsjBmSWCwbEXJe4LFQ+cuRRmgcHJrPO2S1C0qxClwNgab7sy3yPhjD9uk8VQSftVvbpcq0eMePGyqhaHPijuxPIun44XClynqG8mPc0zJBoapiEQz4iRJAgBKctcfLZXlInDvldIOCdKuwG8E2pUmIrD9jXJY9e0DkKMSNd1n8Tw6LjSyYCgblYpV7lQj1nVG6cCBWfav5l2e3qVDJ8JU/0jBXppAaiqev7fTvPB2t0e02AjvP9wIkVr3vOSnCD/SIszv4HHdWPu7E9gB3dbrJJO4W2iV9GHCHlojMpKKJScLkLfzh8dyy6Q== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: laWWZF3IdOQ0wztLwDBQyhAb4vHcT6T97kT95/K9cfIvn75HVUmuBrUztn9sgRuPlvT0ZZT0VE2JA+iMem0UC7vd0ZiOR785utdpHV44C9aoI8qFv8V3XaCVYUtRtUgPtusd2F+01kL5SW1uhuwCmN6fH0Bxs534wwnJqeRoP5Qz/dDvWQ+cDWQiFokZfOxZnStMrzBU9c5ypmafdP1SRgUia2RhS2deVFoMDDnCnAvZ7VZ7UkzVvuH4ssb0eaqY4Sd0lQ9+Z1KfXaAn+PKLNhmPkXnO/NM1X8MqG9Fe5qGkAcoa7XIdTNEVlICEh+1/I/MqXFO+lMsthrwclhjCw1d5Q0FC7CNkXDmL6HjtWcj7SVWh/Igchvwty4UdRp3+HUCxkNjOLAQwEmDdaDAACZhM3Dgs7adhLVgTlRCDIZb2D4Kr9o2kLG+3PMcUlSsSNmIFuqvA8x0mvDXgCcvZQ+2hWGBVKV+l4xcsd26Aix/96+NYWTVXiTrqJ1i+VrFWlXw5G1zutM0hU4yfFHEnplrRXO9H+7e7Ygy5J100Il96VEBsSt7ksu1NkE6O+1vKbLf2ECmu+sIXxqE71zMed+fUWnJSwW0crGgEOghQy8n7gVSw75e2mctt/1XPnRH6XIEFaouBARgj5QkuF1YtZo6oKLRKiBmd45NUWIdcFzbarKZAHQ/5X6FvrgsKOaspStbBGlwcYhNWa9eRQhpgtUKKt37vvmNGjvon4Fq59fPkg3zIW2zgJAvfOKurJxu7kyQGlAGvfuekm7ZooImlSQ== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6f775693-ec24-4069-47fd-08db2025ce4c X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Mar 2023 22:38:15.2541 (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: /asttIBacM0IbghXH2r/8LCcZU4wGIVHnzxFVe4dD2tOoaQQhrhKL/5MqGG9Q9zNvUP+jRi1oZic9iFFzYkqPXghUckbf3uXLR9wwDbGxJ4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB5708 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-08_15,2023-03-08_03,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 adultscore=0 bulkscore=0 suspectscore=0 mlxlogscore=927 phishscore=0 spamscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2303080190 X-Proofpoint-GUID: dOomlXCjnMfzj9lzhFNB39OY0ApoqWTe X-Proofpoint-ORIG-GUID: dOomlXCjnMfzj9lzhFNB39OY0ApoqWTe 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 ec5ebbc4d52f..62c9fb2cb96e 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 Wed Mar 8 22:37: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: 13166527 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 AAF16C678D5 for ; Wed, 8 Mar 2023 22:38:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229801AbjCHWi2 (ORCPT ); Wed, 8 Mar 2023 17:38:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34258 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230135AbjCHWiW (ORCPT ); Wed, 8 Mar 2023 17:38:22 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9C7E562FCA for ; Wed, 8 Mar 2023 14:38:20 -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 328JwkmN018336 for ; Wed, 8 Mar 2023 22:38: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=hVjRnCfspL4P7YZo4v7somjYUjK7m/v7/aZdoU4F3ps=; b=sil5hmlriTuO/5LEWcHrjxfMeNhW54fZBHtGUizezRto3kmctw90FWeKIboTb26Ts/8X ry0mYzxC8IBykhVv0xlE0eM7q5ySRnRcv3TpJzmbV2btoOLZxSSL8m/9EZUqmC9pDcfe xBpmcFVuLCp9tdb9Z6X32CmfhkKwthUGDzWFSJCRls6AFQSKW8uG/Ao9KAPvqEG49mCa VwKPITwE09JQHowbnjQToeT8ffc2CsVydWqyxi+DHbzaJg4XOetIZZll/tldtxhNyPB8 e3unn2+iNiye6a8wj5lKWK913BkdEcl2jeS2n4og0pFPgT3WPs1Xft17I6tnn0TC3B1f PQ== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3p417chcxe-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 08 Mar 2023 22:38:19 +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 328LM2BN021689 for ; Wed, 8 Mar 2023 22:38:19 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2172.outbound.protection.outlook.com [104.47.57.172]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3p6fr9dws9-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 08 Mar 2023 22:38:19 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=We+K41sO2Bk7N9XGkbmuSTdMzjU5trC1IILy+A/54Tzn9JEo5evZHBaFoSLBj/NL8bi3j6DAahL7u0K8bRGKwhKO4HWPwrpsjEKI5gwjcpRguqZVTu4bGWvtTdPLVF+qrUbWZiRsZhHtQKz9jgN3bLYNM3RdeBYhmcDY5sEHQpdZKKENNX1eANKFb9tdybKcixnvh0w98LdoJoDce1z9h2SnSrn7dixNpACFIxiSUL+RYGjKa4cD21yLoBLYriGrr36ma0Pe0xBok0xGCjwYoZ9CqjserGMRjcSqwZUMqPagzA6xE3n5ojFv3km7BruR7D358Nyq1CQiK1qTU98JPA== 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=D7/bADVpgJe2CeZ5MBsMyVefhjaY7ioUlgp1NR27Ur1UOvQHZDMeekrsZ5YmYWBxU0fEei5Zh6h2Zli2Myh23nimp7+6rwXPSSurFTbd6RvzFejjVFcoAyJ3k6U9zxDNdD/g4u29q38bDvbZeEa86civaemmfPc1nCL/wEtI3qJ2/uV4SUjIxPYj1UOUtrIKEL9d9rAXTyam/VtEnvXEAlJTwcIwsnSBmqitbrDceszePLVXbWrH9BoHqM5eWPU97zy5MISbuy9omK4u5m3zbPMWC4rIC3TcQpx/DyJVBwYqh0ozxda9A7BRyIfApxRTlun5IGt5c9avxHVnAY6A1g== 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=S5Y6+J2zEMEQtYVh0blc7gxSen6H8Dweci1xpr7AaY08QG5tdfr+Ovuov/Bi91YNIpPPs0og7iy5a4oK2KchTXaJLHl/J3MxZHEGxYaUM7svXoEJ0gOWGw7EL7cdrL4Ylw/uTKCdI6xJryuwYa7K6ylk3LLTtHzJxQYMRCvj9pA= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by PH0PR10MB5708.namprd10.prod.outlook.com (2603:10b6:510:146::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.27; Wed, 8 Mar 2023 22:38:17 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::2a7c:497e:b785:dc06]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::2a7c:497e:b785:dc06%8]) with mapi id 15.20.6178.017; Wed, 8 Mar 2023 22:38:17 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v10 11/32] xfs: add parent pointer support to attribute code Date: Wed, 8 Mar 2023 15:37:33 -0700 Message-Id: <20230308223754.1455051-12-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230308223754.1455051-1-allison.henderson@oracle.com> References: <20230308223754.1455051-1-allison.henderson@oracle.com> X-ClientProxiedBy: BYAPR11CA0037.namprd11.prod.outlook.com (2603:10b6:a03:80::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_|PH0PR10MB5708:EE_ X-MS-Office365-Filtering-Correlation-Id: 9c929e72-229a-44ab-c38f-08db2025cf65 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +J/A9fj7xONcTQoXr7B6vOKRJYWg+69X6YVuWrRfMOGF1P0Q9ifowZnlMSwrDSt1N8NHvNgOnHkmneeZv/XY0DSuBUelXGVPCEUJtep0LUefsPn8wLXaKKBmbeFn1FKuIubCV6uxWC5VcCo69QONy9Drt/uR5NB7VgBxcMDcxmqyYlCrXJsIQhN1GFajyKJIq+G+/JXqt2bUrx0MVFmMBtYYs5iIUWoJzzQ7G2pXdG2k7LV6Op//3ldC8t242c0sJhhcSt55ySG14YvOemoXCx6/t5u/THEmeO4VFyR3kO035sCntCYRJC7md4CxCAGL2LKl2zYvE7osDeKFPFlxwhXKzrPV1hX1jkpKNZ860nzFx6NxXJODWE1wY1CRA+OfyZNAFO6FuUK+FXkWOTT0E4P/74jOA8Ylr/Piy/Nc1Wt2AymKAkTfUxrlu6cuxWLftdPkWJYnnp5NAEH9PWO+y7d0fS2jY6W02CgT5MxxWyoK2uQs8HdGzhtcKJcTafhuijImzu/YQY1YkGO1K2fmZK6ouvqKEx96YouDwz9ToFfEMo9aoy/WEsUa77wrjyCcpeDKodVa/zadaWI8TUbNiF5BeL24KZ07l2FNYy0LWkDeiVbAhr0eqXNr/WSRa0h7dr3ZZU+OaXnZi9+uQKeBag== 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)(366004)(346002)(136003)(39860400002)(376002)(451199018)(36756003)(6666004)(478600001)(83380400001)(6486002)(6506007)(186003)(9686003)(1076003)(2616005)(6916009)(6512007)(8936002)(66476007)(66946007)(2906002)(66556008)(41300700001)(8676002)(86362001)(5660300002)(26005)(316002)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: X5uWLjrCKZe6diXSGJNk3mi6WBJ1wsNFVSdlWY2BNruWp1pV5y0M5OuzzlfCwfwum0F1SOChwFu6aWsI0TtYgh+J3yTyaiy7+/eSwTBsacwGnxcY0rYOEbUZ9keWdwd4qU1lBfWDNdIMJjDEl/sw+29fWQ8WceJyKDIYU/GFGZwz7cSN3chmB7J2QAwApmfTzl9pZqiLfdFOpc7Oo+Cveprju1lTc36cni2tv4n7BXpe/uHXiNadhz8Td+UagKAVFx8neA5pE0bFDJy2BlVjoNbc9Hd+QPu8V+Bb9oTf9Wza611iCtli14OChouNs5Ct8FUCeWRMuGDOWg1OjXGfEoRiCq6gD3hHol9USFNKk/O8Of5LX94JoIQpr8NGleWDdSmraZoj8ceT06auPpyJ+UwGoVoYbQEc7rQ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1RDAkCAKDlQvo635noWmLd1WFjdWLfuGdBnznvYIkEI9UlFse9EgsDHV1nWgMfFfvJTFt+LTQ3q86sLl21HevWzq6rnV90AIGIvsxlzNCsZVTg== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 4wxd9mA6tl1+9I0UkTKHS9w/tz1WnzSB3/NgyJ81fogDCwKksF5hxKEW5Tlwqszaaj6obuYHTu6ttuqrSOdv+vTmKVlMq2lESDgNBZTUsdWHRZnA3zHVddhfoNAeHmdYnNHC4OSKxLi5TxikR4sB/az8QUGuBoOLNvaytZvibTSzTRLkoOhpDYiOgLWznr6K3IaSDGPxvrFPEEpat+Ig4tbHim1eKK1jcqqTEfAjIp7xEk2phPo9IatoCg7t5HOXjk86uNickuu2tB4NMi8gj1LuvSrLuS8xO5VtEfPbo2B1VU+SaA254EoFOvoM4cGj9tbwu+2wThtSiPA9FDwN5YKgyELyy3IaI/fUFL0DkddyVnVnKv22PX5cY2u9jc0ZnZVhrfD94DxTzYk2mxo8jmltjhGR32IuH09h3685Xu8S2EJKGyax2bO1tPffhLI2Dw66lBUGVviZISzxE7UCftnRF2Aqub0KH+Y8Djiqtra3x5bs3sonW5XRE/k2YDhpQG6wANMfsAOpbKvHcX+y9crfn7Rs3BqoK/l8EV7XfpRROXRUyhi1536kmIMoKNLltztiklPCa9Gn9iLWHSLm3CgtdnOiZHf7LKIXUu9peaYTvBIz3KnLM/rYfbFEBPiUvHIZMR+Uolf99hogjr312zR7s4Iuum8cEOyPuaDmKjDW+xCJqnRbS2vmorSaUkouKU5CeaENllDj/0M+aDIIn8xxMuwTRYLzP/rz7ed7cvI3iZtVg0y9YUSm1hClI2AtZ42fmLkyqUdG5kYs9ur5wA== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9c929e72-229a-44ab-c38f-08db2025cf65 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Mar 2023 22:38:17.1144 (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: J6yRbmxsX0QgVRGI9wyD3ByMPiMyfpqrXlZZafwKGAvyARNViGLjKZTRoIamcp5Bikw/iOy3SpCTLneCaSN1lgTj0iBayivCDYpd2UPrDJ0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB5708 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-08_15,2023-03-08_03,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 adultscore=0 bulkscore=0 suspectscore=0 mlxlogscore=999 phishscore=0 spamscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2303080190 X-Proofpoint-GUID: xzRmNkSIUmisIo3d0Y7eDZ9Q4ZdF-fvB X-Proofpoint-ORIG-GUID: xzRmNkSIUmisIo3d0Y7eDZ9Q4ZdF-fvB 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 Wed Mar 8 22:37: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: 13166528 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 DF7FBC74A44 for ; Wed, 8 Mar 2023 22:38:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230164AbjCHWi3 (ORCPT ); Wed, 8 Mar 2023 17:38:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34138 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230246AbjCHWiX (ORCPT ); Wed, 8 Mar 2023 17:38:23 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D9CC95ADC6 for ; Wed, 8 Mar 2023 14:38:21 -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 328JwkmO018336 for ; Wed, 8 Mar 2023 22:38:21 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2022-7-12; bh=u8ANFXJemEPEl5G2uQUXpknnREMAMf1WLaiUz9lWhI8=; b=GaN68NMPLElFudSZjq7UAfs2Ia4vy3aHMyb073gIaqpoJkyEbSkWpb6+pcLZeV+/cadv zQaeN5NygKI4I07NzJGkWVNUqIvkEmujKCH58+B74M2JP1HnYx/xu3X54duJjvtne0O3 YuNzUaNJlOKx1Yr3w/Y8BRafvImVPZ7WyTEwmQ0g4ipcE9XrcfMFrEm46NxOvH50Nr2F gZ58+DFXvpLGMVFkGFqbTx3zvR5kZuuEVWDtDvmreC/T6jCsrh9pbFas2gZMgFvkR4Tp BTpLWeaT892nVVbm472yN7cprU2McZ2KsAjVXZ8YDs9Y3OLbTufWya5iu8cU6UX+lwFB AQ== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3p417chcxf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 08 Mar 2023 22:38:20 +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 328LwZ8I007136 for ; Wed, 8 Mar 2023 22:38:20 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2173.outbound.protection.outlook.com [104.47.57.173]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3p6g4gd1m7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 08 Mar 2023 22:38:20 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dn8VwsptsyGdjslkdEquIGzQP5UtqnzyNnNMkR2ll/F4m/j9EjbfKpOz+oZleJ+myYqq9YQalL68jVuiHpKQZb0hJmObom5Q/dxTuFoK4yWeMYDU61XtGhfJvmz28WJnyIZ4FwX2dtoFs1k8M3ybw4Qcdo5lTfEfuwZuZWkKnawAvuyvWiHUXa8A1Ddj1LbbteQVsndgaSsZ/mqf7NXuSsuMYQqst2rvn7Dnef5bD6gAG/xt8y5SPjisIrfOvSugBZMd0blUoMde6iGx8I6Ngi04r2kMpLFpmiamHQCpPZjpxxTYCet2cwJ5ynKcxRZOuWRvZv1NLTS/lccZhXD9vQ== 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=kVlj6POb//FlNZjPXRdSzuhNJpd8PbMM2IWr5gRtHzz5OZat/xnSJ6PQew2U8zThZoEegZTidASHou8wK4ZVmLMRGyWG10TDes9efOzHXMzQ4silaE9A2QyiE3bgQ9QRqYbMEe02+EvNCOu1TC/oxVcck7q6FpqynzOX6K4sz2gArasVLJrPylBLhSwr8XoPhkswK+TguIBbz7UZdroZznJo+bQQQq5Wv0ZeFlCrMgAzLGDtVvFRHVIYUfnKCBG1iRcLrxLjjHHZf0sYVTmH4BTpy8d/1kYzV5JYXXntuZYVvk0jptjxbz/jspiKWVyk/isD1nxD4B7cXnCKuFclaw== 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=DftVkn8UjgJ9+a+mTUyj6pzMs1+8YDkm6gSKezdihSRGPid1D7GgYlgzJs9zMxsQposv9dVIVfDkZ1gj5U1sBUEKKjGdA5xsJvGgEtNhiAn0q4fy83M077DAEEmasLMObhoAD4d0bt9o/FfGSkET2O57718RVn3dkM9kaPAEC7c= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by PH0PR10MB5708.namprd10.prod.outlook.com (2603:10b6:510:146::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.27; Wed, 8 Mar 2023 22:38:18 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::2a7c:497e:b785:dc06]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::2a7c:497e:b785:dc06%8]) with mapi id 15.20.6178.017; Wed, 8 Mar 2023 22:38:18 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v10 12/32] xfs: define parent pointer xattr format Date: Wed, 8 Mar 2023 15:37:34 -0700 Message-Id: <20230308223754.1455051-13-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230308223754.1455051-1-allison.henderson@oracle.com> References: <20230308223754.1455051-1-allison.henderson@oracle.com> X-ClientProxiedBy: BYAPR08CA0051.namprd08.prod.outlook.com (2603:10b6:a03:117::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_|PH0PR10MB5708:EE_ X-MS-Office365-Filtering-Correlation-Id: e8a346fd-a1d8-4eaa-a0c0-08db2025d062 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: lpiFawkHtbxHJUwmk86O11IJLjtUR8N0QrNPngQMz7T8VNpCM6CFT986lbEEdqhruBr+KULvICIMZd+t6DQmG1mHdFBqseo8WTPwZOceP5tTdcBT/sQAY0hm66DGdbU7PxnmCXTCCAP2b4o/rBqa2rRP5oBjz5SBqZ4YD+ilzdQak+/0H+8eohLOdij+uplj6SiQQVSvVluw8ttrhEm4P0uECBph3jIt6fWZcNRHSuZ649Vw8K+xEI0GPf5sU4xlVmo81jPgXFSI+q7cWBWdGBYMEHEobj+mN7bC+/4k8V/8ovr8nmqmG8M94zB4dgdgF8TDiA9xYxmZ5pJ28Se3Qkr59aalox1UvGB6v51sm8WyR2Toz83BcmxaeIQrMFF2Vctz/EZc3R5IDih74RDPBv3+rn/UHgzwNTDYYSZO/pMBf1C+70LC0dCkpVQ6QG/IzenMuKw88QJjTwF+meLT55pFURhw26ONDTA3MYMuk+RYhhdbieu2JIhHgj1Lj20k++a+3dYWAZ8IKwIfQt0xL0LPblDgDtrkGxM5ot0L4OTUvNTvNdy2TFm8ADAzCHf2Hsr7RWIiUJ9iDJHHYmWjPXRzNFYXWmPqm2qS7uMYI/SUm2GMysUNW1GxCRCLUkOjYnVUL+L4OQ+G9G2ZzbpALg== 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)(366004)(346002)(136003)(39860400002)(376002)(451199018)(36756003)(6666004)(478600001)(83380400001)(6486002)(6506007)(186003)(9686003)(1076003)(2616005)(6916009)(6512007)(8936002)(66476007)(66946007)(2906002)(66556008)(41300700001)(8676002)(86362001)(5660300002)(26005)(316002)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 5zXUtMtDQU8RC4ipEIhIZKSyVeD1Ap8vaNNhS/r1z31rOyNXjUX+WyzHBPmJczA3A7FDLwwuqpAE3C6EIWJK8TXZpT/pXmHisp36MCz53l9bfRc0O/7DORAJfi263Z8cfJflxrTqJwC9/jwChOgHsFdvzKL7OlW0+6eHwCKIRaeg2xR67nx+meuGShbR9AhcY2kWEKFSVW4C8HLAdSMaq6dDoQFaCvXC789viy8nH8cQE4JXad+HAlnbhTgnSuRR/hfib5OzWgXGjMm7y93NNjVATqvjFC9qY3smfJbrKhquTrSRZnoGof/1ODsZlJDWQAh8yAWfYgnUnnj87tsOWBjH40hUje6/IBnzcWx2+GxB9boEyYSrDnU6+w+oZhXP1UbJHJFVobSEztZjfh0roYdwEs8JFg8nOfRBKyZzAzYNzsliqXAkqTn3oJ8gwJMOcu5tiEXU4mUDqhegbl3pt+fshFb6KT4dtbMwJNTHBfDV/2w9EpUgFU1qdCi7HHi1iDLhMte3p8e2RQ+eM8AREuVjNYq3BC1hBMcShENakqBG1dp7EaPWkH5QEECkvtqw/B3fZmRdT1yhvoHBH7ihp/53eQUGuD9WrRd/nNWzcqZLBu9AgDmHOVgzQbdErF9vVAG1SHHDrNZBI0PwDzTmgH1EheFnEQKilrh9zHhVPGg0HeXOfKq1Sb7MD3zvS9KxHTrFwl7a2I1v8QhzdfSPFcEoiESq56p9PMvcBEIc75XtG+aBI4NZfj3HiYamJeSlgZYpnwfAjYHS176rr2V4DkAC5512wtw4mt4TY4AhdQnBYUeJx5EGcY9MHv57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mhQI93/6+GLK9HyZOk18XkDUA7VwQWgwqjL5wik+HBcw4xJTHwvxRZeKP9as+K//A9UOwaYx3Hd4gHQikUw7wQdnr97vmrC8383Od6CYPphZaAC5YltxYY2K7xNcVOlylXO5OxGMh/OCe5EjJBweHcFzJ3xj2Bok6IzZwcr2S844Oy37YGTgL3KmIOZjMgH9W/exJvAKbjXxhRohWe92IAazIRU6YZ6h09fQfclfrp19MlK5YCFPWQC5vJ64Qg4eRBKesXiRIqz0grGDQv8bs+dcu2sPbb4YDVvS4T4rmbz5c8IiZppIZtSyKuY783HES7hQqStzArVSWFZa/0aHGkuJzMZvzI4+N5t0V66txwvPc/NpZs+5yL38MDzUzGWgk9Xxye2y7b8emMLBlQ9+Jy1fa5vdftoJ3KbsOLQQxjhFWfXygBfKdoh56+3QRqdWwYjnUsPGPZTVmt3cww3JPkP7DA4tj8PfZ45NdHRJuyAwV/bgOfu7tohROfHC3J6yWb9AsjsLNoTCDfOw/WoEfRtQCNVO0Y4ltHBsSxrrXPK0uAYNuhdqwd35VEZIvyeIbhpO7n3+p1rkHg== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: e8a346fd-a1d8-4eaa-a0c0-08db2025d062 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Mar 2023 22:38:18.6935 (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: 1c6btuXn3jdEPdvuCj/nWiwK35XgwhRDDjS3/KK47OGcp158+XRydidpLee5096M7GMpfWBKYuO3zxGHW1sdxqCY5L780LC4jaY9W/j7Y9g= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB5708 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-08_15,2023-03-08_03,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 bulkscore=0 phishscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2303080190 X-Proofpoint-GUID: Y7jgHQ3exkjKyLHpTisw3nmYHbfExB4X X-Proofpoint-ORIG-GUID: Y7jgHQ3exkjKyLHpTisw3nmYHbfExB4X 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 Wed Mar 8 22:37: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: 13166529 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 D9FE1C6FD19 for ; Wed, 8 Mar 2023 22:38:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230037AbjCHWia (ORCPT ); Wed, 8 Mar 2023 17:38:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34258 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230076AbjCHWiZ (ORCPT ); Wed, 8 Mar 2023 17:38:25 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BCF1D61893 for ; Wed, 8 Mar 2023 14:38:24 -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 328JxugW026671 for ; Wed, 8 Mar 2023 22:38: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=6GP8mJBw+M/AN5gzsRzuXZkkeJob7qVdrYUi7TC2yiA=; b=k90hd/NtWcWB9nlDe8/hXPudKEDDpGY1RfovADfx6kZdVBetrowSwf0b502fNiIxgM82 GyhlsizfYBgFWvqUO3gJ461Z65XO5cf31pEIFSXVleKsvqhf12LaptpgD1fhj3WY8TWD eB5kSuXz+SvC56Um5Ku1YKwovoh7wOFDxxXBPCGQvKFddwrsgSPb5ZycMl0a/e4EEdTw aBC8fI7PNWukusPQnuTagiEuGvyUOOIO2S1m9Czb93lwXy9BAkV+zKvO7xvwJml1Auja 8ooskRhRGBHSoG1No77bHHGFG4SluBbpkH6l61E/Y2OejQQIRK4THeNffjHXMiT6GJnJ HQ== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3p5nn95qen-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 08 Mar 2023 22:38:23 +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 328LnwIR021718 for ; Wed, 8 Mar 2023 22:38:22 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2170.outbound.protection.outlook.com [104.47.57.170]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3p6fr9dwug-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 08 Mar 2023 22:38:22 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=b+cuI+zwY082daLhnYlNVEnEXJJHIO2HUphhXOiSxCCK1uCxzF0LvDfFIZgeH8YuuRzq2zvAszs+P+NZyRP+N6L+YZKHje60rZpQXXIi9vy1h+GHKtkBgbLugDO2D58vjtUW67mmZTNo5mAE9yKyUYh8mOLFzJoOH4s4vMxVB8Lgsyk3S/q0wmEBIK0RBuqrcdWZMzNHTkj1e3FV3OcMPExPZxEaoFwuc6b2U9XHAEUP91VwdMBDULxh2/dwr7wo3HYKYQ1gQLB7znwQ1jCk7KB1x8A6jlYzYe7FnFP+dRKA7m2W7kna0X6JjVJU2wZIJ5sr8wV2XFUuAuLFRwFQRw== 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=jdqDNhTrhCSEeB9TpeqwK3suA6LDOFgM/pVqs1NQsds0mUY//nALkU3LRQjv/JELqLrMzuwXYJiNzbzQ7lxmQVx7hih27nLVdmFCm95kD76L8cuYwmZutLFz0g3QQ31vhDI2kVPuqH0CRVwk7JuTGHncnPO5GAflmprkxbK7Ucgi62EHGqOr6bYNfrlrTsriOShvG2NcSpLoFAoZeEPZ2tCmIchDVMlMaBdEQ/uvP0qFvwM961tBSTrsTpOmicSnkejmnX94VLehTjNSoAbQRHqCUa7n3a5UmgNj0BJqpJirD6YscpG7AdZn5hrrOZX3Drd5tNqnu/mdrE+YZwQZhQ== 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=BtVZjXmSGCPNQ+VsgXhC5a1myJYyjUYOpMvvOgVmcA3O1CJl1gAemeAI4XtBidqblwPCPEr1wZBD3caMYxswbpaZbXUKF87GS0miNM3pGFZMEHgmPuH3MgF+XWoGa/eINptTkdnOFmO6J/odVNtP7rMPdnK4y/oOw/3nO6ijjNk= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by PH0PR10MB5708.namprd10.prod.outlook.com (2603:10b6:510:146::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.27; Wed, 8 Mar 2023 22:38:20 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::2a7c:497e:b785:dc06]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::2a7c:497e:b785:dc06%8]) with mapi id 15.20.6178.017; Wed, 8 Mar 2023 22:38:20 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v10 13/32] xfs: Add xfs_verify_pptr Date: Wed, 8 Mar 2023 15:37:35 -0700 Message-Id: <20230308223754.1455051-14-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230308223754.1455051-1-allison.henderson@oracle.com> References: <20230308223754.1455051-1-allison.henderson@oracle.com> X-ClientProxiedBy: SJ0PR13CA0006.namprd13.prod.outlook.com (2603:10b6:a03:2c0::11) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY5PR10MB4306:EE_|PH0PR10MB5708:EE_ X-MS-Office365-Filtering-Correlation-Id: 2c119925-fec1-4a69-5fc9-08db2025d198 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: X8QS0t8tP6318bSppMq1E13V9uDYhbBW5zFCRO8Mk+/2u6b7SgBaroCbvyw/NcyQPGV3rv0hgXE3iiDfRDcGx8nt07/8Lu4JOUo8RpAubGK1sR4UUfTI4aAINK5L5UiLZiSOfEbss/+MY9x3hP8LjXeEGcqwwXicxTC/vnKCIY0W0I+Xzaa5pSn+jfqCYoHVGCYd09xmPKECf1Quhh5GpCEGYc+l1I12SwR4NWkHp0t9vW0VSfl2mB8hL18X+Ci5x3nijVi3IfHKAOjMiMy/4uHcu4dHO3MDk4mcAXjA8D6EzkHMtRRA05gqISzvuSbAtWopgap6kPY/Y0Jds6f6RCvbGuLUUVOy8DYP75VyFkTVG9NyOBa+WTfohnkhPUAMkC73iDTWJPuaadnEeVvwtFIp4n2ogsCqoryEg1WNksvjYeU/JYjYDpbxQAnfVfi3EEm4uVhL6S+d5BFiwE9PLRrYjTM2QvoT9E13Ia4ucEaXAXhLgWpjmMKP5+nbcSLQAGQG13LsjKGxrL7e4AbUHanCNVHIsBrBH/NAmOiY4IdLzPVhF2fy0prNBBsxpR9fnQk131W9ZlU80y2g2W6yjhug/L3Wxk0E1xFCdbEIBOJwy8ubahsS36FGMp/Xxl3WPeGFrQVdQnFEAAGEfVEHug== 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)(366004)(346002)(136003)(39860400002)(376002)(451199018)(36756003)(6666004)(478600001)(83380400001)(6486002)(6506007)(186003)(9686003)(1076003)(2616005)(6916009)(6512007)(8936002)(66476007)(66946007)(2906002)(66556008)(41300700001)(8676002)(86362001)(5660300002)(26005)(316002)(38100700002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hrmtAV7NS0z7L9PbQZ8o7CHgII9P6+fty4q6R1fGj93GfP7CCoTg0HDDlPk2HgUhlBXw8u2kdW6iEiFPsMC+PFQDO9s5BqehuFYqfnxtxqprcZMUxXEmLlUI6BODZCB811fAGQeGJ5f919C96aA/WSWvMFGt3AHrm/B2xWQVWCfYzp+iQg0BGzolD0ITAUqFJl2jvHK1leS4hQU0U4JPM/g93B/sCB4eXtIgio2V3EzJkyPLflVlEFfA0Qw+8B3xB47nPjNYPKI7ChXy8zDQGtKqyLzOP1wQgHYCw0g/5Z4UwkK5e/y+XRd/razkOeXf+2j0D1cNdYxtJBumJ2ZP9VnK5sXUL+0llD4g3zUNSR6mrV1QBbBx+Pi+aUJxrQ== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2c119925-fec1-4a69-5fc9-08db2025d198 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Mar 2023 22:38:20.7403 (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: NeebfuGGpgOyg6IcjEju8Sjsx1ezY4/d50zpHzF4JHoZ77CWtCbNftoK8FQSAsXbqVeY5BiNOsQhL0m05BLKTjVTl9w/LAgQTFgMFY6qzb8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB5708 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-08_15,2023-03-08_03,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 adultscore=0 bulkscore=0 suspectscore=0 mlxlogscore=999 phishscore=0 spamscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2303080190 X-Proofpoint-GUID: D6rPPy1Bq0tPSJdBT8tom5Zov-DzBnYQ X-Proofpoint-ORIG-GUID: D6rPPy1Bq0tPSJdBT8tom5Zov-DzBnYQ 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 Wed Mar 8 22:37: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: 13166530 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 22F3AC64EC4 for ; Wed, 8 Mar 2023 22:38:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230143AbjCHWif (ORCPT ); Wed, 8 Mar 2023 17:38:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35266 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230206AbjCHWid (ORCPT ); Wed, 8 Mar 2023 17:38:33 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 22F383D902 for ; Wed, 8 Mar 2023 14:38:26 -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 328JxoWL009740 for ; Wed, 8 Mar 2023 22:38:26 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=DweW3I+mLWC8natrHHmVltb7/eFKj+e2/ysoXGJRm/0AyoqfP+QB/wr0yti30pIN7/sr cbtdVuTTJtzq4/eq2wqSz+JdPCZeC+mg7jEUXEbhzK/yXaxs+zs+Ci3w3AeVM3qcxTSA x/PCj3Ub5ju83NA8WBYv8SFf19ywFZNCNKdHFSHbCRavlB1EKY+qFYJOJHTmi8FMv6Iu ZtqnDYm/YChGSAomu8qo+Ra8i4lyjwWQezlUcjKozyjRuU2E9uD8SrPFRG97dwHseznj 6R//FPa20uctH0gE083kLUzqvITJOkOj1NH2PFbNdiTUftMvqOxjIui5nfN7/hM9CzS8 uA== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3p41621a52-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 08 Mar 2023 22:38:25 +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 328Lu5MF021598 for ; Wed, 8 Mar 2023 22:38:24 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2170.outbound.protection.outlook.com [104.47.57.170]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3p6fu8mxxp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 08 Mar 2023 22:38:24 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=itWz3bpbZbCgwqvEirLbFwB5ylZXRfgW2XVMZYSs7HG4AyHgjss5g2fy4e4124EFOR29C/Okh/a0Zm/iAi4kgBkgJ9ionL51me4CiHsYPXpyKzRZR/YT4CEplPvt9m3e5wK9yjnq7qvgGOwGwPfXnBDaxmVuGLMr/TbZzJQFwv7ITZFQPxM936LUipFS7tsJh9Xf1vJhw3u6JX4dIX6gzG+I1kRb1WVBBlUyxQbhg47yk5/KRcEHgzRpum1hGou8Fx6zYBuaKRXipA8knCls2qHJ/k0Ksej50xgBFpqCmeJzoYVXSJOM0bTyYNyrzB7g9xq+ivZIGJejWm4j9IZSww== 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=DA3YDJNeCqpfqYj33abSnEUw7SHb9aRQ+cH7X0Zvyq41d0ZEYWZro/MjbJzzvFCnEd177KWX0Ovac4ns8t9DFt89Kbyd20jMG7ST1ZAwJX4tN5ar4HRZUgKokIRvzuXUJkmpbxqL3ed0p97PA2/bFsKlE9GrbfN8NM6/sYpyqaEH+mCbjEL+GGWeR6H4vph8J6afKMe0EFkefZrk0z4+Uqm44hNFfkP0qljHoMg9kh5g0hHjIFOdyqSdNBLX8JANhCR0N63QNZwnKr9ixEolk8a11H366/YzSrZDA/tjjAdtXo80bOYsVJMQjpm3FrKT95WcBqfHp3/5QsyfKfKrRg== 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=v1EvqmwJXf4douTGyNikGWq32eU87oSJJeLyAWhd2oT1qHVDJivORlwCvO2ocxa5I8tD5KC9WcF3ifEPBMBvBPDZjIFuhW+friODFEjU+CZvV+ephgqUaGVTk3K1F0VdBAVZKESVKXZOvLO1jx05+z17MbUWyYm3cBFK3oNQTXE= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by PH0PR10MB5708.namprd10.prod.outlook.com (2603:10b6:510:146::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.27; Wed, 8 Mar 2023 22:38:22 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::2a7c:497e:b785:dc06]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::2a7c:497e:b785:dc06%8]) with mapi id 15.20.6178.017; Wed, 8 Mar 2023 22:38:22 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v10 14/32] xfs: extend transaction reservations for parent attributes Date: Wed, 8 Mar 2023 15:37:36 -0700 Message-Id: <20230308223754.1455051-15-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230308223754.1455051-1-allison.henderson@oracle.com> References: <20230308223754.1455051-1-allison.henderson@oracle.com> X-ClientProxiedBy: BYAPR11CA0047.namprd11.prod.outlook.com (2603:10b6:a03:80::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_|PH0PR10MB5708:EE_ X-MS-Office365-Filtering-Correlation-Id: 5f1157c2-24a6-4572-0825-08db2025d2b2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 7h79ENJ0ZxaP/qTFlC0YVGfMVhF/giuIy8Wil9aIPRVeVgEGeimn9F2Jx7CZX1H6V1b0tjDSkCE2p+uTeDKSOdjD4jobkwiUaB9fi/MbC6nKhgUWX7gYoQAIHeA/dE0IPGmWJnPV2MGhnFknDgHHBTUM9nMd6rv9gDxmm2m6qR5r0E84kpfktBDubPNO+Lyo2ot1EUAc8QVwbEugK61QGtHRPX6VU94/0Ct4g/406CX0GW0Pe3lOd3en2S3x5JS2Mqyyik29mSOL4QpWiaJoAo1a8ZSdp0uZng/ImpgFF9Pw7I1yUGHLAJXNEik/6JJBdNC/1RA3aze/e4blKuBz5RN1wSwMkpaU039Eial5bg40M643lJ1SSXoQfJ9DR4oWBRstyZXLncek3uyzkWkPFz90+uBgZIdk32hXEmyTfKE67uKIBYXe4mJoe18b2di16/sQyyzFqUj/oo1iGVIVRwai5unsAm4Qa9gMoEzaj5z/6J2wLadXZCwbclFsJi0CUS/RxqCZZfd0QMXCx+O953G/nvrLChnC3n9YWQwilqOEaTra2BtcmJbldkG5Zr+my7Vj3X4mXr1dn/HvLboe1vYK35WHwKWf4HeBdl6NfRrnm8SKILwaCUlTav1CrY3Zu+CSzZytThLcCMAQXcK+rQ== 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)(366004)(346002)(136003)(39860400002)(376002)(451199018)(36756003)(6666004)(478600001)(83380400001)(6486002)(6506007)(186003)(9686003)(1076003)(2616005)(6916009)(6512007)(8936002)(66476007)(66946007)(2906002)(66556008)(41300700001)(8676002)(30864003)(86362001)(5660300002)(26005)(316002)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 4t93aITeFkOFPupjAfn7vnt1Yq0ORDCrejFBWhMy+lq4J/fU0XfApuGiPoWmOOmXteoH+jTV2G1ckLX2Ct/wrcLaTxZop50jVx2dgcANzUao3i6CLVpHiPb/gUfnz3WAVmSfD364V5U9tkCtFtBuDh6DPyolUhJoFM55PDAO7plM5MpmgFfNkKNkDLWNRnFzG7+vuxW9P2Ack0wK8rWojwp2e6WNznN75JQn4M/5X/2ZXJq2WZJzyE354yoJ1YkJ/BnALcPf/QWdVXw3slMBT+55Nie0QkU2rtW/WZ2M7CMOFQockyCyf0Uq8S2/C28/q90Cnv05BcdpBtVsA5gqhaz5dF+TYjRQG3kGLC9pVGRfrZp1Ro1d2Zw1gmK/H9h0WMN4JypWrTRWPqMO6uAYG1OHLzd7H9lbv+U6Zjduxjse+UIQe5jNyHb7p6TzYvnZ8Bwd6mG9zvzI7BbN56dinl2jV450OS3MDPaTXYzLquy9ByvLKCGBhaOD01QSuR6P2izs9R5gWy7k1Yf8QalltwNukR2ExrkZQC6tQds0IaeA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Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: msEbG+/SmgDAQbJwjrdx3yeQh2cc5ZHR+4i2NopFVIS+rD5Ekz36BIwGRU5D3kdzX2IoVgU5VV9HdU3nV2ojWyd/8MZUhwAhk9HNhjdspf5rLhmDu5mW1QY3suzeVafIFEV8JC01E5WB5BlsjgZBEJ922vw+mKkpEZGJBbqzjVoRr1f2SHsuaPoTZftP0WBbJDWXWTWkoZHLWdgn/8F7+wFudFKCtuOaqxKhExmY5FEyFdzaLE9WwhIomQy/eluKtiOXYcTblMi99CUDZbpnYWibeNA/NamGR03b5JRpNVMRDnSCwYtHuQRMB1LfedVFwfjyeawRispVYmQsovvoX+qcINJRtMzajV1rQdlhzP246KhMGcKyQU+RtDbWOM2QV/C8FlDRyO/3uMhA1TfW0X1SZ4E7n+8FXJNGXA4OtkcFrcs0MU5+UZg1bvxVArAX2pTptY0tBRi+6ZSPBgq1XFhhMQdaNa4ISi+rOBkszkIZxuPG13lHX3F1JIO0lG9Q7iuajhxVCF7Ol9yZ/j0a8/Kfzs7B4kXNpLahseBGEMWY/lBFqLKDVNPju5HRnnxf9UG5/Zh3YAKZM+fRk/mDGIx84ZMn2UluwbBDctiecsYp+CWUquya3gkSgB/aO+yWC+8mMYXYGVRISAgW84bMInNUeXtEMV+SnKICNKx4LRkkELXoR97jdhIWbIAvRhqIERicDhTvpgr6XjH0lLoluI1Iris3S+6hepnD0xiwEw41sc8+S5M07lV10oqSkQl7wQolM9mD/TN17IM82HnOBg== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5f1157c2-24a6-4572-0825-08db2025d2b2 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Mar 2023 22:38:22.5537 (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: o9anxTnEl3312F83ZPcPK37EF7r3/MXaiInyThRCQNLilwjALug3QuSpcVVQj0shzqxKvsTFpnULxeuHiL5SwBWQXe9l8fuRWmX1RdZFiic= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB5708 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-08_15,2023-03-08_03,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 adultscore=0 phishscore=0 suspectscore=0 malwarescore=0 spamscore=0 bulkscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2303080190 X-Proofpoint-GUID: l7nGS9sCSRaSucb1DvBst5IvhXHbXl0t X-Proofpoint-ORIG-GUID: l7nGS9sCSRaSucb1DvBst5IvhXHbXl0t 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 Wed Mar 8 22:37: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: 13166532 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 DF22CC678D5 for ; Wed, 8 Mar 2023 22:38:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229732AbjCHWim (ORCPT ); Wed, 8 Mar 2023 17:38:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35374 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229544AbjCHWih (ORCPT ); Wed, 8 Mar 2023 17:38:37 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C46FA62FD9 for ; Wed, 8 Mar 2023 14:38:28 -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 328Jwg5o007250 for ; Wed, 8 Mar 2023 22:38:28 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=xijsW7B9KBer/+NXz4hfOr6cRZuKHo40ucfTqSVHY4Q=; b=ZYwi0daRuXayHEtJ1IeGxgUskqprqG3QpNYTMJ1oO6D9qRSsb0yZTt/cxMHhXmqGleOW fe8QPMFBuvA2u3LgNYT1/uQCRZiGFDg+FLlERdGfiYMw8oobK58u902krWUJezkPh0QT XFpc8Kdi6DQiE2GyAXGjVHONUNQM6NAd6Aw9rFh7b790/nCUY5+UImX05DooPXB4wnz4 AzZAwIGKefTkyy5QY4mA6VSe0clJThcffYC5bNSjhfe83VBlxGHzmSHQOWgfI0L9gWaQ xY4NW17QYGt/aCY/KyGfWB/d+MlYwFfoTzXi23gmQqn4zSM/iirO9a5tfLoD5uJL4zoN eQ== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3p415j1fba-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 08 Mar 2023 22:38:27 +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 328L4ZYl015690 for ; Wed, 8 Mar 2023 22:38:26 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2173.outbound.protection.outlook.com [104.47.57.173]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3p6femx3j9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 08 Mar 2023 22:38:26 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=L8GS5CMJnto5z446txTLV7Lw15Ga18kfDNlmDEjSRFmA++eD/U5WUUxcBfvExS2951BRWen7AyfuoJkefU4FhRvBc1LFhWmBvA/dXd8Ag+erX+HRs6K5uZBRJpCndR3tuep42wK00cKReDXxcJ4Xzwlg1V8JFN30LmWICPKm1bjhjb5oiMgqTiRrBwdpwwiFQkN2JbwtwLNZXnSVMnk4JrSZMR2F4rxdaPB6LSV7I3yc6HXqj72hgcq1tTIQDU7C8Rm7tpJ+SX0JMzCD4Tt1X1SpRsuyWM1POmyKm72BL1gjAXN2O/sKgKYFTSunULcsZ4FToFBdIV62MQOr5MtASw== 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=xijsW7B9KBer/+NXz4hfOr6cRZuKHo40ucfTqSVHY4Q=; b=SVyFzewVYNeeq2lBeONMxm+F6YOhljRlYQyRzDrjR6HZGnPnYUlUJ8z7tobppmW5fZtPPj5o9C+IwnSO3OitmynTR+og3nYY/fPZUH6Ps/aj0ZdD6lTTPaYc3mjVMXn3OTP3NRCABpa22uCYauqotY/NsT9aB7wQZRKgfXwWonN6juohBOUImr/ubcI2RjV0/9RW2LpJeuVW5Cmd4gXmNbHvVDa9+CHfE4ba7UBaHZTSqeEPDB9kUg7TTE/twePgwqmbCKIhoxxd5yA77IaHV1reckbFyL1If072ILNCkBHuuUf3PcL0wsYR3mNUO4rWHmHAz15pa2nbNL/LF1EkLA== 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=xijsW7B9KBer/+NXz4hfOr6cRZuKHo40ucfTqSVHY4Q=; b=KNeW7yzavklvMYUbQY+2JkjgeqHOo+lEpRCp6vKWEgNZ9ph7QdgdrtxKKSvKNlC15orL/0/yfdLONOsrVexz02+EOcmGoQ5inSJTUJc3wjhiA2Yk2GeYpod/6Txg8IQ0ivApbhl1fpX7MSVJ5a88dBJh+151vIaP2OMG6FnZ3ig= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by PH0PR10MB5708.namprd10.prod.outlook.com (2603:10b6:510:146::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.27; Wed, 8 Mar 2023 22:38:24 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::2a7c:497e:b785:dc06]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::2a7c:497e:b785:dc06%8]) with mapi id 15.20.6178.017; Wed, 8 Mar 2023 22:38:24 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v10 15/32] xfs: parent pointer attribute creation Date: Wed, 8 Mar 2023 15:37:37 -0700 Message-Id: <20230308223754.1455051-16-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230308223754.1455051-1-allison.henderson@oracle.com> References: <20230308223754.1455051-1-allison.henderson@oracle.com> X-ClientProxiedBy: SJ0PR13CA0148.namprd13.prod.outlook.com (2603:10b6:a03:2c6::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_|PH0PR10MB5708:EE_ X-MS-Office365-Filtering-Correlation-Id: 0b4f8948-e0c5-48d2-56d3-08db2025d38d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: OqLyBpnx9U8nnd9nZ/HVg2fQ7g2cwwpFsE4WQzwbnjgehSKtSZjDhTLnTZwpu4hS0Gp3FKNuGivID9XCKBnXWqMTrq5XELUbFyN7JUfsrCGEMV+phGzt0a1tYO470lDAmP1Tf6IOqeqqymwDPh5sRWjXYB3WberiqnfoBWQdFqa562nAdqBjuTgIIZFuiySQx4rZ01CW1grNin5nec8Ih3Vl0RVjARI/Co1Rc4Xci1qtFsuie77TnnkxhVxmL5aJlc0pV80x3hNfb6qm8ysLM6Yy0Y0jfsqbBO4ty+Q0YKDoVzliadPZ/wQ7Z3JUrkQ22Vw3Dgn2FZDtyFQfrEdIUWw0dyyeSD6/sVypMfp7REvw76tNC+uh4dpZimzug6CwBjdW/QBmAKNng6OwUrWz+sBWfEN9+bNtYFNNObMnf9jL0rZkXhZiHQfuPeZOL9F08kXS5ySIyeQUaTIKf7ROcj8q/xy0kdYNGfgJOCmtK2LfxySGrdHW7j1nD4mNHnSNr0mKHlQe+QOE7MCtbyB4EeAiaIF35HRWwMM9QKXNPlqBeSFsS7A+Ky5rY6LIrXdG2BE5J2nM+CQH/VryByt6i+TF7dU8zTrcRLUjKt4p7kfH5pWSE15kvfOIYCvvN/oP2D+ajI6RtoqvkZMgaMw3eg== 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)(366004)(346002)(136003)(39860400002)(376002)(451199018)(36756003)(6666004)(478600001)(83380400001)(6486002)(6506007)(186003)(9686003)(1076003)(2616005)(6916009)(6512007)(8936002)(66476007)(66946007)(2906002)(66556008)(41300700001)(8676002)(30864003)(86362001)(5660300002)(26005)(316002)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: aAHvaor0UsWhDrK11KZb+gxVcRZvLmORTaHctn2yLep3guzMY2Wk8THbyxg8kc8GXHZpKsr7fVQzHIuKIMIh3DBx5DlfrFJDms3EIvGyUdlDu/C1aSEqMqS7GaAzB7DVqhewAUeUCohbmZ5kiaT7sq7bMl+QKN4LZYWrxMnGNEiZfBCdZygg2gABtsBraMPoyXIQlqmgx2z+Sr08z0ce6hyYJAk/ZEca4Fm1EjS9w28C1XUgrY76PMVt4QDYEwP17dsG51N7iLIFHGJ/RHmQtX1x63UscLC1B9yeh0zfbFLCTaGohfLJMnUATrlvVan4k9CfCGCgvXMzDg2CBK7gHs/2fwfIYXcJs7qlWORpnsVpW/FVELqKvknhjyvkDgQMtOhCDfPX97/grIxDzlz0GKsSHQmxHlR3SiSuEPxQJVRi/fFbsSMGjBoxpxcdM3WMqIoXVzQqSgwTL7REvaHrpDmA6sBwO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Y/MK7DuPoZOZMETGGAF9kqk1JB5h9eGS+qc90IxACpjAKeCYJB1oue5lydgg== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 9in2i4D6aeM8kzAwEs2prBXCpYJ0WC9/Wr20uOeh6wVJEd3RURBc8QcF7k1DqbRUQ3VRwJ2UOUuAMmDhva3cUVUJ30eaCBNIyTOyIkVTRrPkJPMW15789+rt/iEeGdy49Tdl0A60kpAaKZJoOydWhp7TRkBYXcD+wNTg2eqSKRrmfTzhAqmhtKN0jhDMH+p4U4QP69XYF//abMT5MdRlhbWJiLbkV2ADpZKqXG/PK1CB46AD9B2pt4rxLLqFCAxk0WVa3FlWiKk6CBE0VIxMSIT1vePUdcjsPMPt/lC/YR787omcgEq9LoWD+YI6JRmjQydO1Wcb8YXje8Qc3VYPLFqUtCjuJG1MWa+k9U62a0URqx0JTI3PZjD3nR8/jwhTm5F7uEPQmxweEczoJ/IBlaqrXUcEGVfr7ie4w5Zni8f5vOly8kZgmUQw+d4BZ3lfHc0D/eD5xTGgfCsArOXUqEc3AHP7VPDddcSlo3dFioQUTo78paiiAizSpT1l/eWerX4koPIvN2w9GpQ1uSeCFXQwByduF0EY33wQdLUKbbH8c0AglM01sV2ix5x8Ccy9IaZmtyw9SykpykpPkOIju6FaWQDO6IaqeL2DnmoFvlBT/B/z58g2WowVPmNP1nLwBbTP4YlhPTZ1k9BGskYAUDxloatySUEXGRLBHbeGc3XVClVK7jUtCm6GIlQxotsY0Op/TapJUi3YfOF1PmTwa8bJ322OPn3kKx0f4l5Kw0BC9p1CnDVoxqeAbLcQl7zHg9iWtsm2JQ5FYaOfiFcZTQ== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0b4f8948-e0c5-48d2-56d3-08db2025d38d X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Mar 2023 22:38:23.9909 (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: ujj0lHhfHgyhSMGYYQlTtFERb70CfhWiS0a7fGaDP30ZftyTYs4f6afThlwE5HiDgOBYSbjfW98it0UroYAHkp20TRTQCL8L28tSNGzKCUQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB5708 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-08_15,2023-03-08_03,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 spamscore=0 bulkscore=0 mlxlogscore=999 suspectscore=0 malwarescore=0 mlxscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2303080190 X-Proofpoint-GUID: fxv-_yulforc7RaiqX-wsjOQQSxlvULe X-Proofpoint-ORIG-GUID: fxv-_yulforc7RaiqX-wsjOQQSxlvULe 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 62c9fb2cb96e..b63d42d2fb23 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 mnt_idmap *idmap, - 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(idmap, 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 2479b5cbd75e..69ba6569e830 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 @@ -2124,8 +2125,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: @@ -2180,6 +2189,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 7b9a0ed1b11f..8224aed5f938 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 Wed Mar 8 22:37: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: 13166531 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 8A43FC6FD19 for ; Wed, 8 Mar 2023 22:38:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230063AbjCHWin (ORCPT ); Wed, 8 Mar 2023 17:38:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35376 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229651AbjCHWih (ORCPT ); Wed, 8 Mar 2023 17:38:37 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2602C29429 for ; Wed, 8 Mar 2023 14:38:29 -0800 (PST) Received: from pps.filterd (m0333521.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 328JxuSh028471 for ; Wed, 8 Mar 2023 22:38:29 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2022-7-12; bh=l7DL2VDUVdmbsXooSJJPToMM44GocX1HAJKrS546fW8=; b=r3Z5HDvTwxHJ1Zhj+UdIgoWh+5hNI5rhT8EamNJ78GDFlHH1GD5W7c70H6ol+r5xKxwA k2ofmzyTJdOCFOPf9NWvUua6OK/bgjk6m8YQr5wxGdHZjzCgA8tTprVdl3fx0bK5kgOd STLHlEjpWYtUSSQtY0CSBhHpxEQia1+VWc861hZhjkBvS3DnJ/ipaoa70UuBaBHT0rUv SdsH5l8ER8/ni+Zx8kfD5li88lsCkqb2tvAF79JHpaHn9uxZZyqO2Mzw/+hAlohfu3Ti MTvg554V1zW/V5hZrc2jpPzl3HUDzcSpyJC7eX4LZx8a53qKUGUPFBBruMsTTNXDAJFG 8g== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3p418y1efa-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 08 Mar 2023 22:38:28 +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 328MQ9bQ036420 for ; Wed, 8 Mar 2023 22:38:27 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2102.outbound.protection.outlook.com [104.47.70.102]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3p6g464wd7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 08 Mar 2023 22:38:27 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=An5lKCe1ewWD24c2wQrABCRZkKAsoigAageBgg4hc/wIO+Ni8vtj5jLDSfhfCo78HwbScTPjn89JBdnb/jsNsm8vw9iq3bo6lEyYNXNtp9lmJTJcsQ7yG20XTVliJuslwfBSo1djVMPm0/FjtyHIIo9xsQ6vGW76XumxOmn3KWsFqTsj8P+bUv8wlqloUqkKQcr01yvoi5XSqbH8HreesxztRET7kPz+YMkUVx4rSJ9jpM1xwM+gawtkCr04PMy/XEGNwwE+j8ciBd7aHVzXTyh8m0IZAcJAViOz1pQ5EMztWEDq7aGnFy/Q/cdrSqzRGddE3IQTb/1nrjjojXaRxQ== 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=l7DL2VDUVdmbsXooSJJPToMM44GocX1HAJKrS546fW8=; b=TciXOh+MpULotYWwf9fruFlp4IXLtdiUZENRXJtg7rxyanHIutsxxx4c0Goi7bB8lSlPX/T0QzonFndTpl5+Mex+PeUkzxSs257xDdYyIapKmjEXxWus/ouV0WfAFbk4Qv9lTiUf4WzlwOXEgzhjjGEHxBIqAZAWeDwnAE4CTeCLfbQuRirSODPdMZmOBP8I8d4nZl3ow+JfCEyV3Y1wpxixA4gJ9q+nPPjU5jrbQXwZNEQT2m2gPT5qBhxtKvZhn/J8da1I/BoLcgPctAN0TovbnpTivP6WM/cmOXHVByxQWChzIkO6jdGLGfNzzJCvd3LjUAHYYiAf9CTNHDtQQg== 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=l7DL2VDUVdmbsXooSJJPToMM44GocX1HAJKrS546fW8=; b=f2TdN1Hwk7bgCSUN8ZFrpjitUcZvApNXgJzxF8BVtF9iUvQGqVTF9GM/3Citmp2QjoaHnyqYTVW1kDo4BEJ4rkOJ6dTB5tQg5aXSIxEf7i5umcp/fWzOWv0pKQWoMncKOsRsWIyJEztGNMn9rbTlTkv4S6SjwComecpjbzmf7B8= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by SN7PR10MB7102.namprd10.prod.outlook.com (2603:10b6:806:348::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.29; Wed, 8 Mar 2023 22:38:26 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::2a7c:497e:b785:dc06]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::2a7c:497e:b785:dc06%8]) with mapi id 15.20.6178.017; Wed, 8 Mar 2023 22:38:25 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v10 16/32] xfs: add parent attributes to link Date: Wed, 8 Mar 2023 15:37:38 -0700 Message-Id: <20230308223754.1455051-17-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230308223754.1455051-1-allison.henderson@oracle.com> References: <20230308223754.1455051-1-allison.henderson@oracle.com> X-ClientProxiedBy: SJ0PR13CA0136.namprd13.prod.outlook.com (2603:10b6:a03:2c6::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_|SN7PR10MB7102:EE_ X-MS-Office365-Filtering-Correlation-Id: cc94a595-6537-4b6a-cde5-08db2025d487 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: PEwRgJ+ZKxDVqwEuYW/QyV8am/VrWbzQJvYdfRjbkf30NBmWsGhYv4maWt8pnYnJ89JYcigE80za4k5eEvAJWd6wgVLHIideGZl7Bn5TmZwqCzRAZX+2IPYomcKxPaPK69999jnn4JxJUwPxk2galUGVBCSTjtp/dFH1j77hdKUCdov09P2aUIJFEJ5N66PVBEp+EO78LHhfwAVxIsbfBf9s54PMmep/PQYdIuaQdFcd+HDHy2n3k9rDY1ju3ZO0salMUSaFeTM9ZzTI6d784qDvUeEqDc7ShyPncGsn2Dp+hR7Suu0/5B4NUpAC9fFXhthytU8s+BzkD5+QpIkMkesI0DLH7qOxAeS3qnuSgQy556JqGeopCpKbJ2HlC+SP1sckksMvnNqTgGgjr77XVkHZONgg7lwb6DyBT49vlp7Zr0t19UfV9YlBdFSnDpz1OWAli6BG8zgbM4eAqzyaY4mtptQyoRwj+MhRcfPoicgjUqKLvYCEE5QEItR4np8/WQEQ3MpLPkG9J48KxRDNyuYXNH24YpN6vGQTJ7UkGgXBXkdbbN2Ah7qqDsgnowK1TFez9rXKp9kAwSlTauBFr6POURLgivPGJm06rLFgnVAqbXP6DTimS8GuWEKA91lwgdDoGNZ3pniVjMrWaCNfBQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(376002)(39860400002)(366004)(346002)(136003)(396003)(451199018)(36756003)(6666004)(8936002)(6916009)(41300700001)(8676002)(66476007)(66946007)(5660300002)(66556008)(6506007)(2906002)(38100700002)(86362001)(6486002)(1076003)(6512007)(316002)(478600001)(83380400001)(9686003)(186003)(26005)(2616005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: hEpbl1DoU8vc9M8dKI8FZM2+X/H0zQxLjPRwxmW/p/D+Ha1i8LGVuqftupcRlSgMV3nMZfC9OLNQXbuVeWdJJsbJl3/vVFRt2uvcwUZmoEqAFWFxtddGeGas78WHoefunZdH68XRBSi+QOEQZ3IbYgFfVuaMZSHE8kWUlhIX5gFbu5CIaIQDiwwGUTbfTPy07Wo1t89rVG1is8e/QDWZq5V1LkSwSHANmVEvxGQ3uSiaWnfIpoK8alWsT1kf+elI/fppi/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f3vyRiQT4wKQrhPAqN9cJ9uk5NI442JQf5lYsj5rDECBfdwhAi3NevpPDFw== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: cc94a595-6537-4b6a-cde5-08db2025d487 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Mar 2023 22:38:25.6011 (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: DVyfE8gN64VUjwtsnKuhimDUjwL5en23zQTshQWOwLdBNL4Q7DmnnTGYFk5aaGj0ZzdyJPm0NrrPlh6PLLglA2LshtL6MSX5cSKW5xq3NzA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR10MB7102 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-08_15,2023-03-08_03,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 malwarescore=0 mlxscore=0 mlxlogscore=999 adultscore=0 suspectscore=0 phishscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2303080190 X-Proofpoint-GUID: vO0rzVZ1FrzhNUc6tpWRebQbLm-YnNq9 X-Proofpoint-ORIG-GUID: vO0rzVZ1FrzhNUc6tpWRebQbLm-YnNq9 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 b63d42d2fb23..63d750e547c1 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 Wed Mar 8 22:37: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: 13166533 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 301CEC64EC4 for ; Wed, 8 Mar 2023 22:38:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229651AbjCHWio (ORCPT ); Wed, 8 Mar 2023 17:38:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35266 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229525AbjCHWik (ORCPT ); Wed, 8 Mar 2023 17:38:40 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7D5B46043D for ; Wed, 8 Mar 2023 14:38:31 -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 328Jxfij001678 for ; Wed, 8 Mar 2023 22:38:30 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=yx7qPqSV28+oFqwLmDnSGOa8X90dvbh8eKnTaMF1UxQ=; b=DavGHmQh2h34ZMSC/9tih2e0wuWzlT/dxDjb4A3mGPI5IsfmUjiTPC5WKu2xIvM0TRPC gUI3PKbTu+cuS7D+QgMAxksGYs9zwFzZDTaQRn9sZXFZHG1cMG9yIehM/FcLcRWiW4H0 KpiFRP97tBaJio5Pk4TKs0KAwtuHJ9RAJAziPM1H/6pWP2ebUnXqdu3e42PB9T54pDYW 5aGBqMPfLCCnBysWaBmXs7SyFGByBAVKjN6fCltk1SSSG7UbebwgHeneGrpUjYCbjTYi wMGHzti77cTVbk4c4CyOurqV5IhTVH0Z/esUwxNPpESNCXNGJG3fcFpiNupNYbeKCz6o WQ== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3p416wsd2f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 08 Mar 2023 22:38:30 +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 328LljWq022398 for ; Wed, 8 Mar 2023 22:38:28 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 3p6fr9dwxe-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 08 Mar 2023 22:38:28 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OFVDoO3O1ZeQ1tfqYy2yaMY6I4BcSZzsId0+zCO/aRxVHN4TeDRWwB/SkV85AhHsFLRGJpHvkmbB+Mxuc7BCG00nRLbXE8JB59N/iDT3dxeilc3uxvqP9BPCXg32VliI4Zw3sAupJSQ2s/ay3JBN6FLckavd61cTeOB51u+8b2rvKUhqKfNAX1GGjvC8W+Oxu9U+uJs+jDXe6wjU03YBMrNoeHcjEZx1mOncvaU9qN0px7Nd7KQXTxDVtPXozuCX7j73s/0TpAE1DxLwhsHq9gYmgUd5JxhnO6/U2vo3UiUkDmgGF6A5M5/ouMo0ISzLON6FBHGGdQmqA6JI+75nkg== 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=yx7qPqSV28+oFqwLmDnSGOa8X90dvbh8eKnTaMF1UxQ=; b=dwxIBbPnxTuLi8BmaUbmdR1O8pX6H1aWzQGdlzWOJVoy2ACNNPuM3Q/o+b7ISmKWMoROWJYW/O6lROq9XViFHNuLImRftxAHzuQHzTQHeMOKmY+X8wPailfD4sWc/C6OXPcsFhkJ+xl/kH/HwdSayhO/maTFSirPsCOfdTabobGbwl9yipm06z46O54kTyi2kC5iRXD1dPcdw1JxicNt9XEL+TBjHyLuC28dPNSXB4839jo2A4tbQFfnVpGZQjLDH7KIIXhrbScu8Rd2PcvEJ/2wQK2H+Wua11DFrGYqNA3Qfa2CK9NvaDTNpSORop6nDll6HgmFD7cLkrgWWmpmGw== 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=yx7qPqSV28+oFqwLmDnSGOa8X90dvbh8eKnTaMF1UxQ=; b=qUPuQKSM3YFakMjLR7ZDHFJGusRVa6vwaWu1PqOH89cAb6/oAzciHHYt16JloakRr1tHakMlPWinwUYkP2EFe67Uk4cRon6kZzKJflB5gq9pzVf9/3+ID2xrpHMLmFxa12XPlqZkJ1fBotEdX7CUMIywpDWNBDtJvtMN2HbmR5I= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by SN7PR10MB7102.namprd10.prod.outlook.com (2603:10b6:806:348::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.29; Wed, 8 Mar 2023 22:38:27 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::2a7c:497e:b785:dc06]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::2a7c:497e:b785:dc06%8]) with mapi id 15.20.6178.017; Wed, 8 Mar 2023 22:38:27 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v10 17/32] xfs: add parent attributes to symlink Date: Wed, 8 Mar 2023 15:37:39 -0700 Message-Id: <20230308223754.1455051-18-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230308223754.1455051-1-allison.henderson@oracle.com> References: <20230308223754.1455051-1-allison.henderson@oracle.com> X-ClientProxiedBy: SJ0PR05CA0084.namprd05.prod.outlook.com (2603:10b6:a03:332::29) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY5PR10MB4306:EE_|SN7PR10MB7102:EE_ X-MS-Office365-Filtering-Correlation-Id: ac35c147-afab-4d54-9d84-08db2025d571 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: V0345a78n/N/4cggKISjRD9sls5da7V3dFLzL4gfAFfbTYGXfZVVkoABhVXP3X26mudRcbhlgxlerwFevE08p74Padv7Na9red6lbrHKScZIly6VzljhxkVRaBtOqeAJwF6tU6J1aAhnkqCgHUiwJq5fbDaWBC39WdGct6RJsZ3kOAf94JevkZckRAxSJsiR9RQ5cg7qOubFWUrTQAhOE+puWXpYWbdruYrqNRPv6BfbwA4a0zXcFsjCohKyIU/i3SOb3ZnDRz0PvP+huLMhSOEI6mIExVQUilS1O4O8/PGR84H1EpvirJSn3djDm6bR9IgTg9AOoTRbd/3vQIlHocBdwLp/hVzMcCCsJAlQAXIXaaRHBAUUBX7HODBhu+AYJlp+AjRUKqKHQNiykgWVi3VGKBpuLf9T4Wc63hLJ5LMpkKgNT1Xn0L4L5+rUsJIcQZ44+NwZ7vqLqg2bdthazNOAFOeBnGcnC26FpMwQmPuU/9XrUf+XuweJ+KAUr5U5BNNYvVH8Us61+c7l3rliM+IRz5HvNhMRFZ/VSZHlKVZCZ5E4tG3EghM5Hm6UD6JdGg7rTnVGHIcU2vSDl58lqGddBlp62Skh2ZoQsxy+iRQVuCyimc4k2V4dxk3mQz7rqKY3sgyhqwBT1yYCZD1R2Q== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(376002)(39860400002)(366004)(346002)(136003)(396003)(451199018)(36756003)(6666004)(8936002)(6916009)(41300700001)(8676002)(66476007)(66946007)(5660300002)(66556008)(6506007)(2906002)(38100700002)(86362001)(6486002)(1076003)(6512007)(316002)(478600001)(83380400001)(9686003)(186003)(26005)(2616005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: T28hESq88cTUB4WwUehzdk5v7sM9vfZtsnudpvv0wN2pbtgwH9S6VXrvL16zYFP2rzX/+ZSa3EReYkCsCCdIv7jWaxuodF3m4ERBiOKhonDWz05ZwAHGLeai0z1jehxpIZl9ZBzZOia5bJ/2M3quOjEyPS4EyfQl5EE5PSw+BugqDL0HBHNeimeX/xuQI7CB1YqRHAicVE8/wiI6D7leWGJ8mNSquVLRC/5Q62A9isNjizRVJeRi1HEj/bJfRIFGi7UoRhTiFJriUBCNVZ+BHBSeSGVLDuEcyyN2HjM9hC9aJXCVa81My0QzOhGeV9DPyAXj9J+Av1zz1kI1VDPUkYltgdyEJ0TE3fJJQ8x90w1rHiVN4hpEVJool0OpTwy8schuGU+6/B8IKnZsyxzFRkVlDX3GjWhxqPeg58I8PvpmAefR2PY3O7+g9oZ6wAyFxuOwEYVouMVUJ8CB2/0y7DVmQWsZetkK9DzR7Q4a/RiP/DjW5ykSV15EcZzDk67PckLih8SuZKNFU4RxkuOKWupp5v4t2ebNM4dG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alHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: Z52j1/q04cOAXUBEIUf2ujpouqw55uB5Ry7SO1fz/ATQtHF0ibPDn1vCNCuBZB9NafY5eYbUA0JkUyIchJFGBCWS2tckIH3uhQEpW+BeSLjHEKHq1+HWGUCkmBd6aBK9KepVr/H8Gz41/n7KhnAX6aYt8G/KNws3z8HlP/IZBYRx/qTazoKyUxB05qlNMZq2VVc+KGqdT3jVfYF1+3uhaM5AhfhWsqzuZKV7B4CJ6KUi4TUM4tuLyzJxu5tGsmply4iYgpGceOyv3RyQm6LLiqKZFNU1fA+c9FfVS0KK2UBS1sZ+rk0fWNPhl8+jn/uoFKPN+CvTVdzpVIHJWM/Zz7zsiQnFNPCOgP6AeiBFl9vmC1Z9YKWfF6oVrJQqonOgMIXZwIiBLk/faKgO/adX78N1/WBIhd570fSnQel9s7C6X62wAFUhkfkQ2JZVMaCdb77fZtrXKOWGlR8wDdX3/KExDOanjTqswjLPfOlZmsdWCYdIGzClZdDhL+Ofk0CdgIxlKiQqZQcGyUJMsuAq2DNMxxzmw4xLAm7khjBUnTXfF1p7wicV2juIBvHKVx5xlO5oWWK/IKFimMec8P0RFB08VLy53BETALeuM0tmuNweOHSFVtDONsGCrdntFWKO3Xi8lAIYb3d/Lm4repdAIVbb/4H1pmbNBvQDJhBlMqWfhQGK8LO25qcdF3xKCzAH5PnM7ZtwfkbWT11kqM+AyzIhhHYDpHLwv+unlkwHPXI3PZkAqttFLqOV0MdfI2LcjXUb12gLNV0iUGYRjU+Yzw== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: ac35c147-afab-4d54-9d84-08db2025d571 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Mar 2023 22:38:27.1647 (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: INrTmlVvfyY+eV8JZ5TaJJNUzphw3xQqUR/dyqS8vZq4EktOAdlxTAWNiiTuLW4roE/B85Fkq8C9l7qLX0p1jkKCEKPP48YdlZeGeuaYH/k= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR10MB7102 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-08_15,2023-03-08_03,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 adultscore=0 bulkscore=0 suspectscore=0 mlxlogscore=999 phishscore=0 spamscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2303080190 X-Proofpoint-GUID: pKtdBXihQFI8WsLvRMzj3hvmFSRXxmG7 X-Proofpoint-ORIG-GUID: pKtdBXihQFI8WsLvRMzj3hvmFSRXxmG7 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. Reviewed-by: Darrick J. Wong 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 4d5f38936a20..7872397b8b5c 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 mnt_idmap *idmap, @@ -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(idmap, 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 Wed Mar 8 22:37: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: 13166534 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 699B5C742A7 for ; Wed, 8 Mar 2023 22:38:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229927AbjCHWip (ORCPT ); Wed, 8 Mar 2023 17:38:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35376 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230246AbjCHWil (ORCPT ); Wed, 8 Mar 2023 17:38:41 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A24BF86DE8 for ; Wed, 8 Mar 2023 14:38:31 -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 328Jxpjl009786 for ; Wed, 8 Mar 2023 22:38: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=ruiGXC3XkSOuSfmlSYf8jr13Z5YtuUN52vrQPHA7REA=; b=rEDNfOsICTTpudONR6Q9gfsemaGCul51G6oWaVUhpxl+ba17n6g5xk9DnaGlYNL1R8Ay buFWh0fEhLyXk+G8CfJuQCq/ibF4Zve4hSMb0scf7M2HCYlBtHkKF1NWqamjBhRZYEO6 8jYPqKpyyyvn/cwkbS0i+7RWKevFTeHQFZgSwRg9HPELIXv/1ShTwQG3M4liZSdELssX ww6OfPXveZGS/L+sFEQpX/NpVZC1tGquYhNjuOXEMMv08iYVkRxZlTxKjfNOdG85Yne1 FBlX9+7kTAwu12VY5CWSrIbf2FoA3pO2T4aYsgFa7a4LM3ti3BOJ9+9D4jnU7b9jy4D2 fw== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3p41621a55-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 08 Mar 2023 22:38:31 +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 328M4HFC036526 for ; Wed, 8 Mar 2023 22:38:30 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 3p6g464wf3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 08 Mar 2023 22:38:30 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=O/jFNarYUIV8y8M/Os7Tv8Wcrg2+wPIFVyyfeYHkfwhrtw8Wh2fysDGbEhZ4VP/ik/wcWPvkEy1wK5MD2dVKTszNz3Ylnza4DDSw03OYzWNQAaUimX/yDytS44GbzvTc2n7Z8zuhIdu5d9qFXsrOp9fXISs5EZqXfG7amMcgBqwbUoV+6Yd/mt09e4IW9OcreYivS7rPa9WKCos8ariduVlWHAfPK1rBp7ciBXtWyOC9J+tHxL+ZvbUbIbLNYis0jKEqF7KI6cCCrnmc8nFLPtZZKznwmD2gRarCCaqXYX0fZPgIMvf5hDaPBQHGxj08tuJOFmNeXQrVYhH4zPxChw== 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=ruiGXC3XkSOuSfmlSYf8jr13Z5YtuUN52vrQPHA7REA=; b=goUqbXocUVdZYYUS+0gTmfqPEX+NjJ1DyiTsMGUxwph6wMaScZ+gFbcR9PUbMOPgmb+cD5NgjR7yXyoVZcav/uO5XpLsql2U3b6xpAGlMiLtgKBFgEx5BvSHJ5NoPeGG57D3KD8KybAnPHD07NQeoBS7Kv98NMGzUIUoeRCW/QzJwGS70PfOSSMniBru+enQoF4qqd6yTIpv+osqvpMdWSeHsGSlJ74BP1Qw0+2O7bsMJR64faSrpdThGqF60KU39AfoBzbccTCRhzhlSPktLig0AzCBk3j7/JP51J8KLi7BWiR71PiZFuYu6FdIP/0JNE5iEWAAAfdYzbBMwzFhYw== 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=ruiGXC3XkSOuSfmlSYf8jr13Z5YtuUN52vrQPHA7REA=; b=PvZ20hAlmRhFivthF8zRuscjsvjeUhHav9rqINEAod1ks0brPX64WJukwOrAfPP3GNh8VJmlKsuItNcv289VR0yuLJpn2BlUu5h/i6jktt6T8PH7D2tBlaKhC9AqUEYJt1QFyHGig72lINgWAr3MKJauP4Oxftz7Aepek77XcGI= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by SN7PR10MB7102.namprd10.prod.outlook.com (2603:10b6:806:348::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.29; Wed, 8 Mar 2023 22:38:28 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::2a7c:497e:b785:dc06]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::2a7c:497e:b785:dc06%8]) with mapi id 15.20.6178.017; Wed, 8 Mar 2023 22:38:28 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v10 18/32] xfs: remove parent pointers in unlink Date: Wed, 8 Mar 2023 15:37:40 -0700 Message-Id: <20230308223754.1455051-19-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230308223754.1455051-1-allison.henderson@oracle.com> References: <20230308223754.1455051-1-allison.henderson@oracle.com> X-ClientProxiedBy: SJ0PR05CA0185.namprd05.prod.outlook.com (2603:10b6:a03:330::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_|SN7PR10MB7102:EE_ X-MS-Office365-Filtering-Correlation-Id: f02d61b2-ade2-44fe-a733-08db2025d656 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6rHunedDfY8UHKwDWVJQ6zXO0fKf445M2droARL674Rd0aXU14dc7AwxrnwXvRw1XDXi0iJpa/fyiERYsOilbF2yhmym7haBeJ7ah7cgBmkokB4jGyo4l0y3F4ei39r3Hzg5O6D9huqH7ILPff3bDwsAxjd7ccZXTGlLsjqVgZnV9ULf5vcr2GygsIVydSt2wqcOmH5Nzj9ok9sNxF0Zb2r8lxmTuLu2QQRCliI6uxRAYRbdN3Ko/zXjRva+/AVWxp++ZScpdK6J8GXIJKbobl9+bYuVNVnQjyla2Pk9Sbb6bZWNcl8bJqo1CzU5ICZECNlL+TRpA3snwQByJ32neTpvZQjuQ0AyngKJvqYaNGXC2wPGPyYeM4U4svePdE/9SzBza1AjDWnbnyLKxvOm3aTbGPSXne6C8dJPZtayxVerZRGqTOJ4EOh5yPe/iRHn3Sojo5qJaJYWiYUm9kbQas4WuGOEaIIOlC7R6ndH1aJjvNEO+D2/B1FSAjOq36Os7AFQWMmrhG+YQAmm5gJd8r1wAmeL7tNEfBNGWR3SeMZcR58z10YAa0G2ZabCc0UF+3GbI2td9Sr7X5BMqsVQjNs7FnLLT4NXlwiGve8OJZtolkqM8BIOqzZnIVseLspAf8b3BQLfTOHwU8g2VjFGDg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(376002)(39860400002)(366004)(346002)(136003)(396003)(451199018)(36756003)(6666004)(8936002)(6916009)(41300700001)(8676002)(66476007)(66946007)(5660300002)(66556008)(6506007)(2906002)(38100700002)(86362001)(6486002)(1076003)(6512007)(316002)(478600001)(83380400001)(9686003)(186003)(26005)(2616005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 2ciTcvfPr6W+e3mvCQeQqg+8E1MDjt3jMPC3zQRNaOR7LCrYiQW37Cz4l7ZLYEWnYPCrrCI+aWbux+jMnxLlKr8mZfwmdafBbHmsX9/jCTvA+zX95gwXMJw/PmF0Y41+hRFi9SgWgIRsS/aiqdMfzzxgN8eZK7d9M982ivyPBFO6Jc3jXeenWwVsEQVihwsF/Sao1cZrgMh4rH0Ed2diqwFQWYP7TfaMJw8Z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UJVpF/pC9bYsvOgEWZvsQcf2gQ+CphKP1LOhUwCFmyp1i/pu+ZqxjafKVQTxJXYK8DZu8Te8kq2R8CympOXrhgidVcwlg2Hg== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: f02d61b2-ade2-44fe-a733-08db2025d656 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Mar 2023 22:38:28.6501 (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: QJpAwtECj79xf2WlyD7x9z3bkYUWlfN3oQJ9LncHvSfS+rJNw1M4XXBpo1vImFmXaojetgtLtcQpZeCmwisaT6e7be76iqcAGySM+g+UXcQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR10MB7102 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-08_15,2023-03-08_03,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 malwarescore=0 mlxscore=0 mlxlogscore=999 adultscore=0 suspectscore=0 phishscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2303080190 X-Proofpoint-GUID: Ca1h59Az5Nftp0hctVA2ii_2zoVqojPd X-Proofpoint-ORIG-GUID: Ca1h59Az5Nftp0hctVA2ii_2zoVqojPd 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 63d750e547c1..f12966224005 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 Wed Mar 8 22:37: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: 13166535 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 90862C6FD19 for ; Wed, 8 Mar 2023 22:38:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229544AbjCHWiq (ORCPT ); Wed, 8 Mar 2023 17:38:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35354 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230076AbjCHWil (ORCPT ); Wed, 8 Mar 2023 17:38:41 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5E60F3D902 for ; Wed, 8 Mar 2023 14:38:33 -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 328Jxuqi026675 for ; Wed, 8 Mar 2023 22:38: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=XRZP0/EZTRxSM1aJCideZZf+Koqs7S6Dw49Pwjjg+Vw=; b=fxpJN0ztDQXvSbPMqZTietqa4SSj+72ABu6RRhQq/2aDqMcKv1/wzrtirt1NK7nBtjok FnjqPZjxt8NO95T9AMzp/bWbywC01jLbgGts2OGDWKhVQs55T2w4PI690vCf83JmPfjc mGDYzS1XmSBw51tGCF5Ax5oJlZUBGa8afQ/ph/HGq1Rvl0YMpRaZTZN4/rd98lHI73BQ 18TVloxUTyXTBNmUCiOhvJPxVHODPg5nd1dD0h5fMp5LOK+iVPzUFspFA+A6gDmhUrCa ouwfAu6Mp5kMdm18TP5T5wXhMooEuORwTHdT+6JlfBuXzWn2m/pCOe/YvQwht3B/dNN0 TA== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3p5nn95qes-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 08 Mar 2023 22:38:33 +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 328MCXhP007128 for ; Wed, 8 Mar 2023 22:38:31 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2103.outbound.protection.outlook.com [104.47.70.103]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3p6g4gd1sk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 08 Mar 2023 22:38:31 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Befu4yp4X+ohT8ER8eqR0F4QAJK43gS+rpxerCXI1oc1/Y+bLpkB+uhj3H5MEbaMl1QJqh1/Gq0wZzAB9jhiLSGZO/Dl4NQ8dd+zUzboItYG3DdshoEG5aSApIxGLZl7Eu7ftAHNkmJVAZKNPhAI2RJo7WkSQ/QLiQUldAywpYsilqVLcwtaYFdGTSAKB/dS1mDrmZeLBMMCoiR08Zl7IMiyi4l7buYJZ6F+Mt1iUZlnIqolvq7KKviVXk4zXcme3lUoQUInzOZJoFL+5AIZKsHEIraUQW3Enw2ObZTbyqc0u8OJYCmpQ+W0ZpT/nIqFqRH2JmC4hyVjgSgqqA/s4w== 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=XRZP0/EZTRxSM1aJCideZZf+Koqs7S6Dw49Pwjjg+Vw=; b=P6aKm9Ak2l6hwWTN2/VnKiBkty1XLUXWPgjSq8CzJBPKlPGs8YosIbeFMhGrJkTUe0wHDDNB0Jk7Lwv3mAT4ZbEEZUU1lZZSZ90sxowDfIXg+9hOoCOELcbAEogrZa+mdFAAAp0xsowsky9202CFKNJUMXGsJ19gu26b+YwA2XMmxXiKX6HzE29X6y++ivMHOy3Mjh+53BnyBm8s8A6OGDiQxPd3GOvn+hoYXWVq9nBgKPMIGW5qx79kzPINb8K3zsMxThAP/YVnEAHA9FagmXXO4QI6UndQlY6EfvQ6FVXROAu98IhZo96FrjddRxxoKhkrQzoYnoIHEkP4hA+CHw== 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=XRZP0/EZTRxSM1aJCideZZf+Koqs7S6Dw49Pwjjg+Vw=; b=UchPDepwQ6NU7zVBC7ui1RoL0n2bbzLgxKVxSMnT8TGJ5D/+zI67VqvvJU8DGXi3KJeZFl6/7+w52C94pUhT0oZ3h4MXwR0wDqf6N3aUbQUgdFaQVbejNkbNrWsHn+8bxsp3PEQWAFIRdjdcKzoOuX62pX3JCKCrwuXkxtz2o/4= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by SN7PR10MB7102.namprd10.prod.outlook.com (2603:10b6:806:348::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.29; Wed, 8 Mar 2023 22:38:30 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::2a7c:497e:b785:dc06]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::2a7c:497e:b785:dc06%8]) with mapi id 15.20.6178.017; Wed, 8 Mar 2023 22:38:30 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v10 19/32] xfs: Indent xfs_rename Date: Wed, 8 Mar 2023 15:37:41 -0700 Message-Id: <20230308223754.1455051-20-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230308223754.1455051-1-allison.henderson@oracle.com> References: <20230308223754.1455051-1-allison.henderson@oracle.com> X-ClientProxiedBy: BY3PR10CA0014.namprd10.prod.outlook.com (2603:10b6:a03:255::19) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY5PR10MB4306:EE_|SN7PR10MB7102:EE_ X-MS-Office365-Filtering-Correlation-Id: 9e30fa0c-dacc-4903-2e5b-08db2025d75a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 0dgfiKX4bGkxSekvcOIX2IyH+6+kWIt9woYBWtMVcr/LEgN58Us7hpDha9vIA8f3BkTxgEQjiuIGA9hBLOGEb6X/Tl2m+QsyQDr9k50xSCNjYozznTsMj3EWXDHs95M/kqmJlSAFn68tvHkNL0SJ3XSsko+cPsIyPLJRMEVTf8ETGJMLelOqK0G+xXG5cxetIyfNAoLXbXdzb+/8CvBjdsbBgEgmSamOuOReMBQNepHw0nSg/0t67xasWu2FAN2++U7oDey0OzDFUdJxhFVwUQ8ldwokoD76hRrAwGSn1teidDGAiC4YFQQyGrqM51nu6nLNm+Bzt3QyXd5CeEKCmOF6KGx3rH53IwkgWgMWy7OQeGcqrrvVw1ylW18ay5sUhBdNVZ9C/xs7eCHcaijWtuDqjnu3pxV+U2yiS8ra2Hvwdmd9pNXvaDcoa6olvmxzXcmR4PkYeb2XmEYNfVznVJ1iwFVsJrW+lcIB+5Q/MBWEbaZPqh9xKUjfgrQNXMGQfxzWlfanpmN8eBTm9k8S8FeIBqzTkbJFcVym7DsF8bKqr2anBC/pcJ7P3RSZxmZNl2PiNPDIcu6JZzfdw4HSTuW2zKxGzUlfXAOz37T6KlHuU0bLpYjrccMxFJIpfxcGrbtWVbr7ZkHfZn1Z4m5eyg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(376002)(39860400002)(366004)(346002)(136003)(396003)(451199018)(36756003)(6666004)(8936002)(6916009)(41300700001)(8676002)(66476007)(66946007)(5660300002)(66556008)(6506007)(2906002)(38100700002)(86362001)(6486002)(1076003)(6512007)(316002)(478600001)(83380400001)(9686003)(186003)(26005)(2616005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: kGfcUtR4vJYEh799IyrWYgSr1rA9rsxsQs272z3Bx5p/uCqBMcB6eYG2bia2tsQUCxGLc/6tvTfS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WO6BmpLzLNUO74IYvNJW4Do0iphRngMRqghC0dUYjtwdkutdCe3nI9ZtubS8I6T+0qoeq9QDP9qexpiP4YXmUB1jXAkL7Cb9fNx62FQl/BhnHkAejC/Xt4wz27qXH9mX21ECrVuQEP0thkg63axhnyJqyAmE+4OcScxsdOZynj88Z0pWH/j2Rn3BEDSJhqV6SNOM8zBKAyxBpC9m/k5YCjf3pgm5b0U/FD4+tKOG9G2Fkqokur8J3LBdzuZDg== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9e30fa0c-dacc-4903-2e5b-08db2025d75a X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Mar 2023 22:38:30.3209 (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: EzwR7mVhECp1xXJe0zb1TqAJeArsxZuGLrhE8d5WL9SFenilFMPStX9lpLBOIFD1IMH+G3u+89ynlhXi8hnlIKWTeyI3zj8ShTKjV4TekCg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR10MB7102 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-08_15,2023-03-08_03,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 bulkscore=0 phishscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2303080190 X-Proofpoint-GUID: p8QhS2h7BYIspx_Hueu1Gd_DVQ7vGCjc X-Proofpoint-ORIG-GUID: p8QhS2h7BYIspx_Hueu1Gd_DVQ7vGCjc 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 f12966224005..66d83bef4352 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 mnt_idmap *idmap, - 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 mnt_idmap *idmap, + 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 Wed Mar 8 22:37: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: 13166536 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 8BD47C74A44 for ; Wed, 8 Mar 2023 22:38:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229971AbjCHWir (ORCPT ); Wed, 8 Mar 2023 17:38:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35264 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229935AbjCHWim (ORCPT ); Wed, 8 Mar 2023 17:38:42 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5FC325ADF9 for ; Wed, 8 Mar 2023 14:38:36 -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 328Jxuqj026675 for ; Wed, 8 Mar 2023 22:38:36 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2022-7-12; bh=aIrrq5Azbsvh/zFXYxZRoVztWXpR4KrBZY4D9aFuMw4=; b=fmOme2MZFaq+tSoyTiSK7/0wEu8xNeuK60rWh7aggggPHzP83ucRy1i02LNMZOrcUn+k VFvY+j+0s76mvLqIqldxXVPe0wBb60RTdYkBIS6vRdNBurMKjEFMFBinMrKM9Qgo/Qku DmA4G+IBY4tdUElBALZUy3Ar4M+355ez+944IZdLpMFPwy760kl+X4KW38ik3qQntqcg 1J2798HIAFZ/LE266WUGU+b/VGFCie9d3QlyajkhVH+VeT+YqnwW3pvzamRG1iKJQ7gt QiK+h7Xpu6IIJN8DQ8R4UmwSTaeL0oNleEjCsMphI2op9tFd6H8p+mbLj3V6ciqclyIj 4A== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3p5nn95qeu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 08 Mar 2023 22:38:35 +0000 Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 328MZ0Jf007322 for ; Wed, 8 Mar 2023 22:38:34 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2107.outbound.protection.outlook.com [104.47.70.107]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3p6g4gd1tm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 08 Mar 2023 22:38:34 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VoXxssuZFLSEAhlcFsJvKfAiQL03MvQW/8PUlzX71sQVj+vXtUAKquH3z3bLS3J8bP1ciR7ufyZOJTLFKlGz7m+A2OejjsTfgIXFA2Uu4EayKFrFoAeibgIfvSlS1XfFSeGrVFG4iwgXzDqHMgDUcMmmhF5LY/XfqipegL/9N+rVlqmO+bmOBeKpZbgII+o51uUkEwbuUpnA7OHIERZDLtF29I3/NIEXJuxzMhCA608d+YyfN9bfOGUQ3GIBbcyMUSfXlVKg23L19c7CsPY3x7l3+EPFITImGoKPo8cjN60N+uEaKGqEDgoUPbc8YnF1jZvDPxELpbWpJj/X9Jfc8g== 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=aIrrq5Azbsvh/zFXYxZRoVztWXpR4KrBZY4D9aFuMw4=; b=BJy0vjk5K4LmQnGknB7i/bICuc/7ADVT3ejvfgLo7qXJBUMPiwWp24v6diWrFLk/rja//Qbdu39NYQe+JWEOE+pPbzVB//V9y532kt6P+cIMITNYc7k7Pt9JkINn1d2VGpIbPNS9IPCMbM+lM5PSVSxUMRFixXU7Qo9AoVtR7huIMd7l+wv1EKJnpxv6dsEjco9RAPfSwfCI7MTC1GxSh363fLB4tA6TCAG2BYwL4k5FXUvckd2+zInIauZDK60UTDRZDeyXmh/sIhtT81FmXc988y4f12RFngrSHjRoQbwFEGGdVZ6u+keD+hhwr+9vHUJRi3GeHein/JZL18GKQA== 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=aIrrq5Azbsvh/zFXYxZRoVztWXpR4KrBZY4D9aFuMw4=; b=lbjEmAaRPqzoqRn5L2B6flBgkt4mnPxX6Iv1h79lFOvUSdbdkTO7slgqbgrrNmD0BjUt1MiLJFXFCHWMc7h3Qe7W1nKVHl//fUOR6ghj0UpS87sCP0IsmCJlHEyBWsIn47BP6clhZZdfPd4tUV8uLMZ6ajuYX+4tQ3glMnFO+A4= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by SN7PR10MB7102.namprd10.prod.outlook.com (2603:10b6:806:348::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.29; Wed, 8 Mar 2023 22:38:32 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::2a7c:497e:b785:dc06]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::2a7c:497e:b785:dc06%8]) with mapi id 15.20.6178.017; Wed, 8 Mar 2023 22:38:32 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v10 20/32] xfs: Add parent pointers to rename Date: Wed, 8 Mar 2023 15:37:42 -0700 Message-Id: <20230308223754.1455051-21-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230308223754.1455051-1-allison.henderson@oracle.com> References: <20230308223754.1455051-1-allison.henderson@oracle.com> X-ClientProxiedBy: PH8PR22CA0002.namprd22.prod.outlook.com (2603:10b6:510:2d1::26) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY5PR10MB4306:EE_|SN7PR10MB7102:EE_ X-MS-Office365-Filtering-Correlation-Id: e0a839db-5bbb-4670-b74e-08db2025d8c2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Us0apxRwiZzcix5bDvfiMDHinnKDmIp5+on5C+yBgxZqqnUl+fCaF4tPF4zD2Qki0Tx2lpHNcKBgrv3oh4P440k7F9/+yVTn42kJiImv18rQ3f0nvfGN+UUCdMLtz9lVMhH2XlGQj907AHwbJDOsgwfL4Y0RxQ0QV7nk72l3JOUecQoGSIxyKYq70K/27ljwLviGx7OuL8zSVJIC7fKKtHgEiibD+BN2SfT2VMCSjAS4DVEOnL+9j8hzNAfijradzXAhOQDoNFDm7h04hFASYCm2LpkM1Cvwmq+v36WbeHA+1bWNqM8Bn9bztVCPA0l1PXd6X/dA3jpTe8IqPOouqdfLmZyZ/S/uh4OrOeqIl+8wJj3lmCPZFRmzVd5qpQ7cKk0qb66yN7Jvv4eUdCNaNSuVBMf06jSmyOkeC6c7NW9lbzLZZZV3SfZgjA8uVPKy0B+SWBJbnZ42z7qF2DE9PdgbfvEeMXCLou2f2qQEyqplN00XdC7drNBTEZig21P0xJFPcAUoD/XgKmUNUAijHCBBj99zQSk61Edn7INOTVwWFHQ5vBpMFIp8aD151mzs8TD3oJUw1ajwDnVVa+BXQiIG4obnimyufwJjKEcBLD3UXQwSYzdne7BU7/Cg7yJzrp6PKu/4yc2mwsSkzR5LRQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(376002)(39860400002)(366004)(346002)(136003)(396003)(451199018)(36756003)(6666004)(8936002)(6916009)(41300700001)(8676002)(66476007)(66946007)(5660300002)(66556008)(30864003)(6506007)(2906002)(38100700002)(86362001)(6486002)(1076003)(6512007)(316002)(478600001)(83380400001)(9686003)(186003)(26005)(2616005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: G/8QDjUNrF7G2JQs4YYU8R2EHDtT7ckU7o69A4dr5fXwhvP8FoFnpOmwxQGfuwPiYOpObYRMYKKtSjuDZDplSXKcLWZKEp7jCV3BYsYTWHINEv2WL1yMNjFqGzMdx/u4IfI5VXaT83gfuRBzvytmGuTljVmu5KnRmnb6wL8lUFcUM/YTVNDShS5QbuOTQJzaeB2g9zBfYRc/9TG+iPe7irSQlBnNjwF/kIffLktcR/4CvurU4KYNdfAsvEf0BhHwD31vq0QXQ8/u/l5Wy8B8nj0w2rp7TsIR6EXqkvFyT+e5Qwavt6c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ifm1NbRsEza6yvv/k5Q== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: e0a839db-5bbb-4670-b74e-08db2025d8c2 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Mar 2023 22:38:32.7294 (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: Ew4jUhkxfbEHM9TUaID6h3iFN4hM8xPNUIp1CcJxC3ER8r6Me3AxUw7w3dzXSLKmtIXritCgSu+l3M8lENTgs7WMH81fmiy6hl4679dfDrc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR10MB7102 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-08_15,2023-03-08_03,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 bulkscore=0 phishscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2303080190 X-Proofpoint-GUID: 2kYt3YqqkDmpdziRnR0sVTkx4DT4d04C X-Proofpoint-ORIG-GUID: 2kYt3YqqkDmpdziRnR0sVTkx4DT4d04C 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. Reviewed-by: Darrick J. Wong 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 66d83bef4352..f069556c8dfa 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(idmap, 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 Wed Mar 8 22:37: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: 13166538 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 D18AAC678D5 for ; Wed, 8 Mar 2023 22:38:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229935AbjCHWis (ORCPT ); Wed, 8 Mar 2023 17:38:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35490 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230135AbjCHWin (ORCPT ); Wed, 8 Mar 2023 17:38:43 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4A687618A7 for ; Wed, 8 Mar 2023 14:38:37 -0800 (PST) Received: from pps.filterd (m0333521.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 328JxtST028433 for ; Wed, 8 Mar 2023 22:38:37 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=kO6CRlVBmkNsneDN2MF1zdUusIW4+1OKlw9LuQ9pwt8=; b=Q30/Qv9n6Gd3aAaso3Txl36h4NNihwwpMCf3Ako526EBn6ygn3Ec1PBt4Ezo9z/nxz4B Q0sw5WuKRJbJTMQ5sD11WP/CYPUkE7Z+LE5KLHSuoD1r1a0h19vkkA221qriKM1lvWjz x3HrYS5wSdSui/OCgvi/vFuxUCxN5B5KnxLUFbWeJqRB2uK6tAjzSAYzgX2ve6mWi8bU Z9Z9FNTe6VfPXlzvCiVum01BEIkAo1YgvG+xHEQptQvsPMrko3qVV19fQBexCLltVViG FKDyVtp2J6FVFWs+mGBkOF0uZ3eLrgFjYP6Kupw3Cjs9Alqou/Zs6h3DAAWazsxj+wVO Ow== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3p418y1efg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 08 Mar 2023 22:38:37 +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 328LXpgI021719 for ; Wed, 8 Mar 2023 22:38:36 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2107.outbound.protection.outlook.com [104.47.70.107]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3p6fr9dx2g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 08 Mar 2023 22:38:36 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AD4kXgHFRUPzBIrbQOLOm4B2ho8ffCsv/G3wwfcZs6M++GN+nXI00Hegq/ffxc/6bnMzUhURhdUYV5cJM8cgN2DUfVRXayO9jKMurByLNMP1/0kvMLou7aIRMwOCHz9k0hl4Pzd5EHudzUyOup4DPLl88Q+JnB9IqKxG+oHnYCpfFsX1Q3sfmt0IetOZFyyyqC2ywC/B8PlsBVfj37bj579vEM0jDTDJ3wMvP0MJx3nSD0Ys1GEq/RudX5xDpAoHGU+8cVax9fVJqNcjIeUczr/XrGtQvP8G7hNPZ/avMnYfVtCSxRd1JRwQIEE2+Pf/6A/D5tLJmT6knPg1wbHZRQ== 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=kO6CRlVBmkNsneDN2MF1zdUusIW4+1OKlw9LuQ9pwt8=; b=B7oul88Nbg2QfiGy7GT1lDbqJqfQEwhE3vHahoKIqVIQo5ccLxlPwBG32e6/YNsc1UlB7nIleVxkOgaS+7y0+hYCmqEFVTfQ/uW40qDG98spC1Bp9sLov9WDjwT/egYIDaCVH69Ys9qkEAcy+Czr5htO2xVRpo9U7xzruAUIMG4nhSteqMImE+yEqbsZzbtHFtavdH3dzrrnn+9P6P3RBg19Ri9Pt8pHFzxntYHdYKcNR7tl5IDkMU9CInoUvf4MmzvE+46II+YkkWw6M0SvYuMy3uhblK85YKTddgKQvy61Npa3AvKCdI/aHhIB9bTxkRIL0CPRn+N69C3B9FgC0w== 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=kO6CRlVBmkNsneDN2MF1zdUusIW4+1OKlw9LuQ9pwt8=; b=vkUcFrpRMABbd4AFCMa5yI4QZ/L3XE7J5K7JOKVaIWr4wop/aJBe593shhSwuDW2B1zvNUHAdCtq9yzbbWh/fxxYpxNtbGT9TxgGvQYAEf8CphO09Zm6AA4lUb5r2qkMSfW3wTA6ZyYBSWrsr3UVZF8jAJdzXpZArge4f+gHD+w= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by SN7PR10MB7102.namprd10.prod.outlook.com (2603:10b6:806:348::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.29; Wed, 8 Mar 2023 22:38:34 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::2a7c:497e:b785:dc06]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::2a7c:497e:b785:dc06%8]) with mapi id 15.20.6178.017; Wed, 8 Mar 2023 22:38:34 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v10 21/32] xfs: Add parent pointers to xfs_cross_rename Date: Wed, 8 Mar 2023 15:37:43 -0700 Message-Id: <20230308223754.1455051-22-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230308223754.1455051-1-allison.henderson@oracle.com> References: <20230308223754.1455051-1-allison.henderson@oracle.com> X-ClientProxiedBy: PH8PR22CA0009.namprd22.prod.outlook.com (2603:10b6:510:2d1::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_|SN7PR10MB7102:EE_ X-MS-Office365-Filtering-Correlation-Id: 5f63da65-4812-486f-e9da-08db2025d9ec X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: L/FJw5ZZjaELTzmUKNJ0aLndL6ZcNkX3pmJ5ajVbZ6KiJ+fFtlTRmwWdFBJgA032DJzR7HEC+ZOfl+M/1eJ27BXMwftLLKTwRlL+yo8bDA3Z5rnkMEu4d9V8CuvOl7UUFU0AcNbBUqcNBOV4dCAMckTwNhCOsjLgXHy6S/XbpqOpWCr9ZtXKjQFmRJhG01zS2suWBCJrG5wLMV6ZOkiihfq1KdpsL7nmxEryelddeWgoVlylQtfclkmU2FuP9+CFFmdEaT5S6v558En5ldOImgpvMLGyUgNxpdA9RN1LmmDWZG8rR6xJpHdTc9li7/wwkKTQlyA7aPH29h7whsMqcRpEbQo1jMBOdhdAbGd7XAr8TypizJio80Tlntn5dSI1WhJOC48qXVqXsIeo9ojDPLo/oo+XL/fJVz1QFaYDsRN9+TjJaximr1H45T5ZzxM9IT0rtSV9euSSoMfkWEfLvHQ4vRlr8cKG2FOfDaPCgkwJJpqjIqRPiwKPpoJUFCN46ASvzn+KOEoUq9MDGr3o6BiWv3JDw47YTDawQbyfTUz8Ak/VajQgEnZQZUtez/Ee0Sb+OlGSUo2tUkwasSsHW3fGym5pEIraGXcefQVx1zsXZAKybA+CDTz9ELQlU2785JMQMQyrUYTvRxPU8wO8Og== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(376002)(39860400002)(366004)(346002)(136003)(396003)(451199018)(36756003)(6666004)(8936002)(6916009)(41300700001)(8676002)(66476007)(66946007)(5660300002)(66556008)(6506007)(2906002)(38100700002)(86362001)(6486002)(1076003)(6512007)(316002)(478600001)(83380400001)(9686003)(186003)(26005)(2616005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 20pc8TQJ9M/4zTs+IA9za+yp7x01eMGdehogl+Fqi5IczRoplwHZoTAMatGs1odY160OUt6wWTqdZTjLtCXHnYvDNPbCEvNXeUtmFBFcZMVWRj48a/zhP3arjOr44JDOT/CtXzQi5bYT7Rm3XCmzjvFp41pEPhpNrAW31THRmOeHjB/A7A9TymyG9R3TGtIaBG7K8xuKziRE9Wc3heNQEW/sxJuX1NejvCBM+76lfw8d72tWGaBSchrdh+Drf2JtHo4P03enhqDhvFpyOsgd2Gm2x7fcesf18+zGi+t45u/IZKbBaML+5I4RdUYjwrarvJsu4dvYgtMCkt3wh56OzsbcbfW4rNXfQ7uXYva78t9mmQi1FMvVddLdaHh0aOlzF9pbqKg7qVq8BXSGgtve79KkGoX3R50RFllKzKPN2AjrPj0PCR/ZhmwEkNQZoEDgfvSHc3uAZ7NskPrY4D0Xy+eRtkR7BLY2/oykGwiJHx9+nRroHe1Exl+Tdivt+KmCo0E8ocaR6U+WLitv7e3148n0ydxLOhGraqViDtHqjZhK2WF2dz3P51KVivA2CeNY8xFMlh4Fd4iiGOLW9AIPkKYqXKT2UCZmO5NloLfy4ZuUWn0UEZnoffT7aV44KixJHPqesFoGfbsElIcxaG7sSkJVfy9uhVDJdzaiZx+0aalhCBB0vQnrKDCPBSbqtFWzEwYAXHjfEp7YZYOAXbXyrvn+r09vTr+6YXTpFoZiUC6bMvD+XRgQ2eg2SrU9jH609G79jQeTWUdQ09Sal7tX5Qbk103cv3PXi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HI8f8ulEfEq91ytDV7t759e3/SKKxcJ8qU757vEoUUv0Os0W9O2oNK+zDC8T/X8hjsNbgcZl88+OfN6d1EF2YNI7IuWVaMz1r4PULv8yefcMEhZP6OI8O2lle0R1gjsxH1pedltsjo8nb5yTggVuYovFjJCEvtoEJPao6opiLAOEdctikpQC8nf9SVrMPrVD+kL/vbSt4fJBhMJMLb50cTN6zeoEOBqyEnONAYkKX5kAOqDumuXIEcCgY7a/6OYVEZALwU4WYd210Yzzb001uNufHS00tDNzA+5oHxkJapTL6RfNUgXDw4jpU2Bg2U3ZS9JJkUK95C17huovl68HyeRfVuk4k4vuBNlQQNTfZDqSG+Z73HMUizMAQmR3jXbtLlB6yeBbOUdk6gGThwFI4aBZKHfr6We4Uxv22CoKx99iXFyAXSUQZSXAivW9GVvdeTzkPzwkb/LRFk44fA1tHwAkHcrqFWJTfE2gSNt9T2UrMf9RxCBRBwAfOhtlRy4thpA1kWlWVTWXhmJPfud4XHFWb/AY8OjppQYCxMOw09XdcM3qW4EEWpjOaWzHvl7hAQfukbdjCt8JYbl43TV0LrL6QfrptoWIHUT0sw== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5f63da65-4812-486f-e9da-08db2025d9ec X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Mar 2023 22:38:34.6680 (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: T7FT/HbpaJ6VQt8TwXUcvnrQKSPoo9EhrAXzg6c8zDjV2UmMA3yCtJXKSCwAUHL59pLsQxl1cv2cuJP61vo1aOOG7CWHHAd2PXvK2O8LUzQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR10MB7102 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-08_15,2023-03-08_03,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 adultscore=0 bulkscore=0 suspectscore=0 mlxlogscore=999 phishscore=0 spamscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2303080190 X-Proofpoint-GUID: _w2QZPwUA2AxCtQTOVPKaf3hdC8duLw1 X-Proofpoint-ORIG-GUID: _w2QZPwUA2AxCtQTOVPKaf3hdC8duLw1 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. Reviewed-by: Darrick J. Wong 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 f069556c8dfa..20193ebd3a99 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 Wed Mar 8 22:37: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: 13166537 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 8C1A2C64EC4 for ; Wed, 8 Mar 2023 22:38:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229667AbjCHWit (ORCPT ); Wed, 8 Mar 2023 17:38:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35702 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229846AbjCHWip (ORCPT ); Wed, 8 Mar 2023 17:38:45 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6FCFB6284E for ; Wed, 8 Mar 2023 14:38:39 -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 328JxuU4026697 for ; Wed, 8 Mar 2023 22:38:39 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=K5nYh1SuT8O+ZbUYUlc9rpC4+vyhu5xR4zFh4s34nlg=; b=qOobBHSpWD659zZEuhuxXygk1l3Zfi0mZwaJiD1b3jRMPrFRReOrv1zqNxzKu1a/0NZb HwyjjiWN3rmESuYmfBIkgdsmLclDHnk5l4mZymImkmhnJl0lPNRgYEZUCeT8om/roPI0 hk/51ZWMvpPrxv2WBHGzpxk6m3nkQESosDAOkr7bXmnynxNMq2ob68U8SsbO6mhVtgsw A9+OVp34YOqV7VI/NqxOIFYWdGmqdZLQOLpLUBPEAo4x/6h9AKkTytZ9aP0iugSDu9YZ 5CG2uZoRrScrmZJSa4ot5RhIgETXoXychilL1rJ6mlyArGYLFWmOwIqjtlCMzcXrZaoM 8Q== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3p5nn95qev-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 08 Mar 2023 22:38:39 +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 328LpdAY021666 for ; Wed, 8 Mar 2023 22:38:38 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2105.outbound.protection.outlook.com [104.47.70.105]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3p6fr9dx38-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 08 Mar 2023 22:38:38 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kHexzkURXCzak8sTMNlx/y9kdf4ZI1OQMCjZju2ANyUaUtlnvXp7Y6Kor/q/Ci7eeL2uXMcRsmWk3twgvShExFzEgcR8vpNRVrfz/7OpNr/U6Fn+2dmPOHkW7om1oBtuoPl+4Txs2O6U4tEk+Cd9u63DDuh200B6sTqFNObptMpb/WDbzJ/QGjbZE1bIX1Flzbs03zTG2uiBBO0Qu1iziWvbOjcGW1T1WPr32KcpisCwRDkbEv9cbDII/rzZzp6Lwq4lywwO8rSyjy3G4rszITMCVSGoaBMIKjy9jE7SWmseMqOWHbDqnckrCc3E7MWRDxuKj1bIHdX/ig6+6zARrg== 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=K5nYh1SuT8O+ZbUYUlc9rpC4+vyhu5xR4zFh4s34nlg=; b=SROPM6BZCpimGP+WhJBO2XJFr+8pbpbLLPUA+MHwPEHoaVzBRAVskXr9jvPyt19Zz+KI5SHtvivS9HakTjFJr0fqLNRN3cFUB4P47zb1a1B6+LGH3tdG8Gqk8B2o+JWN41qkw/nOnQ136qAYr6uPEqHShMm/2rucQXEmCclIpA0VxRravljdTbhiUCXzHx30nMEGH6TB9XOOpTeMMJ7p4KLWXHtjMWFK1+yqvdFTcI6jtgdSTIf7JB9n205G1CtN7pRIZolk5Jy8XADjKUhH2R9llwnpNbTS1v+3Np/lJgokeRFAiB9Uk8Ti6kTuIhUdRv5hvijtYmZpW68ievyz3g== 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=K5nYh1SuT8O+ZbUYUlc9rpC4+vyhu5xR4zFh4s34nlg=; b=ESUY8F96gsbaXP4pxfhLkqMk4QqkNMUADVd0G2hL6e6ptpjeraBOGv3uC6aKmsC3rILMFM/WhPUtbLo/vgfTDZLjBrg90e+0NlwypLAYXZGEUFEZihzZhofaQqSZ5Xq0QrCMHc0EsCx3BEnLgn1R8ZKIljgoCQHFCPu3kyj9sTg= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by SN7PR10MB7102.namprd10.prod.outlook.com (2603:10b6:806:348::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.29; Wed, 8 Mar 2023 22:38:36 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::2a7c:497e:b785:dc06]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::2a7c:497e:b785:dc06%8]) with mapi id 15.20.6178.017; Wed, 8 Mar 2023 22:38:36 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v10 22/32] xfs: Add the parent pointer support to the superblock version 5. Date: Wed, 8 Mar 2023 15:37:44 -0700 Message-Id: <20230308223754.1455051-23-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230308223754.1455051-1-allison.henderson@oracle.com> References: <20230308223754.1455051-1-allison.henderson@oracle.com> X-ClientProxiedBy: PH8PR22CA0008.namprd22.prod.outlook.com (2603:10b6:510:2d1::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_|SN7PR10MB7102:EE_ X-MS-Office365-Filtering-Correlation-Id: 8d641a69-8af3-492e-b823-08db2025db14 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: a4OhxCD1BB1yYbbBxYP5hQ14kJSb+RbW5DwF2TesDfYEZDPS8+mkpRTJLx4BKWDvMEEOooobjSHOcCj+N3HVGg4eOufNAUtx8aSu3vggNm4J3B9GOVOuieCFSuPkI5/inyyJhI1rnCLAsrpCwVXY8Dh6SyHXtPKV0xeVCS816q8+zwRyVa5u0gu2s89Oih4Vm0AEhXt6btLa+bFLtw/J7GfO7H82WoRCruuskM94D/abu8Nw10Mnl4vt0QWS7cmDl22+QylzofRm5CabZ7SrY0paR4rW8lkeBXQ6mv0Hx3jz1FwJDdl8uM37UP36ZAet5pllv+yhaCRGFxLXdVlvb7sJNLx0O3FagVyfHB+13BmRER1k4hQvYJMU5dtovTKaWh2r2Dxk9TtHcg2Dun/at1FsckE2In3JBCJLjJo2paWHTF6uBXLZDjpB+ATDZ+1cJgozc8yiy+MWsZr7BYtoIvuPpQepzY9ytQIp9emrToDX8XRt2uJ+fEqEiTT0q1f2jkfuvza5dIMc0PRBwVyTSvzKoBPYNhYzYyIUtE13nWN3XBT3+iInqwzohKTgZkOShIjIV1yqeIzj38bDT4VezvQlgjTeVorPQbhPlBKt6cLhqoL3mBo6pwnlbuqYC+pqVZ89YLrHWbj9NzzfevD/Sg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(376002)(39860400002)(366004)(346002)(136003)(396003)(451199018)(36756003)(6666004)(8936002)(6916009)(41300700001)(8676002)(66476007)(66946007)(5660300002)(66556008)(6506007)(2906002)(38100700002)(86362001)(6486002)(1076003)(6512007)(316002)(478600001)(83380400001)(9686003)(186003)(26005)(2616005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ilhYxa4uegS0/mCXFL+NktX0ewtgEpzJnoPa2nonS4p87aWfOrXqQi03PzVkCEnEqt85Nn1hZ7CTc1hIZATJt6UVRUrrM/QoCPOu4ZbRRKpAPnychEl3cuLt60VblOWjz7D/PeYaH1oN6RaC0fP5a9rBzBZuG5PxkDUAW/3iWRlfKTx8OQg9s13N2EOB4qEeaQjZKmXzQkikkD/v6C64KgRlLLhNY2B18Luo+FUAF3B2evJ25arigySPAUNYtTrCq4hbg/H2/+Mdkg45DsiGAf3uVs1lziwndvb8MCqyl1PslXbsDaRl+9juoNp6bLXx32xOcTar9+S0aBmD+fk9JDBBmNckfdzMZyER3QjZ6o03hX2rzIv2uVDv7v/66wYFDJF9qjjkD460uPdTFeMAnD8Caxg+ocEp+JY7qQ3bFSzLCVz8FxqfQSgND1qD2QPCAYXn/NSF9uwkLQFE6fnhXpJksv2ytdkG4p1PWYA77hu1nX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wm1hKkvP+goIhVaSyDKkupVmAKaQ== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: ttUbgqUb3PCM6MPAyrHxyPc/BNb9QGDH0HUhiL6dHlJ+qRxk0tIcoM3HITBySx0kgUejdgc1NleBoN7MGCgpKqaTIg8qtM22YihrP3zr/O1e+tnSf4P7pkQcU5XtDOOWLRm84YF25lQ/vbt2Glh7QVFMC9n47014+adlyj7B+0eCaSjGZHLiBwGcKwnaBf3yCPSI5e9i0JY7aWPEMiC/CdZusSgBlKkhx8x9APRH4I+atdMoKJM4IO5fyOTx0JAbFDvpKPNn6XsST8JMDwAOXEdRqOY+smcMs9yQ5lVxVANykAw1UMphy8KUVkjN/SJ3peFh9KORy0YuCqKl8XYn62GCybeTEUgOmyLBo+65H7t3j093HMzhhyLJIaY/9tHfrjcZnerTM6NHPY3jtdwkDjRy/Vs5j69Rquw4xiMraYtxsgSlRXOH88rM20coriisFjSWJbIolfKR5kGX6TMX1lzWHOknHp6cjumaGkjg14+swlMc074YcuHSnhi4ubmqqILZWTwmcahjVJ2u0PaNTjUTuErztnvFsWlysEPNRg1rCBE0huj35S1NAFdV8mmYC+GuiGrEwiriMqoPp17iLjeRL7IQiLcjvsCMrTnWGUorm+lyVHg8hNQiVDcjkaBs9rNJA1ljdgdQPagTwKcRpdH4gEm/IbHGCZaeILUS9hqoABVQcu9QghqMr39ZAsDfS6bHvTrr2C5jAt6e4VRy/3eMAmcNH9FgMJ+eqKkSUuoKDVVHOdmRIGoSS5YE/XDIxR0GGv2mN8uFTYecqntjyg== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8d641a69-8af3-492e-b823-08db2025db14 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Mar 2023 22:38:36.7472 (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: Yp26UYhwNdOnmmkPF+qwzSwDYupV/nrqP45Qarl+BeE/H4uXk49QBHMiTxrMA7gWYm/F59Ycx+rLgiDaejdP7J6+I2ZOCYdGksNz8qBraIA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR10MB7102 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-08_15,2023-03-08_03,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 adultscore=0 bulkscore=0 suspectscore=0 mlxlogscore=999 phishscore=0 spamscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2303080190 X-Proofpoint-GUID: aj7s2rWr5E7tV7y4LU4NNsZIdNqoHrC5 X-Proofpoint-ORIG-GUID: aj7s2rWr5E7tV7y4LU4NNsZIdNqoHrC5 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 99cc03a298e2..c47748b95987 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; } @@ -1190,6 +1192,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 69ba6569e830..a0212622507a 100644 --- a/fs/xfs/xfs_super.c +++ b/fs/xfs/xfs_super.c @@ -1674,6 +1674,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 Wed Mar 8 22:37: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: 13166539 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 33612C6FD19 for ; Wed, 8 Mar 2023 22:38:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229735AbjCHWiu (ORCPT ); Wed, 8 Mar 2023 17:38:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35750 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229525AbjCHWiq (ORCPT ); Wed, 8 Mar 2023 17:38:46 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4A37F59811 for ; Wed, 8 Mar 2023 14:38:43 -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 328Jwoif020849 for ; Wed, 8 Mar 2023 22:38:42 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=OJMdApohwbTZMSn1v7vP2XL8Lolkn36rKp+MWOdS4xM=; b=MCzUNtLF0iV4pXW4BjcG9a1cBkyii4PTYxj4D/T4lr5+vijwr6bmxsnUuy9pjov41ihE TcTJUqApo0vG0RXQ65i2GEqqdnyxORPID9ge3nmKRm07qWvVne5RGhXM2dp9D3E+ZM9b h0PuoO/Vh/6G1gaTlPbdTqaS05pwgZFJzKRwkci5+jAZKnxCbUDsXIAtfS7fuUpvtpIi N/K29qYvuCtY4pfEIPl7Mr529eSpykERvECLw4j50WDqne3/8s+Lc3yT8wuHPj3V1F5b Yg3skuuc3szRkG4q8Xcmax2/qOxE/wxAoFbxr9oLyzi2xrLNs0y7YAyG8uc6QTZE13ah AQ== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3p41811a3e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 08 Mar 2023 22:38:42 +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 328LuWGd020781 for ; Wed, 8 Mar 2023 22:38:40 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2109.outbound.protection.outlook.com [104.47.70.109]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3p6fu8my53-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 08 Mar 2023 22:38:40 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jcozajOW/RRYB51gmFKyak6lsiINjBsC1PWF66dmmrSAYVVNkRwPV4iQ64YZrAEEuhK8jR1W4lU03WFAGrt3cxM8DvpoIUKX2T123xIulVbL273MxwloOnBKvW8OFLor3GR3uP2VumHWBh+RSXVJSMn87MFo4j77qZDiPHgMzGaXPcOQVOTri6TjwGDaJAdXrGery9TLo5aAUsOcu/TlpAD2tkfDDZyRWGqKtcuxZlzJSFT7H63R+qgLA60P0BmYkqjzmAHV7qaIztedk0D5z2VYYab+K0HV8pxVEH0GTbMSDUGZb3f0yZ981z90h+23vXgMGMSKcBWVZTh7RNdaAQ== 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=OJMdApohwbTZMSn1v7vP2XL8Lolkn36rKp+MWOdS4xM=; b=CdjoPTKlVm/UKfWM8+iPy+byJcL7fDqSnOypb3MPwbFSKDo9k5ZXL6OP+SKzyUPi5bfKEM2B2h6pRAXYb1iB0xhH7OXsuV6BXb32vM0vNMQvb8yxZO5k+VtQiKVw33QyNjhQlhjVeYwqXWT7a1/STwCm8xdZKwlb+RyjZAq86yuLD/qrLC1/Xlh+RwazfYS29FMX1qpLKKn21/VZCtegOSAwk/ehLJrEpYVUnRfpCh46D840lREK1vR/WWg62HxH6MJ+W56nWgwmKRdVmj4Sl5Ijg7Jk0yQsGie0T3rW5lWAqC2/dxlIsOLsVeqHwmMrUgTpXalMdt/icuJEF2Elvw== 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=OJMdApohwbTZMSn1v7vP2XL8Lolkn36rKp+MWOdS4xM=; b=qjz7pZWIENtT7niazgrWiR3oog09cN+QBoTpPeIjLcYmWTtvrf1nRL8I3qsOaSPndeuDhtmj4iDbl6Ox2iBzbhi7vOfP+TOVV5EYJr77RJQKvbOcDYuiXSeeJ84AQlsVSbQhi9O1BXkH/6VifjDQ81IYbOQpxHe+P50D5xx+cUI= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by SN7PR10MB7102.namprd10.prod.outlook.com (2603:10b6:806:348::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.29; Wed, 8 Mar 2023 22:38:38 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::2a7c:497e:b785:dc06]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::2a7c:497e:b785:dc06%8]) with mapi id 15.20.6178.017; Wed, 8 Mar 2023 22:38:38 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v10 23/32] xfs: Add helper function xfs_attr_list_context_init Date: Wed, 8 Mar 2023 15:37:45 -0700 Message-Id: <20230308223754.1455051-24-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230308223754.1455051-1-allison.henderson@oracle.com> References: <20230308223754.1455051-1-allison.henderson@oracle.com> X-ClientProxiedBy: PH0PR07CA0113.namprd07.prod.outlook.com (2603:10b6:510:4::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_|SN7PR10MB7102:EE_ X-MS-Office365-Filtering-Correlation-Id: b26c9f39-7e61-444a-47ad-08db2025dc60 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jmJBd4P7nQiEbI67BZwWihhNWOn1zu0cfB+GcY8NFUYWqZIOczSZkPHxWdQS0mBsupn7tGayf5J8uGjmg7Z32lMtW4RWs0BRpWSQVg4Se530dHHRh+tGBgqikXyEkh+/TkbqVW1qHnYUQ8Z1hY3h8lxRVwpYrLe0X1JRNUhT8d9xC4DTsUolmgvWB2kJ7c3OxdOrVq0Dth7hsecmqHWGc2iASYQzOeKa6WJCOmyetC/ztDdoMWMHqNBuX2ypOdfzqT4zohiJpGKC5ih42oOeiTSfyLNrQS68jzoKiqh7aiJPRsyIicLDwmKu83Qq6UHcCRIciEjBNud3hfHMuzh2xO4MKZN+8TFVkbsuxSG5hPUInsCizvSuy/eW9c3VFtvkdx+hTd2gL1J/F57iuaGyPTwNwXgptEh3CmfCz47kBAzWCTwNxhdgzeuqNIO1ZBvKwZuY3A46F2Pz1VJYLG8UFGElpu2ti97B/Gvde0Fg1sXkVIu/I+nF36qrGrKdAAFOxxgrh4Y3vl9sv8w6be/7VcmPosACTVxI5EQtTxDQqwQmAGYMWPImYqqNwwPRDp5VIX8kQW32sy9FrqWb5NUORfnNiqBCoOJZo1m59n7hWNzkc4uPxVfWDRql0rUE4NlXxUEOZpaRSYgkyOIFRiynsg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(376002)(39860400002)(366004)(346002)(136003)(396003)(451199018)(36756003)(6666004)(8936002)(6916009)(41300700001)(8676002)(66476007)(66946007)(5660300002)(66556008)(6506007)(2906002)(38100700002)(86362001)(6486002)(1076003)(6512007)(316002)(478600001)(83380400001)(9686003)(186003)(26005)(2616005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ZpZslY2zKDM126u2y7JPDOlyMAMUMPl40fwpgaeTBEYJ5VBid04aDcDPdm2pSoEaOainLfyuRqgqF2wbqZhZf/rq6zxFd/BFZ/n+1F1kl0yoDL5k0jPWCECObd56DouBAESHs1lTHJFFTBKKR3DNwSq3JbOmle5vo1xR0r3I5FEa/Er2ZjF+tUTqpT7pBf58oLDRfRd4w40p/GdWn4bE/CQ7Z2Vc3OWOeKFj9VsidCkPnp4/zaAiHhHMYac6MzCWv6MP52OZk8UulF1TSDlEOCYSPiZLQRbR8Vly1ONV7L4aKBDd79c6x7DMabhRuMUvKmKQlI8+q4ip2kBD/x/hcV7sj67Jku7SvLIqwjqNLFcw5VEFyHZpzv3hs8RkhTP14EUp6yncmzBQRXBfCq8oBECtBSFuN8MAO69qvICloFOXRnr85p0TqXYHzhL/2UtWcfC93Zn13/SI2KCoEpN4XKx8LoXcsg6MRRdlIsnHN0+L8jVDshop4lfCfD11s6rKS1i4j01NHI6ebaGULn2jb+9dQcVLSQwGJAYt6ZG+fyh0gwOPFx1ie7zaXcahbRioXSc3wAnw7CEqJGqIUrb//BDEjGvZU0xBuDMoQUhl0XTPXx+bZuDrPo/Q6MGTyGgXrJ3GSsa8Ux0JK8anAD7xQts89NvMF9ZJu/c1kn3syz95n0qT+8r6U0xA0z7TXFqMiWdidT52OSR9OA0qyhdIyeRwW2O+rsK8do6aPmesy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qwnI8sHkzpeMztPje7WPCzjcPKUxNPnqPrinK+CL++NtX9roh/lCZWTo58gQSJEikO6UkeFYeD6JgpBYzEN91Ectr2yYS2BPB+Vv2JJ1nbXU67WsnsXrifnTY8wCNIOebIEXDkS5ky752Np8VgZgBvN19rKA/pEEo4L60ViuEKtH1g/oxlyOHyEt+SVD60EfTaMvnMCLcawRTXqpJ9kjTk59K4CgZYFbF8gMoOiyKPDIk5uJ7sOi9uQB9BJO/ShtXSblc5/u2DB5FrsE3fK47ojhYsnP+EBHWk1yZudkdD230Tv/UGQm72zeCDjWzVE52+v6LC6OkO46+xP8SF65zh5cP1f24bpgZ9vF3cjtCF9WmKuRPpcy6tiGiMrmGsDsCsCDdlYQI7ihyR6m1HX+CUEDHN1mJyuJmYeYCWEGwenU2e5rS+4uoX+O1Ji+VWHnWt5Gr/moLIKFo2IfC0C4RF3y6ygA1KQVkYyC/Ncws9+hEcQGDa1ctLskFw+7DEbATic/bU7W6uz5+4gZ4GNBhdljueKS7yGC0SZL1CyIe4cJAV6mLXBYL2LgkKF0dfL8aczh3JLnAEBUv2vSfGClOCJKw1lR0Tgd23QX2BDLoZxh+Eswo2BMzxTs5WtQZg/OOMHtCXaPvWn39Q3x6bROqkC45UOCOJQ== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: b26c9f39-7e61-444a-47ad-08db2025dc60 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Mar 2023 22:38:38.7795 (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: 0txJ6QLJ422pk5K55Cu+YpLYSXEW+RJUoiY1ewYL25oyPArI1fpLqCtOh9y4KylLzfhmwyUsVbB6XBvWQQxyYKC2x92YcHBlXRSGDoygvKs= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR10MB7102 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-08_15,2023-03-08_03,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 adultscore=0 phishscore=0 suspectscore=0 malwarescore=0 spamscore=0 bulkscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2303080190 X-Proofpoint-ORIG-GUID: HVa_Sj6X8JmFlkcvC4lbeZniDDiYuY1M X-Proofpoint-GUID: HVa_Sj6X8JmFlkcvC4lbeZniDDiYuY1M 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 705250f9f90a..2ffa4488e246 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 55bb01173cde..59987b95201c 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 38be600b5e1e..955a67261dc5 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 Wed Mar 8 22:37: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: 13166540 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 18F65C742A7 for ; Wed, 8 Mar 2023 22:38:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229846AbjCHWiv (ORCPT ); Wed, 8 Mar 2023 17:38:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35756 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229929AbjCHWiq (ORCPT ); Wed, 8 Mar 2023 17:38:46 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 13C1A5ADC6 for ; Wed, 8 Mar 2023 14:38:44 -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 328JxfJK001618 for ; Wed, 8 Mar 2023 22:38: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=vY2b0PAVZqhDeM2fqCeNFFN29eS0+5CCp5vgTqu9cUE=; b=YX5RL8pzuL6mBmY1gAWhNFIHf9v3ioMI8CR2Bzj53SpxoxQESCvDJop3QUgnuAK18TR8 kHmYsZ24rjqJR2CD410HkWQe1v4DgCEE7Ng6EmNOT7zcpCv7zYRKEKR9vk/srOC1unvI 9yyIW8FcFaX9kx7uP0eBnueXVFuY1Ueu3xGY99xm1nPMPBhLFaMO7QXDgH6WCvVV17At kAiqjVCgQGyknSqH0wuHA3bkqA9pDj5pZtFovgoZg/KjFP5AH9NkEcrJCr6kROv0EvyW Ryak5bgKK1n7JlA3nsmyKMSrxhYC8v01gSXo0E5he78SHVjxkq6FgOwtK0StGuRnWWHW gQ== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3p416wsd2t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 08 Mar 2023 22:38: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 328MZ0Jl007322 for ; Wed, 8 Mar 2023 22:38:42 GMT Received: from nam02-bn1-obe.outbound.protection.outlook.com (mail-bn1nam02lp2046.outbound.protection.outlook.com [104.47.51.46]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3p6g4gd1wt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 08 Mar 2023 22:38:42 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=E0ll/EyAcIaVKYa1YLnuWbEM39Gj/I6tdc8Z2bXzDqtIIFFYG4rTYo8c0VI/ioBFgZPaWutNdqDphYcuPsWVPtFQEUrOUtk2UVOjAfC+c4jqmrV3Qmy54gqZExFGa11+wJ49ebDGzGmZk6Z9lsOm/4UCUb/+XMrgMLWe20XenfGhgtpoRAExICYYmPaoOGvxbkG43clF+pvwI0KUYxFMSR8BWZYfy338l9PJ0lsq7tSrV2IR4wsuh3Q+12gfHbupw1OFNuOOzWIPRK8VhaU1ccOJwACnG85qgNp8n5ukSc7T6QWGwEQlCK6l8aQCIOresgiGQ/fXX4IbZw/HUg6XqA== 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=vY2b0PAVZqhDeM2fqCeNFFN29eS0+5CCp5vgTqu9cUE=; b=L4aFqvfpHpBKuqtKdJ3/cAzK4NsIadjAwvtjh79B/RVVKZ3Wq+DZK6p4L8pANEazaXGEK6K0oylbOPXMR5fnYPBqWCnkV4zaO4v8d6n/5DlZ+gd81vBxbzKF97beoFPPJZ9ji1HwIncx6ZCCuwr3nLNNRaw+Xcuzrvngolq97IqQ3pYVV8/vcqXWhSMkt6ddCZOh+GbZtNnxBRvnXwffGs2zL1stMQm4BbPsJNz2nGv5mDKWT7RXy1kj2q+EH2UpDvJK42RZrRGCcvkGa/bfO4nixlTpc2zuwXX4NlHhTeK+wCAmSJ7lOzh2qKD2NylVWyjKiaGnoxxZ1tRDmLPr/w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=vY2b0PAVZqhDeM2fqCeNFFN29eS0+5CCp5vgTqu9cUE=; b=PGuZblayFDjGZoWY7DsDNxyslX2upg5VCioRJlPiZ9M88TY6rRnfFN8P1Bl6OS4qxNvf6oGhqZx638Ll7I/sUAw6TnAxP2XJfaN82lMW+TvYX/+8drF06tLSC/EwesKrUC1zREPfYoZZDyM2JpmJE5TGeXQW2AK36fiAd3+s56A= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by BY5PR10MB4162.namprd10.prod.outlook.com (2603:10b6:a03:20c::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.17; Wed, 8 Mar 2023 22:38:41 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::2a7c:497e:b785:dc06]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::2a7c:497e:b785:dc06%8]) with mapi id 15.20.6178.017; Wed, 8 Mar 2023 22:38:40 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v10 24/32] xfs: Filter XFS_ATTR_PARENT for getfattr Date: Wed, 8 Mar 2023 15:37:46 -0700 Message-Id: <20230308223754.1455051-25-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230308223754.1455051-1-allison.henderson@oracle.com> References: <20230308223754.1455051-1-allison.henderson@oracle.com> X-ClientProxiedBy: PH8PR22CA0008.namprd22.prod.outlook.com (2603:10b6:510:2d1::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_|BY5PR10MB4162:EE_ X-MS-Office365-Filtering-Correlation-Id: 035ebee8-f78a-4b01-c9b1-08db2025dd8f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: XpeSRCZGRP6glnV8JxipDugNG/S1ZcW6kEuOgcwfdoi6B7LlGm7Ak6BOBw6PsgAhfS5mFCrM7z6mqchwEk3ce54uafBqfDsHH8N6i9gUpCuNOPRQ29+lCOHyQJXXACwHi6/m7Kwdg+niZsijIwzV0GfY/Nrme42p1gqjEnuqbjdr07tLEEIudLvFYBqMi1LHMZNAzeMZulrx9GxsgSZgG6HJauA7o8Ln8VcYXxox6y6a7Y/0Rf+L9Ipci0fQsYmbB931uxAInnrEiI23Vj3mVF6hrOAqdGhQhRDFlzR+ggqcxzb/FQQE4X3kK+/NABwm54yGWNMBLVTs+uPa428YAVgf7U8Sd/qZ30QtWfm+tiKIdycs+avi0mmrm0pIks1RF8oYUShRGDPmPG07g0vqRlfJmalg4mRJHtYN7gyVC9iPUaiieGPShwCDBQbejH/VTFllQbqCIHZK3ya2w2ONwrbAbk+Q1hbgFcEQNd8IO3fd+DVHQjL7myVV5LH/Nwk6WLEiepfs61ZJqhQv9QZg2Ii7oTNU0KmIZrNOhCmDPgukvgKLLV8zSsAosHrHXrfq6LQ8MO8uGE9GnVHbxjvLLEHFnXpu/Qnl4dT7WUE1L+v22llZrYqeAyNAAH8hwlBn3bRaFCvvjsCIW5QW/CN21w== 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)(376002)(346002)(136003)(39860400002)(366004)(451199018)(5660300002)(8936002)(8676002)(66946007)(66556008)(86362001)(66476007)(36756003)(478600001)(316002)(41300700001)(6486002)(6916009)(2906002)(186003)(38100700002)(6512007)(26005)(9686003)(6506007)(1076003)(2616005)(4744005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ATEZSeMJHzBOPppXaZKT6PhUT93vd+wfuKNEzgzwblE/rQI9FkmUGtUfv1ZTrddbDSxUtSwWjTu9BHKilBIhh0gtz5yKA9jBpGOzZoSG9CB+vaOfScu7qqI4E1H1Nle4I2Qy+EaCR6kZqrwzpZ0QtBufqFhcldxkkxLLALmIO9SUWTt+Qf3PUJOINsqtm468F5JMCa50D/B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wctymNbB62kVzPa/2vBHaYj2K79blSpn5tEBld2URzXex0TNSIQlnD4H7mcy6C+JKLvC7RtHi8jL3Q2NUZFY7yhhCyuYUyPxsfyQ04wKVTNiAqOC/EqpMc/50O//0mweGNMmwATzHnoISIJk/A== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 035ebee8-f78a-4b01-c9b1-08db2025dd8f X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Mar 2023 22:38:40.7696 (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: GClMuK1e/aQr+ZT6pbEbgsGTlVaUdChxlvXBPMDUIvIlirMFs4/KVLNeawGWylG3BxjVtC5q7GSPvL4T90tKMCFwwrS7gxjICPNGZPVQk20= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR10MB4162 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-08_15,2023-03-08_03,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 bulkscore=0 phishscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2303080190 X-Proofpoint-GUID: szQIOuGevCnVBNChuTcwYQZYB4q2IOHb X-Proofpoint-ORIG-GUID: szQIOuGevCnVBNChuTcwYQZYB4q2IOHb 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 Reviewed-by: Darrick J. Wong --- 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 8224aed5f938..14a324bbcf59 100644 --- a/fs/xfs/xfs_xattr.c +++ b/fs/xfs/xfs_xattr.c @@ -234,6 +234,9 @@ xfs_xattr_put_listent( ASSERT(context->count >= 0); + if (flags & XFS_ATTR_PARENT) + return; + if (flags & XFS_ATTR_ROOT) { #ifdef CONFIG_XFS_POSIX_ACL if (namelen == SGI_ACL_FILE_SIZE && From patchwork Wed Mar 8 22:37:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 13166541 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 2456BC678D5 for ; Wed, 8 Mar 2023 22:38:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230154AbjCHWiv (ORCPT ); Wed, 8 Mar 2023 17:38:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35854 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230034AbjCHWir (ORCPT ); Wed, 8 Mar 2023 17:38:47 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F376D59811 for ; Wed, 8 Mar 2023 14:38:46 -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 328JwfA5021962 for ; Wed, 8 Mar 2023 22:38:46 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=osx2BRmek3LOfWl8WanI4Tp+HkrnP616x7FMcCq8FeI=; b=GMrTI/7sWBtNLWCCe6mltzc0jglbU70125w4kYnqxmX0d+hoBfwYpJmjEFwoCla2EE0U LKZ4/LdQUEB3erTnbFAMNf6X87D9X0Q7t2dzvpwumyWEK7JPfi7LDxc6LkzkgLHXwwkq 9R2t12AyFoNbTJjht9cphjiAZFpIE2R/WAwA/NVuggqMRl0iidieSO6ffd+S26t83zSh Hay/ye83Safz1q/dlTH9TAP11dgKLSHaBIVMjVXjcjfn0tLZN/ts68lGrvhbeQMqgVzy xM8/Le+Rsa4F7mnPMEjJx2bKmZViNAmV9yIAApwKq53N024YVvpXGvJ5U/fo/hv1Mp/T BQ== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3p4168se0y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 08 Mar 2023 22:38:45 +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 328LqwPE020912 for ; Wed, 8 Mar 2023 22:38:44 GMT Received: from nam02-bn1-obe.outbound.protection.outlook.com (mail-bn1nam02lp2049.outbound.protection.outlook.com [104.47.51.49]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3p6fu8my6f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 08 Mar 2023 22:38:44 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FT2G16gDdl/HPiW+sQx0kqRsv8ngD4KSkKTxUxwyAfYrUYLzl8rt+c08azsHq3IIDkIfEuRUgzz1HV5swxYVNy8OyTtzlq1MHfWsUUNE+pG0hC7PzkuchTQ4RRw0HNwepUEW0vNZajmFGuwYWGDyrzGT3yxCoF+oeD1E4yL3KYIiPlnXiyzFBhDuqXhTZ8Z+nW/ab94UEYtgFWuCS7eQ7hjxUE+r3gMxVUYSYnHwdbbZ9Zvo+Y/ilAv5JkUQPxZ840VGM5EK3RmCRPnVZBfLblmecahAa3qNaeb99LiYOqmfDjKRW4HEkMf6ueqhCLx6vrh8H3ygB0eAhtcA6A0PjA== 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=osx2BRmek3LOfWl8WanI4Tp+HkrnP616x7FMcCq8FeI=; b=MEwGdrEpnuk/m+NE1Ph3ZZzpHrnNrnWLYwIqHF/hg9enR2IGKJFvxqaeyEhm3wZA2AELFwfL1rLAy6JJtM4jYJUx8R/8i5zHlexKt5TOgRKl1GzOMfkgTXo4qI5yruOcUmfcX49qeIN8q0osco7qxuheQ7hHh0fsse+xATLMyP/bTlYjjPkqT84KhlGUF5NxytI8aZR4MwG+nCF7ozlQi7LSPG2Q6xKZ+i/8aW/B9OdI07Qu8laWLYpuB8jZJUD4i6fCzGw+NC3NU7v6VEIAWvxPb8dsCiy249uPiDglZjtmtcwTXZF7eocxVePpsibOqRmwYzG/WgpO7OzigjgN3g== 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=osx2BRmek3LOfWl8WanI4Tp+HkrnP616x7FMcCq8FeI=; b=gDGnrzTl2focu45oa/RDfjw6jS5V4i+fCLkQUBkgofgnuWv7PgH3zKgqMiGfWqR6EPpRB08VKeE+63m6uqfvl3F020jDPujSlduobJRpNebr7pQuoWnLDYfzJ2yrzkQKE76UCNYxQTD07C18WQIieZ4OvmS155AoWYWYqk+Buqg= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by BY5PR10MB4162.namprd10.prod.outlook.com (2603:10b6:a03:20c::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.17; Wed, 8 Mar 2023 22:38:42 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::2a7c:497e:b785:dc06]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::2a7c:497e:b785:dc06%8]) with mapi id 15.20.6178.017; Wed, 8 Mar 2023 22:38:42 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v10 25/32] xfs: pass the attr value to put_listent when possible Date: Wed, 8 Mar 2023 15:37:47 -0700 Message-Id: <20230308223754.1455051-26-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230308223754.1455051-1-allison.henderson@oracle.com> References: <20230308223754.1455051-1-allison.henderson@oracle.com> X-ClientProxiedBy: PH8PR22CA0012.namprd22.prod.outlook.com (2603:10b6:510:2d1::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_|BY5PR10MB4162:EE_ X-MS-Office365-Filtering-Correlation-Id: d90f4146-237b-46a9-057b-08db2025de70 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: DfVx8pkv+pHMMbyO4k3lNaAusjBFN07l+sX0qUsusHsovFb7ORdm4iq5DEuABbbZ1lpKxX291UcMcRXy6vjEGB+PWkq30YgQ//kvMHXAmUm5yhM/hHDhvB/u1KVaN+/zSyeI7gMbJIr+Vp4vgf1sBy0lel/p46X1zrXNGecSolsVLFaw6LTxGLi7o/TbHex5rCgjpIMI2qEyKGgI8cyfPui2ITCBP8RFt/6eX5G+uC3d3+gSYQYX8FFHi9I1XHgfqTEBJlBaGRThif3u1XCb3+IJCXaiulgRZLx/Syxb/+yWYCu6uhvGJlJhP5y/UtYBQjV/MVwMbOJsOxhptjxGrzTJyj75w3J/PiLC3tpJvl/PnZkBnZ3imPY8F7Zi6Ynj4ccEv7fk33hWGuH+xO7ZQf6MzIo8AvytXOYG/4VzjtGSghJIOR//W5AKD+xonS1O/VDziW8HP9vySZv0cs8ftyeYaHWVYEnm3FnUM0xtr6EPXpfWD7vMyx3Q8uLHK4AmGbr65X4sOi12MPryNiTdSZjEeTezAEQihzbp+773ZWIinDAixlt1Sq4U2EXesJj8915Wl6B2qDJ91fn5Z1ObL7opA5DtlGl5RkzDsB1flp65TxhbdzST0/DAqGruNYrnjyZBf60eFoELQ/Dr16kjeA== 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)(376002)(346002)(136003)(39860400002)(366004)(451199018)(5660300002)(8936002)(8676002)(66946007)(66556008)(86362001)(66476007)(36756003)(478600001)(83380400001)(316002)(41300700001)(6486002)(6916009)(2906002)(186003)(38100700002)(6512007)(26005)(9686003)(6506007)(1076003)(2616005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-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0Oq98OP3QXmtmNRcIoFwiHt6XLS7365HZbcxmugtBEBe9qBYX4yOyFOCtDm0NMnbvLZlUDU5nm1xXNYPP6+MqceNh9TMSB/zu+8Z5EEMmTXsgZRkbmVKwHuiO5h91Lk2Lvqy3e0ms1zjizfIxTJueJqNnHfkb5f/P9juSPQ70DUGfwnPNbV16Kjah+My82i9W9/eGxwwWhtUDBDYxjouxpoWi4pX8suI5aaXKvppKT8im7SMGypRh301K9oEHsjmoQiHlaBVkSeXsTlr2YrJaIsTKDHbWdFrkC6sQRCu6vF/heHUTYCU3mW4epVc5oshF4Evxhjaahyh0voAhxRprYVjtYsyVIfUd9c4wDWQrz4g== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: d90f4146-237b-46a9-057b-08db2025de70 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Mar 2023 22:38:42.2706 (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: 8teGICxCVE9EiD3k8Tq0lnQioxdi7PQxGIiGzCioBivIWcVTIbn8CIm7A7Ss6o7xtQAtlNXxO7UtPzFCOlfVDx+Js10gn09F5HclCylimxc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR10MB4162 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-08_15,2023-03-08_03,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 adultscore=0 phishscore=0 suspectscore=0 malwarescore=0 spamscore=0 bulkscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2303080190 X-Proofpoint-GUID: TjUwU660M8xXIl4c8qVVpvEsknFOJctt X-Proofpoint-ORIG-GUID: TjUwU660M8xXIl4c8qVVpvEsknFOJctt Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Allison Henderson Pass the attr value to put_listent when we have local xattrs or shortform xattrs. Signed-off-by: Darrick J. Wong Signed-off-by: Allison Henderson --- fs/xfs/libxfs/xfs_attr.h | 5 +++-- fs/xfs/libxfs/xfs_attr_sf.h | 1 + fs/xfs/scrub/attr.c | 8 ++++++++ fs/xfs/xfs_attr_list.c | 8 +++++++- fs/xfs/xfs_ioctl.c | 1 + fs/xfs/xfs_xattr.c | 1 + 6 files changed, 21 insertions(+), 3 deletions(-) diff --git a/fs/xfs/libxfs/xfs_attr.h b/fs/xfs/libxfs/xfs_attr.h index 985761264d1f..b034cc165274 100644 --- a/fs/xfs/libxfs/xfs_attr.h +++ b/fs/xfs/libxfs/xfs_attr.h @@ -47,8 +47,9 @@ struct xfs_attrlist_cursor_kern { /* void; state communicated via *context */ -typedef void (*put_listent_func_t)(struct xfs_attr_list_context *, int, - unsigned char *, int, int); +typedef void (*put_listent_func_t)(struct xfs_attr_list_context *context, + int flags, unsigned char *name, int namelen, void *value, + int valuelen); struct xfs_attr_list_context { struct xfs_trans *tp; diff --git a/fs/xfs/libxfs/xfs_attr_sf.h b/fs/xfs/libxfs/xfs_attr_sf.h index 37578b369d9b..c6e259791bc3 100644 --- a/fs/xfs/libxfs/xfs_attr_sf.h +++ b/fs/xfs/libxfs/xfs_attr_sf.h @@ -24,6 +24,7 @@ typedef struct xfs_attr_sf_sort { uint8_t flags; /* flags bits (see xfs_attr_leaf.h) */ xfs_dahash_t hash; /* this entry's hash value */ unsigned char *name; /* name value, pointer into buffer */ + void *value; } xfs_attr_sf_sort_t; #define XFS_ATTR_SF_ENTSIZE_MAX /* max space for name&value */ \ diff --git a/fs/xfs/scrub/attr.c b/fs/xfs/scrub/attr.c index 2a79a13cb600..00682006d0d3 100644 --- a/fs/xfs/scrub/attr.c +++ b/fs/xfs/scrub/attr.c @@ -109,6 +109,7 @@ xchk_xattr_listent( int flags, unsigned char *name, int namelen, + void *value, int valuelen) { struct xchk_xattr *sx; @@ -134,6 +135,13 @@ xchk_xattr_listent( return; } + /* + * Shortform and local attrs don't require external lookups to retrieve + * the value, so there's nothing else to check here. + */ + if (value) + return; + /* * Try to allocate enough memory to extrat the attr value. If that * doesn't work, we overload the seen_enough variable to convey diff --git a/fs/xfs/xfs_attr_list.c b/fs/xfs/xfs_attr_list.c index a51f7f13a352..8e3891b96736 100644 --- a/fs/xfs/xfs_attr_list.c +++ b/fs/xfs/xfs_attr_list.c @@ -94,6 +94,7 @@ xfs_attr_shortform_list( sfe->flags, sfe->nameval, (int)sfe->namelen, + &sfe->nameval[sfe->namelen], (int)sfe->valuelen); /* * Either search callback finished early or @@ -139,6 +140,7 @@ xfs_attr_shortform_list( sbp->name = sfe->nameval; sbp->namelen = sfe->namelen; /* These are bytes, and both on-disk, don't endian-flip */ + sbp->value = &sfe->nameval[sfe->namelen], sbp->valuelen = sfe->valuelen; sbp->flags = sfe->flags; sfe = xfs_attr_sf_nextentry(sfe); @@ -189,6 +191,7 @@ xfs_attr_shortform_list( sbp->flags, sbp->name, sbp->namelen, + sbp->value, sbp->valuelen); if (context->seen_enough) break; @@ -443,6 +446,7 @@ xfs_attr3_leaf_list_int( */ for (; i < ichdr.count; entry++, i++) { char *name; + void *value; int namelen, valuelen; if (be32_to_cpu(entry->hashval) != cursor->hashval) { @@ -460,6 +464,7 @@ xfs_attr3_leaf_list_int( name_loc = xfs_attr3_leaf_name_local(leaf, i); name = name_loc->nameval; namelen = name_loc->namelen; + value = &name_loc->nameval[name_loc->namelen]; valuelen = be16_to_cpu(name_loc->valuelen); } else { xfs_attr_leaf_name_remote_t *name_rmt; @@ -467,6 +472,7 @@ xfs_attr3_leaf_list_int( name_rmt = xfs_attr3_leaf_name_remote(leaf, i); name = name_rmt->name; namelen = name_rmt->namelen; + value = NULL; valuelen = be32_to_cpu(name_rmt->valuelen); } @@ -475,7 +481,7 @@ xfs_attr3_leaf_list_int( entry->flags))) return -EFSCORRUPTED; context->put_listent(context, entry->flags, - name, namelen, valuelen); + name, namelen, value, valuelen); if (context->seen_enough) break; cursor->offset++; diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c index 59987b95201c..9abf47efd076 100644 --- a/fs/xfs/xfs_ioctl.c +++ b/fs/xfs/xfs_ioctl.c @@ -307,6 +307,7 @@ xfs_ioc_attr_put_listent( int flags, unsigned char *name, int namelen, + void *value, int valuelen) { struct xfs_attrlist *alist = context->buffer; diff --git a/fs/xfs/xfs_xattr.c b/fs/xfs/xfs_xattr.c index 14a324bbcf59..b92fc38bd550 100644 --- a/fs/xfs/xfs_xattr.c +++ b/fs/xfs/xfs_xattr.c @@ -227,6 +227,7 @@ xfs_xattr_put_listent( int flags, unsigned char *name, int namelen, + void *value, int valuelen) { char *prefix; From patchwork Wed Mar 8 22:37:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 13166543 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 83BDBC64EC4 for ; Wed, 8 Mar 2023 22:38:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230221AbjCHWix (ORCPT ); Wed, 8 Mar 2023 17:38:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36036 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229929AbjCHWiv (ORCPT ); Wed, 8 Mar 2023 17:38:51 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3B5685ADF9 for ; Wed, 8 Mar 2023 14:38:49 -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 328JwgsP007266 for ; Wed, 8 Mar 2023 22:38:48 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=/8yCf80a3UVJE56blLxnuFxp/oVL5re5hI1WSsPMdDY=; b=UuZ5wnbuTWPBV+G47/k32pw21z5/+8wCwXezqHWTw4PEW2EcHLtWXTtAXKLy4ARys4N8 HfLy+8GI1BJLOJnpf5OWtbGMN2hJGPCvVPwyd6NAuE1l4cONxuHY78IoUnEu/yns+i39 mtimxJGsw/22o4GZcaQILGrdTk4tWS9Q6MB8Pz04OCOhM3D8eJXy/JHOybtqDfSOTkCl p2S2dghtg+z+DnKqCvdpWHIVOHebyRoWl6NpABJI0PUrpjFO/KueSXE2h6URYVMCKdD9 FlkO3B+DaevFlla1eGANkylnIG+hGI6mRmzzyRw7wNkoUl+OnhkOT+c+LAMsuQZ9L/AH zg== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3p415j1fc0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 08 Mar 2023 22:38:48 +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 328MNwmL026505 for ; Wed, 8 Mar 2023 22:38:46 GMT Received: from nam02-bn1-obe.outbound.protection.outlook.com (mail-bn1nam02lp2040.outbound.protection.outlook.com [104.47.51.40]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3p6g9uc28k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 08 Mar 2023 22:38:46 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Yb65lNEj2QGWQvvoa6grZ07r2WrXRXD6nqZxYOfxPzjy+lncpz/ypBhAoXNwLbnErcPkY4MmU8d73nUZqQCxwwhEMmtG7RqtjRgIC7z4uDo1wm6V5zfGNVWnwWIJWnfwKVh6bFHkfHLtW94X5nXnmetBmqq3sOSEcKjASUp4iDLnuQ2WFvKKGfJzdJsSSfUvSuPv4LnU9yS2iG2ttCgIQN5BK4LZpE4hWw27FpiwmGlYf5eKFoalonzM6Og+y1w/PlKhSiEZNdKQTTxuomJgXBBUPZm9jCH7i4l16vpwvMVs3kxXc9sObGqz3WrrvZn0MCxGos7o6dockiuxJmZNBg== 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=/8yCf80a3UVJE56blLxnuFxp/oVL5re5hI1WSsPMdDY=; b=AcDdBohE1oW4hI01pX1rKykEdqLm4n+FeT9mLI5H9IB1zX3VKsh7lZq41e+srXXRr6fAEfVrFdkAqNvqk5Bot0yKDX6FIurqJZHsz4zD9oWNSznW5cwUarw8FQ4D+JO0gyAvPLSFdumCPjB735vcha+zQv4JhpJozZBbw87cytLQs/eT8Dvs/JReHfYM+Tyel8GU09pkYKDD6S3x/OEzFLJLL2tq9hiEhwAtQobsHEvvNPaWjGlV2i6bz0HAtqJy3c9uv+KCWUJMLR99jKUGV+8hMSwACWnfmERbAw6jNAxJV0E0ZpfW4EufLLQO0mLJMmmzmX/bbWa9CFf8Ves9OA== 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=/8yCf80a3UVJE56blLxnuFxp/oVL5re5hI1WSsPMdDY=; b=Azwt1e4xMEaNQfsLX8EWHO83ikpwq5sCZk0VyDjccmKgr17aYtY4zPcmuDblF0E1qtpUg5uYtv5NPVgwHsjyr4wlp61QfHh5sxJBu844y4WXaw0g+HzmIgwgQzn/INb/fRTL2SPM7Unf+94MnnegeEvx47AQY9mgl0eow+uGyhY= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by BY5PR10MB4162.namprd10.prod.outlook.com (2603:10b6:a03:20c::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.17; Wed, 8 Mar 2023 22:38:44 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::2a7c:497e:b785:dc06]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::2a7c:497e:b785:dc06%8]) with mapi id 15.20.6178.017; Wed, 8 Mar 2023 22:38:44 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v10 26/32] xfs: Add parent pointer ioctl Date: Wed, 8 Mar 2023 15:37:48 -0700 Message-Id: <20230308223754.1455051-27-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230308223754.1455051-1-allison.henderson@oracle.com> References: <20230308223754.1455051-1-allison.henderson@oracle.com> X-ClientProxiedBy: PH0PR07CA0103.namprd07.prod.outlook.com (2603:10b6:510:4::18) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY5PR10MB4306:EE_|BY5PR10MB4162:EE_ X-MS-Office365-Filtering-Correlation-Id: f1f2d5e3-3981-4ffb-21e3-08db2025dfb9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: UhsdVT+AiSjswGmXjgSokGMgo8oeE+1JabhgT5kBf0RCgsMFRgeH9tEtsBPb8HRqAK5tuCDmH33HygoCTpWj9dnH7HtEBc7K8HXGW2XnDFyQxxutUfZHh/Dr1m7J6jbE23cfXopRxWSyk9qxYYjI+ve8EeGLEZeMDLrTdgZlyUo+IwvOsuNtqxdqOk2om3QHJVesiw7FU55GgMt/lxG4OOJvk2IMAUzF9pYvGxG3iDlGs7LlOdvGvfOUBTiWKefmnrHbu7PQYopMB6+ZEY6Z6PudpvKeodj/AeTcy9HJkavDQcHlzSpH7LW5aXVM5Yati3BIy580TRRK/XV/2W6Hk1fAawiZ2sqckKisTa11LaljecK2mntmjVCqDL6iwSV0+qvbrg9OZs55HvLgVjkHxK4Ek6MvB9QcRf3BTh0AHqnitGw3HMgOX/QOMUvG8+KCeUcGrymePsHrJjvAqbEyahnvXDzAh0dmq2y4Q1WrUifoCNPQisrGTOdqEGL68/3yuQOg31YhRGbRjvE1n3CpcItrPT7iVujggp+cL9k3NtZqDaGI54ki7urN0mXjsdoYqhBhPVGb4ZoyIMfdi8LumAzSfxLyAUkn0O1IRkItNtrBHiGGf7sY29DKaAL76v+PwwREwV9EtM1VMcMQigh64A== 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)(376002)(346002)(136003)(39860400002)(366004)(451199018)(5660300002)(8936002)(8676002)(66946007)(66556008)(86362001)(66476007)(36756003)(478600001)(83380400001)(316002)(41300700001)(6486002)(6916009)(2906002)(186003)(38100700002)(6512007)(26005)(9686003)(6506007)(1076003)(2616005)(30864003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: XVttGJLVRcdEXdajyjppM/WzNTLIUcNrbn+s7XQz66ELag86vVI+Y96y9ldQcav1HFuuo5n1THYCuHmr6hEp+1nAz9U2URSms2ZMAiPKctJ5r5zDQOKsQsvpC9hE3BJJes2M6tdOl+HbHBHLrHOe5MYYXIXjraE6KCeYdFs8no64z3/u/GPFjp/zW9+TkE1om8HZecUO9hnE2tIcw7RloM0guG8+q2TUy9nWx/h16LtJi7vJEbJzlFH33jGJs/8s+9iiOBnhQaGG1U50Iw7AKvo3bSw+WuNI+5t1gtcj5/48u3GMhMlD6jjzy/yrGS3rdJqMct0ynh2qYpcZr44g8+IU7AZK7J//n5OgsBgXZh014mmPCggGuGucBo29SfbMTG2pIpl7DtXqMkEFj/W2NCymc/IWaFapMzbh3Vj5iChtbHY+ceJROEm8CiM0b+B2phWV384PlwDWl05mFs9ZvweqD0i410IvzzWNPV0MvL8jALyY1BON7F+keL6t1V6canmEn5lRjOK4Ht1fU3Ki4iJ+uO8/eht2JFXhNxU69baaI5NrvuQHqYxxa2w51lS75LlciO1BYA0kqvEdIHjpjF9l/NIMmcbqDmFPvrcWkLPEJpraDMBQf1W37lw+WgArZHPqy1GcNvoLFhU//jdW38RBScSpWnNi+hLE1LEBmOp7yIXrC9oop9MNP7pVj0Su72703pJe03J72mswN7gbmo1ZlajO/oeEpvsgZzvjqXsZISly5Nf6nyEvXaENetMfW1IToVdMoi0nKPkvq/Smbh2eDW+qdTMWJ+53gy+85wG3C8lLSmA/kwAWJxIW59VjBsvUiwb7u7nepUx3cVrAXLDbKHR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z1KLxDWOVHwyMpZFZdZ/filhGlMP8JNb1dvyv2DF3VajHVVf+Llk6GrODBn7w7wZLXNm+UURhvEvWPUujrPFP6jMWhJ+H5tMiyrUFTtAtRAEKr7EmE9Ft0q8N3c06a/7np0d3K+FVksHJEymW4Z+xkk+VYULcBZb43kSDapwDVgS2snJhB/BWc02j40UNbaYEpgMk3q/xsdQcdZW9X/kRTZCpqLnxc+tbvtU/vldAwS537hvODlPu+o+R5muHcsIUweSwORW23KJkTKclhSOSci9//gaDT/uxvXNG2RpBZOSNK0osfCkghLDAqVUVqPNExLGZ/chatMB0IOSxNNplwzYZIUIw91Sc53FOc8Di5VeiW3bktm01LeSyrtSLttDrQiuXsmF3eGL62I4G2UDAKTp3BzR0mrNIHu0i2QQzhvSn8ldg0FgFeFmDDP8BTp6gYiPxGrbFOskauGeBGKsGiWpJ3/OoqCq4vybPIf4EdZ4Yye6OOmtdyzEVjvqYwu5A0w37Ku9X3oQw6i9I7+V9Ugidq3m950hXrGUBK4u2W+EUCcAZQ8wMw== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: f1f2d5e3-3981-4ffb-21e3-08db2025dfb9 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Mar 2023 22:38:44.3963 (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: l5XM7JES4eOXKz431kQsylNZ5lLDiS4pg8tHiH8U7zhVonk/J459FfySFAhUqkXv5h3Uhsz/vU7vK89rTqhtVkX2iLrrMxGZ+RhRB+J1P2w= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR10MB4162 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-08_15,2023-03-08_03,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 mlxlogscore=999 adultscore=0 bulkscore=0 spamscore=0 malwarescore=0 mlxscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2303080190 X-Proofpoint-GUID: qPh_u6Mqi5kG_i37-TVRYjEj5UnX4DXZ X-Proofpoint-ORIG-GUID: qPh_u6Mqi5kG_i37-TVRYjEj5UnX4DXZ 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 Reviewed-by: Darrick J. Wong Signed-off-by: Allison Henderson --- fs/xfs/Makefile | 1 + fs/xfs/libxfs/xfs_fs.h | 70 +++++++++++++++++ fs/xfs/libxfs/xfs_parent.c | 30 ++++++++ fs/xfs/libxfs/xfs_parent.h | 19 +++++ fs/xfs/xfs_ioctl.c | 135 +++++++++++++++++++++++++++++++- fs/xfs/xfs_ondisk.h | 4 + fs/xfs/xfs_parent_utils.c | 154 +++++++++++++++++++++++++++++++++++++ fs/xfs/xfs_parent_utils.h | 20 +++++ 8 files changed, 432 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..0db0c8fc5359 100644 --- a/fs/xfs/libxfs/xfs_fs.h +++ b/fs/xfs/libxfs/xfs_fs.h @@ -752,6 +752,75 @@ 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[]; /* 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; + + /* size of the trailing buffer in bytes */ + __u32 pi_ptrs_size; + + /* # of entries filled in (output) */ + __u32 pi_count; + + /* Must be set to zero */ + __u64 pi_reserved2[5]; + + /* Byte offset of each record within the buffer */ + __u32 pi_offsets[]; +}; + +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 (struct xfs_parent_ptr *)((char *)info + info->pi_offsets[idx]); +} + /* * ioctl limits */ @@ -797,6 +866,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..cc3640be15d9 100644 --- a/fs/xfs/libxfs/xfs_parent.c +++ b/fs/xfs/libxfs/xfs_parent.c @@ -61,6 +61,36 @@ xfs_init_parent_name_rec( rec->p_diroffset = cpu_to_be32(p_diroffset); } +/* + * Convert an ondisk parent_name xattr to its incore format. If @value is + * NULL, set @irec->p_namelen to zero and leave @irec->p_name untouched. + */ +void +xfs_parent_irec_from_disk( + struct xfs_parent_name_irec *irec, + const struct xfs_parent_name_rec *rec, + const void *value, + int valuelen) +{ + irec->p_ino = be64_to_cpu(rec->p_ino); + irec->p_gen = be32_to_cpu(rec->p_gen); + irec->p_diroffset = be32_to_cpu(rec->p_diroffset); + + if (!value) { + irec->p_namelen = 0; + return; + } + + ASSERT(valuelen > 0); + ASSERT(valuelen < MAXNAMELEN); + + valuelen = min(valuelen, MAXNAMELEN); + + irec->p_namelen = valuelen; + memcpy(irec->p_name, value, valuelen); + memset(&irec->p_name[valuelen], 0, sizeof(irec->p_name) - valuelen); +} + int __xfs_parent_init( struct xfs_mount *mp, diff --git a/fs/xfs/libxfs/xfs_parent.h b/fs/xfs/libxfs/xfs_parent.h index 039005883bb6..c14da6418e58 100644 --- a/fs/xfs/libxfs/xfs_parent.h +++ b/fs/xfs/libxfs/xfs_parent.h @@ -8,6 +8,25 @@ extern struct kmem_cache *xfs_parent_intent_cache; +/* + * Incore version of a parent pointer, also contains dirent name so callers + * can pass/obtain all the parent pointer information in a single structure + */ +struct xfs_parent_name_irec { + /* Key fields for looking up a particular parent pointer. */ + xfs_ino_t p_ino; + uint32_t p_gen; + xfs_dir2_dataptr_t p_diroffset; + + /* Attributes of a parent pointer. */ + uint8_t p_namelen; + unsigned char p_name[MAXNAMELEN]; +}; + +void xfs_parent_irec_from_disk(struct xfs_parent_name_irec *irec, + const struct xfs_parent_name_rec *rec, + const void *value, int valuelen); + /* * Dynamically allocd structure used to wrap the needed data to pass around * the defer ops machinery diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c index 9abf47efd076..f34396fb2e88 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 @@ -1676,6 +1677,137 @@ 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_count. + * + * 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 *file_ip = XFS_I(file_inode(filp)); + struct xfs_inode *call_ip = file_ip; + struct xfs_mount *mp = file_ip->i_mount; + void __user *o_pptr; + struct xfs_parent_ptr *i_pptr; + unsigned int bytes; + + if (!capable(CAP_SYS_ADMIN)) + return -EPERM; + + /* Allocate an xfs_pptr_info to put the user data */ + ppi = kvmalloc(sizeof(struct xfs_pptr_info), GFP_KERNEL); + 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 (ppi->pi_ptrs_size > XFS_XATTR_LIST_MAX) { + error = -ENOMEM; + goto out; + } + if (ppi->pi_ptrs_size < sizeof(struct xfs_pptr_info)) { + error = -EINVAL; + 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 = kvrealloc(ppi, sizeof(struct xfs_pptr_info), + xfs_pptr_info_sizeof(ppi->pi_ptrs_size), + GFP_KERNEL | __GFP_ZERO); + if (!ppi) + return -ENOMEM; + + if (ppi->pi_flags & XFS_PPTR_IFLAG_HANDLE) { + struct xfs_handle *hanp = &ppi->pi_handle; + + if (memcmp(&hanp->ha_fsid, mp->m_fixedfsid, + sizeof(xfs_fsid_t))) { + error = -EINVAL; + goto out; + } + + if (hanp->ha_fid.fid_ino != file_ip->i_ino) { + error = xfs_iget(mp, NULL, hanp->ha_fid.fid_ino, + XFS_IGET_UNTRUSTED, 0, &call_ip); + if (error) + goto out; + } + + if (VFS_I(call_ip)->i_generation != hanp->ha_fid.fid_gen) { + error = -EINVAL; + goto out; + } + } + + /* Get the parent pointers */ + error = xfs_getparent_pointers(call_ip, ppi); + if (error) + goto out; + + /* + * If we ran out of buffer space before copying any parent pointers at + * all, the caller's buffer was too short. Tell userspace that, erm, + * the message is too long. + */ + if (ppi->pi_count == 0 && !(ppi->pi_flags & XFS_PPTR_OFLAG_DONE)) { + error = -EMSGSIZE; + goto out; + } + + /* Copy the parent pointer head back to the user */ + bytes = xfs_getparents_arraytop(ppi, ppi->pi_count); + error = copy_to_user(arg, ppi, bytes); + if (error) { + error = -EFAULT; + goto out; + } + + if (ppi->pi_count == 0) + goto out; + + /* Copy the parent pointer records back to the user. */ + o_pptr = (__user char*)arg + ppi->pi_offsets[ppi->pi_count - 1]; + i_pptr = xfs_ppinfo_to_pp(ppi, ppi->pi_count - 1); + bytes = ((char *)ppi + ppi->pi_ptrs_size) - (char *)i_pptr; + error = copy_to_user(o_pptr, i_pptr, bytes); + if (error) { + error = -EFAULT; + goto out; + } + +out: + if (call_ip != file_ip) + xfs_irele(call_ip); + kvfree(ppi); + return error; +} + int xfs_ioc_swapext( xfs_swapext_t *sxp) @@ -1965,7 +2097,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..829bee58fc63 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, 24); + XFS_CHECK_STRUCT_SIZE(struct xfs_pptr_info, 96); + /* * 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..9c1c866346eb --- /dev/null +++ b/fs/xfs/xfs_parent_utils.c @@ -0,0 +1,154 @@ +// 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" + +struct xfs_getparent_ctx { + struct xfs_attr_list_context context; + struct xfs_parent_name_irec pptr_irec; + struct xfs_pptr_info *ppi; +}; + +static inline unsigned int +xfs_getparents_rec_sizeof( + const struct xfs_parent_name_irec *irec) +{ + return round_up(sizeof(struct xfs_parent_ptr) + irec->p_namelen + 1, + sizeof(uint32_t)); +} + +static void +xfs_getparent_listent( + struct xfs_attr_list_context *context, + int flags, + unsigned char *name, + int namelen, + void *value, + int valuelen) +{ + struct xfs_getparent_ctx *gp; + struct xfs_pptr_info *ppi; + struct xfs_parent_ptr *pptr; + struct xfs_parent_name_irec *irec; + struct xfs_mount *mp = context->dp->i_mount; + int arraytop; + + gp = container_of(context, struct xfs_getparent_ctx, context); + ppi = gp->ppi; + irec = &gp->pptr_irec; + + /* Ignore non-parent xattrs */ + if (!(flags & XFS_ATTR_PARENT)) + return; + + /* + * Report corruption for xattrs with any other flag set, or for a + * parent pointer that has a remote value. The attr list functions + * filtered any INCOMPLETE attrs for us. + */ + if (XFS_IS_CORRUPT(mp, + hweight32(flags & XFS_ATTR_NSP_ONDISK_MASK) > 1) || + XFS_IS_CORRUPT(mp, value == NULL)) { + context->seen_enough = -EFSCORRUPTED; + return; + } + + xfs_parent_irec_from_disk(&gp->pptr_irec, (void *)name, value, + valuelen); + + /* + * We found a parent pointer, but we've filled up the buffer. Signal + * to the caller that we did /not/ reach the end of the parent pointer + * recordset. + */ + arraytop = xfs_getparents_arraytop(ppi, ppi->pi_count + 1); + context->firstu -= xfs_getparents_rec_sizeof(irec); + if (context->firstu < arraytop) { + context->seen_enough = 1; + return; + } + + /* Format the parent pointer directly into the caller buffer. */ + ppi->pi_offsets[ppi->pi_count] = context->firstu; + pptr = xfs_ppinfo_to_pp(ppi, ppi->pi_count); + pptr->xpp_ino = irec->p_ino; + pptr->xpp_gen = irec->p_gen; + pptr->xpp_diroffset = irec->p_diroffset; + pptr->xpp_rsvd = 0; + + memcpy(pptr->xpp_name, irec->p_name, irec->p_namelen); + pptr->xpp_name[irec->p_namelen] = 0; + ppi->pi_count++; +} + +/* Retrieve the parent pointers for a given inode. */ +int +xfs_getparent_pointers( + struct xfs_inode *ip, + struct xfs_pptr_info *ppi) +{ + struct xfs_getparent_ctx *gp; + int error; + + gp = kzalloc(sizeof(struct xfs_getparent_ctx), GFP_KERNEL); + if (!gp) + return -ENOMEM; + gp->ppi = ppi; + gp->context.dp = ip; + gp->context.resynch = 1; + gp->context.put_listent = xfs_getparent_listent; + gp->context.bufsize = round_down(ppi->pi_ptrs_size, sizeof(uint32_t)); + gp->context.firstu = gp->context.bufsize; + + /* Copy the cursor provided by caller */ + memcpy(&gp->context.cursor, &ppi->pi_cursor, + sizeof(struct xfs_attrlist_cursor)); + ppi->pi_count = 0; + + error = xfs_attr_list(&gp->context); + if (error) + goto out_free; + if (gp->context.seen_enough < 0) { + error = gp->context.seen_enough; + goto out_free; + } + + /* Is this the root directory? */ + if (ip->i_ino == ip->i_mount->m_sb.sb_rootino) + ppi->pi_flags |= XFS_PPTR_OFLAG_ROOT; + + /* + * If we did not run out of buffer space, then we reached the end of + * the pptr recordset, so set the DONE flag. + */ + if (gp->context.seen_enough == 0) + ppi->pi_flags |= XFS_PPTR_OFLAG_DONE; + + /* Update the caller with the current cursor position */ + memcpy(&ppi->pi_cursor, &gp->context.cursor, + sizeof(struct xfs_attrlist_cursor)); +out_free: + kfree(gp); + return error; +} + diff --git a/fs/xfs/xfs_parent_utils.h b/fs/xfs/xfs_parent_utils.h new file mode 100644 index 000000000000..d79197f23c40 --- /dev/null +++ b/fs/xfs/xfs_parent_utils.h @@ -0,0 +1,20 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2022 Oracle, Inc. + * All rights reserved. + */ +#ifndef __XFS_PARENT_UTILS_H__ +#define __XFS_PARENT_UTILS_H__ + +static inline unsigned int +xfs_getparents_arraytop( + const struct xfs_pptr_info *ppi, + unsigned int nr) +{ + return sizeof(struct xfs_pptr_info) + + (nr * sizeof(ppi->pi_offsets[0])); +} + +int xfs_getparent_pointers(struct xfs_inode *ip, struct xfs_pptr_info *ppi); + +#endif /* __XFS_PARENT_UTILS_H__ */ From patchwork Wed Mar 8 22:37:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 13166544 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 1A370C678D5 for ; Wed, 8 Mar 2023 22:38:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229929AbjCHWiy (ORCPT ); Wed, 8 Mar 2023 17:38:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36122 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230076AbjCHWiw (ORCPT ); Wed, 8 Mar 2023 17:38:52 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 98C1969CFB for ; Wed, 8 Mar 2023 14:38:49 -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 328Jwth4021240 for ; Wed, 8 Mar 2023 22:38:48 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=FMFZzNlUciC1q1tDNsOHAP4N8Beas64UvkLAnDU8CdgNHCIPGL+P0FFVMbI9koW0vc+o H6sLro2fbW3GWiAxjNILfOUeWvwcPOLuw5UH7mkyTdLImOkqdUpVnTLyv3T2cx0GuQmr MOvuZkVLxS4U27YnoECz/OhdlC3I/aCfS4cl2gbnHuedK9fff7Mx5Oblu21yHjtQGKd+ +MnmdFyzogFxum6VTNhVbpkbff4kLZsQa9voe3rc68ibXrDhxVsmda4qNEFSfYKqgt5r iKgEehqYituOElrjgAycAckJwVNOIUVeoblxA6iD1cJTApEGEfdvgCGvBchDjhYjKqrY rg== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3p41811a3t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 08 Mar 2023 22:38:48 +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 328MNwmM026505 for ; Wed, 8 Mar 2023 22:38:47 GMT Received: from nam02-bn1-obe.outbound.protection.outlook.com (mail-bn1nam02lp2040.outbound.protection.outlook.com [104.47.51.40]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3p6g9uc28k-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 08 Mar 2023 22:38:47 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=odyH1fco0oL+IKFuAMnXGMSLePUOr0iR7aCZAB9vb1bMkL2RNdWnHkAZUkxGugljyHrWqTmKFeuH5bdzyOL/XhGKjMttavytz6balniKccIqhF85i6J2MAQcJP3Tqrw1OqVuWkdTo1AN+IfdznRBnWD3pFBEJXxPzphtUaQVZrcwFRO8nxc0y15VEc24GnAiOOGxSBrilO5BWyBwpwLPBx0HqW/px5Nh1TSNeum8s3nDJzRVaWbBIUStm27YFFkVbKQIDrII929M+eKV8bxW26X/5WoTkpnIBc7MZ/MPF4hhut62MCXn18x00uJO1wt14gTcHQA67gM8B0TSMCZsdQ== 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=T6Gr6fUeGcvorWTlaLBK8+BLRGaygZIzo5fmNIJC4acaJ+FG4CmEOY7TIyCkgZI72vyRzCzXA0dJwjchieFEtOG1KruAiTCYiZGvDTx+znrQ+dkb7hnQFienX1kyPevYxWJIf9IKht5pOaN7aO+ED3dDhYucXtfBY3KXBmmlhHMY+yCfL4WqvqpDhJvQpgT9hNS11TkLh5G9pGtOdvFCpDVVBvsSr+YH6SgBkc94HTp3nFVG07WH6OMrK4Vq4Jt0CeQ18LH1KF0/0AAp7PHaFKOiRC+cElqsUcE2or1hMEz+S8XQ4tjCVpH5kY3ks1cPwmLB3BnwQbe2rlTzRL82Zw== 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=NKPqnNbuD70unbe+wXCHAbdPB7oN8xopOkxWMo+OoAXDlSXmcqyj5EUd71WJJWvpboBTxhHxAzri4tpFOrxXcuVWYM48Ev+34lT9BnkpLKxom8VqUoqPvzYBm+j/qk6wo16ascBLfa/WcN4JjR7oPAZDQxO2CoI1pl7fdouwdjc= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by BY5PR10MB4162.namprd10.prod.outlook.com (2603:10b6:a03:20c::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.17; Wed, 8 Mar 2023 22:38:46 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::2a7c:497e:b785:dc06]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::2a7c:497e:b785:dc06%8]) with mapi id 15.20.6178.017; Wed, 8 Mar 2023 22:38:46 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v10 27/32] xfs: fix unit conversion error in xfs_log_calc_max_attrsetm_res Date: Wed, 8 Mar 2023 15:37:49 -0700 Message-Id: <20230308223754.1455051-28-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230308223754.1455051-1-allison.henderson@oracle.com> References: <20230308223754.1455051-1-allison.henderson@oracle.com> X-ClientProxiedBy: PH8PR22CA0006.namprd22.prod.outlook.com (2603:10b6:510:2d1::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_|BY5PR10MB4162:EE_ X-MS-Office365-Filtering-Correlation-Id: 42108495-d7ff-4fae-64c7-08db2025e0d7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QM58/DFG6m4KwdOUrVXV83WLS8tDfo4PKZ4qYH/jsCEt9FOyw0ZtbeX3BT0uKjygrqD8He7+0YLe7C0Nyd84ugIu1zdLnvK3Z3lFSRgOqnkDdTxSudwqeU80waeCp6upOCMdfjDsCTb8SRDC5qvEQH7XOfUEUF8PeXc0wtvdVBZa4u07P8h89vtfXJplBoW2v/BZG4TrpRTHfgjFO4PfJDYClKfEdjTmd2wsgQDdaJliOrYSUgdarmMJmQkbukFMOW2aPQ2hKNygMVvYcENXsa/B7Waq8SyvfBSS6e80aPQzPewF7HWIxF9wi+MhCipa82Znb+5A+ebkbZsvMISVqz2W23g0C/g2OHcyGr+HIu+56ih45WgxNvWgV6JsL09bec2i9CrAUKEkeOqrLUFv5dtzBBO/2pbmhqDhBwoFyH1czMLRMwBcjXt2FEj+SUOs093kRNTpJIJCvn+T5aJ8MjcqFivdKqLREp6gVMMqg/g5Ndon+5uiySDxQsDsy0mFen7WBRUDZaiSlD6dB+ZFdqcB06sXlB/Vv2qkeaPltV8X4XFO60A8K4+hh6PIS7uxEIpdsL2ncKCDzf36KNQEfI7NKz+gTTCBKRutlBwDPVFvgB0LJg6tiEwbPmtFSF2onuKNHMnVZ6kzj41rTSFrmQ== 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)(376002)(346002)(136003)(39860400002)(366004)(451199018)(5660300002)(8936002)(8676002)(66946007)(66556008)(86362001)(66476007)(36756003)(478600001)(83380400001)(316002)(41300700001)(6486002)(6916009)(2906002)(186003)(38100700002)(6512007)(26005)(9686003)(6506007)(1076003)(2616005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: c09ACDzT/YuesFTJibgY8dAhsCbk7W2Zhz67lthEx8najZGtidaiGcP/63EcpofC5M4Og8dPelARPVWG47ENU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UV0OO/ItH5PvP2C+KXHxlGE7amPTnItbYal6mOKycO6DvhVkJz2Ci0SKQGaoT4aNeWO2YdmiWlpN7vXE0zCQf5upt3LjAdf8n6SwYZZoYc1cDztnZSA3o5xCB7+LtcqzZ1QUSFOHMmlJEfyj+0bcrzxXbc4YB/1PMDBH0IROmHIflWlLQH/TcKaSS0Wtkkjcnp/kxIiJ8A33jF1+VPs1N9HYCfpOJZKr0aA8ajUCRYtn397cOqHpYWaSd5+SFuGQw== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 42108495-d7ff-4fae-64c7-08db2025e0d7 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Mar 2023 22:38:46.2398 (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: 2naAYrPuM7ORuzcvr2G1bDPoB/VtVtREWgYQrGzwRDUi/iBayQTIOaFCj6quqKyTRc1D/tVcx6dtqCnZbZD6VqBaJJGZLHcrwSGE9jNmJYA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR10MB4162 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-08_15,2023-03-08_03,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 mlxlogscore=999 adultscore=0 bulkscore=0 spamscore=0 malwarescore=0 mlxscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2303080190 X-Proofpoint-ORIG-GUID: fL0u5IikXKynuFUZNaAQRjbj0jrT9qO3 X-Proofpoint-GUID: fL0u5IikXKynuFUZNaAQRjbj0jrT9qO3 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 Wed Mar 8 22:37:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 13166542 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 42D4BC6FD19 for ; Wed, 8 Mar 2023 22:38:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229525AbjCHWiy (ORCPT ); Wed, 8 Mar 2023 17:38:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36146 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230206AbjCHWix (ORCPT ); Wed, 8 Mar 2023 17:38:53 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2189A62FE7 for ; Wed, 8 Mar 2023 14:38:52 -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 328JxoOm009767 for ; Wed, 8 Mar 2023 22:38:51 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=p7wNHHtIZ6iIbr7THThQOdm/+O8hfvRf1n2WwIrdvNEhYf2j5eB3JskrVu2ivbD97Z9q VMTaG+Cmh62UJ8Fobs3FPVPm69KFJeBLCJ2aP786yL6LbI1tMnhhL+lTHI1PnFZbqTse YMbo5innJ/rT8Eut7IGJJk3eVFCAw8Zma2Tc0xZahtYlajOX6qwr6XilbnW3VD1SEo52 vFarKB5VUeD441bDpTrQkxHscaIZPeqdUh5UPDRYeDGaTUZHqgeAP7lYXVaEtsCpYj+D K2L0TUC3s8FQOudzLf7gbwde3QoSpm3zW+ev3K9n6vBXtttud3nrSy1dZgZyHLWoz+J0 jw== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3p41621a5q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 08 Mar 2023 22:38:51 +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 328LRn5A022428 for ; Wed, 8 Mar 2023 22:38:50 GMT Received: from nam02-bn1-obe.outbound.protection.outlook.com (mail-bn1nam02lp2049.outbound.protection.outlook.com [104.47.51.49]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3p6fr9dx77-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 08 Mar 2023 22:38:50 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dE6aSVPqfDIfwEm1bnwZ53HB4g8IKq95qHf4kfrqaHGQLXJbXc+aupTXNyaIcHGAJefZDqRdhdCMOE+ylc1U0DS1AvWh9Nx9w4EmjmVqEp94tDoU/9uTyY7GyCCZjM+3mL0EheUaBZEY4Xdv4r5ZV47mS2rw2M0lGePd/aA8Fwz+MlyatO4FsSzPFT2dixdiyAfLOwtAV8Bg0tSzyYGITWPjFvJ9H1Hj5RMFkxeVhLx2I83GXac9UdpeoYwRCW49x370RAK7t23UYoW2mNnf3D0AQdIzc/zsU+R/FY6rn6Any7ex6f0ZrxTlw9Zbd+UoqccYNemMk+0pDhUbgb8ReQ== 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=lJkUV77i+kjKg7+7DpzD4bL5+wZtWYIFrHQXI+Mq9whVSkS/9XNWjSUWxwQSGl/9KzxRdWxA9584Dq1GSzvDV6bNMUO5yaLmpdlqPcayTMMvF6FlezYqFlqPbq6W7Bq3sroOc6RhHEMr+YY620b/ezcCw7TC5PjZF8HqZns7Z2uXwwV9aydbKr6ch20yvN/IAjN9QBOD5t1lkznVLb8vefEtD2Jm0GgvfqeRppq0ainpWluSIKlDk+DQf5EeJKLl29FU79tmhnMALefqEY1oxKGo0tyuZ/I/6j0eI91+g8snECiLqki2R4qEXaq+slVc3mNXlaeKqJRTgqtSjAz3fA== 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=DQEQ0+41NMNFKt0qSEz77N6Ztyso7RLV8Wlf/4tyO+IjaEBQKmhSvUzjPoChctOgKK+HVCRr9Nh6S91+WJTp+fJOhwY1C5XKQH9mTxHpMHAnNflE2yZJXKhIThQ0e+GG0J0zlGRTuARXo8ie+vShqwB6k+SbRo9kad2wqlQ3rAc= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by BY5PR10MB4162.namprd10.prod.outlook.com (2603:10b6:a03:20c::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.17; Wed, 8 Mar 2023 22:38:49 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::2a7c:497e:b785:dc06]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::2a7c:497e:b785:dc06%8]) with mapi id 15.20.6178.017; Wed, 8 Mar 2023 22:38:49 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v10 28/32] xfs: drop compatibility minimum log size computations for reflink Date: Wed, 8 Mar 2023 15:37:50 -0700 Message-Id: <20230308223754.1455051-29-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230308223754.1455051-1-allison.henderson@oracle.com> References: <20230308223754.1455051-1-allison.henderson@oracle.com> X-ClientProxiedBy: PH0PR07CA0044.namprd07.prod.outlook.com (2603:10b6:510:e::19) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY5PR10MB4306:EE_|BY5PR10MB4162:EE_ X-MS-Office365-Filtering-Correlation-Id: 2d0e4733-d075-46a1-f457-08db2025e278 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8QUUMEy/VjDzX1+mx+AydjRP5eQg4/pGYn74wbkMEgjGP1ewHA7IV/Y5wp1xGV3MOcF1ssRFQrOnborKyulhE4flzxitZ29gtfN43bwQxGWKhr2pPbjZgehJTfgbyxL6dInRAyCtZA9OeHR0+GhHRnScqdZI3jgxy8+aS4CNNzVCebVPRaR5kbBOU9QNiAz4YZbsGZvhKmBx1iR8rqPFMT4MSUtrjEVQnAgzztyyJFy/FvYwE9rWBhMDn3GOY6iFQfNHY/WNl83JB5ajWmnjr2duXC+zKOGI51bPciyao463/OaiFx0g0cH8ZhVCHbKzdkOFRV7c6lyssPqMQk6JR50qfhSqCjJlHWG+e6KwxUANEB0KNWY7JQTKDbsNTpKMabVachQecnymI8cnCUEjDfzq1NE/RCrtmOB8lX9sMruFGgubpSB0YqtImlgboZszhartPHlM9Ry6p3f5EWz9ciQjwu1lVTnvI500U9+el7bc3k5b3y7XV16azzqFiJUrXU1mqAnpGr+hxkUZzi9DFKcip103wz6mjpH9//TibbMjGcP4ilWb6ViJIxY2swgcCQPwjUF/Pzf1pCetx2L76zU0sqbGimvKk6qgqSm2AUu+6Mgk37WDfk/u5H8lW6Cdv+puRgONbXEoDDGG6Cf9ug== 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)(376002)(346002)(136003)(39860400002)(366004)(451199018)(6666004)(5660300002)(8936002)(8676002)(66946007)(66556008)(86362001)(66476007)(36756003)(478600001)(83380400001)(316002)(41300700001)(6486002)(6916009)(2906002)(186003)(38100700002)(6512007)(26005)(9686003)(6506007)(1076003)(2616005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 73WiuEEzOVBWKhYUs0k0mivw8uks+q2Ef4NsOM2VUNq+AChV5juWs/yxzr3TlQ8oOHL2UAr2FYZ2WJNew4jHgoyDIatlHmi7tjAJe5lM6A573kNJek0nOipw6ppNPgSj6GhSDgIedpGiPSq25zad8v0nDZxdafzmN5hT+z3WQ+4XM4KoIJ9d+TEuYg5Ui/OjeVyB7bjzE3t7Wy/cDfnRTWdmvy7Mr54wdixAExm1yI8QjGX8j41U+hrnnrVAo5mFT29W2/lMWUqfOqA+tK79WLggOEaKLTeQ6f+8ll0Q+5S9Mc5SJbsA9XH4kh/yv5N8LiDcf+/nzYS4IrONDdmqCGICl2YtMVYEGSFthx9RJrrMbn2Yo4/BnnwpJrKA8WLqqucJ/yggvuFSt+v3K7YP/3LJ1qOxRqWTVLlUd5tLnErAk6UjjYfOVDZi2sU/Ydtrxh/1N8P2iddJHDR/Ugj3Kd+iwIP9DoBg0WmusS6op0ZyoMFueOvk3R1WExcl/prrBV+u4zuP3Sb0aoxXsdQJfTivavvjvK0i4FduwZdv3LAs3Twjb6IxKEgllupVwPe2z00qc5TRtRamcZT4hqLzdbUlJ0YvYY7Iv/XtKDY12BwE1mpxyZ8R6M32jB1COX034K56CXZqxiVOvq5sg+j8NKcWpaelNeT/Ghschon3B00NpptdCTA3xKfmwF6nCBqtY04OCKEJY+Z30Yfk3QNpt/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Sr17vKgvsB6ff9IzUlr5wZQD7LjedFNw2ITjW6cwxzC+S2QSNlDRsLTwOoz95UjCto1dTmRgnUzW5MaDmfukIzLWkViq1z8i7b//QfvD76KobNmTGwLS85sn8dlBmbN3AsUTSSjCHXLXoo6btWzDA0L56oMPFfYw9qSgs8L6SmiJVzGalnbn0gPmwIS22X1oB79re9B3UWmzPjun15bF+iPtlsh6477Z8ETAtidpxpjTdJR0wMXzuEUSty1B46/fF6xbAsttQcJgWuVk9G2pBHkT2fDsuitXd5/WfY+4gnKh2++715HYMy4k12eEuiSZUBjKMPSJQWDAYDtaxs8Ye+ufB4Dhof62rimzLka5TEp7xOw98N6bXWFJ5FgaynL59abXP+KP8mASrAiNU4qUcmWVmbfLQq2YmU7RaFX2XsA20wvLmfOS2zNwqzOW3DSuK8JAfImT0n7HQWVNlAwfCu3ZfoH1XHNROTD2UjzYomDh7Xrv6H0bCvmIIYOQkrBGgmiO1SfwLnw4tUXfCxdMrkqRBYe5QReFpbTQ5G8PA1WJFc/4OSZLDnS92RN00E2g/2stijUk3XWpWFrN+BFvBC87REFEq5o5SFe3S40K6XVJKmYQorUHvKbn+9k7WEuptem3pJJtOeqTH6ybTnz0wQTktZyqPl9cPdAeYZ35MH8Jz9A== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2d0e4733-d075-46a1-f457-08db2025e278 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Mar 2023 22:38:48.9919 (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: ulwZqHRLlq9PVa9NvUKBF0XoNwa60rWmgiUSg7m0S5+bsPXnXgEEr+weemQxVCKPMegn7nyLTpeQ510sEgMGyyynfaRTTQNiUim6ycffGjA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR10MB4162 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-08_15,2023-03-08_03,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 adultscore=0 bulkscore=0 suspectscore=0 mlxlogscore=999 phishscore=0 spamscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2303080190 X-Proofpoint-GUID: HjN7crxr_T8cj8C3dJvwAlOOkkicHMcE X-Proofpoint-ORIG-GUID: HjN7crxr_T8cj8C3dJvwAlOOkkicHMcE 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 Wed Mar 8 22:37:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 13166546 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 3DAE3C64EC4 for ; Wed, 8 Mar 2023 22:39:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229904AbjCHWjJ (ORCPT ); Wed, 8 Mar 2023 17:39:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36550 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230076AbjCHWjH (ORCPT ); Wed, 8 Mar 2023 17:39:07 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 564DA5ADF9 for ; Wed, 8 Mar 2023 14:39:04 -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 328Jwg2J021992 for ; Wed, 8 Mar 2023 22:39: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=kmZSEmx36yTqtiETZ4vr8FH1l75IcseSvObnLOyOdyk=; b=GJynIcVJ1+NMxJnfAYPUinvciD0N3QRm66DRu0pKgjp63kR8W2rjx95TRYVGPnDHfFJU gW+lGPZ9gHI2AIux+ppMzat5D3ntm5lOV+dc/43beW621uDa2XTO084WdpECRq+naDJY uLE1kMQ5H3obbiOYbdhaOcyd7xbBg/7+9qxH+m/2qFljJgpIKNbBZKmfNfm4rT1JXAVO OJS3MV45DYahV6tha3T/+WueYSSDziHX1j0wk7plqTx4efdFY6496G7Tc4y7IZiyEKAA mAt3a/6AMMa3tgOG43e1lWXTV6jXLvPhH1shzW3tiVtcebM+Pfn0Xw+PnT5ZEpbdU9FB nw== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3p4168se15-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 08 Mar 2023 22:39:03 +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 328M0gkk020914 for ; Wed, 8 Mar 2023 22:38:52 GMT Received: from nam02-bn1-obe.outbound.protection.outlook.com (mail-bn1nam02lp2040.outbound.protection.outlook.com [104.47.51.40]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3p6fu8my98-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 08 Mar 2023 22:38:52 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JTYUpCsBQf/z1XyjPJCl0hHicjN1s+laqyNnXv1oPAzZrsDqe3PQzZD/vUiCOQOrpC5O7gWyEIKi36r3+7csfGD2fjMCFkI22xG6YRWAKz3c0O9PgMFKnn3UwqyPpxKuz6ycenJBXHg1gYJJkVh39BuJEYksR/rnxjyS+LwknZJrO1pQkPkr8uzKunFGnmGwK18vNSmVY6QPwJbmtRpMFaRU/qWcicj8/nItvPhMLsGeQ4GQoq7UAryytL3nW9Sp8EQ6P3UknDAzIxFO1MXCb3USYBUDUbFzJSuTx+HQpg9G66ZWTNuJsViDJut4xmy4sXubrVtCIEu/HKOo0HF/+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=kmZSEmx36yTqtiETZ4vr8FH1l75IcseSvObnLOyOdyk=; b=Z/ZDYE1cDmrESZ80VEm31XFmvV21inw2l3Raw9DXlRr0oBJcpOnLAq05caI6n3G5Y/cUEN+vMlDfDW8ySduCOTrQh9qYorg5VgFlCAJKBRD7knjAzoEIBvw3Tn8l6UzrbKZp+9bHzMdYdARu288WSZVdP2UIyg04l/3dy0thgnV5cECWz4rxViAamOL8pjIc3bxNXqp0OGF5wVzAognOIYIlPfKw6d/T2Bvl5OGLKM3Wfr8KIvzExx2PsZ6oFrPO2o4+rxqvE8gnRjf7XPlshLkITuz/TIqoqPd8V7+eoiRPiesTfEZnbBUW/5tVPrkDnMJNxXDOr25GT+eWmqd4NQ== 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=kmZSEmx36yTqtiETZ4vr8FH1l75IcseSvObnLOyOdyk=; b=Lg7pcX10WUIM5wLnd5+n829Y5nGnuRipZBZzaB6otFK4FggR+jFpzCloTOzROFV5qaCj+F2L5cRLxcsd3k4hihcP4X4IZ1xnkdwu0u+MMVGaMIv7IOqeqCBPk+jiibIGrLXWkPRHh0IVEgUNvF399b1GI6hCcHJ3ZxITTTGFGBw= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by BY5PR10MB4162.namprd10.prod.outlook.com (2603:10b6:a03:20c::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.17; Wed, 8 Mar 2023 22:38:50 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::2a7c:497e:b785:dc06]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::2a7c:497e:b785:dc06%8]) with mapi id 15.20.6178.017; Wed, 8 Mar 2023 22:38:50 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v10 29/32] xfs: add xfs_trans_mod_sb tracing Date: Wed, 8 Mar 2023 15:37:51 -0700 Message-Id: <20230308223754.1455051-30-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230308223754.1455051-1-allison.henderson@oracle.com> References: <20230308223754.1455051-1-allison.henderson@oracle.com> X-ClientProxiedBy: PH7PR10CA0024.namprd10.prod.outlook.com (2603:10b6:510:23d::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_|BY5PR10MB4162:EE_ X-MS-Office365-Filtering-Correlation-Id: 87c4a5e7-29bb-47ea-30a0-08db2025e354 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 4/bCYNQjICxQmXax2SLvJUDck/FjZVy1VGfl3n5um1MIWCJzMh2eTs+837MV7uyDW3Ya+iAz8+DuXnTO2Zd39L2VQuhT0r8/SyiIBDDw61s6C+ceebDl4wHNUl+i5kBM8OX0lPiO0bsAE1TeRhxpSRwUs1h+IBfq6NSWT+cehM9/IDQqFty/1nbWQXmjtKlAFZKHBSCdxdlDOGNJ8ahffA0gQdsDRmkVnq98Yu1locUEmuiXZb16ETF/+6mC0P5KBB/22qW7qdVr+gCsYtgFYRpxDdWDxTL4tavx/ux9Bw3dkoBQfXDYs8AW5wVijU5o7CukAaGlRaF/xJPZ4vgYLYuKb+XND6FTma7b6GwXB1ZFRzZgrxafNAJgo8cnYOBZDc0NLHemEh0f64VkygNzyeaBplso4dc/2/FuSsfoKibKlglsKZfxRtCTW/OAn2GYiJhXyUCFiF9v0wOq5K6DVmzWBZh/eznC/4BwgwCo2CJN15HxURqd3K1+4gAe/cH2AA0shY1/ZsDjdySF6sgA14B2Q8HEfkDEhmRqYb1MNusZ5+mP5Z7YrVcJyfM2jZRYDorNNBkioi2zXXpKe9mxzHx36vls4pmsPYxQL6gXYvQzmiuHolAFcUVkmMabdB94ekCLl00rRHB14aPpsiI+Xw== 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)(376002)(346002)(136003)(39860400002)(366004)(451199018)(5660300002)(8936002)(8676002)(66946007)(66556008)(86362001)(66476007)(36756003)(478600001)(83380400001)(316002)(41300700001)(6486002)(6916009)(2906002)(186003)(38100700002)(6512007)(26005)(9686003)(6506007)(1076003)(2616005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: TPAvps2+Of6JuFSC/iTkEWq1xjZZNfuWuTnkioU+VgBSxfrWecigLBorCc4p7+CEngYAmeIwcF6fAa672lZwhf8+a8NKDEpjyn24e/cNLMiAQn1ysnARdf0bmx/uvpQfK0lVNIn0+gKy847ZHU7abc8oO3zlH9zOnYakLdnVKaOsjEA7JI4edEuiBirpqT/5oLwDmx94jBVXNHAqXULKiOuEtut1SxggQ0+R/nZRgPmMmZNFAl/Jt8QBMZh1a9Y6XjQs60OLFRZ+WSJRXls0NbJX8dtZw5VyQCh1j91ilFZm4EzZy9t1p0lFyrzhd4i2bnngpf38p6Za5e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rg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 87c4a5e7-29bb-47ea-30a0-08db2025e354 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Mar 2023 22:38:50.4287 (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: G34aGd3w+yfN5c7lkAujafnA8lbd3w9XqaZ897im86qniRfxEBODPDvz1i2eT/jaV5cS09ki/fTWajIjBzl7qjxHWMVJ2oStUW8qYHxnUGg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR10MB4162 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-08_15,2023-03-08_03,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 adultscore=0 phishscore=0 suspectscore=0 malwarescore=0 spamscore=0 bulkscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2303080190 X-Proofpoint-GUID: eBvgbwKvyUrmtLaxyO8H9zcA3xPxkhhq X-Proofpoint-ORIG-GUID: eBvgbwKvyUrmtLaxyO8H9zcA3xPxkhhq 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. Reviewed-by: Darrick J. Wong 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 7e656dd42362..e32aa547222e 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; From patchwork Wed Mar 8 22:37:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 13166547 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 E1DC1C6FD19 for ; Wed, 8 Mar 2023 22:39:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229977AbjCHWjJ (ORCPT ); Wed, 8 Mar 2023 17:39:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36548 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230135AbjCHWjH (ORCPT ); Wed, 8 Mar 2023 17:39:07 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3E3D6591F7 for ; Wed, 8 Mar 2023 14:39:04 -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 328JwgMY007308 for ; Wed, 8 Mar 2023 22:39: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=s92jZpqBPmoWVrbQZZ2+zXN/qbxJ9ptS5VSkb8O1/mg=; b=0gKpvy3nq8mvrNmg0BnuRJ0ZtxyTkYI/sUfA+KrLgjOojaF22KxDPsafBk2Kan6sqOHZ lf00PF4gJvzSjtlMRNI6NGhVVp9fUbLaFBjzdMh8pGy7TAwXW/NgDUgX3thm1zB2VHNn kEBKY3ltwQU80+YBtiGjoC8hrPj4d/XRZ9SfC1EyF6uGAchKqlJWnUv32mpodJatRjB3 cCm0UJ2l9eWnGr4nqe2y4AWz6pjR33kF57zX8IkWV4s2pfSnEIFE7TmT3uIiPmkWyCAE JjIYt+4UVUfnFND6y62a0hE3+me/e8Ik3Rr+V3YgvUctJaMlUpd4dFqPWPW+yuyI5IFh 1w== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3p415j1fc4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 08 Mar 2023 22:39:03 +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 328MLOU0020875 for ; Wed, 8 Mar 2023 22:38:54 GMT Received: from nam02-bn1-obe.outbound.protection.outlook.com (mail-bn1nam02lp2043.outbound.protection.outlook.com [104.47.51.43]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3p6fu8my9s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 08 Mar 2023 22:38:54 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Vhu7jMTvCLL9II4TTdwGp5L+Xq6/fDPzkcdUl5JmHaYLklmPujcv705ka9HBWe54LVdGeJ4izhd8N+yn0eMzilDfNCidzovrUSJf/6D47EB2SvR8RsNTl4oHDiMSkSUA5zs5q84TYSD6s5R7mskksyCR/Mj42z11zMjt3GS5Bt4Jpw45ClRRzHsXryULlZVC+Zw83uCI2sLNNf/k9cSg5HJwhAaxe7SmGHFsivJuwmySZRrYetdkUj1qrpTWS1m6MIG8n7PS+qSfmoX30Mj+WoX6hroOBeJr8aj1HLJOuhM3tAJeV0UZ9t93nc3y2yvWhH8dSH7wefbFMxYO9xDnyg== 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=s92jZpqBPmoWVrbQZZ2+zXN/qbxJ9ptS5VSkb8O1/mg=; b=OSm2iYCkDpNWUEOSQM1zqrRQcpl984TzIC/JOnsiaYDYWjez0fynAeBdmu3OAUvYf512XCSBBhpW7qufdmluc+9gqmcgbVh3a/zwPty+56dQZDwZVblK0guPZPxW4szwFR5TItQc30XKdpNRDRcfU8rDxvOq/NAtqOVo2cCB6/JKuzoXDA0kvKkp0sebUOwqNfkkO7X8cXTjnsW9DIxWRLsmwSAd9MsiuPs6Jen4OzYt3pgnVlrUSk0QnavxJy/kwvNLhmi38L8GG29KKmezWWonLEBmcBzoue27OUFGmslgh2ZKBii+znd90Csz9u5TqwuKZraArgTyKlxq8+yhkA== 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=s92jZpqBPmoWVrbQZZ2+zXN/qbxJ9ptS5VSkb8O1/mg=; b=h5/QP2UAzazBU7ooB4jTw24EPv2BLQqS9qe5AFIwXcs0IePVFrOdx63sDgusDxa/pKRAyfUKZDASjYU/8pXwEDRKhH9EeZ7btp5c+Js5tcAaOhJ6/qWkzDV6e3dJUwhvKb9T7K4o3q1pVWYWO5LW9C4rb9rbU2Ls7aCKF7pGG9c= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by BY5PR10MB4162.namprd10.prod.outlook.com (2603:10b6:a03:20c::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.17; Wed, 8 Mar 2023 22:38:52 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::2a7c:497e:b785:dc06]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::2a7c:497e:b785:dc06%8]) with mapi id 15.20.6178.017; Wed, 8 Mar 2023 22:38:52 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v10 30/32] xfs: move/add parent pointer validators to xfs_parent Date: Wed, 8 Mar 2023 15:37:52 -0700 Message-Id: <20230308223754.1455051-31-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230308223754.1455051-1-allison.henderson@oracle.com> References: <20230308223754.1455051-1-allison.henderson@oracle.com> X-ClientProxiedBy: PH0PR07CA0039.namprd07.prod.outlook.com (2603:10b6:510:e::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_|BY5PR10MB4162:EE_ X-MS-Office365-Filtering-Correlation-Id: 5f26f208-6979-4111-9414-08db2025e479 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2Of1Bf7Tn+6pN+iIvz1zQjHd5uG5eEc4dzrcvvtpNsp8JzfF61XzuklbFYFANKNsE7OhQRMV+rXtwAaPJ0kgNcypZQdfysVUrQKT9n2oE3dWb4GTYkNO//l6w515xv2W5VBDtCoGLmzwS5iIzjADe9VhdAi9OXhtT/UdjwlfHO9zAc9fsGgv1Oey3S9pwgXYg1LjrF7fwhqckqYpX96DpPXQe6Mg8pGzCn44dnRPWHkNPTO1gVFRMQy43lE59J9Nj2A1XjulOuSnrdcGLYrSwRtOoDRA/topCVsomPmc++YcjaqLYx26bEUmPIFbk34RQcXpdhmuI8PLAYJQkULQMLepw1455RtjTaRW5bJ0AuaIyvZ/5sEkn3ROqoYyKXBA1aUl9+AuD5x+hUy6RudUNnWyQnk60TyCK0bT2gCi/+5fYDT4ivtSFLcM5ZJvqG5RLghbP5RNZFCtxuo/oB/dvfCuyckfQmdQ4U8+myMJVi/FMgOUZj8YtIIvYJdyB4TK6oPDfmmjlP5PGC0XS0kMV/Our+m3BIWZVN+EkejQw1S60ahCGkdsuha+hrKU1lAnvTwMSM1y73WVNdy74AcUA9mrqtWgUued/Hp8VrwUt+U8/cu9de+1UFSKd+nKYRVhfZHGiGq68s+Jrml6U7TzVQ== 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)(376002)(346002)(136003)(39860400002)(366004)(451199018)(5660300002)(8936002)(8676002)(66946007)(66556008)(86362001)(66476007)(36756003)(478600001)(83380400001)(316002)(41300700001)(6486002)(6916009)(2906002)(186003)(38100700002)(6512007)(26005)(9686003)(6506007)(1076003)(2616005);DIR:OUT;SFP:1101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zm5CbA9wlysIfCcb6NVQxA3aDO6zvE3ChPJUzZGrkRji6hDgnXarzRo1T/Hdk3iBb6exk3CNbOh+N25EtRUN6rqzomK6q/EZjv30bQTKR3YIB+FtSuXMXLFNuake/NbCrQ9CnNZMFOvYIeFKlWLgzziXHdhCekSYBcQQOSYl/Oih2aHGdIShyLEBAM5jNp852hl2XkbBAzCQCM6Ir+mESoQxVfj54tbnCnxKBHy3MwMTW4NFh0ARIU4aFvtziFYvQgsfs7+C+XINol8n/L9JnD8k7Hof4JBlYtstSskT2c3AShO5t+4ydkGr9axx8W3mvnSIsOLTACSaK0jT2vSCWPlMgGsG4vyyaf7KssuwyOzrj7Ib+2DBy9wy+emRMZiqXT3naOUUkg== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5f26f208-6979-4111-9414-08db2025e479 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Mar 2023 22:38:52.3685 (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: 08dEqhAbtE3Arsuk/MVaCTnUOOiYAyHF2ncQ6UrI0x+/Y0DQrPzf2OUndjGQFzAy2CZXjwDl8mxdObnlJNgNSOfRBh0zoUoK/oktgLlMSaQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR10MB4162 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-08_15,2023-03-08_03,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 adultscore=0 phishscore=0 suspectscore=0 malwarescore=0 spamscore=0 bulkscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2303080190 X-Proofpoint-GUID: AM2YJGF4uLiWWNbD4L5-OAy39Q9MZGmM X-Proofpoint-ORIG-GUID: AM2YJGF4uLiWWNbD4L5-OAy39Q9MZGmM Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Allison Henderson This patch is part of the ofsck specific additions for pptrs Move the parent pointer xattr name validator to xfs_parent.c and add a helper function that is later used in ofsck Signed-off-by: Darrick J. Wong Signed-off-by: Allison Henderson --- fs/xfs/libxfs/xfs_attr.c | 55 +++++++------------------------------- fs/xfs/libxfs/xfs_attr.h | 2 +- fs/xfs/libxfs/xfs_parent.c | 44 ++++++++++++++++++++++++++++++ fs/xfs/libxfs/xfs_parent.h | 7 +++++ 4 files changed, 62 insertions(+), 46 deletions(-) diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c index 57080ea4c869..3065dd622102 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -26,6 +26,7 @@ #include "xfs_trace.h" #include "xfs_attr_item.h" #include "xfs_xattr.h" +#include "xfs_parent.h" struct kmem_cache *xfs_attr_intent_cache; @@ -1577,36 +1578,17 @@ xfs_attr_node_get( return error; } -/* - * 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) +/* Returns true if the attribute entry name is valid. */ +bool +xfs_attr_namecheck( + struct xfs_mount *mp, + const void *name, + size_t length, + unsigned int flags) { - 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 (flags & XFS_ATTR_PARENT) + return xfs_parent_namecheck(mp, name, length, flags); - 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) -{ /* * MAXNAMELEN includes the trailing null, but (name/length) leave it * out, so use >= for the length check. @@ -1618,23 +1600,6 @@ xfs_str_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 b034cc165274..02a20b948c8f 100644 --- a/fs/xfs/libxfs/xfs_attr.h +++ b/fs/xfs/libxfs/xfs_attr.h @@ -552,7 +552,7 @@ 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(struct xfs_mount *mp, const void *name, size_t length, - int flags); + unsigned 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_parent.c b/fs/xfs/libxfs/xfs_parent.c index cc3640be15d9..179b9bebaf25 100644 --- a/fs/xfs/libxfs/xfs_parent.c +++ b/fs/xfs/libxfs/xfs_parent.c @@ -45,6 +45,50 @@ struct kmem_cache *xfs_parent_intent_cache; * occurring. */ +/* Return true if parent pointer EA name is valid. */ +bool +xfs_parent_namecheck( + struct xfs_mount *mp, + const struct xfs_parent_name_rec *rec, + size_t reclen, + unsigned int attr_flags) +{ + xfs_ino_t p_ino; + xfs_dir2_dataptr_t p_diroffset; + + if (reclen != sizeof(struct xfs_parent_name_rec)) + return false; + + /* Only one namespace bit allowed. */ + if (hweight32(attr_flags & XFS_ATTR_NSP_ONDISK_MASK) > 1) + return false; + + p_ino = be64_to_cpu(rec->p_ino); + if (!xfs_verify_ino(mp, p_ino)) + return false; + + p_diroffset = be32_to_cpu(rec->p_diroffset); + if (p_diroffset > XFS_DIR2_MAX_DATAPTR) + return false; + + return true; +} + +/* Return true if parent pointer EA value is valid. */ +bool +xfs_parent_valuecheck( + struct xfs_mount *mp, + const void *value, + size_t valuelen) +{ + if (valuelen == 0 || valuelen >= MAXNAMELEN) + return false; + + if (value == NULL) + return false; + + return true; +} /* Initializes a xfs_parent_name_rec to be stored as an attribute name */ void diff --git a/fs/xfs/libxfs/xfs_parent.h b/fs/xfs/libxfs/xfs_parent.h index c14da6418e58..f4f5887d1133 100644 --- a/fs/xfs/libxfs/xfs_parent.h +++ b/fs/xfs/libxfs/xfs_parent.h @@ -8,6 +8,13 @@ extern struct kmem_cache *xfs_parent_intent_cache; +/* Metadata validators */ +bool xfs_parent_namecheck(struct xfs_mount *mp, + const struct xfs_parent_name_rec *rec, size_t reclen, + unsigned int attr_flags); +bool xfs_parent_valuecheck(struct xfs_mount *mp, const void *value, + size_t valuelen); + /* * Incore version of a parent pointer, also contains dirent name so callers * can pass/obtain all the parent pointer information in a single structure From patchwork Wed Mar 8 22:37:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 13166548 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 DC017C678D5 for ; Wed, 8 Mar 2023 22:39:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229702AbjCHWjL (ORCPT ); Wed, 8 Mar 2023 17:39:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36564 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229672AbjCHWjJ (ORCPT ); Wed, 8 Mar 2023 17:39:09 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1B22E29429 for ; Wed, 8 Mar 2023 14:39:08 -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 328JwkmR018336 for ; Wed, 8 Mar 2023 22:39:07 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=31bDCUHnTjGX+o3xxPHsVWfh3Ak6A1k/Sp9WFrcda4Y=; b=tDAf/bWtr3XcrTfn5UKkPam4G9bFxjTPl450PosI0ZNwratri11bCIopZEIZw6rnBwWj 69BdFfA2xjAfzT0Lf8qM42QyfgzFil2Iz+F6+0/Ht5Rms3KuhQBayF5cGn+qwkgRp767 L9y07DmLI+k2o0n70sMrFeX8l1kPTUyzug2sIx+nvBVTnqVvvjKtAEn2DVZZoTjinRf8 7ttSvEpdN+t4LQWzo8UeJo8C6Qq1mgx5j20KLFSNZHou1jWXlBsAfh21Z51csYc1IDXR XfscAEerhtRw3BE6wKlnM4b/ETk8x86XSjywLGWXPNmztz42M5kohhZNsqyJDg6L/9Tc ZA== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3p417chcye-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 08 Mar 2023 22:39:07 +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 328Lt6qG036616 for ; Wed, 8 Mar 2023 22:38:55 GMT Received: from nam02-bn1-obe.outbound.protection.outlook.com (mail-bn1nam02lp2047.outbound.protection.outlook.com [104.47.51.47]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3p6g464wsh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 08 Mar 2023 22:38:55 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lJXYzpLWRbzQBdH1RhMqDu6dOjvO9IJVs4VAP9ZwG9MU+6IvPW20s7qIc8Gmg6f0evMhY9/QiZbS+HFEqUKXW+GSchGrrQ9e64lNW6BVacIEWSpFHe2GIflxG5frZ+YlfaDoUwZTowvOWNw55u1pGF332Sl4rPlDym3He8Z/Qmh8B2Ei0ZzhX3WgBvM7cBtK3+4Co+2YN/C+UqWE+KfjER4VcPMit5jy/XIuv3WTuMNisbIkYuDMsVAdoMfFlZDyXXS+YUhZ4GucwQmQG/pb/EXsAg+vWn4KHZhe2ud+MaZFOuoM5wQqvdSzoAia6efkKOLK9KE2q1YTU41Zrj+/3Q== 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=31bDCUHnTjGX+o3xxPHsVWfh3Ak6A1k/Sp9WFrcda4Y=; b=QKvrvWnsZNuQRMdbwODJVgCX8Q+uEL7Nr1qZ+wmTnI9erJ/7ZzE/bepCrdoVLOrt2LX84dme2zwdcBf0P0SCUy2L8GHVXEzb4SY1GsQONmzwzKpNq+MloH9No/+sSIaidXewx67GxXHPGmbpLiZt3cQvKSlYPyl1KKAdglV1vhMVd4ioURJw941IwVgyRNUO+6fFQeHnlFpsPpQEVoAtmbnAJoapi3th86J09MsnvlNi5cWVKJ6nfzIcTl/KJ9QXNkdwyjTEIzuJDt3SydIIPmU0FaHr/qcTgKeBRBktpuQrcusDfjBWxG1D1OzmY68SUfRoe4GTE9ADDG83DfvHLg== 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=31bDCUHnTjGX+o3xxPHsVWfh3Ak6A1k/Sp9WFrcda4Y=; b=nvVEjddEtbvNpQVsh39zsVeRpy+dyKxIRyQtwrJZT//wvXh7APQTqWIagUKZAcejG7sh66PX3I1qlLk8k3KEyP5+qosq8U2u39HEu4UwBv4IoQr4dWP3tviXc1m3sD/h6Lt5KjAksAIUVbSlkmQ0B8gaFLlCzzNOSex9S7Mzn9Q= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by BY5PR10MB4162.namprd10.prod.outlook.com (2603:10b6:a03:20c::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.17; Wed, 8 Mar 2023 22:38:54 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::2a7c:497e:b785:dc06]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::2a7c:497e:b785:dc06%8]) with mapi id 15.20.6178.017; Wed, 8 Mar 2023 22:38:54 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v10 31/32] xfs: directory lookups should return diroffsets too Date: Wed, 8 Mar 2023 15:37:53 -0700 Message-Id: <20230308223754.1455051-32-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230308223754.1455051-1-allison.henderson@oracle.com> References: <20230308223754.1455051-1-allison.henderson@oracle.com> X-ClientProxiedBy: PH8PR20CA0004.namprd20.prod.outlook.com (2603:10b6:510:23c::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_|BY5PR10MB4162:EE_ X-MS-Office365-Filtering-Correlation-Id: fbf2f96c-a3e8-42cf-04f6-08db2025e5c5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: iVingXgcULB+W/Bjkv8msdZqjp5epjr4iGrnleb9N/Hu58TK5HE1COC9pzKex7k1F0jwEFR8NGhQLYQ6cvPGxP79kOg/V5BEsmlMnblmHqLB78jM31rrQuA9BuQVDe+CVT4hivxXdySvsup7cdsJ3kB8Fgwl36tAgm1Z9mT5hNbavNwrgkKrt2kmjrSNExlt3a9JnVFTx44RZlSHmsrX4Rk97nH7XWvJC8WNbttKq8MZt0tjNN4pEHLrehZpYDK5/O6M8P+dD+tfBsEkhN+3P6LsJKM1yvmoaqANF6ahAMpWWkTAl3EZzmrmvaGTNw/Xc5ZG/GflLPU3omLgOzKw0KD4sh0t9XuQV2xAcMlMUqYVHNCA3ZY/yTBzSNm6mN3qS3cD/xgkGEn4y1xoH8Je7OQeHdI2LqkYIUS1KtzRC5C6ISujUQpn+Fu23whT4+FDhL10SWOd7RlWSTuXcUwbJvbucxclI/kZZ/QW+OCiessQqchsPy3PySg2BMntHE/D+wXY5FMa1V8UEhwN7TBPwljTnkE6mvmKr9DAidubBjHlc8lFF+sKJy9Ov55plkUanVQ7zJYA33ho5hqB4ni9QcDhKXuvSIyT6+pVd0ccETukMBHrjioW9sTmQD6njG8t+bbYWGZCo1csf8UyoqljwA== 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)(376002)(346002)(136003)(39860400002)(366004)(451199018)(5660300002)(8936002)(8676002)(66946007)(66556008)(86362001)(66476007)(36756003)(478600001)(83380400001)(316002)(41300700001)(6486002)(6916009)(2906002)(186003)(38100700002)(6512007)(26005)(9686003)(6506007)(1076003)(2616005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Jrh26x4fpNaxKfrz0mZKWVVDhbsQYJ6YQ+IeOlAv5fVUpWlVCzavk5r9J0203AhDBTqJkcWY1lsc7UuvXFz7hxT0vRwQNYcof0dHcPkT5haxPnbZSY6VifZvnNQX2l5E5EXKoilXBZKEnHpbbJUqSH28h0zUxBRch0h2YHy4HhzxkPXK+vJErs5AqZExpL4vzzsa5NcvQszMWE85lvv7bWk2itvoMKoBUFFJMTB3aez4im43OnsCUr1exYgz1ZX/bsMz5Apr3aXKcNRc+cIIzYasx42jdZbsQ6r7T4X+ykVHs2tS2Tf6WScylgq6OcfM9NOQ6QPX88gquVZiKu7UUBNjpdT5mjCpVACqssYvVWym6lcezAOkk97k5W1Ro1wPWg0VwceH0OrYqdqN/IBC1Yg0UrX7420sLF7XSjrP7IvZ3FfZKUQFasoBRF3gV2OFh57cdBQknTA1YRjCKLZubPasI9IOS1l3ts2lYIyy6XVKQDt3n9VCtWisW82Yfdown82miBqv0e8q5i7+Vvf4YiINJa66h0YueEsG0UpkQroRzhElm7RQSXpI39vCLycgth+Y761c3BP0X7xpTfcqPk1fAoEHiP4UHYTIUqHNNG/D0aa6rMnNLnA8w99MPzi4uwJpDHM6CzUc7+0WAYc4UT+QmIIFcZMF6Z5rz46YUZnOiid5wJqP3QJh2clTlPWx5psAU6Ua3zirXkgzah1ZLEh+NYei6aWipAdoVKSWsJ+FHXFoU3fApg700Qfz7BxkfMX8+15v/Jq3RZ/y3teNuuAYeZFvMviV3LXIH4kyzAgChCLwtJKuDnjDvNI/IwqTqRGvTQTc/KggtkCNgLzLbzOj4GkkDUpI4QwDcqaBMpLODiy8MywNufSVBTBzH8ADQWmKothsNfqDT9r9j9c7UwJsipmahGJXT8jsEx36IPHC7ZFjiV7lDTb0elKns/0D6uUvxjQIAs6qlkaIEBgKP1GX9/89hbW3nRVEBF2a4xS3WugLaXddVSYfrZwC+rCv85fMzmacZLP8sNQnwaddZS2msfPiTIefZ5m1Cx7ldmjYWZgY6yc3cIkIA7/2Qw4zb/cwUuAeqjkdLo2YPU37QsHp2sKfX6IedIfBDQTNqJNq+1dbbcbQ2zqwHZ43prNsQ3OZqaiPGaA0HlazmA0KbkvWsaCaWHPRHzyfOLWOvJAbDusYjzg/WbYRVz7lyzSPibzixL40sxLfzKONTsM6Es8guqFqLMn/+8cw04Z1ghP0guBQr4YGS5sNg7J8qJOmp+3oh3PRymUharjge/7HM60oxALS7m0zop/Ew+Ozy7aMzc4ZkyDRER83B22LvEa1F9y/FsKFbYhMc5e287pxU7KxTnaddeNWU8Xyn98jUzcZ/1fSHqtDBg/Jh5VrkUBcA66nfCO9r3UnEnpsiaa7ODW1phk8qalD5eGGdHY4GHjN3McDnS1qTSgjXHQCNPPpnKYgLSol/2d/2cisyBA9KtQJOx/MgSojexWRjTr7B8yml+zTkxNJ24Id5JD1le5koerig7DkjTpqKU7giYtNTFbsemS2eWzvYzI5IIj1bSwvN6At1olW9hLEvl6qCd6XN427gPGPScFYV1OWQc3niA== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: dHVQB4jXUXh39hdkqS6gHxdtsByAkL/yKBQJi+OTXr0oiACxb6Qj1DmHJJOTQtgY0ABiLHiBWUj/FCL7cRwVSl2HwZG0HzLRWrrUuG0GQuwkvdiv7mlnv9lkX0kImwcKVo5DApFffKDMyn0f1lha8jvlDHUiCs05EzqR04k0OEL+FXE/mAp8WqckaGX4EMd0oGjhvWNNhMXykKrVpHn4KO7uHtilyEsMoFNQN6QimpLwxhEtxsSDW5e8PMDDuJGqJhTyC0NNH82K59/ShFKh5U9Dfs03pPC1msSMqFIPA5ardKRJnCBEH+XKBJ8ndpzAYdMNlzvr9f1bcFsNEO28y91inU4CmHFj4STqmevPHSRqFWDqbsy5pdGJYbQGpL7hfqkWNcdCk5Lw1RrhdpRPKIkp5y7O1QlMQM/fMVHnHjr1gtr1ZkMHY/+ADeeqixz8KTeSyuYJWopPTbmCzTcnket6IQeXbQymX/2w2PuID2MrHt8Z+Ae0DB8G3YePiWq4r06WLPtxF0+nEF0I30/MmBRI1ECLIRs/ChKXCSrsK/NZ44H2uT/FUrroFnYng7n6IKM9bP0R1moAiWalwFuDhiUVPiGIIQ/q9ffsD21EgXqENNpJNkfadKiqHumZfMGi0mgk/OwbxIxhKYZDHGIuozY7ifarQNKK6mXM7/KqtfRzhprt2Xn4eiCBFnD+14biuf20UBtCMTR8Dmwm60wzR65gvkOgdS8tDzFTHHTLVwPIxm8BTKYy1H7zL2+uOlZI8SwYc1LuCTJnvbeCZ6sfqA== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: fbf2f96c-a3e8-42cf-04f6-08db2025e5c5 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Mar 2023 22:38:54.5392 (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: kfyPXhLtGjiLqtZlxy9y/WGJxr3QKS9JqkDXz8bXh+8WRnM21JJzF+BenwGgv4w9q/7XFREVDv+E3LKKE+6zXkVFp7lnC1LHOKB5EDx7k38= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR10MB4162 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-08_15,2023-03-08_03,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 malwarescore=0 mlxscore=0 mlxlogscore=999 adultscore=0 suspectscore=0 phishscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2303080190 X-Proofpoint-GUID: RgONXPrfPN5yvEgytv2oJ4qYlEHCV0xq X-Proofpoint-ORIG-GUID: RgONXPrfPN5yvEgytv2oJ4qYlEHCV0xq Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Allison Henderson This patch is part of the ofsck specific additions for pptrs Teach the directory lookup functions to return the dir offset of the dirent that it finds. Online fsck will use this when checking and repairing filesystems. Signed-off-by: Darrick J. Wong Signed-off-by: Allison Henderson --- fs/xfs/libxfs/xfs_dir2_block.c | 2 ++ fs/xfs/libxfs/xfs_dir2_leaf.c | 2 ++ fs/xfs/libxfs/xfs_dir2_node.c | 2 ++ fs/xfs/libxfs/xfs_dir2_sf.c | 4 ++++ 4 files changed, 10 insertions(+) diff --git a/fs/xfs/libxfs/xfs_dir2_block.c b/fs/xfs/libxfs/xfs_dir2_block.c index 0f3a03e87278..24467e1a0d6f 100644 --- a/fs/xfs/libxfs/xfs_dir2_block.c +++ b/fs/xfs/libxfs/xfs_dir2_block.c @@ -749,6 +749,8 @@ xfs_dir2_block_lookup_int( cmp = xfs_dir2_compname(args, dep->name, dep->namelen); if (cmp != XFS_CMP_DIFFERENT && cmp != args->cmpresult) { args->cmpresult = cmp; + args->offset = xfs_dir2_byte_to_dataptr( + (char *)dep - (char *)hdr); *bpp = bp; *entno = mid; if (cmp == XFS_CMP_EXACT) diff --git a/fs/xfs/libxfs/xfs_dir2_leaf.c b/fs/xfs/libxfs/xfs_dir2_leaf.c index fe75ffadace9..b7ea73b4f592 100644 --- a/fs/xfs/libxfs/xfs_dir2_leaf.c +++ b/fs/xfs/libxfs/xfs_dir2_leaf.c @@ -1300,6 +1300,8 @@ xfs_dir2_leaf_lookup_int( cmp = xfs_dir2_compname(args, dep->name, dep->namelen); if (cmp != XFS_CMP_DIFFERENT && cmp != args->cmpresult) { args->cmpresult = cmp; + args->offset = xfs_dir2_db_off_to_dataptr(args->geo, + newdb, (char *)dep - (char *)dbp->b_addr); *indexp = index; /* case exact match: return the current buffer. */ if (cmp == XFS_CMP_EXACT) { diff --git a/fs/xfs/libxfs/xfs_dir2_node.c b/fs/xfs/libxfs/xfs_dir2_node.c index 53cd0d5d94f7..f8c01e8d885c 100644 --- a/fs/xfs/libxfs/xfs_dir2_node.c +++ b/fs/xfs/libxfs/xfs_dir2_node.c @@ -887,6 +887,8 @@ xfs_dir2_leafn_lookup_for_entry( args->cmpresult = cmp; args->inumber = be64_to_cpu(dep->inumber); args->filetype = xfs_dir2_data_get_ftype(mp, dep); + args->offset = xfs_dir2_db_off_to_dataptr(args->geo, ++ newdb, (char *)dep - (char *)curbp->b_addr); *indexp = index; state->extravalid = 1; state->extrablk.bp = curbp; diff --git a/fs/xfs/libxfs/xfs_dir2_sf.c b/fs/xfs/libxfs/xfs_dir2_sf.c index 032c65804610..f8670c56c7a6 100644 --- a/fs/xfs/libxfs/xfs_dir2_sf.c +++ b/fs/xfs/libxfs/xfs_dir2_sf.c @@ -889,6 +889,7 @@ xfs_dir2_sf_lookup( args->inumber = dp->i_ino; args->cmpresult = XFS_CMP_EXACT; args->filetype = XFS_DIR3_FT_DIR; + args->offset = 1; return -EEXIST; } /* @@ -899,6 +900,7 @@ xfs_dir2_sf_lookup( args->inumber = xfs_dir2_sf_get_parent_ino(sfp); args->cmpresult = XFS_CMP_EXACT; args->filetype = XFS_DIR3_FT_DIR; + args->offset = 2; return -EEXIST; } /* @@ -917,6 +919,8 @@ xfs_dir2_sf_lookup( args->cmpresult = cmp; args->inumber = xfs_dir2_sf_get_ino(mp, sfp, sfep); args->filetype = xfs_dir2_sf_get_ftype(mp, sfep); + args->offset = xfs_dir2_byte_to_dataptr( + xfs_dir2_sf_get_offset(sfep)); if (cmp == XFS_CMP_EXACT) return -EEXIST; ci_sfep = sfep; From patchwork Wed Mar 8 22:37:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 13166545 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 64ADCC678D5 for ; Wed, 8 Mar 2023 22:39:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230034AbjCHWjD (ORCPT ); Wed, 8 Mar 2023 17:39:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36464 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229904AbjCHWjC (ORCPT ); Wed, 8 Mar 2023 17:39:02 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 686D229429 for ; Wed, 8 Mar 2023 14:39:01 -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 328JxuSj028471 for ; Wed, 8 Mar 2023 22:39:01 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2022-7-12; bh=S0UDWEZEQ7wjM3PnNrAw+hb3UMPHndWMzynBWAS+RKc=; b=k7NX7zEz+4kHm+A6DIAOMtPFvbBkvGwOMhK1ZeNWMF51V4+lcmbXq8NqpKCvixJsmhLK 9NVZ/XM6FDMEq3ScRvj7cv4KukzrBfu6+/RZ1D5QzHVgvbc5tZaD7fu4ZSztnrJ3U2pI VvRpGh452RI2VX4tRJtyG+VFp4I68xW8wwt1rvIOtCgAJ0TguUFObVYwgbvR/tvG2VtW LRwEusNSL7sGR74+0wl73bX/JsqnUZCCqUipEx7vgcPkCfcz7ZFiuXnmJ2ULBWzAeCNU VTF2mBtrNFJFc9RAVZDIsFfYTY87xdsLG4QBSF8Ai/8pP6s3tLZCmjQr4Ie91sdZ55wD 9A== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3p418y1eg7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 08 Mar 2023 22:39:00 +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 328MC0No020848 for ; Wed, 8 Mar 2023 22:38:58 GMT Received: from nam02-bn1-obe.outbound.protection.outlook.com (mail-bn1nam02lp2043.outbound.protection.outlook.com [104.47.51.43]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3p6fu8mybg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 08 Mar 2023 22:38:58 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kbmJfT63OCHazW+WFYUw8ioRcKv/kppKS1k6GxiLC9pI1goYx7GjCJgS7aYuiwS5GG4MRddQB51/7RcGM2hIzYe0kF0qWsfcHy9G1S4U8Jis9+7TwU1VPrjHsfej4xpYw5v9D8j+O7gDJMjBaUnsMqK9t0TymXzVd7P4RlSjqQmO2XH/0HEqaqEBFuIfW1yp/vyTlXWbNNg7i4y9lmZeeJwwUNZzu7T3/bt88QcrOgUb5Wl7KVzJeVL4wjtvBti9bHSAx1SPMpQzotkVEDXlcBUXf5/wL+7476hXCCoOCMQE5ijMbvN9snqOEDE8v/dRleIiBh6r0MxqcuP7iiyBVw== 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=S0UDWEZEQ7wjM3PnNrAw+hb3UMPHndWMzynBWAS+RKc=; b=TPcNyoCX8HYNzuk5y4Ah6LA2SMPHiXEWa44UlLKqIFw+Kq4avXuJP49s7W87D6Cu2YOSkcaYqkKkX6MfhhO8iFsTNl/uetvf/dSCc5LzyPgv+QkrtWXOE0k/1wLnPGDLMwcrwBHFmFS4VUwx5iWjM8HkA0pEABASEc+SqabBq/ZjBSC2ET2IpQ1/99E01/lKAFAQRNO7nEvwBecbcbI3BvAkuP9bSDllAvKR5vauW1pvfeKaeLQEZRk8K0fT5iVuzF8DPdhZXZkTdaGvwFr0KFDBUBSMeWGIdhTcii5zfROmehqhUeJ0zukXPuwZDwg07OKtkQFJJ0TO9ZuXSqvgZQ== 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=S0UDWEZEQ7wjM3PnNrAw+hb3UMPHndWMzynBWAS+RKc=; b=zOQh70bhyNN4bAqRanNiGC6hfW6FHzrXq6EjYvwF8NQFgNzQVWNVR+Jb93IHYUhGrZlhfqWe1hfWknKKJm0g59xWu5Lf5naTP4SdjdosigtXMkquGq3YQcfwBMDK4P3tEbSFj5QYmn4qmILurB1olRo00eR9uiWV0gyrVE5z1gI= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by BY5PR10MB4162.namprd10.prod.outlook.com (2603:10b6:a03:20c::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.17; Wed, 8 Mar 2023 22:38:56 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::2a7c:497e:b785:dc06]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::2a7c:497e:b785:dc06%8]) with mapi id 15.20.6178.017; Wed, 8 Mar 2023 22:38:56 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v10 32/32] xfs: don't remove the attr fork when parent pointers are enabled Date: Wed, 8 Mar 2023 15:37:54 -0700 Message-Id: <20230308223754.1455051-33-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230308223754.1455051-1-allison.henderson@oracle.com> References: <20230308223754.1455051-1-allison.henderson@oracle.com> X-ClientProxiedBy: PH8PR07CA0010.namprd07.prod.outlook.com (2603:10b6:510:2cd::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_|BY5PR10MB4162:EE_ X-MS-Office365-Filtering-Correlation-Id: b3439cb3-7485-48f4-8d37-08db2025e6f1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: qgHhHQK3o0HhzD39MrVeRRUcomGQnZuYQDnHwdVO8VUf0pUHlt1p0obikGTiOvOHjrocSAEexAtiZDp7Yd6FULZ8zpKb/IDiAnJkB28RJHvNyfDvqH5N3mtX22sgpoFFbmqBdPYuN7TuOOWtBOLVWwU4wf6u6bmHoVBHsQMeUA64ss4hiKV9rqcq4sZJuH+TWuTrI9gizMGvE/HxVs40QpeVUe8qGV65xLBy3i4+x4APk5JOQvoHBtQP/wfRR1pqKZYo2MmBuk21GjhlDskAWtUkONVezqN4LOJ6FCDvhl0BJeiHdP2nMUAh1bsgOtvsIgNkvyMiWtfebihPXUWlXBGooaKtbRkgft/T1e1LWFRK49CpyvPmsRiIGoWcLSTMFi45OSOSbU5DoGoKIuzFo2KFSVAColJd4HgG9svDrjQ5iPwNnAFpPteM7oAzXqonCojBnkeeVbB7mCiRlFJjNpqA0OZAI866Uy9k1Qt3hq/hjYx5S1h5vePST+Mkfw1VmElKGiam9ZY1Wg/BNxJxZ2G6RXWWvIn3YfnRJOvZyqSum+LyLnwfN1ov8pjdPQ4NgZhXRE4yPTc6BB1DB0PuSJNvnP7TMo4mTnPXC9C07cMKonI26nVB0QcKkqTq0wkAyyEIB8S/J1bm/7OYQXYVag== 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)(376002)(346002)(136003)(39860400002)(366004)(451199018)(5660300002)(8936002)(8676002)(66946007)(66556008)(86362001)(66476007)(36756003)(478600001)(83380400001)(316002)(41300700001)(6486002)(6916009)(2906002)(186003)(38100700002)(6512007)(26005)(9686003)(6506007)(1076003)(2616005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Z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YJYQisv+CtE5Mavmj7Q5sZlwFlVKeYTOSYZgI3y55Pu22kL5tOIupIlItMQLgUBcr8z7ATNeSjK5luc4KeeVG1DlcjwjXbernTmt3cB7yZ50VyXY5p/qqLkFpZLaLvjkwNqqkeSOJShszzewCOQI2vTGBsjndDojAKENHlzqRNxCB5mv7RzpAkjYAucscXPMAjsxsie3U1J7f/sBCb6M2d/qP/P7Q2NExfiPogon5/BzXgO87oBUtL8xGzeniaFWQ8KBK10MPWkjDTxOJaJrwOhwjWUwgcoPGX9F8R9K2DhQ20czBKoCFSYdqBFSYDcZCPLx3gT17hPzrCG94oDR+VaavNog0B3QD+uy6SBn9crmEZcvDYcMmVWd5GS3yLpOzHBno154SuVyTLBQp6sJrDqzoPgpBNjnoVUxoa1JhwWmVI256E6sXowNl5ujRgk0dX3LqRlhfgXboaA475hLHR9t8G9ikRe3yIItoKUmDEjheO2Mq/8O6mYYNpQv8oKbz5sUpNm46RnpS2CFTlArpjQ== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 6X+oaoehp5tKqCW/XgtGhYciMESX3GHgSmsgBQbMyqiEWt9+v+S6cQ5CtbpMRPFR4opkIpo0+tuA7cAlOhDlP2GPLVEsa90lyF85nubeW9B0JAJQGkUvqy3QpyHkOXT90mHG15MZyI93mVHeK6Qc08KWmNe2zekQXnlJEa3dlW4q23+uwqyxIAHnn9wamv5dApk9+kd29q88IZpZdYXYHbrE00eOXShTST88R6YQGzTKBJ2C0bRy1inqlQQlAuHN1tanRy+HgmunTHFAb6d8V78YS2YCJ98qihUce9xxzMDbUKqwIRymEVigakMargNz+GIOsm1dJK2ABUnX+oi+nOziyPd/dNdrjFstZn7j7u3phkpFqfV5Vqi7jrALwgsh0VfRs0NkrXgR52wYVZ0+fVKzSp/Vec+5gtSHpH8Ghl3aZFPbsX3cyUrDSWP86NcDYAIUViFE4kK6Mq7AyneNqsjhNh7DvPA30xe/puNisEJuILI+NiNxEwE/Gr3b1T1EYw3es+BnXp3MY7mSuYMWla6JFuyE9dSjDyZt7HXUAHKa9ypjKf0W4c1kgKdcTmlBuTzGMzTGFgsAZkqFd94kcqwtoi9YWv8dvBZ4BCr9rOaRXUEa77YVko5J8njRhTL8hmvy55CzOFzNTQBHj23qfNHTJqkYJlfLIWgJhPnqFPRekFgV9HxOh8XK8dUD2KSSX4YRTFm1bVRfzzrdrzavbKMzv8NA3FFkxFMlOrFdWI+JFNYqRMKKgEtSa/zm1f/hKzX8L7Ueei/tD6HqUnklNQ== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: b3439cb3-7485-48f4-8d37-08db2025e6f1 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Mar 2023 22:38:56.4931 (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: gSdo5ytjV7UQxeJPbnhqfKOz3zjaGCtRSQRkqL68d4uKh2rZg5LKV+eEUjlcxdbWrER62wYcnnnN2egEdPoLOej+mH2yhYi5GoIpZDp+6PU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR10MB4162 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-08_15,2023-03-08_03,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 adultscore=0 phishscore=0 suspectscore=0 malwarescore=0 spamscore=0 bulkscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2303080190 X-Proofpoint-GUID: SyPi1FH1FqkYuUyvMLvLTyPqAx0ONQ4r X-Proofpoint-ORIG-GUID: SyPi1FH1FqkYuUyvMLvLTyPqAx0ONQ4r Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Allison Henderson When an inode is removed, it may also cause the attribute fork to be removed if it is the last attribute. This transaction gets flushed to the log, but if the system goes down before we could inactivate the symlink, the log recovery tries to inactivate this inode (since it is on the unlinked list) but the verifier trips over the remote value and leaks it. Hence we ended up with a file in this odd state on a "clean" mount. The "obvious" fix is to prohibit erasure of the attr fork to avoid tripping over the verifiers when pptrs are enabled. Signed-off-by: Darrick J. Wong Signed-off-by: Allison Henderson --- fs/xfs/libxfs/xfs_attr_leaf.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/fs/xfs/libxfs/xfs_attr_leaf.c b/fs/xfs/libxfs/xfs_attr_leaf.c index beee51ad75ce..e6c4c8b52a55 100644 --- a/fs/xfs/libxfs/xfs_attr_leaf.c +++ b/fs/xfs/libxfs/xfs_attr_leaf.c @@ -854,7 +854,8 @@ xfs_attr_sf_removename( totsize -= size; if (totsize == sizeof(xfs_attr_sf_hdr_t) && xfs_has_attr2(mp) && (dp->i_df.if_format != XFS_DINODE_FMT_BTREE) && - !(args->op_flags & (XFS_DA_OP_ADDNAME | XFS_DA_OP_REPLACE))) { + !(args->op_flags & (XFS_DA_OP_ADDNAME | XFS_DA_OP_REPLACE)) && + !xfs_has_parent(mp)) { xfs_attr_fork_remove(dp, args->trans); } else { xfs_idata_realloc(dp, -size, XFS_ATTR_FORK); @@ -863,7 +864,8 @@ xfs_attr_sf_removename( ASSERT(totsize > sizeof(xfs_attr_sf_hdr_t) || (args->op_flags & XFS_DA_OP_ADDNAME) || !xfs_has_attr2(mp) || - dp->i_df.if_format == XFS_DINODE_FMT_BTREE); + dp->i_df.if_format == XFS_DINODE_FMT_BTREE || + xfs_has_parent(mp)); xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE | XFS_ILOG_ADATA); }