From patchwork Tue Jan 24 01:35: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: 13113256 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 60BC5C25B50 for ; Tue, 24 Jan 2023 01:36:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229605AbjAXBg3 (ORCPT ); Mon, 23 Jan 2023 20:36:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56510 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230363AbjAXBg2 (ORCPT ); Mon, 23 Jan 2023 20:36:28 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B7DA51258F for ; Mon, 23 Jan 2023 17:36:26 -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 30O04avJ021868 for ; Tue, 24 Jan 2023 01:36: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=p+Mj2o48KZIU06tjOsGJKlU3MX9+qMBJYtvtML+DC1k=; b=nhSI6huIlD9ZNgl5RD/vevRSf9YPfM62Dy6MDujMcB5Oe1mfWopO4jUBuR4tLoJs5o7c bRLIgSa5VCi+LVoUnnDVL/I7/YzDv77Gy2SEEQqiHoOYD6J9tJdUclNURKOBlXUw0WIj KRqPVC7BuC/xPRqGvweyXcYto5uXbzDp8v59NeSBmvV8qAGnFsz8kUfSwYK2Ss0uhIsf dlsjwVtExgLoCCK3QlfxGJ4hw2xN1i89MpaPUi9LufQJFevod3PL+KoKd7dyeON+QP6N 0UmeCsvCmXtTP5BXbuvOdMpzfNxeekhW39SKdRhodvAcNNbBmq28hivdHZZdfzm4wphX 6A== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3n88ktv8ch-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 24 Jan 2023 01:36:26 +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 30NN5GwA040221 for ; Tue, 24 Jan 2023 01:36:25 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2107.outbound.protection.outlook.com [104.47.58.107]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3n86g4a7rb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 24 Jan 2023 01:36:25 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hX62WwmJNDFB08JwjTOdL655dhM9QibxMemTmYrSs3lXr9OdXQmRaAg885LFnmlmtnhegpJ3SJe4xJp+IPM1SlPVZ2klkvs8u/bwWwKzej/uzQwsGX4ojUp6uocKh/K++3REh6PmMHHnMOLejJPpF/ooluVPmvchBTxr0c0y8AEp/XFZBut7idTdNUtRhf2BW1MML8xNt20OlRLMwotmpWvzBECQgZosdsJW7XOR0AvikjSFaf2YvY4chI4Nlt8clMFBh+fdI1c8oT6IMEyNJv2SMEKZNd4LHaE9fsd1kqpeVUEC5SFVPlTzF8QsOb+/6qlJ8tNzX6n0LIBPwD6ubA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=p+Mj2o48KZIU06tjOsGJKlU3MX9+qMBJYtvtML+DC1k=; b=P8h3+5KXA+BA7x1aU42YaDuUQXagoEfjw53NhdJL7MIMvG+ZXRbRk2BAtVi5drXRqOS8nMR5pGSMB5B2ndH0R+Xh33DFgY8AP12RogEBw9UZEYQbs4gceZ4twtdBms7MUsG1lh3oGTv6eqSj1nZvauO2VtnXWbdSp+u4gvmzMeNipwv7QllVbeIQzVHB0BRetZ0MVgB0dKBJ+JR32nwKTrKgSurwhgvfpU0nogJzs4TH3mmPKUpnRi13GJW1ibnSjMedrOGU0SePFYOhmRoAT7pcvS25nUXyKLWiu6+Nq+GbNhJKTsGAkPJ3XFS+q4KZKd7FD/z8Tx98Hi31PHMOZg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=p+Mj2o48KZIU06tjOsGJKlU3MX9+qMBJYtvtML+DC1k=; b=iUI+Z6hwRXoTPYfWZWDPt7kh+Ul9h+xDaRIPiyqQDi9gNnKkbXFIEVd7fTAqXxGSDpIs/oY+yJRnBR32th5qtGrV78Nm+b8KkQPoGtM2Q7Qe+WLNquFkX2JWoEIOzAxB+IJuiEMMYeAZEyu699PYjlo0KF0O01RlBrqHclO3JSE= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by CH0PR10MB5052.namprd10.prod.outlook.com (2603:10b6:610:de::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.16; Tue, 24 Jan 2023 01:36:23 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::eaff:9f55:4641:db38]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::eaff:9f55:4641:db38%4]) with mapi id 15.20.6043.016; Tue, 24 Jan 2023 01:36:23 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v8 01/27] xfs: Add new name to attri/d Date: Mon, 23 Jan 2023 18:35:54 -0700 Message-Id: <20230124013620.1089319-2-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230124013620.1089319-1-allison.henderson@oracle.com> References: <20230124013620.1089319-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_|CH0PR10MB5052:EE_ X-MS-Office365-Filtering-Correlation-Id: 054ef252-a62b-4d6a-bd44-08dafdab6696 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: pbc92fXUK7lqwNYnVHP2wdmUG2IYBhtVuSW5r+tGMVZA1h0aeQFlcQXGGqfTwMeZQvWMkK8i2jSZldBEC9obGSz76ghv6fNtm4v5HxWkqrLbxmGmvkSvoicsdcXKlD/Rgr6VPdkK6DP2FImGTA0HAT7O9VMr7SFfuZMo5zo9avl9/oYSKIoH6KzAThDOln+6RR2nraNI6ruwdpsUlRs+2tA/hAylvaZ+lDpI719moGjEZIfTgwVYzcmdYDTPmOJ9gK80yAB3G+bh+3M8IquEiO5kqKf+03FhVCI0DxGtw1UHVg9Abmvp3ir64K+1li0eXGgYjFKd7x7UteUrzkZMetx6ouSHZjgXMLdwMRmUzqjBWNxxoB+fHUm4IQRn24WWSjhfKnHIqL4FXjXmBwgtRjPr0RtWMH/cZPdvjkHQ5FRDgokRkgeR/g/+sO5ncE2Dop1yufpe+UfslPC81xmpluIfFCEN82Al3cO2OAm8Jo6PAZH5zWOMzKypY+YiAATb+xUiKL8CrbiIImFGjWxSq1LEOBOb07aERBvZo+HUpuzz4bT2YRZoaVhdTdi1QWsTItI7v7SRhGeLUqszYgYiluF/hjEIU02MODOKNIa6o6GWcucBiKXBgoC0PBNOx5Qb/Xf09HebApQL6gcsQvex6A== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(39860400002)(366004)(136003)(376002)(346002)(396003)(451199015)(1076003)(83380400001)(2616005)(86362001)(38100700002)(36756003)(6916009)(8676002)(66476007)(66946007)(66556008)(30864003)(9686003)(5660300002)(2906002)(41300700001)(8936002)(6666004)(6486002)(478600001)(186003)(6512007)(26005)(6506007)(316002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 6ImZxCQO4+Geoi1ib+9+ve/hbmlKJivGyq3t8QFG5yaVO5ZEjYqs/PCV+QUO61EJAkIb2+oVo1yhJ4lRVDKxzRAllmrWQPbipKeornItPo/XC/h7ujGh40hePCV8r+xQJWK9su1zyqhh/v7WLdjDLfQhshkBzOtahz02BL1vzxIfTIesz64Z1B0vCBC3Tdv95ccZ2+PPg2Qsg+uDbH8X1N6Ew0tvsYpdMPtEG1QTH7Xd4tQcCzNoUuQggoEoo72q3Xx2VbNyl6ZjIu/Cm7egegoUTFCAqtDCI2bB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MjKNvvz6IxMvxVof/AxgqwE3iUPx/r62nAQFQS0tsYqLw3OL3w== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 054ef252-a62b-4d6a-bd44-08dafdab6696 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jan 2023 01:36:23.0610 (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: Fh6T92LqwZzneyuoq1clsLTvVgHPN7UYCA1Kp9/SeezQANNV3KN4Omdv29dpIhU5c+n7zwbM5UhfVadCI1jfrpgcPUYWSvUG6IhvoqXS26M= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR10MB5052 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-23_12,2023-01-23_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 bulkscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 spamscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301240010 X-Proofpoint-GUID: 73bO1-PnwynMSDbwJHuPifqg72fuKXIn X-Proofpoint-ORIG-GUID: 73bO1-PnwynMSDbwJHuPifqg72fuKXIn Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Allison Henderson This patch adds two new fields to the atti/d. They are nname and nnamelen. This will be used for parent pointer updates since a rename operation may cause the parent pointer to update both the name and value. So we need to carry both the new name as well as the target name in the attri/d. Signed-off-by: Allison Henderson --- fs/xfs/libxfs/xfs_attr.c | 12 ++- fs/xfs/libxfs/xfs_attr.h | 4 +- fs/xfs/libxfs/xfs_da_btree.h | 2 + fs/xfs/libxfs/xfs_log_format.h | 6 +- fs/xfs/xfs_attr_item.c | 135 +++++++++++++++++++++++++++------ fs/xfs/xfs_attr_item.h | 1 + 6 files changed, 133 insertions(+), 27 deletions(-) diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c index e28d93d232de..b1dbed7655e8 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -423,6 +423,12 @@ xfs_attr_complete_op( args->op_flags &= ~XFS_DA_OP_REPLACE; if (do_replace) { args->attr_filter &= ~XFS_ATTR_INCOMPLETE; + if (args->new_namelen > 0) { + args->name = args->new_name; + args->namelen = args->new_namelen; + args->hashval = xfs_da_hashname(args->name, + args->namelen); + } return replace_state; } return XFS_DAS_DONE; @@ -922,9 +928,13 @@ xfs_attr_defer_replace( struct xfs_da_args *args) { struct xfs_attr_intent *new; + int op_flag; int error = 0; - error = xfs_attr_intent_init(args, XFS_ATTRI_OP_FLAGS_REPLACE, &new); + op_flag = args->new_namelen == 0 ? XFS_ATTRI_OP_FLAGS_REPLACE : + XFS_ATTRI_OP_FLAGS_NVREPLACE; + + error = xfs_attr_intent_init(args, op_flag, &new); if (error) return error; diff --git a/fs/xfs/libxfs/xfs_attr.h b/fs/xfs/libxfs/xfs_attr.h index 81be9b3e4004..3e81f3f48560 100644 --- a/fs/xfs/libxfs/xfs_attr.h +++ b/fs/xfs/libxfs/xfs_attr.h @@ -510,8 +510,8 @@ struct xfs_attr_intent { struct xfs_da_args *xattri_da_args; /* - * Shared buffer containing the attr name and value so that the logging - * code can share large memory buffers between log items. + * Shared buffer containing the attr name, new name, and value so that + * the logging code can share large memory buffers between log items. */ struct xfs_attri_log_nameval *xattri_nameval; diff --git a/fs/xfs/libxfs/xfs_da_btree.h b/fs/xfs/libxfs/xfs_da_btree.h index ffa3df5b2893..a4b29827603f 100644 --- a/fs/xfs/libxfs/xfs_da_btree.h +++ b/fs/xfs/libxfs/xfs_da_btree.h @@ -55,7 +55,9 @@ enum xfs_dacmp { typedef struct xfs_da_args { struct xfs_da_geometry *geo; /* da block geometry */ const uint8_t *name; /* string (maybe not NULL terminated) */ + const uint8_t *new_name; /* new attr name */ int namelen; /* length of string (maybe no NULL) */ + int new_namelen; /* new attr name len */ uint8_t filetype; /* filetype of inode for directories */ void *value; /* set of bytes (maybe contain NULLs) */ int valuelen; /* length of value */ diff --git a/fs/xfs/libxfs/xfs_log_format.h b/fs/xfs/libxfs/xfs_log_format.h index f13e0809dc63..ae9c99762a24 100644 --- a/fs/xfs/libxfs/xfs_log_format.h +++ b/fs/xfs/libxfs/xfs_log_format.h @@ -117,7 +117,8 @@ struct xfs_unmount_log_format { #define XLOG_REG_TYPE_ATTRD_FORMAT 28 #define XLOG_REG_TYPE_ATTR_NAME 29 #define XLOG_REG_TYPE_ATTR_VALUE 30 -#define XLOG_REG_TYPE_MAX 30 +#define XLOG_REG_TYPE_ATTR_NNAME 31 +#define XLOG_REG_TYPE_MAX 31 /* @@ -957,6 +958,7 @@ struct xfs_icreate_log { #define XFS_ATTRI_OP_FLAGS_SET 1 /* Set the attribute */ #define XFS_ATTRI_OP_FLAGS_REMOVE 2 /* Remove the attribute */ #define XFS_ATTRI_OP_FLAGS_REPLACE 3 /* Replace the attribute */ +#define XFS_ATTRI_OP_FLAGS_NVREPLACE 4 /* Replace attr name and val */ #define XFS_ATTRI_OP_FLAGS_TYPE_MASK 0xFF /* Flags type mask */ /* @@ -974,7 +976,7 @@ struct xfs_icreate_log { struct xfs_attri_log_format { uint16_t alfi_type; /* attri log item type */ uint16_t alfi_size; /* size of this item */ - uint32_t __pad; /* pad to 64 bit aligned */ + uint32_t alfi_nname_len; /* attr new name length */ uint64_t alfi_id; /* attri identifier */ uint64_t alfi_ino; /* the inode for this attr operation */ uint32_t alfi_op_flags; /* marks the op as a set or remove */ diff --git a/fs/xfs/xfs_attr_item.c b/fs/xfs/xfs_attr_item.c index 2788a6f2edcd..95e9ecbb4a67 100644 --- a/fs/xfs/xfs_attr_item.c +++ b/fs/xfs/xfs_attr_item.c @@ -75,6 +75,8 @@ static inline struct xfs_attri_log_nameval * xfs_attri_log_nameval_alloc( const void *name, unsigned int name_len, + const void *nname, + unsigned int nname_len, const void *value, unsigned int value_len) { @@ -85,15 +87,25 @@ xfs_attri_log_nameval_alloc( * this. But kvmalloc() utterly sucks, so we use our own version. */ nv = xlog_kvmalloc(sizeof(struct xfs_attri_log_nameval) + - name_len + value_len); + name_len + nname_len + value_len); nv->name.i_addr = nv + 1; nv->name.i_len = name_len; nv->name.i_type = XLOG_REG_TYPE_ATTR_NAME; memcpy(nv->name.i_addr, name, name_len); + if (nname_len) { + nv->nname.i_addr = nv->name.i_addr + name_len; + nv->nname.i_len = nname_len; + memcpy(nv->nname.i_addr, nname, nname_len); + } else { + nv->nname.i_addr = NULL; + nv->nname.i_len = 0; + } + nv->nname.i_type = XLOG_REG_TYPE_ATTR_NNAME; + if (value_len) { - nv->value.i_addr = nv->name.i_addr + name_len; + nv->value.i_addr = nv->name.i_addr + nname_len + name_len; nv->value.i_len = value_len; memcpy(nv->value.i_addr, value, value_len); } else { @@ -147,11 +159,15 @@ xfs_attri_item_size( *nbytes += sizeof(struct xfs_attri_log_format) + xlog_calc_iovec_len(nv->name.i_len); - if (!nv->value.i_len) - return; + if (nv->nname.i_len) { + *nvecs += 1; + *nbytes += xlog_calc_iovec_len(nv->nname.i_len); + } - *nvecs += 1; - *nbytes += xlog_calc_iovec_len(nv->value.i_len); + if (nv->value.i_len) { + *nvecs += 1; + *nbytes += xlog_calc_iovec_len(nv->value.i_len); + } } /* @@ -181,6 +197,9 @@ xfs_attri_item_format( ASSERT(nv->name.i_len > 0); attrip->attri_format.alfi_size++; + if (nv->nname.i_len > 0) + attrip->attri_format.alfi_size++; + if (nv->value.i_len > 0) attrip->attri_format.alfi_size++; @@ -188,6 +207,10 @@ xfs_attri_item_format( &attrip->attri_format, sizeof(struct xfs_attri_log_format)); xlog_copy_from_iovec(lv, &vecp, &nv->name); + + if (nv->nname.i_len > 0) + xlog_copy_from_iovec(lv, &vecp, &nv->nname); + if (nv->value.i_len > 0) xlog_copy_from_iovec(lv, &vecp, &nv->value); } @@ -374,6 +397,7 @@ xfs_attr_log_item( attrp->alfi_op_flags = attr->xattri_op_flags; attrp->alfi_value_len = attr->xattri_nameval->value.i_len; attrp->alfi_name_len = attr->xattri_nameval->name.i_len; + attrp->alfi_nname_len = attr->xattri_nameval->nname.i_len; ASSERT(!(attr->xattri_da_args->attr_filter & ~XFS_ATTRI_FILTER_MASK)); attrp->alfi_attr_filter = attr->xattri_da_args->attr_filter; } @@ -415,7 +439,8 @@ xfs_attr_create_intent( * deferred work state structure. */ attr->xattri_nameval = xfs_attri_log_nameval_alloc(args->name, - args->namelen, args->value, args->valuelen); + args->namelen, args->new_name, + args->new_namelen, args->value, args->valuelen); } attrip = xfs_attri_init(mp, attr->xattri_nameval); @@ -503,7 +528,8 @@ xfs_attri_validate( unsigned int op = attrp->alfi_op_flags & XFS_ATTRI_OP_FLAGS_TYPE_MASK; - if (attrp->__pad != 0) + if (attrp->alfi_op_flags != XFS_ATTRI_OP_FLAGS_NVREPLACE && + attrp->alfi_nname_len != 0) return false; if (attrp->alfi_op_flags & ~XFS_ATTRI_OP_FLAGS_TYPE_MASK) @@ -517,6 +543,7 @@ xfs_attri_validate( case XFS_ATTRI_OP_FLAGS_SET: case XFS_ATTRI_OP_FLAGS_REPLACE: case XFS_ATTRI_OP_FLAGS_REMOVE: + case XFS_ATTRI_OP_FLAGS_NVREPLACE: break; default: return false; @@ -526,9 +553,14 @@ xfs_attri_validate( return false; if ((attrp->alfi_name_len > XATTR_NAME_MAX) || + (attrp->alfi_nname_len > XATTR_NAME_MAX) || (attrp->alfi_name_len == 0)) return false; + if (op == XFS_ATTRI_OP_FLAGS_REMOVE && + attrp->alfi_value_len != 0) + return false; + return xfs_verify_ino(mp, attrp->alfi_ino); } @@ -589,6 +621,8 @@ xfs_attri_item_recover( args->whichfork = XFS_ATTR_FORK; args->name = nv->name.i_addr; args->namelen = nv->name.i_len; + args->new_name = nv->nname.i_addr; + args->new_namelen = nv->nname.i_len; args->hashval = xfs_da_hashname(args->name, args->namelen); args->attr_filter = attrp->alfi_attr_filter & XFS_ATTRI_FILTER_MASK; args->op_flags = XFS_DA_OP_RECOVERY | XFS_DA_OP_OKNOENT | @@ -599,6 +633,7 @@ xfs_attri_item_recover( switch (attr->xattri_op_flags) { case XFS_ATTRI_OP_FLAGS_SET: case XFS_ATTRI_OP_FLAGS_REPLACE: + case XFS_ATTRI_OP_FLAGS_NVREPLACE: args->value = nv->value.i_addr; args->valuelen = nv->value.i_len; args->total = xfs_attr_calc_size(args, &local); @@ -688,6 +723,7 @@ xfs_attri_item_relog( new_attrp->alfi_op_flags = old_attrp->alfi_op_flags; new_attrp->alfi_value_len = old_attrp->alfi_value_len; new_attrp->alfi_name_len = old_attrp->alfi_name_len; + new_attrp->alfi_nname_len = old_attrp->alfi_nname_len; new_attrp->alfi_attr_filter = old_attrp->alfi_attr_filter; xfs_trans_add_item(tp, &new_attrip->attri_item); @@ -710,48 +746,102 @@ xlog_recover_attri_commit_pass2( const void *attr_value = NULL; const void *attr_name; size_t len; - - attri_formatp = item->ri_buf[0].i_addr; - attr_name = item->ri_buf[1].i_addr; + const void *attr_nname = NULL; + int op, i = 0; /* Validate xfs_attri_log_format before the large memory allocation */ len = sizeof(struct xfs_attri_log_format); - if (item->ri_buf[0].i_len != len) { + if (item->ri_buf[i].i_len != len) { XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, - item->ri_buf[0].i_addr, item->ri_buf[0].i_len); + item->ri_buf[i].i_addr, item->ri_buf[i].i_len); return -EFSCORRUPTED; } + attri_formatp = item->ri_buf[i].i_addr; if (!xfs_attri_validate(mp, attri_formatp)) { XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, - item->ri_buf[0].i_addr, item->ri_buf[0].i_len); + item->ri_buf[i].i_addr, item->ri_buf[i].i_len); + return -EFSCORRUPTED; + } + + op = attri_formatp->alfi_op_flags & XFS_ATTRI_OP_FLAGS_TYPE_MASK; + switch (op) { + case XFS_ATTRI_OP_FLAGS_SET: + case XFS_ATTRI_OP_FLAGS_REPLACE: + if (item->ri_total != 3) { + XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, + attri_formatp, len); + return -EFSCORRUPTED; + } + break; + case XFS_ATTRI_OP_FLAGS_REMOVE: + if (item->ri_total != 2) { + XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, + attri_formatp, len); + return -EFSCORRUPTED; + } + break; + case XFS_ATTRI_OP_FLAGS_NVREPLACE: + if (item->ri_total != 4) { + XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, + attri_formatp, len); + return -EFSCORRUPTED; + } + break; + default: + XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, + attri_formatp, len); return -EFSCORRUPTED; } + i++; /* Validate the attr name */ - if (item->ri_buf[1].i_len != + if (item->ri_buf[i].i_len != xlog_calc_iovec_len(attri_formatp->alfi_name_len)) { XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, - item->ri_buf[0].i_addr, item->ri_buf[0].i_len); + attri_formatp, len); return -EFSCORRUPTED; } + attr_name = item->ri_buf[i].i_addr; if (!xfs_attr_namecheck(attr_name, attri_formatp->alfi_name_len)) { XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, - item->ri_buf[1].i_addr, item->ri_buf[1].i_len); + item->ri_buf[i].i_addr, item->ri_buf[i].i_len); return -EFSCORRUPTED; } + i++; + if (attri_formatp->alfi_nname_len) { + /* Validate the attr nname */ + if (item->ri_buf[i].i_len != + xlog_calc_iovec_len(attri_formatp->alfi_nname_len)) { + XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, + item->ri_buf[i].i_addr, + item->ri_buf[i].i_len); + return -EFSCORRUPTED; + } + + attr_nname = item->ri_buf[i].i_addr; + if (!xfs_attr_namecheck(attr_nname, + attri_formatp->alfi_nname_len)) { + XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, + item->ri_buf[i].i_addr, + item->ri_buf[i].i_len); + return -EFSCORRUPTED; + } + i++; + } + + /* Validate the attr value, if present */ if (attri_formatp->alfi_value_len != 0) { - if (item->ri_buf[2].i_len != xlog_calc_iovec_len(attri_formatp->alfi_value_len)) { + if (item->ri_buf[i].i_len != xlog_calc_iovec_len(attri_formatp->alfi_value_len)) { XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, - item->ri_buf[0].i_addr, - item->ri_buf[0].i_len); + attri_formatp, len); return -EFSCORRUPTED; } - attr_value = item->ri_buf[2].i_addr; + attr_value = item->ri_buf[i].i_addr; } /* @@ -760,7 +850,8 @@ xlog_recover_attri_commit_pass2( * reference. */ nv = xfs_attri_log_nameval_alloc(attr_name, - attri_formatp->alfi_name_len, attr_value, + attri_formatp->alfi_name_len, attr_nname, + attri_formatp->alfi_nname_len, attr_value, attri_formatp->alfi_value_len); attrip = xfs_attri_init(mp, nv); diff --git a/fs/xfs/xfs_attr_item.h b/fs/xfs/xfs_attr_item.h index 3280a7930287..24d4968dd6cc 100644 --- a/fs/xfs/xfs_attr_item.h +++ b/fs/xfs/xfs_attr_item.h @@ -13,6 +13,7 @@ struct kmem_zone; struct xfs_attri_log_nameval { struct xfs_log_iovec name; + struct xfs_log_iovec nname; struct xfs_log_iovec value; refcount_t refcount; From patchwork Tue Jan 24 01:35:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 13113257 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 C777FC54E94 for ; Tue, 24 Jan 2023 01:36:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232010AbjAXBgb (ORCPT ); Mon, 23 Jan 2023 20:36:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56522 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230363AbjAXBga (ORCPT ); Mon, 23 Jan 2023 20:36:30 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 14C8011EBD for ; Mon, 23 Jan 2023 17:36:29 -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 30O05r8Z022928 for ; Tue, 24 Jan 2023 01:36: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=kjnJXb4QLTI/gC6onLA0jkmfXuy0GCZXIVbvceEUfO0=; b=qdiEHyayKAdzwKU4Ep0EWO9IW8uubsDd3Ow/JcYLTlatUOpilxqZrbi9LQK8AbBn2Nb0 aYP0wVIrXxVybnZmbN2ramS8vrjqHlEDPWv4/eXzoPWZ58vEtfLJ6LZ1Dvqpo1AX37Ws +Stk7Rt+r2KVCXxiSvn6vdqT6FpiD7d1fOEk+qfZEchqafXtefzSYHi/JYLOL5wdgJR4 Muf3i8p7dlWlOZ+AkvQ4QRXFcijNuQZQ0ukfvweyrLE3YWhbHiLIYSk66thNSiMdvA/4 Ka2L5teXKIDDNwavHLMUJmRNADBFIBOT1Wh+oQJZYdVEhub0DzLuuKl+mwuznF2eVRxs 5w== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3n87xa4a12-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 24 Jan 2023 01:36:28 +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 30O1M9Jr039626 for ; Tue, 24 Jan 2023 01:36:27 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2103.outbound.protection.outlook.com [104.47.58.103]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3n86gb4ase-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 24 Jan 2023 01:36:27 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jTOtIOYrLMF6nNBI8sSYbFPlhorjUQEPZnV+UAEeNylhGCUW9LD4hnO3uXiy4aXZHBWLC06x/Sym0ndKt9+Ml+RXnERVOyoWUoDWqXqvxtjCjLCdp83Gvb9GfmDhbenOYHbbz0ljeJErQX+NqX0oxDl6N0kr3V4wWqrEu+1TWhU+T25Asq7o1ZRcpN8BAk95HeQ1+/xNKtKSGCQC7lt3xabTsv+7RO0aMLhF5LYs91pBMGhNA0tY7azA8pe3agE3bPcXAfD7wc4PwUISwfHL2QpJBCtDkE3ZTT6qDMGNxqlg0drYjOAT7sItKZz6A3ArJSKhkHQVycqlWlGZPA42wA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=kjnJXb4QLTI/gC6onLA0jkmfXuy0GCZXIVbvceEUfO0=; b=XUqg9sj8hc+LTr8nPrGOyt6xTXpnEuVr72e+7a3x39EDVDZr8J2DbgaRk/+7zPyb7xTs/ZlZUrRPxyc25dknaA2C3nW4Ug/NL193ObHZYh4zCgb+4iYD7SkjyfbnmFmyFrFC8xpEJGW1Bl58qBn2I8PwvDUHMxUKDV8fySHzksavlMMrbMIH1nIC9e/WGgoYPJZFqFGq991JLtBLdGQyHTIV5JOBeNTesn3J7uDo4VYqZkWG9FGcYYA12U/1yVdSR1oJyARDmJ2IVNGL0YU9krUfUqwJUsNfpUJyUtUKPU42AqI9J7i48GQQBY5hlY6rHcp/tB6MEUVuf0s1JkdcLA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=kjnJXb4QLTI/gC6onLA0jkmfXuy0GCZXIVbvceEUfO0=; b=IoNRg3zwOmtgMmJ6nZhBBOv85+SNH/NNX2od2U5CljWM8RPbL55G7rMgAyOlPEE5bJ7/qR+fQwCCi8lwRgfR76UPY6EUR0rM4rJUePwSodim+MVs54RZ/i8CpNkop3s7EnRboRB86GI9CWnx/VKIGxmnpPinP3oPrXUx1ynja3A= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by CH0PR10MB5052.namprd10.prod.outlook.com (2603:10b6:610:de::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.16; Tue, 24 Jan 2023 01:36:25 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::eaff:9f55:4641:db38]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::eaff:9f55:4641:db38%4]) with mapi id 15.20.6043.016; Tue, 24 Jan 2023 01:36:25 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v8 02/27] xfs: Increase XFS_DEFER_OPS_NR_INODES to 5 Date: Mon, 23 Jan 2023 18:35:55 -0700 Message-Id: <20230124013620.1089319-3-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230124013620.1089319-1-allison.henderson@oracle.com> References: <20230124013620.1089319-1-allison.henderson@oracle.com> X-ClientProxiedBy: BYAPR07CA0082.namprd07.prod.outlook.com (2603:10b6:a03:12b::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_|CH0PR10MB5052:EE_ X-MS-Office365-Filtering-Correlation-Id: 2ba92335-dc03-4b5c-222f-08dafdab67db X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: AZQP4o6tMEY6ixrmFwxOJ8k1WHOv6mL8YkTk/wxk7QKNanf0I7rKi2et91Y1FfyZ8BHNlJKHUysuit1UDfVglZr8oIKnox9aADbdT3tw1tA+PTe7viKFIt8Ls/h5WewU0cg/AmUS4jG1XEpXTi61nK2j8bnPDi/PyPuqWBtIcBrFxvFOQ+QEywyu26xTjFJ6pe0rvJ52PClUnuBENoD7L23moDBV3rfmbRwTa2J1drVRxkha2IFhVn9aMIv9kreh2NVue92cKeE3sgV1aH1RS/mYLAZBe4PMYmdJt9Qc5crJFNHfPXjr/Di/H1e+8gxVn12/9eLbcRqfiR5c1W1T7H5wnWySiEgB33p9Ez49Ro/bccuonLQmXQOq72eTN0USxm9cluM/alX/xMdY6fYqs2R1pYaEFieBm1As4DxEtOoJ/54ME5OnHK1vOZ18XuoRAO7AjRlMbImkriRlMrZTZG/QarYF7kxq4msyux7PxaV+23RyKPfIyze2KJBS15InUCRgVQvtvh2t2ykv2VBbxvIFIv8uFUKr6GPEwBqFNimScZordHrgrMh3qDw/fsQllMwFrOIT3F2kIP/OK4iTmnBcEqPNgS0DAN46g1zivD6B8DGQj0S91Y83wNLUrKG3oFKLnqV8zx2HJpIve3ydqA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(39860400002)(366004)(136003)(376002)(346002)(396003)(451199015)(1076003)(83380400001)(2616005)(86362001)(38100700002)(36756003)(6916009)(8676002)(66476007)(66946007)(66556008)(9686003)(5660300002)(2906002)(41300700001)(8936002)(6666004)(6486002)(478600001)(186003)(6512007)(26005)(6506007)(316002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: vgE2YoCDr+D9bVGeCtNGNedJrSrEAbOlVKq5sQ4RxUsU+PEaNwANCQdMxBLAvqzRfGyt3FStODN5ZsRyhOmIYO0b3eyrFYEiNGAHnxXUwPlx8RWi0rTo5huu0JYF3Bi6ZmnopIxZ1Tr5WZWANqrtFRlaOzvpl4OSzcsivHpBA7wZGXGxrQsZgTLE8PLPEoRcXXcK9my4iPPTsXbmFPkzlLJR/aV5oEg6H1awfP7W5dBCy74NE+CifSLULzwYVwY6dwJa/ee8GI3RG9YhPpugz5nJM+qcxBQ3TQ3Hd7jfWBOJSHMTUG4AJ37KLf3krjfA3DIr7JazDR+oJeI6yhprivP7rxgmTkkBM0RdZFO4vreFpYSrcuFwakOzznMT0wqoIuE38wbw+KLuNwMonSNBgTcaMntZduXYZAOlFD+5kDCE51oOdWFNxJPn131zvNJglEDW+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Vp9EyIgzf0gOko0rh/CLao5+2WOgeKNxi/GW963pSM1lkOHrne5PsrqXQwJqNPEJVSNTaqb11L9UFuABoq+Nbb8A== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: je22eDZB+jYtvNZsO7QIJJlQKwDsyBZCPna1+L+8kE/XTDjFSpAeIZQl8ZWPDccXPr5S8cgNkLtWLyig0SN311IXJV4Cg3vPUHBq/oJYZ2mkhcssiI+fbX+KBZrh2KyVJSdgLw8NodK43GM48F+dYHEb0MZLFrsXNGpIXyqdsv1evFD8MZNHosLJlJgx3TXhbHDsGBHoEPb3mxF3BVRrBQ5g3SOw8dAc6bdkurRYgZK1GtYiBc8EL2fvcjSAr2mxQBgk3s79hDVME5gLQED7noipjz7ty4mpnnwiNChdiBJZ2NRDR6GImEmE+DgS+s821zT90kCg5/MVjvrTxpbLGVRDeTuAN6Vp8wVY01OP3lMzG2JZKyrM1dPJbnTIHkFZTPfXcAN7L08gHau6cRU5vUs6O1gCtR/RAyesHzVbnoxvPX8Lf4n56MCdmIflNZHfK0P33TDziuoq/uHYk2eYhkI4UGCf0Mz1whbBbJ8qjUIrSHmg7Lbadnwm+M08wuv60q+aVT5eXhPEU9Xue9OM9I6M9qgr2gVpLwCmNJGy3mRs8TPmnR04mHfdJZYuCqCRxW8DTsM1cXeLSb3tXWcGYwITz9C7Zpbn4EbAjKaVcsrbBFINnBiW92ZaLu+sF6AAAZwLJGzHYc6V3o6gbNcsbhClrnsgTnYmE7fRPJCSHi8crQGff3St0SK8NpIj7N4guc+FnGDked5gXHyFfn/5Wt6uooIK0sOt3e2tRQ4pnx5Mh83wW1mC/7ISdJrOJjurR8b5MfScd11n46ERQ394yw== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2ba92335-dc03-4b5c-222f-08dafdab67db X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jan 2023 01:36:25.2182 (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: dXHmli45zaV8DebHCuXwD0Ynb5Bg1tJqe0Gut63xxQD0UrqAbHjZPZPzkEz3JhiyxetS0iC7yDymKdepnT/wOqfKVGtLsQ0PJUDtdX6gYm8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR10MB5052 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-23_12,2023-01-23_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 mlxscore=0 spamscore=0 bulkscore=0 mlxlogscore=999 malwarescore=0 adultscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301240010 X-Proofpoint-GUID: OgWg3ohLaTry1X26AlAID-9TyJM9oOZz X-Proofpoint-ORIG-GUID: OgWg3ohLaTry1X26AlAID-9TyJM9oOZz Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Allison Henderson Renames that generate parent pointer updates can join up to 5 inodes locked in sorted order. So we need to increase the number of defer ops inodes and relock them in the same way. Signed-off-by: Allison Henderson Reviewed-by: Darrick J. Wong Reviewed-by: Catherine Hoang --- fs/xfs/libxfs/xfs_defer.c | 28 ++++++++++++++++++++++++++-- fs/xfs/libxfs/xfs_defer.h | 8 +++++++- fs/xfs/xfs_inode.c | 2 +- fs/xfs/xfs_inode.h | 1 + 4 files changed, 35 insertions(+), 4 deletions(-) diff --git a/fs/xfs/libxfs/xfs_defer.c b/fs/xfs/libxfs/xfs_defer.c index 5a321b783398..c0279b57e51d 100644 --- a/fs/xfs/libxfs/xfs_defer.c +++ b/fs/xfs/libxfs/xfs_defer.c @@ -820,13 +820,37 @@ xfs_defer_ops_continue( struct xfs_trans *tp, struct xfs_defer_resources *dres) { - unsigned int i; + unsigned int i, j; + struct xfs_inode *sips[XFS_DEFER_OPS_NR_INODES]; + struct xfs_inode *temp; ASSERT(tp->t_flags & XFS_TRANS_PERM_LOG_RES); ASSERT(!(tp->t_flags & XFS_TRANS_DIRTY)); /* Lock the captured resources to the new transaction. */ - if (dfc->dfc_held.dr_inos == 2) + if (dfc->dfc_held.dr_inos > 2) { + /* + * Renames with parent pointer updates can lock up to 5 inodes, + * sorted by their inode number. So we need to make sure they + * are relocked in the same way. + */ + memset(sips, 0, sizeof(sips)); + for (i = 0; i < dfc->dfc_held.dr_inos; i++) + sips[i] = dfc->dfc_held.dr_ip[i]; + + /* Bubble sort of at most 5 inodes */ + for (i = 0; i < dfc->dfc_held.dr_inos; i++) { + for (j = 1; j < dfc->dfc_held.dr_inos; j++) { + if (sips[j]->i_ino < sips[j-1]->i_ino) { + temp = sips[j]; + sips[j] = sips[j-1]; + sips[j-1] = temp; + } + } + } + + xfs_lock_inodes(sips, dfc->dfc_held.dr_inos, XFS_ILOCK_EXCL); + } else if (dfc->dfc_held.dr_inos == 2) xfs_lock_two_inodes(dfc->dfc_held.dr_ip[0], XFS_ILOCK_EXCL, dfc->dfc_held.dr_ip[1], XFS_ILOCK_EXCL); else if (dfc->dfc_held.dr_inos == 1) diff --git a/fs/xfs/libxfs/xfs_defer.h b/fs/xfs/libxfs/xfs_defer.h index 114a3a4930a3..fdf6941f8f4d 100644 --- a/fs/xfs/libxfs/xfs_defer.h +++ b/fs/xfs/libxfs/xfs_defer.h @@ -70,7 +70,13 @@ extern const struct xfs_defer_op_type xfs_attr_defer_type; /* * Deferred operation item relogging limits. */ -#define XFS_DEFER_OPS_NR_INODES 2 /* join up to two inodes */ + +/* + * Rename w/ parent pointers can require up to 5 inodes with deferred ops to + * be joined to the transaction: src_dp, target_dp, src_ip, target_ip, and wip. + * These inodes are locked in sorted order by their inode numbers + */ +#define XFS_DEFER_OPS_NR_INODES 5 #define XFS_DEFER_OPS_NR_BUFS 2 /* join up to two buffers */ /* Resources that must be held across a transaction roll. */ diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index d354ea2b74f9..27532053a67b 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -447,7 +447,7 @@ xfs_lock_inumorder( * lock more than one at a time, lockdep will report false positives saying we * have violated locking orders. */ -static void +void xfs_lock_inodes( struct xfs_inode **ips, int inodes, diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h index fa780f08dc89..2eaed98af814 100644 --- a/fs/xfs/xfs_inode.h +++ b/fs/xfs/xfs_inode.h @@ -574,5 +574,6 @@ void xfs_end_io(struct work_struct *work); int xfs_ilock2_io_mmap(struct xfs_inode *ip1, struct xfs_inode *ip2); void xfs_iunlock2_io_mmap(struct xfs_inode *ip1, struct xfs_inode *ip2); +void xfs_lock_inodes(struct xfs_inode **ips, int inodes, uint lock_mode); #endif /* __XFS_INODE_H__ */ From patchwork Tue Jan 24 01:35:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 13113258 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 203E4C25B50 for ; Tue, 24 Jan 2023 01:36:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232064AbjAXBgg (ORCPT ); Mon, 23 Jan 2023 20:36:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56548 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230363AbjAXBgf (ORCPT ); Mon, 23 Jan 2023 20:36:35 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D3BD11A498 for ; Mon, 23 Jan 2023 17:36:30 -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 30O04hmD021665 for ; Tue, 24 Jan 2023 01:36: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=Z/gy7ED2uc3DAI5xAdPVy6QP4ZkCdVt2xfjOsudSWUw=; b=JqsBSkbmfTrvuBPdE9CvXwwpTN30aOXYysl755TMAV+pLqn2iXumnu/IrtHah4jB70U/ a/sEZSCbvkcrvKSSxHrRVDM4XZK4gkWRq5uoZx8gGmd8OoDdmEXR6ozeZC9icoTjPGTn x5bBVS7nGLMviqO6X7Sxl3NdglgnA5ZwMp3dEBlEEOHxoA4pbZFdfvRkyi37tUp4kTyO Yv6r/MqnP7cIEFpu2MHbJoDF1oEV+7xnqfFzJ2lgtURw/QwG3vJlX80jcDYzyzWb9Rxm aKSWXYyZmZioOrQmYad86cwOjLDmoOqlnNOqdpWKnqNNVfb5GOhj2JqcXlYEgg7cKvhq qA== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3n87xa4a15-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 24 Jan 2023 01:36:30 +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 30NNDwKj001236 for ; Tue, 24 Jan 2023 01:36:29 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2109.outbound.protection.outlook.com [104.47.58.109]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3n86gakvem-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 24 Jan 2023 01:36:28 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Z4AoWZm2dFoPvUbYlP1rlhK9YKIrf0wQCXsQ4Pm2FhvAMtoH/JMMea5UV/2Tq8g1NusZNu+eTY8rkwsPrHrvkm7THxusnT57tU9ReyKYYtAs8ZWqwpEmWXoJQKB/hJ3/2CfawJeijT8G1zyhI607rehuq4IxiAHTY8CjHewNvIUzwZ+s4AMBolVzt4yCXmPhMxAVVZGTTKjgk0FzIEbPwIiBSljnBS88uyxuBL8D0JfzzBaAmbAx3EJiSv+yCNRE5lrQ3S2Uj2KzrxPml73sbTlCMRd8Q1bLtUwQ2IrSnmd9i2wvMTrAGn/zhOd2BQX3J3kX9FGc0iQhc47eUeK69Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Z/gy7ED2uc3DAI5xAdPVy6QP4ZkCdVt2xfjOsudSWUw=; b=i+GRj5vvlrJLwTO5/AMUfyNppbMfEHsvLBTdW/mTItAgT/umd3TEE9D5Fi01PUwlMUb9+VZOKG9WYwcQy/sLy8LwE4qFNEB8WwZ6QlHb7H4pdYthZMRhS/zPube5PpH06LHiUuWPKsYy00YbInJphD5agE/wjbFWhnSvJN+H0WOrMmEG/yj7kky0S6SFmtK4xPOxpn7wIUlF3YMPqmrAoaGJ3JYBVh8nffaTAyrkM1/8tnuc81Jxs+C/lYOC0itedkDXxur4No8THpuY4/T/x9vfufOyW680OlBi0wFTkxJEsrkVuuuTfe0DBtHlsjhfdXmAObgDqxfbbExNH69VKA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Z/gy7ED2uc3DAI5xAdPVy6QP4ZkCdVt2xfjOsudSWUw=; b=noJRZZlMpmBejF9uJqdECucYwN4DQutdVExp8lOGQE3z6AYkTm7hiykTtnnedTzk+O36h+Tq/wsOAfC6Fll6Sk1y7mMbFezG/DoHQIPcxqi+HrdPtj9VeIzrcXyP3Le1vXAyw/roGkxZZecx+9NRiwk7MxA11ziD5sp422+HgRE= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by CH0PR10MB5052.namprd10.prod.outlook.com (2603:10b6:610:de::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.16; Tue, 24 Jan 2023 01:36:27 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::eaff:9f55:4641:db38]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::eaff:9f55:4641:db38%4]) with mapi id 15.20.6043.016; Tue, 24 Jan 2023 01:36:27 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v8 03/27] xfs: Increase XFS_QM_TRANS_MAXDQS to 5 Date: Mon, 23 Jan 2023 18:35:56 -0700 Message-Id: <20230124013620.1089319-4-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230124013620.1089319-1-allison.henderson@oracle.com> References: <20230124013620.1089319-1-allison.henderson@oracle.com> X-ClientProxiedBy: SJ0PR13CA0103.namprd13.prod.outlook.com (2603:10b6:a03:2c5::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_|CH0PR10MB5052:EE_ X-MS-Office365-Filtering-Correlation-Id: a0fe42f9-7890-4d51-bff5-08dafdab68d7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: F1+/PpRzRoEaOaq1oJ0XYWVWXZiMfjucqpeJaCq8nAaQeeq1xAlTFVPXL14H15QlGAGe2EySMD+GGL5g7FxIbJ9O36FS4cC6hfqUDb+7HtIKkM4zI1131jO466SXRKb55deZOrG20PC5iKrKBLwMXRzvA4s8GDxuYF8Ph+WuSwr8i29SrmRpoDawvF9f8p9eS8UVIxS9Fi9wdMoy5Erd55NUuLxP6TQ4fCBmkWIN4qsUziS5tIrDSxy6OwK1PPJaL7VUO6uQ3L2nBaZvozyDnP9WM5xy20BVnu+MK4ImClbkGOg5GggAb2yN68lPUMHMjPCriP4k30OfOh1ouuojR7fZGB6SJ+0dfCQ65xDnE7wxCSPg6gD33VsbuUf82yFb+lzHbLbJBiFwfm37PTmgqBDDUEbE4Ds7MBNXWEzcgUdT+EfOWaI0JAIoxP2Eaw37wTvmCI6aUBgDtTRERJofJFQsVln87vcqzFxuPtBlxlq9yxjCcEmcHiGiSlIoKzkWwHUEcIyU6oh298OL8YLh5TSn9CkbtApDUc98PIUJ3kVwPJ1Y0baNZPs8HSX8RURdWu6xTY/QLHlxoRa264zflHrgRbSsno4/McVYh4cbXeE8ycNFzXA8jm6ItJ4Y0ioJvf5hEKWC667HkPF9nK1eQA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(39860400002)(366004)(136003)(376002)(346002)(396003)(451199015)(1076003)(83380400001)(2616005)(86362001)(38100700002)(36756003)(6916009)(8676002)(66476007)(66946007)(66556008)(9686003)(5660300002)(2906002)(41300700001)(8936002)(6666004)(6486002)(478600001)(186003)(6512007)(26005)(6506007)(316002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: AEIqu6GSi2pDuh7Kn6LYO4Ho0ym/vZ26OQT01Chl8Zpei3QLEjKrkWy8KcFb90eGnO8ck8vp9X3PDueC/sjy/ZSfKz/pAB7hORLegeKcp9wsTUyCLp1k2CLjhJI3YUHkdjKeOOxpwHYrhy1RSOl0YP2B6jpep3IpPEXrcNdk8znfU7LltDHCb8tAnvYWL78b3/GSszxgo+slv+lxY5MkWrQNq7s3LgVGlvo3vhBiZFq/ebXq1vrXQV7IXOtxrIPzOLcwTFUpx2M9BA8Dhy7ost9TD7B9cgd7Ez+dyptSJDPtrkwsTglYNqH91HleWa+y0bPCcwAmUo6xqm4M8Ylk1MvUmWJceabJfNb3mfrs5mNORbIfUHTP/iiCf4iYbDxsl6f+jLdL+GlgX9wbtSOEFydDy3kkV39V+4qe7EP2gBkPoQpKawtCjOZ4mza+Y5ie3Gi/5W5aeLs8lo6NbAiWDuEM98k1ATWqO/oLosoPIKgJ6qiDzO1IjKG1xj5T214G3SndlwI/tqyIke9oRhsHBXgA0Kf2ka6htrg/k7m0c2Ldy2aOf9Rjo0zHcczhBmzkWzk2650TJbySvgmlZzgj7MgyURxkJC7vw25SOlXShL1nCNf9CSQ/Klbg2VmFA9OozFLWCuEymG/pYH6oVdbrkEbGLuH/Pp079Pg7ghRVz44CkrlbwyVIDDz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YxjATcalEc0Cyyuyh69rkVkPzkyd0fMP4j7+tJzcx6LDbZwF53JTT9hPFi5W3pok296lGYsKyp+INt5EaOoZhlemlMImm1jBbPH88FweHPwug1I+Y+vXb51OkNZSgYQBYTGNWZ4j6e+CEmEU8ses4FnSer4kNi7p1M7wDMZcZN/ThaYUdknkKCaTQVl2+y5fw2E5H3nG47/+jqHjh8GvT4FZgC+cse92dlRuu/ry1QR3XjWuB1GYMrINkvkWNIdHLTNXkiSZwkrSbqEvZHEQBMeA5jQDZC10XyOH7BA215rGnSn3A2lcgSUsPnxwFL2F00OgEannlFOXFM06mqkYHhIHQdvuJhrrYVj3ROqHMrGFlwIgn9MrnvbuHymSzCEcYR3bpEazLhOLu+yLe6XubpBcyz5CBNJGpKY6SfJunK67H9kBmUEPaUeEarPXGD+knrfbyY5BtaKRiLz+fFrI5bZPrBtKmGzoBsQ6DEVs6yIVIjK7YsxyHKwlEPt0CVkewa/uUiQ96d1f1aJrITO2T/XLGuUPLl7buhq2haX2NmLcPRcVJT4bvxxwZIqytwTKH7oV2KkjIlbP+8/ZSk4pyLwRBrzoPyvGlOjFCVagA8EI2mmPIMj/hh+iB+kuN7gQfEVB4g6OwlwOtslh1VxTxg2ufUFy2DSeFcb1Alf/7u1L5eeTMsdrT670Bj1sxqxA39gL19dIA== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: a0fe42f9-7890-4d51-bff5-08dafdab68d7 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jan 2023 01:36:27.1081 (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: VfbfWAmAVSoiAWIpbNsxVJ/LEBpU92ukRz5FNHkX4/hlFcUa+8S7cAEG9CnS0QZqng4MvR+fIqI6Kn/zZyV53QOcfo3AV2UaWP7UyWNDywY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR10MB5052 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-23_12,2023-01-23_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 phishscore=0 mlxlogscore=999 adultscore=0 mlxscore=0 suspectscore=0 spamscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301240010 X-Proofpoint-GUID: OPZRuawUVJ3Uwa8x3qnQQkpypJ0D3B0V X-Proofpoint-ORIG-GUID: OPZRuawUVJ3Uwa8x3qnQQkpypJ0D3B0V Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Allison Henderson With parent pointers enabled, a rename operation can update up to 5 inodes: src_dp, target_dp, src_ip, target_ip and wip. This causes their dquots to a be attached to the transaction chain, so we need to increase XFS_QM_TRANS_MAXDQS. This patch also add a helper function xfs_dqlockn to lock an arbitrary number of dquots. Signed-off-by: Allison Henderson --- fs/xfs/xfs_dquot.c | 38 ++++++++++++++++++++++++++++++++++++++ fs/xfs/xfs_dquot.h | 1 + fs/xfs/xfs_qm.h | 2 +- fs/xfs/xfs_trans_dquot.c | 15 ++++++++++----- 4 files changed, 50 insertions(+), 6 deletions(-) diff --git a/fs/xfs/xfs_dquot.c b/fs/xfs/xfs_dquot.c index 8fb90da89787..9f311729c4c8 100644 --- a/fs/xfs/xfs_dquot.c +++ b/fs/xfs/xfs_dquot.c @@ -1333,6 +1333,44 @@ xfs_dqlock2( } } +static int +xfs_dqtrx_cmp( + const void *a, + const void *b) +{ + const struct xfs_dqtrx *qa = a; + const struct xfs_dqtrx *qb = b; + + if (qa->qt_dquot->q_id > qb->qt_dquot->q_id) + return 1; + if (qa->qt_dquot->q_id < qb->qt_dquot->q_id) + return -1; + return 0; +} + +void +xfs_dqlockn( + struct xfs_dqtrx *q) +{ + unsigned int i; + + /* Sort in order of dquot id, do not allow duplicates */ + for (i = 0; i < XFS_QM_TRANS_MAXDQS && q[i].qt_dquot != NULL; i++) { + unsigned int j; + + for (j = 0; j < i; j++) + ASSERT(q[i].qt_dquot != q[j].qt_dquot); + } + if (i == 0) + return; + + sort(q, i, sizeof(struct xfs_dqtrx), xfs_dqtrx_cmp, NULL); + + mutex_lock(&q[0].qt_dquot->q_qlock); + for (i = 1; i < XFS_QM_TRANS_MAXDQS && q[i].qt_dquot != NULL; i++) + mutex_lock_nested(&q[i].qt_dquot->q_qlock, XFS_QLOCK_NESTED); +} + int __init xfs_qm_init(void) { diff --git a/fs/xfs/xfs_dquot.h b/fs/xfs/xfs_dquot.h index 80c8f851a2f3..dc7d0226242b 100644 --- a/fs/xfs/xfs_dquot.h +++ b/fs/xfs/xfs_dquot.h @@ -223,6 +223,7 @@ int xfs_qm_dqget_uncached(struct xfs_mount *mp, void xfs_qm_dqput(struct xfs_dquot *dqp); void xfs_dqlock2(struct xfs_dquot *, struct xfs_dquot *); +void xfs_dqlockn(struct xfs_dqtrx *q); void xfs_dquot_set_prealloc_limits(struct xfs_dquot *); diff --git a/fs/xfs/xfs_qm.h b/fs/xfs/xfs_qm.h index 9683f0457d19..c6ec88779356 100644 --- a/fs/xfs/xfs_qm.h +++ b/fs/xfs/xfs_qm.h @@ -120,7 +120,7 @@ enum { XFS_QM_TRANS_PRJ, XFS_QM_TRANS_DQTYPES }; -#define XFS_QM_TRANS_MAXDQS 2 +#define XFS_QM_TRANS_MAXDQS 5 struct xfs_dquot_acct { struct xfs_dqtrx dqs[XFS_QM_TRANS_DQTYPES][XFS_QM_TRANS_MAXDQS]; }; diff --git a/fs/xfs/xfs_trans_dquot.c b/fs/xfs/xfs_trans_dquot.c index aa00cf67ad72..8a48175ea3a7 100644 --- a/fs/xfs/xfs_trans_dquot.c +++ b/fs/xfs/xfs_trans_dquot.c @@ -268,24 +268,29 @@ xfs_trans_mod_dquot( /* * Given an array of dqtrx structures, lock all the dquots associated and join - * them to the transaction, provided they have been modified. We know that the - * highest number of dquots of one type - usr, grp and prj - involved in a - * transaction is 3 so we don't need to make this very generic. + * them to the transaction, provided they have been modified. */ STATIC void xfs_trans_dqlockedjoin( struct xfs_trans *tp, struct xfs_dqtrx *q) { + unsigned int i; ASSERT(q[0].qt_dquot != NULL); if (q[1].qt_dquot == NULL) { xfs_dqlock(q[0].qt_dquot); xfs_trans_dqjoin(tp, q[0].qt_dquot); - } else { - ASSERT(XFS_QM_TRANS_MAXDQS == 2); + } else if (q[2].qt_dquot == NULL) { xfs_dqlock2(q[0].qt_dquot, q[1].qt_dquot); xfs_trans_dqjoin(tp, q[0].qt_dquot); xfs_trans_dqjoin(tp, q[1].qt_dquot); + } else { + xfs_dqlockn(q); + for (i = 0; i < XFS_QM_TRANS_MAXDQS; i++) { + if (q[i].qt_dquot == NULL) + break; + xfs_trans_dqjoin(tp, q[i].qt_dquot); + } } } From patchwork Tue Jan 24 01:35:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 13113259 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 E4FDDC05027 for ; Tue, 24 Jan 2023 01:36:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230363AbjAXBgh (ORCPT ); Mon, 23 Jan 2023 20:36:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56550 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232022AbjAXBgf (ORCPT ); Mon, 23 Jan 2023 20:36:35 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6E33C1258F for ; Mon, 23 Jan 2023 17:36:32 -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 30O04YfK021740 for ; Tue, 24 Jan 2023 01:36: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=1xoDYsuWG2SRerMtDZ+ug4VReqHwhjGAddR6C0EnDaI=; b=LTF0UaG+YBIRugp0XIQjasq+8+yG/FzY6b5dWsg56Fs7yBq7S8moq4kMEavDapVR2eIM CWXMgsxy30nIkPo/3AvZSebYmHqImOOMcyUZrA6W5AvVVTfou9icxP4eAYmPjuaFXIqV 8Xcv7zflr+5kP2stB4SWmG5UuHb+gaiAwfvcxSbRN5xUUz4vZYBuUQuCDyaZUpQ9oNnN BVexPl1kbexZiCF2cV+VL5Nc+ZHBQbqC4vpnqN18aQ52KX+tAKuCgAe2f7AxEXGavIXu hQ5CDewZZDp9GneSMmcg+YmDKxd+ECVyj5YhvVUXZ0v8nUVXr4hdCONtlgrQ4GIhAgSy IA== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3n883c4afm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 24 Jan 2023 01:36:31 +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 30O1UDZu039617 for ; Tue, 24 Jan 2023 01:36:31 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2101.outbound.protection.outlook.com [104.47.58.101]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3n86gb4auf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 24 Jan 2023 01:36:30 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FVp+i/xra4BplNck6AEB9dw/LIUrkS7QReb/4iF8u5bvVSpt0nb8Zjxo0SD4HU2Xs4pCiSOF8MmBZMZjrbAwwtM9JsSeQKqdtTPGT82IZqGsNiFBXuoSJ6s1SMb9YJUCmD4Gck8YEuYHT3lR0WI46y+xP2bD77Ql4wAQQyHIIPpQ28SZUBsPjopOSsT8tLSEMAAxYXutOIRdKvaWyh1Jxqqjv5H7KuBlcQVFWdIJriEOfL1bMzjMUN/c9Bplx7L6FZB17zZq1qkTk3+f8zIlH7wpXbUc65JUvtJZuTYn/uQqRzVOaRHox5sKQJzfDeWhl45eN+KrLClY5Ogq7ri+5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=1xoDYsuWG2SRerMtDZ+ug4VReqHwhjGAddR6C0EnDaI=; b=AQyjDzmYzfbtTDaDP5KUr7aQnNjLhXNLzxi23eLqZH6CbSLCoMxumsB45usb14/z5zO2wO2YPS/MdULXVSmaNXBFnsyPLzfiozAfCvcjjpb8vxh0BBK/n7fQ//1zxbUD9H6XJ/Hjb2sbVfSdiWrGy1S9T81j2SUdzTpq2i0KicFrj7uzdJty64CVkqC1hXtgi7wGP7lFEPxMKr2kIIcVkXkqnu3l9vDXRIgeZDZNYYzbToHu6gLdxNgdAWn5eg3AFteG7lXa3eR7I/sy+Z2Rhh47IPktn7n3cqh+d4G4xHJqC029xKagqQcUxHCsp+p4MhSPyzwT1I9/K5W/APvdkg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=1xoDYsuWG2SRerMtDZ+ug4VReqHwhjGAddR6C0EnDaI=; b=can+xst1O4y++VQ3OZNAyOBOPyKFAzepex8byrDmru9HvtD8HPrvwEYX3IrkVtviCmXVSHQTLiPwNv+LmjK2isrA0VrHoVwq4cpWVzMwrme0bn5p1FYe1IjbIeB+mpd95HM9PgFgN2snLq7RKJfwQH9FZoo81KETK3/16+zGgsI= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by CH0PR10MB5052.namprd10.prod.outlook.com (2603:10b6:610:de::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.16; Tue, 24 Jan 2023 01:36:29 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::eaff:9f55:4641:db38]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::eaff:9f55:4641:db38%4]) with mapi id 15.20.6043.016; Tue, 24 Jan 2023 01:36:29 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v8 04/27] xfs: Hold inode locks in xfs_ialloc Date: Mon, 23 Jan 2023 18:35:57 -0700 Message-Id: <20230124013620.1089319-5-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230124013620.1089319-1-allison.henderson@oracle.com> References: <20230124013620.1089319-1-allison.henderson@oracle.com> X-ClientProxiedBy: BYAPR06CA0022.namprd06.prod.outlook.com (2603:10b6:a03:d4::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_|CH0PR10MB5052:EE_ X-MS-Office365-Filtering-Correlation-Id: 885d1f36-169d-4021-19d5-08dafdab6a21 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: T7Eom+tuDGBa0a90esgmEorUd32BB/OclFTOqeN1dK55pTU8mzGEmNOPqp5ZhARXDJz6rDo+AKjvR45PIlHve64kGcn1c8QoBqlLxz+BYz59sAcbOKKo0NV+8bnDn0p5cNU/WFM5A4Ak2aC8iLs+g7JZdblA9COtYgVUl9AP4bXkwMVrb7CifIaHVCwA+WAiPqO/aogPIP04uLQ7afJLLmsNqhjuWeOJT+qGQzFNk0VrPEtpGpgcbX9wBOxZnvyYjjxy343PyAGX8488Mx2DC2zhyxbx3XHzjvWC1BhwSfZOsWH1BtbvvoIKLtwClzU0L+g4BbcqRWnv2Y0fMcNPg7tUphxpccaHJzsH1AhdS9pPq92qEPacNB8+dYmLrFSFQebOaP8RxrTvaKtCeaQK9asWMLzV1ZJS3l0+Eg49ZV85YnKgS5HoT5ZISKHOOeynCL+4WemTcN/NPTgOj0h6P+ex7wfmFEt1A5qhwNeMcDJ28dyUJsaP8mF+clwcMliVcb7z7x6NwqZeE0FWebEKUnI5GovQZu9/Tj6Smg3fqJMc3g1H/sqvSC6YlGOVzJiClGDkdV9qS2sRY8OfaM6lOX0Ys9TYQBFdzbbf+3Zz+gQ+K5CU1pahcgTdy9hsTFeMFAJeVts3wQBSyHxbUBmIhg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(39860400002)(366004)(136003)(376002)(346002)(396003)(451199015)(1076003)(83380400001)(2616005)(86362001)(38100700002)(36756003)(6916009)(8676002)(66476007)(66946007)(66556008)(9686003)(5660300002)(2906002)(41300700001)(8936002)(6666004)(6486002)(478600001)(186003)(6512007)(26005)(6506007)(316002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: du2wkKOMGu8rajkKQlZwQvVK5B+X0zyeU5gX5IP1dlq19IaLWwyDuG6189ZbO40FVa3AhjXeO47VMAGmfOY7aeUQNlMuTXPtUoEeWVvsvK3IIgLTS4SmmT2x2yoEXN0vowIrRQsPKQ6oRmytekpIRYwIDj1jAfGMzY/NYTK0OTiOOs6dlzoJQlT/hcLYIV7gGijvSA7MOKjqWNqIdZbdxENEV9uYpbuGHSzxAOWSqastdWXNYwJVlE1k9xLXwROh3sWi7DBMncItxlaggrXaPDnlQmCnlzFmJ6oCihwP2N8fxDMMZxi9ipP+CMVnTvtdPdv71hMkBhnnrpJKbLdlkFqt4kpMEW0AcCJTSLzJy0JQyjlkzbKCJ/RAt/MDVNqZMNlimvdeTuo5Cn9PC2h/T+BMzApm9qyj8t4/R4/KUb7HVfwb8k5KaE6Y2aPWSHAtP+PYz/mBiNLa3xoA2fEZ4yRhTjG03A8KHFyFS0XgL66wP7DCVYNitPCnlUGweDDUwAkB+b5wxLKBQYPPn0pciXCZOKscq9tIz3HTKhWQqx7WCsM8EOmLY4gpbmD33djb9++Q2yFOE2KjMsOWCif2D4rH+vq2A+I/82fih0KuZs+RXeXHJ7L/wj1yx5sjf7WGO7CwHEIHCgq3Nhb+WGQT4w44nUqXXbW/8hT4uZRU3kfukgwYxAcRT6H1hEsFBALVIG/WlXCXPuGzFNxumPW49HuQcsyAOxcUIaghSS+ZcBuj+O7Rs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tCBPnKWT90CqJO6CI674qvrODys6+eCfd8Jv5T8tMyiji3uObWu9q0GGJPkGYDu1KZuvcSehwTAidIqOLDo8uOkGXGL64ZWX15rEjdLPxb9absvPCdSAbaOCYlFWWjg6ns3t5Lyzr6L6CSDnZ0kmQzC5Djo+9Y3yO8je4d0sIy5nep2xiq0yxx8ngdn6ny5AumU62D4yzX2XYk5fn1pcbCt0J594d8O+bOCSOwVOSx3GEOhJHEhkHn5tlnzpGM3WSkgQwOBpOL1QgLb8drQln1+6rtHPAFan1v7rErCcBGxDWlaJRIbzsIT8lo3Cr3x45/YPsrq+2YaJtet+CjWNslzDE6Ubb6/bPljFnhdwpEJtKcoNEVHskJa6QicEsVnxZGGgW31srLzkfOrJgH4zq2oGO8qcIRJxHOCYXNqtM2fTFo0V9Ieb+tfAyY5d+4e0z/vAK0YksMnAgk41hyP3ROFaf4ZRP7elZvOEGjlwaZPIpTZd3pabwE9WmPlWF3CIpvOkVIts+cFZiLpiSV+3v1a3KbmXk7ZHHZeGEM8ltTzz90iXuwGGOZBTKh8q9I/QePgQDumsAHIDSya5iNiGkSBe32i7uBBkM6A+0RGR+b6+fzxxd1xpJUFvNATg74zIV7vnzJzD0N6A== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 885d1f36-169d-4021-19d5-08dafdab6a21 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jan 2023 01:36:28.9854 (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: caNxjyAKipfe6S5KTdKonDyeR8wg8cGe+suyUA27syyABGomX3pr6bhukiUgt3cFDke/n0T5LJmT39bUwmwlrZ0wdigDJB+eqSETRTYR2ZQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR10MB5052 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-23_12,2023-01-23_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 mlxscore=0 spamscore=0 bulkscore=0 mlxlogscore=999 malwarescore=0 adultscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301240010 X-Proofpoint-ORIG-GUID: WmTDwJA6bd0goAY9HO4RaAvAW9Qxw4V- X-Proofpoint-GUID: WmTDwJA6bd0goAY9HO4RaAvAW9Qxw4V- Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Allison Henderson Modify xfs_ialloc to hold locks after return. Caller will be responsible for manual unlock. We will need this later to hold locks across parent pointer operations Signed-off-by: Allison Henderson Reviewed-by: Darrick J. Wong Reviewed-by: Catherine Hoang --- fs/xfs/xfs_inode.c | 8 +++++++- fs/xfs/xfs_qm.c | 4 +++- fs/xfs/xfs_symlink.c | 3 +++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index 27532053a67b..772e3f105b7b 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -774,6 +774,8 @@ xfs_inode_inherit_flags2( /* * Initialise a newly allocated inode and return the in-core inode to the * caller locked exclusively. + * + * Caller is responsible for unlocking the inode manually upon return */ int xfs_init_new_inode( @@ -899,7 +901,7 @@ xfs_init_new_inode( /* * Log the new values stuffed into the inode. */ - xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL); + xfs_trans_ijoin(tp, ip, 0); xfs_trans_log_inode(tp, ip, flags); /* now that we have an i_mode we can setup the inode structure */ @@ -1076,6 +1078,7 @@ xfs_create( xfs_qm_dqrele(pdqp); *ipp = ip; + xfs_iunlock(ip, XFS_ILOCK_EXCL); return 0; out_trans_cancel: @@ -1089,6 +1092,7 @@ xfs_create( if (ip) { xfs_finish_inode_setup(ip); xfs_irele(ip); + xfs_iunlock(ip, XFS_ILOCK_EXCL); } out_release_dquots: xfs_qm_dqrele(udqp); @@ -1172,6 +1176,7 @@ xfs_create_tmpfile( xfs_qm_dqrele(pdqp); *ipp = ip; + xfs_iunlock(ip, XFS_ILOCK_EXCL); return 0; out_trans_cancel: @@ -1185,6 +1190,7 @@ xfs_create_tmpfile( if (ip) { xfs_finish_inode_setup(ip); xfs_irele(ip); + xfs_iunlock(ip, XFS_ILOCK_EXCL); } out_release_dquots: xfs_qm_dqrele(udqp); diff --git a/fs/xfs/xfs_qm.c b/fs/xfs/xfs_qm.c index e2c542f6dcd4..fbecf54d3b44 100644 --- a/fs/xfs/xfs_qm.c +++ b/fs/xfs/xfs_qm.c @@ -826,8 +826,10 @@ xfs_qm_qino_alloc( ASSERT(xfs_is_shutdown(mp)); xfs_alert(mp, "%s failed (error %d)!", __func__, error); } - if (need_alloc) + if (need_alloc) { xfs_finish_inode_setup(*ipp); + xfs_iunlock(*ipp, XFS_ILOCK_EXCL); + } return error; } diff --git a/fs/xfs/xfs_symlink.c b/fs/xfs/xfs_symlink.c index 8389f3ef88ef..d8e120913036 100644 --- a/fs/xfs/xfs_symlink.c +++ b/fs/xfs/xfs_symlink.c @@ -337,6 +337,7 @@ xfs_symlink( xfs_qm_dqrele(pdqp); *ipp = ip; + xfs_iunlock(ip, XFS_ILOCK_EXCL); return 0; out_trans_cancel: @@ -358,6 +359,8 @@ xfs_symlink( if (unlock_dp_on_error) xfs_iunlock(dp, XFS_ILOCK_EXCL); + if (ip) + xfs_iunlock(ip, XFS_ILOCK_EXCL); return error; } From patchwork Tue Jan 24 01:35:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 13113260 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 BC748C54E94 for ; Tue, 24 Jan 2023 01:36:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232022AbjAXBgh (ORCPT ); Mon, 23 Jan 2023 20:36:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56552 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232062AbjAXBgg (ORCPT ); Mon, 23 Jan 2023 20:36:36 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B598111EBD for ; Mon, 23 Jan 2023 17:36:33 -0800 (PST) Received: from pps.filterd (m0333521.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 30O053AT020438 for ; Tue, 24 Jan 2023 01:36: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=qaNGI5HY7M26yc6xXQ6HQ5L8rSDjtUAzjw+adU2Iewk=; b=aIyaIFk/TPi4Lf5QzeuE1Yphbc2rjTHXQ9T/m/4O3hsf6ywAlazEQjx5RgwUfM96tbvq 5XuHR6L111ZemdijdEsQ1lPcpH+BL5r3iwGc84jLWkwiIz3wiVCnFzbtAhAKVPNjNjt1 RsDnLPoCMk93TnBD/oy21WczKmMrE6ZpREp0Q97uvdDk5WKFOEwLih4IGvFxj9Z/BzTR gthVhWI8NXMVGNcqx6eILBApVqvUQfSpfqLw5a/Nb8nKDLWU4yan57lZJqLXabd8R6+j zl2AmlnNXWXZ2aYVuI7iWP2HtDQMQph39jVO25CyFxh4vz+N8uQb/m91tkxysbXz7vY/ fw== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3n86ybcbhq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 24 Jan 2023 01:36:33 +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 30O1OHnf011678 for ; Tue, 24 Jan 2023 01:36:32 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2103.outbound.protection.outlook.com [104.47.58.103]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3n86g3tmp5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 24 Jan 2023 01:36:32 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OG4ESDMHsSN65dp/V2C2mIG2eSRmE/OM1D9xJW49mkbTWGtAoVFed/ut7EVNs/t6UX0/DW+XsTIlEXKGYuLxHYv39Y18dFdmFr3dQoKL7u6VVDY089fEcElS23nJdY5Z4KrsOh6lN+zXGADpjRgWHQJ1VqSdVsOtWjdHyOdIFX0rTbATr6D0+lVfV7Xo9HkxB/qyy9njGC0zuGNkE0cTE+SVONSJMiXrhDtweofTkqaUlfIRGLlbnZs83OUjxqVsAHs6FjqRzBENWbffjHriZ6Ny7JZxi5OB5HlZwYc0TPDOZwG67toYfnROd6dx9BPmKeJYbs81HRPN+GSex+5qOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=qaNGI5HY7M26yc6xXQ6HQ5L8rSDjtUAzjw+adU2Iewk=; b=kprl8F1JFNcBgNhPtaX/PMj1pr/ys1p6XNXhNCwNVb4LeMK1sxc6SIfn5a1wRGqcT7ZYP9GsbBRfkBYn6a7SLy3Eqlgcq4YkEFzv5cqMiPS7rIg+oKsg8F2RkNNp3zNrkXmtJA5hbibkX/Wsrjl6Kkx6EKKPi9HJkRAjnDIUjiXgO/1pjaiFQvE9/rgbVXpTmyEIpP4ooum3tym8Xy2+BarnrjDUcCswZzHSoMOOFiQDf4VZPs7avvxTIQPGVOi4GoKCG+Ob/uW/jGcxVe/GKkUVFAPrjUIAUB/Vy0XDfZaL38qrPMp8wL0Oiw/bGX715M08+VILfH6Sdt+T8b/KuA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=qaNGI5HY7M26yc6xXQ6HQ5L8rSDjtUAzjw+adU2Iewk=; b=bIFVuuKwaYlaJNV69SyamJR5vX1mfXs9jEFhpqnfbHiDdWntAp4EO6EYjdVlYskqMPweOqqj1ix5Di1ryd/1ZYgmJSx+NUbNU1YkP64pUi3eDecG13e/eTPtWjXidLKv1ScDJZnRX40EC2ZYjR0o7quSpMd5HvrwVNZYBEcJSLw= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by CH0PR10MB5052.namprd10.prod.outlook.com (2603:10b6:610:de::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.16; Tue, 24 Jan 2023 01:36:30 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::eaff:9f55:4641:db38]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::eaff:9f55:4641:db38%4]) with mapi id 15.20.6043.016; Tue, 24 Jan 2023 01:36:30 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v8 05/27] xfs: Hold inode locks in xfs_trans_alloc_dir Date: Mon, 23 Jan 2023 18:35:58 -0700 Message-Id: <20230124013620.1089319-6-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230124013620.1089319-1-allison.henderson@oracle.com> References: <20230124013620.1089319-1-allison.henderson@oracle.com> X-ClientProxiedBy: BYAPR06CA0008.namprd06.prod.outlook.com (2603:10b6:a03:d4::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_|CH0PR10MB5052:EE_ X-MS-Office365-Filtering-Correlation-Id: e63f887c-dd38-461a-47f9-08dafdab6b2c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Ac5CecpJ3xQ99gBB2SBKWEbGJlDVvLmp2s+Gf7H+tb+6T/eo/GVAwWwNob0gatgcX0tI+vHcbOarVvX6+toERLEn6V6q6GcXRJZV70dDvtVOpPFIGqZ2LXJ/ZzMoThx0CFGX1BzXOOLg0FG58ybspcSv6Sa0jmhNsQpuG9JxnPBBAJrlWwqUpEbk+nacz4Ky/PSCLlnX0YXL85KP9mwwadtP06iherfgxkIWbVEiFKbw9aTLMGTKNtGr8hjRRQ10LJ9nlBAV26VhYKX5SEnMwajEaU5ke+EIToR3/wcDi2EepjGkTcnWrGG+9lxOYaYcMbm5XNcgogFqCTxCBR/W/Rhui5CTz/QIe3yMAKJBxTeHUXuALIH3E12yisDUopQ7DnlogmyrjDKAr3v43yUgIMnHwPyvuZCsIkZV9ODFnYgaCYlbXppuz7rjcu3tLSmvE9dJb/HbEY1SeDN89OQ4wEvF4iPX6ntlTJsgCEvJPZjvwchib2R0HsoGaJ86hWEigA6ZU08Rg6ZMX4xXBF3/blpiuMRRePS9gJlF7g6KUukvw+RzDM6Gq5qPtCE48jUYIIDWY7XOUO3pEc/Xt9XFsk895y332P4Mw+gcB6Qn9WYDWwI5Uc15TNrMy8GZB7Ge/3Q4Rc42Lc5AURR2Fa1gcA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(39860400002)(366004)(136003)(376002)(346002)(396003)(451199015)(1076003)(83380400001)(2616005)(86362001)(38100700002)(36756003)(6916009)(8676002)(66476007)(66946007)(66556008)(9686003)(5660300002)(2906002)(41300700001)(8936002)(6666004)(6486002)(478600001)(186003)(6512007)(26005)(6506007)(316002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: HyS9mtbwXYy4ugCVKG/3RGYp2/FvABQMcfqZVVKSPBt1ikXL530bjIahlKR3utSnXFns3tY3zBzf6Msd7auKUhnYRFG4laFboB80xDc+W4Xolbv74tNYXY2OR+lOFSvUb6Tku/hTbW98MrsPWfNt5tUA9uXxSBVEXp6dOplf6EtsKCceKmjlkN5rMwkgs88o+hqO4IWKkIuJqQAjgWKTPE5CttqCvPUg8ar7T6Q8gISns9A6nO81UCsN0IdtZ7zOkuDhUkv62s8Fj/joPRFU02XLlwYaGbgBxNKeC1qC5bvTkdN05Z3G72/AdJVfs2bxzrCCAjHJidPBscvuGqp/25j8yhJKOPklWp9UY79Qd2tJa7Y+g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le.com X-MS-Exchange-CrossTenant-Network-Message-Id: e63f887c-dd38-461a-47f9-08dafdab6b2c X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jan 2023 01:36:30.7967 (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: 6UPLa+8pCH0NaoKykaeu4l4F3kL/FHXcZFiWvkaSfOY5/LL7yw9fQkA9othXKl3teUX9QHS+3bZp9QmMRzySTtFTclmpasWgrk66prn6kds= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR10MB5052 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-23_12,2023-01-23_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 mlxlogscore=999 malwarescore=0 mlxscore=0 bulkscore=0 adultscore=0 phishscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301240010 X-Proofpoint-GUID: QlTI_s3aa2SLA-83wTtItRo2Uakw2suG X-Proofpoint-ORIG-GUID: QlTI_s3aa2SLA-83wTtItRo2Uakw2suG Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Allison Henderson Modify xfs_trans_alloc_dir to hold locks after return. Caller will be responsible for manual unlock. We will need this later to hold locks across parent pointer operations Signed-off-by: Allison Henderson Reviewed-by: Darrick J. Wong Reviewed-by: Catherine Hoang --- fs/xfs/xfs_inode.c | 14 ++++++++++++-- fs/xfs/xfs_trans.c | 9 +++++++-- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index 772e3f105b7b..e292688ee608 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -1279,10 +1279,15 @@ xfs_link( if (xfs_has_wsync(mp) || xfs_has_dirsync(mp)) xfs_trans_set_sync(tp); - return xfs_trans_commit(tp); + error = xfs_trans_commit(tp); + xfs_iunlock(tdp, XFS_ILOCK_EXCL); + xfs_iunlock(sip, XFS_ILOCK_EXCL); + return error; error_return: xfs_trans_cancel(tp); + xfs_iunlock(tdp, XFS_ILOCK_EXCL); + xfs_iunlock(sip, XFS_ILOCK_EXCL); std_return: if (error == -ENOSPC && nospace_error) error = nospace_error; @@ -2518,15 +2523,20 @@ xfs_remove( error = xfs_trans_commit(tp); if (error) - goto std_return; + goto out_unlock; if (is_dir && xfs_inode_is_filestream(ip)) xfs_filestream_deassociate(ip); + xfs_iunlock(ip, XFS_ILOCK_EXCL); + xfs_iunlock(dp, XFS_ILOCK_EXCL); return 0; out_trans_cancel: xfs_trans_cancel(tp); + out_unlock: + xfs_iunlock(ip, XFS_ILOCK_EXCL); + xfs_iunlock(dp, XFS_ILOCK_EXCL); std_return: return error; } diff --git a/fs/xfs/xfs_trans.c b/fs/xfs/xfs_trans.c index 7bd16fbff534..43f4b0943f49 100644 --- a/fs/xfs/xfs_trans.c +++ b/fs/xfs/xfs_trans.c @@ -1356,6 +1356,8 @@ xfs_trans_alloc_ichange( * The caller must ensure that the on-disk dquots attached to this inode have * already been allocated and initialized. The ILOCKs will be dropped when the * transaction is committed or cancelled. + * + * Caller is responsible for unlocking the inodes manually upon return */ int xfs_trans_alloc_dir( @@ -1386,8 +1388,8 @@ xfs_trans_alloc_dir( xfs_lock_two_inodes(dp, XFS_ILOCK_EXCL, ip, XFS_ILOCK_EXCL); - xfs_trans_ijoin(tp, dp, XFS_ILOCK_EXCL); - xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL); + xfs_trans_ijoin(tp, dp, 0); + xfs_trans_ijoin(tp, ip, 0); error = xfs_qm_dqattach_locked(dp, false); if (error) { @@ -1410,6 +1412,9 @@ xfs_trans_alloc_dir( if (error == -EDQUOT || error == -ENOSPC) { if (!retried) { xfs_trans_cancel(tp); + xfs_iunlock(dp, XFS_ILOCK_EXCL); + if (dp != ip) + xfs_iunlock(ip, XFS_ILOCK_EXCL); xfs_blockgc_free_quota(dp, 0); retried = true; goto retry; From patchwork Tue Jan 24 01:35:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 13113261 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 DF143C54EB4 for ; Tue, 24 Jan 2023 01:36:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232062AbjAXBgi (ORCPT ); Mon, 23 Jan 2023 20:36:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56574 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232132AbjAXBgi (ORCPT ); Mon, 23 Jan 2023 20:36:38 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4BE0D1A941 for ; Mon, 23 Jan 2023 17:36:37 -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 30O04TrE027000 for ; Tue, 24 Jan 2023 01:36: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=dQvLZOogNQQ17Eu9k8jhxLtyxVP8S0cseb4hxja3+38=; b=phIeSkDR9mYzI1b7xB5zal4lq1Wr1smE5GnsJZgCQfbJ41Po6gbGDv2yV88szKCMx8JE eVTBxU+5Adz+arQCbiRaJ8mNYosJxzGerfR3tV9cuHfwBsUeX7/1hmMJV2+jXNUYW64N qh6J0/4ByRsxY/dQpIKA5rI0jL6Z1XgwY4LOj4145j0w91odPszodHQbiPw9W8WuV0KA kdoypTZ1yzLx0VExjTdU3ssGclM9gP30BO+QezxXgS6IBfQt99JpbUOPoUTn2ZyQB1ai PWMyJ+fYFGGofoWALoJArT+F0wUlIS3oh+Z0PC+88HVW9RQzwYtRCkWfYdHtr3C3d3JY WA== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3n86n0vcg4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 24 Jan 2023 01:36:36 +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 30NN6eeQ001121 for ; Tue, 24 Jan 2023 01:36:35 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2168.outbound.protection.outlook.com [104.47.58.168]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3n86gakvhe-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 24 Jan 2023 01:36:35 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eKYQT0KnYTduVuKCURMgvGpZO6i4FonVa80KZjS4wesqpbDOdIX3HO5fLO1zwKodOwRrtPu0Ci4P3ljnCi2hcny+X3CyrTABz0/r2Qp8p2tIE+x4LOXCwg0crNh4V7Ser474GlmMe2GHgXYOEwuQjaN3l9DqoabOLStOEm+It83izDg7VefSahFuWnlMpy3R/I4AieATo2pQlCaibP4jGVaRMnhoV3etDmPH7KXit2SF6pvKyjx0wuLOXkisvDCOoSSfUxLtEvNX2e/zR4KOlnU6BAALT+NdER+cpgVd26yrmG5tHZMJHuScGE0HgkBIMToxNtt5tpWmNV/17A4wiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=dQvLZOogNQQ17Eu9k8jhxLtyxVP8S0cseb4hxja3+38=; b=f7st9y/mj2T5ssIDk0CYNOwEzBFbgRl3+SzLo6ri+gNa1tcmpynV5L/GIEvqohE9IT/MdVp06PWA0K9aFuVdGpQQvoZvuTXAuFMKKxZ2BM13JT9IiRFk/2L6+GYRzzBT54TuOazOueDLjGhxiI2M4+XhOK722znt6wCjEKh5DhbVCSC/7sKTSTG0rjTsJ9jWPUbWJKH5yHEX8U4nu3n0vbYQQT33kTZLZh/AXzqTwmCHKSiYqTE/26P1RgG+1zDfe/kvgDkMxo/1pvzWXI8x70IId0hTS+XT4oDrtMGE9ENVeCcoOluKyc0aIUs6vkOQhL8//NHiceTWX8JzZsxggA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=dQvLZOogNQQ17Eu9k8jhxLtyxVP8S0cseb4hxja3+38=; b=EcLSyxbhmpA2TNZ7RvzQIgL5Ys+NEOxaW11D/jgqhqGBI3kwWcOOvJuY82U9kJYaQ1KaFKnFJmPxCiVYb24R/xKiHPij05kceO04iuQ1qDqRa2Sq5pHwrJnRNhz/Na9O7Zgxbsne4uWYMOnJN5bQNXxb6xqbzQHK6HXNtwB3UQk= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by BLAPR10MB5041.namprd10.prod.outlook.com (2603:10b6:208:30e::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.17; Tue, 24 Jan 2023 01:36:33 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::eaff:9f55:4641:db38]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::eaff:9f55:4641:db38%4]) with mapi id 15.20.6043.016; Tue, 24 Jan 2023 01:36:32 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v8 06/27] xfs: Hold inode locks in xfs_rename Date: Mon, 23 Jan 2023 18:35:59 -0700 Message-Id: <20230124013620.1089319-7-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230124013620.1089319-1-allison.henderson@oracle.com> References: <20230124013620.1089319-1-allison.henderson@oracle.com> X-ClientProxiedBy: SJ0PR13CA0112.namprd13.prod.outlook.com (2603:10b6:a03:2c5::27) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY5PR10MB4306:EE_|BLAPR10MB5041:EE_ X-MS-Office365-Filtering-Correlation-Id: 673778a7-978e-49c9-d2a5-08dafdab6c66 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 53zPmaSFehEPrwb425b+g9BUJDTQ7oU5zEGXK5u0OPJBX25e4X6A35NgpeoNj7Rk54FyUvALIFklQRTqMmkbnew6AlyHudxXxZN/8p/6JTQ2m4qNrcaAQpFZ4As4nzT6FlL47tV2Jvd3L20/EmYxiJd8/WgEVue0zDaiFin/xoF1SUSfPFM2z3T4P22X/jWk0zdyzrqb9JWATqa4SfEeuLoQ9Z8GGEkMFjWIGd7J0i1HriOj5OgrbqX97qOkUYG1Q7xh+5v+QmWULwDGKsrs7MCPMu+Xir2EsCanmUoFy50pkxNQkQzz+Ia7pqLWmfPBP4LHH+RIjoMFG4okfqxvsar94odmJ3Ju3bnHxgkIJinmadMybYzdECZVPBSs9h0D/Q/WJiHWBpUg7YXJSplDSX0h0rRTDQxgMuGOdkDnXLrIaII+jnfczKh8rhuyZVvNvIkDUnEmPBxkqwv/4AMZsYG3AtVmCizMRRa8+njOvBeyy8cZgqwmmg1EbEkIUgEMqbOlid/eYFUbsceghFPjrml0LKASHBfl0L9Tzlg2rWyZMAbuxnR7231bn8dJ5I9XIv3k6lLlNxGV1vWR46+asyWpsDH61KIAIrSr2sZwX4QfK5NbhSVeqYJnTnbNq/tkzlLEekakbJtn/bJbkQ1XYA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(396003)(346002)(376002)(366004)(39860400002)(136003)(451199015)(6486002)(478600001)(6666004)(26005)(6506007)(9686003)(6512007)(186003)(2616005)(38100700002)(1076003)(316002)(86362001)(6916009)(41300700001)(83380400001)(8676002)(66946007)(66556008)(36756003)(66476007)(8936002)(5660300002)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: napEbjXn1e/I94x9W4QfRJmqOyeis75yp6ZnBFXxicADEom3g81J4Yz0hm/MhvySAplZAuVHstSS2ahgZFg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Vqzj3petb8+aLZ7kkxnzlpVE2n5HexwF6fc/BgttZcFSYSxPgrT+6fWNSghwBIVYEaK6zB6Uf/+4jDqfCHib75Nas7P2tJH+olLOBckOm/Dy5XtT3eleHK+l5d0iYVP1kNMYVBsqFIkXwUb89O983cOyJK+fnIU/mwneqLZym0DqyWH/EaUA/FauA9gyt/oBa7DwCKZzxOgTEAWlVKg79oOngfqxT0IyCWQ84CBjqr+KVKw2kHcA6W2GcYBaSaIOQ== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 673778a7-978e-49c9-d2a5-08dafdab6c66 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jan 2023 01:36:32.7508 (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: 2tM8XUCM1Q9iKFpt+V9nF+CPNV/c+2pJPS2NgmAqmh2lBQrEJZb/UiF3zuUBX7elkTeUlHItSpZbQbEkCAv5WnsFfdFtwHEEM22CoMxF+i8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLAPR10MB5041 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-23_12,2023-01-23_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 phishscore=0 mlxlogscore=999 adultscore=0 mlxscore=0 suspectscore=0 spamscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301240010 X-Proofpoint-GUID: 1sPVE43Gg9z6wWyIPYAgIslXrHHrwLwI X-Proofpoint-ORIG-GUID: 1sPVE43Gg9z6wWyIPYAgIslXrHHrwLwI Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Allison Henderson Modify xfs_rename to hold all inode locks across a rename operation We will need this later when we add parent pointers Signed-off-by: Allison Henderson Reviewed-by: Darrick J. Wong Reviewed-by: Catherine Hoang --- fs/xfs/xfs_inode.c | 43 ++++++++++++++++++++++++++++++------------- 1 file changed, 30 insertions(+), 13 deletions(-) diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index e292688ee608..131abf84ea87 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -2541,6 +2541,21 @@ xfs_remove( return error; } +static inline void +xfs_iunlock_rename( + struct xfs_inode **i_tab, + int num_inodes) +{ + int i; + + for (i = num_inodes - 1; i >= 0; i--) { + /* Skip duplicate inodes if src and target dps are the same */ + if (!i_tab[i] || (i > 0 && i_tab[i] == i_tab[i - 1])) + continue; + xfs_iunlock(i_tab[i], XFS_ILOCK_EXCL); + } +} + /* * Enter all inodes for a rename transaction into a sorted array. */ @@ -2839,18 +2854,16 @@ xfs_rename( xfs_lock_inodes(inodes, num_inodes, XFS_ILOCK_EXCL); /* - * Join all the inodes to the transaction. From this point on, - * we can rely on either trans_commit or trans_cancel to unlock - * them. + * Join all the inodes to the transaction. */ - xfs_trans_ijoin(tp, src_dp, XFS_ILOCK_EXCL); + xfs_trans_ijoin(tp, src_dp, 0); if (new_parent) - xfs_trans_ijoin(tp, target_dp, XFS_ILOCK_EXCL); - xfs_trans_ijoin(tp, src_ip, XFS_ILOCK_EXCL); + xfs_trans_ijoin(tp, target_dp, 0); + xfs_trans_ijoin(tp, src_ip, 0); if (target_ip) - xfs_trans_ijoin(tp, target_ip, XFS_ILOCK_EXCL); + xfs_trans_ijoin(tp, target_ip, 0); if (wip) - xfs_trans_ijoin(tp, wip, XFS_ILOCK_EXCL); + xfs_trans_ijoin(tp, wip, 0); /* * If we are using project inheritance, we only allow renames @@ -2864,10 +2877,12 @@ xfs_rename( } /* RENAME_EXCHANGE is unique from here on. */ - if (flags & RENAME_EXCHANGE) - return xfs_cross_rename(tp, src_dp, src_name, src_ip, + if (flags & RENAME_EXCHANGE) { + error = xfs_cross_rename(tp, src_dp, src_name, src_ip, target_dp, target_name, target_ip, spaceres); + goto out_unlock; + } /* * Try to reserve quota to handle an expansion of the target directory. @@ -2881,6 +2896,7 @@ xfs_rename( if (error == -EDQUOT || error == -ENOSPC) { if (!retried) { xfs_trans_cancel(tp); + xfs_iunlock_rename(inodes, num_inodes); xfs_blockgc_free_quota(target_dp, 0); retried = true; goto retry; @@ -3092,12 +3108,13 @@ xfs_rename( xfs_trans_log_inode(tp, target_dp, XFS_ILOG_CORE); error = xfs_finish_rename(tp); - if (wip) - xfs_irele(wip); - return error; + + goto out_unlock; out_trans_cancel: xfs_trans_cancel(tp); +out_unlock: + xfs_iunlock_rename(inodes, num_inodes); out_release_wip: if (wip) xfs_irele(wip); From patchwork Tue Jan 24 01:36:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 13113262 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 B2C9EC05027 for ; Tue, 24 Jan 2023 01:36:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232132AbjAXBgj (ORCPT ); Mon, 23 Jan 2023 20:36:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56592 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232235AbjAXBgi (ORCPT ); Mon, 23 Jan 2023 20:36:38 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E96E71ABFA for ; Mon, 23 Jan 2023 17:36: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 30O04wbJ020301 for ; Tue, 24 Jan 2023 01:36: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=6V8jvoFTXiqb5KGxOUdyTpyXBvusz0Drjv+6VgVQpKY=; b=RY8m3gJCi/0S5sJAGU/rZMhyXmvBtt1YXPeTr9WOInQjCGmLxRZXBgV/ymZ/B5312aLo OhauY3yaFEcLmpgXXOv/906qg5c8APCudn6UX2RWADEMvx/kQ7Qk0xBFj8zSzjnfO2vi 5EHFrEyKoWGOYsGvP8aVNEFCkUI6PdxKezyf6UltVFgMv4O+r5ACidQgHufS8Tmwf7tS 4ZfrAJ53aaghhLVziVRi34rP4NB60Wk3vgdfHtRgrxAxTO4ZNO3aCc+JXbxmw9Z2RUYg QIz8f0fIWMnIhvYklLapTeWedEtRE6u4WWx1GUOp4IYQSrAqi2XyR92WhwU4w+wEIop9 NA== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3n86ybcbht-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 24 Jan 2023 01:36:37 +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 30NMo5c4023221 for ; Tue, 24 Jan 2023 01:36:36 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2169.outbound.protection.outlook.com [104.47.58.169]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3n86g4akwp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 24 Jan 2023 01:36:36 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Y2pjOz0Bh809ek46CItz46Xb01B2atawMX12bDJK49nIvwliO5/IQgsF9Xy2rieuEBAAloLvtnbbXym+9/5Ae4WZQketNSnEzugrydHllmILH1xZlFYP2u6rrf3uW+m2jdWYLQVsb8VmAqCeGPB0RvIdY1NJ8wAz9VXtJk4F3YI0X9NG6V+ZSxxUyzWcIcjtG+EdI7awjfEkYNh0JEKg8U4RWTjigxZbC7CRChL+tOQjJuRZAEp86s3X10PjHMNTuNctBJb36WY5uS3/3/Eghhaq6hDKw0hkqto8NtSi6ANaZlNNxuVt/s3slm3LEN3jasRZe3ZeFcEZ2j9zJhw3sw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=6V8jvoFTXiqb5KGxOUdyTpyXBvusz0Drjv+6VgVQpKY=; b=Hlr1IYJo3PqgdUCUj/Vs1rtwAQs9Uut5D/wseh0FAeg0tzLMgusgEKLfDqm9D6B6vhCySY9qmV14nSl0yKeO8a2UMXQDx+9aLs5mVMswIF7MucxofbB+hqq9L9QaCR4vRdAM3xekjEiJgK1j1YfKH1N6y+hutapBSccd1jqP4vEBQwyFueuujTy7/P3/mfmb7OWZwVnpVTB7AGxf9TOycL6+l3JnDIHakl7PbRrjK1pcHcLaJMxstr6v7WmIQindClCGYcW0ANt4tp73uM7jF8ZQQnfPe74blIZyCg+dUEyv9m00AWT3otyDhJ0apcuzwCFNPIsKAHAqKSnaUzkwXw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=6V8jvoFTXiqb5KGxOUdyTpyXBvusz0Drjv+6VgVQpKY=; b=NyiUWjV+X1tmSxiTnGPcpu8QbCvUkQ0pDa0xqA1YTlvhjW4LYWdpEtHjk7T76V2sYZrZ2u7E1yLNARRMe4Cu6MXp6D0zDhifERKABLbKbHN7arF6V5RYVmuSyXruZipXwYRSc6mpKIFhwR+cFB9FvNSBDVT9AD2uSz2+AzT9H0U= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by BLAPR10MB5041.namprd10.prod.outlook.com (2603:10b6:208:30e::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.17; Tue, 24 Jan 2023 01:36:34 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::eaff:9f55:4641:db38]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::eaff:9f55:4641:db38%4]) with mapi id 15.20.6043.016; Tue, 24 Jan 2023 01:36:34 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v8 07/27] xfs: Expose init_xattrs in xfs_create_tmpfile Date: Mon, 23 Jan 2023 18:36:00 -0700 Message-Id: <20230124013620.1089319-8-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230124013620.1089319-1-allison.henderson@oracle.com> References: <20230124013620.1089319-1-allison.henderson@oracle.com> X-ClientProxiedBy: BYAPR05CA0093.namprd05.prod.outlook.com (2603:10b6:a03:e0::34) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY5PR10MB4306:EE_|BLAPR10MB5041:EE_ X-MS-Office365-Filtering-Correlation-Id: a2ed2086-b70f-485d-efbf-08dafdab6d6e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 3KRNRO9txWXC41tLXfh2as0moubgdAId859BSWPknWaSd5aIKr2vWdg86Zb1dLi7gEPI6gMXVQbEN5qQ7zCOpYEwoeGcknWqo4TYP/UNhTnDcaaKr5FAIOVKUP33qbD7kAQMTjr+lSj/EwkgWxObvf22Bgf0Lux9PHC1vD47PefNL4dobJ9OOHsJxc7k0AwU2M1yPyH41DBUut/3ldGbeNaCDbJB74O02/Ab+gOKJAbv+n6D4tYI9+rqs1kNUAFWtK9zaJ4o3J7t2lxwOFSuDSI6GJ6/qF00lDEOnmfoQNB2efGjhwkUrA3J+dtAyIiGRZ01aS/6NvVoIqR4dTJ2dwZ5sLMU+F2dxo6TKgkN3tHDAY63DTgS/lPeOzhzobUsK2xR6oJ3qcRYxKm7/ONKp47bedo8MSEzCHTqCUu8/CLC6VHpTt6GbzOLE0ftGloKkmvykJvDjCuFF05b9cnVaIa+qhp+TMpt7X0L+RND/QTIskFB862VNrPzUXc8Cp8mpqGtZoUb8pwjBJgDUXpthsEYPnCR8M6VUlL9lH7r8pZVnQej0utX+T16dMpCvuxFUK8IXk39Jm/hV2a+wP0J8q/q8gFEGwCB7yT770a2XsLs5uYbbUmgE6xe6Zzz030gMCgoo6uwfIq5oRyyv2KUiw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(396003)(346002)(376002)(366004)(39860400002)(136003)(451199015)(6486002)(478600001)(6666004)(26005)(6506007)(9686003)(6512007)(186003)(2616005)(38100700002)(1076003)(316002)(86362001)(6916009)(41300700001)(83380400001)(8676002)(66946007)(66556008)(36756003)(66476007)(8936002)(5660300002)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: B+dIVFmhAtxsh74CHdVxEoCksq+uVljAruPGtIcT4kIF7Wa79lQd/wnSI8uK1olrfO//inIttjFp91KPx+vPiPw9EKyrOE8PED6jDL8pfemxNbJPEfHQmglDh57GXDPG3a7eQRcSY4HNPE3sHhGBu+JIGxS+goKnyWkAXwBa+Ycik7NujiUrUqPYDSxjs/Hc34SmGolHItNqRWoEI2q9YHLRHccBP1FarxmT4M08wklKl3Aue1Z4yWRezO8NCIDtN38Kj5Xs1W5TLgabKE0q6FOCUlk0RFQsIRv8dTJfoiol51a3MKQ8O546k5hE6tHcMyk3a7ZBsc7pFF9cGzQubUcTn6/An2Y0N+KlpL+/U6NJOusW7fMYlRGZC8u5sgiG5q1bNy6w25lxBovJklQ+VE6wuuvKXL7mHkes+VdfYnaY8IfFI6g5xtJtomIanORrtl9rS8UTEWT0cKo6F1+vLdHyVOvUFsOQ6pgKJVbTvtrtc4M3z2+iDDiC6kPujxgOgcyGll+FuXUxfTvmuc/jlsa0wBJm225U3MZtp7EXGeYXxPMUTDp9Uc0PfRMwCStVgAMVh5n01tx3On1ImUfDZZ8budBgqAD2GV6AkaI/9PBB216xsMpiJJnOsMnplf8rEXATiVnMKBLiC/yt3HghVQuDLrYXYPrDByfv3AFCuScRUazo0FP8t8WtSe6CU86GvDIt+R8odXMMctR/L2VqwGX/md8DtVdzh49u8aHDtF092EQ2A2wXEXdUTpo/DE9nYM9rAtxLdzwVGdE0oqkGf+0pWTeYqGd7a7JWPgm4N7ovdoDUQKXluizd7qlNhfbfqRRfsG3AcAimIfl46bSJ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AU7R1oXGGtgpi5CT7jzjpShllad+3x5/nOUZu5mIoGlhENuCUU7z+JKeYv1kqTMmqVtrK7N7EVDxUcKtBHEDWbf5GVg2UABy27k28FdGncFR7St3EtDxhn+uykqy0wyYBHYe4MZtozn0oijx6geja86kD8Q++Pyqz1UD0YSEuKVmPCcOLgeYKXavg3IFZLNxlKZ1krPoGVu2gktBietJU2Mda6z/iUs5IdpVYf2Twwi9OXFPc/WpITgZY34c1w+PvPrU17K04o+P1b3nhTeL+cC2Kw3jDLU+b7i5GyWYodzmAr7l45wWqFw2Kw1MbZ2Svdd/antn+2R4PdNU54nyVJTrx7unQw/9tCKJOCHYF5ImishJLXBvk4AJmSio9h1cYj6q6JRyWB/ZX6LsULVxi9+to+YLPRtDiGihmshvkhiVtIL3fksuHrW9nAE68asRlO2WKsEvdAba9hKv2c20csgCNAdBSrMk7+cXxQonWtYiBPQ0v3/aWr0iH39xhvhY2RtHN57f0KOq34Prch3suOH5HBAEAsT2kcCYxZVhiC1YQmw== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: a2ed2086-b70f-485d-efbf-08dafdab6d6e X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jan 2023 01:36:34.5442 (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: UxOkQR/+6r8bTMC6HdL8naMBWcDEfYyBTlwTpc0zlGegqYd7J2Ctie9Qu7FkdoqiI8A/ICGOlU8qI3zqEygPwSvZuy5IUinb+mvv7vpJqhI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLAPR10MB5041 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-23_12,2023-01-23_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 suspectscore=0 malwarescore=0 phishscore=0 mlxlogscore=999 adultscore=0 mlxscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301240010 X-Proofpoint-GUID: ms0kZf6XBspGALOb8FQHiRHgvt09vKsl X-Proofpoint-ORIG-GUID: ms0kZf6XBspGALOb8FQHiRHgvt09vKsl Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Allison Henderson Tmp files are used as part of rename operations and will need attr forks initialized for parent pointers. Expose the init_xattrs parameter to the calling function to initialize the fork. Signed-off-by: Allison Henderson Reviewed-by: Darrick J. Wong --- fs/xfs/xfs_inode.c | 5 +++-- fs/xfs/xfs_inode.h | 2 +- fs/xfs/xfs_iops.c | 3 ++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index 131abf84ea87..267d629a33d9 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -1109,6 +1109,7 @@ xfs_create_tmpfile( struct user_namespace *mnt_userns, struct xfs_inode *dp, umode_t mode, + bool init_xattrs, struct xfs_inode **ipp) { struct xfs_mount *mp = dp->i_mount; @@ -1149,7 +1150,7 @@ xfs_create_tmpfile( error = xfs_dialloc(&tp, dp->i_ino, mode, &ino); if (!error) error = xfs_init_new_inode(mnt_userns, tp, dp, ino, mode, - 0, 0, prid, false, &ip); + 0, 0, prid, init_xattrs, &ip); if (error) goto out_trans_cancel; @@ -2750,7 +2751,7 @@ xfs_rename_alloc_whiteout( int error; error = xfs_create_tmpfile(mnt_userns, dp, S_IFCHR | WHITEOUT_MODE, - &tmpfile); + false, &tmpfile); if (error) return error; diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h index 2eaed98af814..5735de32beeb 100644 --- a/fs/xfs/xfs_inode.h +++ b/fs/xfs/xfs_inode.h @@ -478,7 +478,7 @@ int xfs_create(struct user_namespace *mnt_userns, umode_t mode, dev_t rdev, bool need_xattr, struct xfs_inode **ipp); int xfs_create_tmpfile(struct user_namespace *mnt_userns, - struct xfs_inode *dp, umode_t mode, + struct xfs_inode *dp, umode_t mode, bool init_xattrs, struct xfs_inode **ipp); int xfs_remove(struct xfs_inode *dp, struct xfs_name *name, struct xfs_inode *ip); diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c index 515318dfbc38..45e66c961829 100644 --- a/fs/xfs/xfs_iops.c +++ b/fs/xfs/xfs_iops.c @@ -200,7 +200,8 @@ xfs_generic_create( xfs_create_need_xattr(dir, default_acl, acl), &ip); } else { - error = xfs_create_tmpfile(mnt_userns, XFS_I(dir), mode, &ip); + error = xfs_create_tmpfile(mnt_userns, XFS_I(dir), mode, true, + &ip); } if (unlikely(error)) goto out_free_acl; From patchwork Tue Jan 24 01:36:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 13113263 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 02114C05027 for ; Tue, 24 Jan 2023 01:36:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232462AbjAXBgn (ORCPT ); Mon, 23 Jan 2023 20:36:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56618 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232235AbjAXBgl (ORCPT ); Mon, 23 Jan 2023 20:36:41 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3F7611A483 for ; Mon, 23 Jan 2023 17:36:40 -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 30O04qRa023718 for ; Tue, 24 Jan 2023 01:36:40 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2022-7-12; bh=2mD/+w/gIEcqSKEpz/PYuGTNBS+UC4p44L++8n5sVQ4=; b=ZCSxSUTnb29Exq7NQvSyJuHMg1yacHwQi9PP3XWqqtr+0jEOBaTaQ3rRZd+gNlzwdSls /76CQeVo5djHKb1+uSzR6M/rG4/T9VFmSN2mBzTHSiOMNxDitGD/YxVPPuHPYTD6yGSh 4ZlRoYd5CqJ+gAe7+NnMHlUIGtU5RCym16X82Us5G2ORb4GWfZhIYUh3ePAWMRcqYbqS MMrnTpG6RxrPEWGqB+blaumeWP6kYGipAQb1UUCbAt56k6OuKKnQ7Saq/sQ0j5nbEAYu hVFyYLHQZrIRbIIDJiCCMB0TJA+PXtxTdxm5W5Hd0U1/GngjLlQuIDPok6EiICxdQemP pA== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3n88ktv8ct-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 24 Jan 2023 01:36: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 30NNWhx5039605 for ; Tue, 24 Jan 2023 01:36:38 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2168.outbound.protection.outlook.com [104.47.58.168]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3n86gb4axj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 24 Jan 2023 01:36:38 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Av7wJv16GOMW4Ov0tZV6P6+qOhXmYZ8audt9vxMsLPzXfs9NYTfmU8QlyYFt8bC7jPUtsuoeRQDqL8lX9HsYTCYWVKBCH25O56/nabtw7nV/dyhh4EL1yb/j186qynXDII7YjIM8/0kB23bpHVApiCLWp5jifgVQtqWuJ2GjpgU5Gb076pe6idJc9uS/7P0RgAzMpoWwJDAhZ2gKZGKmkog+7egj5evA9CYcRAyBASSb2+kXTkQ0KCGbq0Cm8gAGnnrVwhgj9UAE66G8r8bg61SR24thN2QzdvyYuoqmQurYy31c+74cAn16kY0k1NzZHmAxF6GOpvrMzFQAg+oF9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=2mD/+w/gIEcqSKEpz/PYuGTNBS+UC4p44L++8n5sVQ4=; b=a5X8xZV5kLLvVzRqkwxprBzj4Fi+BFXIOtArtQYjd0gBZ+hzP/A0gEEZP/P2v5LWU0nC+QIAuynHTvj1t+N3OcsUjEJi2Cmn0rDRR2tIFCOv4gdtg2qga0iXZ+GPNbUtM511M/+sG9k3XI19M9nKMav4A0dwDWyQxPpZ31tKPBXiZkzvsR/iozjUJ4AMw7RWSY9IsT0HNm3/A+0qBeU9RCZUlGCeUz9aKEaS0u48qvL3WV9XMH6VCy9YLZIQDj72RSHpom5mVVOlIypzHUzjg+ELFLrrnDwke1CapiJWnbT7PHxp5NTmQT0v9gBCAdQ055RtLklfguIpKJIvj6s3lg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=2mD/+w/gIEcqSKEpz/PYuGTNBS+UC4p44L++8n5sVQ4=; b=wJ4HeXVIaCB2Nwq/CSWITxcSUJ0rg52MLswwu9DXTWegri/4k15CKs+wKZ9RLdUvhefljaogXCmJKNozFHAmPalDZyGlxvmtNMZOs3V3YcjMb6PkjXm7ePHiZXISQTluFzx2z4M1FD8MzcUNTFlgmLiMB0QMcxNuS/HaS9STcKs= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by BLAPR10MB5041.namprd10.prod.outlook.com (2603:10b6:208:30e::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.17; Tue, 24 Jan 2023 01:36:36 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::eaff:9f55:4641:db38]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::eaff:9f55:4641:db38%4]) with mapi id 15.20.6043.016; Tue, 24 Jan 2023 01:36:36 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v8 08/27] xfs: get directory offset when adding directory name Date: Mon, 23 Jan 2023 18:36:01 -0700 Message-Id: <20230124013620.1089319-9-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230124013620.1089319-1-allison.henderson@oracle.com> References: <20230124013620.1089319-1-allison.henderson@oracle.com> X-ClientProxiedBy: SJ0PR05CA0035.namprd05.prod.outlook.com (2603:10b6:a03:33f::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_|BLAPR10MB5041:EE_ X-MS-Office365-Filtering-Correlation-Id: 7ea23feb-3af7-4774-4eaf-08dafdab6ec1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: rZpXOgTBu0GfIAMxeejUCxOfTbeciF5HTzbLUTKkj8OrxIcKy+rMlPuXFlIlyARFYV4t/HWHc4VcKda2TNGT6Dwj9WXGci7qf+QxKEeguFaZ5/MQ2B4NdKjdXPgKDm1fUUn4XlcDU7l6prlyVRQEFYjC3tEn2p0mQDunsftNdssu+XXBtL+RpS6MR0lpJiYx+E/PEJdXP1W1DCD2sIHJk12ewkx78yKJkq3Q9PVIugdtb8VjjVWGThgJUvc8GVvzs4KHjieLnQTtI/wjb5pCpWAQPWvNUsph6JIP64f/3B7yGDgl4VvQ91uagbURr5Ntug768pXEzua3sfJcFyn3tUgYdKMzfOlZO+v+vxWMNSg0YM1tqrvfafwQf2oaqMVICjgiyO4Oso89BlkxqlBgfJacPSeO+55SsweAjIcErEJ9sksmzjdpfMA2or6SMlfguoA8MYpt0d8eKE5ezaoLQjn1turmydHwCtp709iUJ4MsZcaZIk8yTuVBDq/TJpT7XcTjNkRaceaAbhwJSw7giSP+YVM0XB7Iv1yY2D5proBN4ZJAE0PsyP5tcSV4XBkFJOqAGSkRS90yn/jDjljM/z1N4PhjfJ+JP/FHXLxw6UcfMntDXmNQqJxX4I54p3h6RygjVfYzyqVh66HAFYKOzA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(396003)(346002)(376002)(366004)(39860400002)(136003)(451199015)(6486002)(478600001)(6666004)(26005)(6506007)(9686003)(6512007)(186003)(2616005)(38100700002)(1076003)(316002)(86362001)(6916009)(41300700001)(83380400001)(8676002)(66946007)(66556008)(36756003)(66476007)(8936002)(5660300002)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: z/UIXyxVHyv8TXubyNoaGBB5WvXBuj7miV5X/HylX7Me2g9Jqu6sqMmOZAD8wDOYcCwsFtpSn3AcRiZmCKUYrYEyQl4byzq5rMwwe8NEr04bLEc0SWCcv6InoCkL3OAAAGiEC+LBOGMWIf9ns76w7KOiz0/R9MPimeTkiCokrRyKyJjcZh/vKUw0walJ+UCvABOEvnTnPLQEEdxLJfMbx5wl6Lk/M5RkL+GAvxChahFZ20+eB4JgmnYpEMycCC8FdCvTkiYTuDq3DN+CrzGRFyYvYYZ7kQX9N7FsnfdDQ4Wqp9ZmoluwiOQyDxjxUWArC2GL8DFe6ESceXrlMEm3RQF6KRBMPRnpvj83zaDWKUW7RyeqFx9dnRVsQ8HmvfrcQl6jHPgEQAnByVCBXr9uGKIjGcTl3MUHZ11/Yis5aNCZJUeFjD2CDVZSqkKNPJ2wRNOol/q4YHzOhrXgqgQEeQRsc4lzZYV9jEzeHtrMDPoTk2Ov3C0+kgGKJLB9Ln8AJsI51+dY5W4sf1dhNLBGgbtDN5yKE9NiTAd7He+lAY9gQXggVYNrFqMHHgTmP8Rq+OfUdM8OmzAwkj6pgBI20Ql4m/iWfvJGXhSlHEmssCuJ5sES1TNfTaxovpLfKd/tVhISBBmTYJM69v8rhCrBSIkmhW0hnDnmWZ/qQJ2jsxCtR01eVTtU/ZI2O8YB7m7t5nDn0j47oY5c7haXA5Rwjl2ifsHePnoe02LTLY9Mi0VnrCf2aFiC/KQpLyt8Rtarr75S2gRkHMZQn7IibjBRx06T8+5DCjCSUYRnV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sxROcjI/1HybQ7mvw3DM4zCmSTgzIbLm9atdM+CqkHBuxF2UuBMJwtpoUbPjblpWHMBruppkQWPdJx4yNX3cFEnnnF+nHK73C+DIt811qk7vPHB3/Xg+7NjSpOFpqo9BaGfYYZmGWUkMk8+kdWNzOEPqij1HVXLPXuiObJKa4wIM75SfRHGiHQYcGpHisTlOrKq334YHF8fpM8Y7nPmzi/D+avEmP4vkGi0bMqln/jKDnvl9qAaYVYOSuOm3oSPdRPo6rwyr4X84VuK/if4plkUjN3yywsrQdPvzTWdRLelOduKHFvj4TXHNdJxhCBeEtqCqa6em1sAma4fe1dpHWawTglDz5IR1UmqzQnRMX+VLsGbfi/+YGAHODsIptzRBjY9jy2DERpvmadSfvSqcSeW2KPCy6qg1xp/lHy3vtBzv9y3fT147fSSbUXIMb+xvmMWeOJlVdgDM5iMt7wPiOq27Cmt/7zLL7cG62uTf49aKFinIQ/b3LfjVl2NCWJtF6dd+IMCge1Wl1YFNzmoiPKqbpqS2RTKImvegpcT6lLl7Za5znmeCDWNehC91HRLpGSVlqG+9zUfjvdpp9o9lV2Qc/MhUYOKxYCFioqtKaw== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7ea23feb-3af7-4774-4eaf-08dafdab6ec1 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jan 2023 01:36:36.7149 (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: 0ET4pPrD6Ovtu80ZTbMFaWrIIvfAABVkuM5mw0qz7vZnQLcZyJL38H5zKJV8I6rcS7PFtLa6OMh1F4v7RE9YPD5CY5sQ63/fUtGwakTN8GM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLAPR10MB5041 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-23_12,2023-01-23_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 mlxscore=0 spamscore=0 bulkscore=0 mlxlogscore=999 malwarescore=0 adultscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301240010 X-Proofpoint-GUID: g2-0SYxmkP2gWWph_QqlvmBLEk4ytWLV X-Proofpoint-ORIG-GUID: g2-0SYxmkP2gWWph_QqlvmBLEk4ytWLV Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Allison Henderson Return the directory offset information when adding an entry to the directory. This offset will be used as the parent pointer offset in xfs_create, xfs_symlink, xfs_link and xfs_rename. Signed-off-by: Dave Chinner Signed-off-by: Allison Henderson Reviewed-by: Darrick J. Wong Reviewed-by: Catherine Hoang --- fs/xfs/libxfs/xfs_da_btree.h | 1 + fs/xfs/libxfs/xfs_dir2.c | 9 +++++++-- fs/xfs/libxfs/xfs_dir2.h | 2 +- fs/xfs/libxfs/xfs_dir2_block.c | 1 + fs/xfs/libxfs/xfs_dir2_leaf.c | 2 ++ fs/xfs/libxfs/xfs_dir2_node.c | 2 ++ fs/xfs/libxfs/xfs_dir2_sf.c | 2 ++ fs/xfs/xfs_inode.c | 6 +++--- fs/xfs/xfs_symlink.c | 3 ++- 9 files changed, 21 insertions(+), 7 deletions(-) diff --git a/fs/xfs/libxfs/xfs_da_btree.h b/fs/xfs/libxfs/xfs_da_btree.h index a4b29827603f..90b86d00258f 100644 --- a/fs/xfs/libxfs/xfs_da_btree.h +++ b/fs/xfs/libxfs/xfs_da_btree.h @@ -81,6 +81,7 @@ typedef struct xfs_da_args { int rmtvaluelen2; /* remote attr value length in bytes */ uint32_t op_flags; /* operation flags */ enum xfs_dacmp cmpresult; /* name compare result for lookups */ + xfs_dir2_dataptr_t offset; /* OUT: offset in directory */ } xfs_da_args_t; /* diff --git a/fs/xfs/libxfs/xfs_dir2.c b/fs/xfs/libxfs/xfs_dir2.c index 92bac3373f1f..69a6561c22cc 100644 --- a/fs/xfs/libxfs/xfs_dir2.c +++ b/fs/xfs/libxfs/xfs_dir2.c @@ -257,7 +257,8 @@ xfs_dir_createname( struct xfs_inode *dp, const struct xfs_name *name, xfs_ino_t inum, /* new entry inode number */ - xfs_extlen_t total) /* bmap's total block count */ + xfs_extlen_t total, /* bmap's total block count */ + xfs_dir2_dataptr_t *offset) /* OUT entry's dir offset */ { struct xfs_da_args *args; int rval; @@ -312,6 +313,10 @@ xfs_dir_createname( rval = xfs_dir2_node_addname(args); out_free: + /* return the location that this entry was place in the parent inode */ + if (offset) + *offset = args->offset; + kmem_free(args); return rval; } @@ -550,7 +555,7 @@ xfs_dir_canenter( xfs_inode_t *dp, struct xfs_name *name) /* name of entry to add */ { - return xfs_dir_createname(tp, dp, name, 0, 0); + return xfs_dir_createname(tp, dp, name, 0, 0, NULL); } /* diff --git a/fs/xfs/libxfs/xfs_dir2.h b/fs/xfs/libxfs/xfs_dir2.h index dd39f17dd9a9..d96954478696 100644 --- a/fs/xfs/libxfs/xfs_dir2.h +++ b/fs/xfs/libxfs/xfs_dir2.h @@ -40,7 +40,7 @@ extern int xfs_dir_init(struct xfs_trans *tp, struct xfs_inode *dp, struct xfs_inode *pdp); extern int xfs_dir_createname(struct xfs_trans *tp, struct xfs_inode *dp, const struct xfs_name *name, xfs_ino_t inum, - xfs_extlen_t tot); + xfs_extlen_t tot, xfs_dir2_dataptr_t *offset); extern int xfs_dir_lookup(struct xfs_trans *tp, struct xfs_inode *dp, const struct xfs_name *name, xfs_ino_t *inum, struct xfs_name *ci_name); diff --git a/fs/xfs/libxfs/xfs_dir2_block.c b/fs/xfs/libxfs/xfs_dir2_block.c index 00f960a703b2..70aeab9d2a12 100644 --- a/fs/xfs/libxfs/xfs_dir2_block.c +++ b/fs/xfs/libxfs/xfs_dir2_block.c @@ -573,6 +573,7 @@ xfs_dir2_block_addname( xfs_dir2_data_put_ftype(dp->i_mount, dep, args->filetype); tagp = xfs_dir2_data_entry_tag_p(dp->i_mount, dep); *tagp = cpu_to_be16((char *)dep - (char *)hdr); + args->offset = xfs_dir2_byte_to_dataptr((char *)dep - (char *)hdr); /* * Clean up the bestfree array and log the header, tail, and entry. */ diff --git a/fs/xfs/libxfs/xfs_dir2_leaf.c b/fs/xfs/libxfs/xfs_dir2_leaf.c index cb9e950a911d..9ab520b66547 100644 --- a/fs/xfs/libxfs/xfs_dir2_leaf.c +++ b/fs/xfs/libxfs/xfs_dir2_leaf.c @@ -870,6 +870,8 @@ xfs_dir2_leaf_addname( xfs_dir2_data_put_ftype(dp->i_mount, dep, args->filetype); tagp = xfs_dir2_data_entry_tag_p(dp->i_mount, dep); *tagp = cpu_to_be16((char *)dep - (char *)hdr); + args->offset = xfs_dir2_db_off_to_dataptr(args->geo, use_block, + (char *)dep - (char *)hdr); /* * Need to scan fix up the bestfree table. */ diff --git a/fs/xfs/libxfs/xfs_dir2_node.c b/fs/xfs/libxfs/xfs_dir2_node.c index 7a03aeb9f4c9..5a9513c036b8 100644 --- a/fs/xfs/libxfs/xfs_dir2_node.c +++ b/fs/xfs/libxfs/xfs_dir2_node.c @@ -1974,6 +1974,8 @@ xfs_dir2_node_addname_int( xfs_dir2_data_put_ftype(dp->i_mount, dep, args->filetype); tagp = xfs_dir2_data_entry_tag_p(dp->i_mount, dep); *tagp = cpu_to_be16((char *)dep - (char *)hdr); + args->offset = xfs_dir2_db_off_to_dataptr(args->geo, dbno, + (char *)dep - (char *)hdr); xfs_dir2_data_log_entry(args, dbp, dep); /* Rescan the freespace and log the data block if needed. */ diff --git a/fs/xfs/libxfs/xfs_dir2_sf.c b/fs/xfs/libxfs/xfs_dir2_sf.c index 8cd37e6e9d38..44bc4ba3da8a 100644 --- a/fs/xfs/libxfs/xfs_dir2_sf.c +++ b/fs/xfs/libxfs/xfs_dir2_sf.c @@ -485,6 +485,7 @@ xfs_dir2_sf_addname_easy( memcpy(sfep->name, args->name, sfep->namelen); xfs_dir2_sf_put_ino(mp, sfp, sfep, args->inumber); xfs_dir2_sf_put_ftype(mp, sfep, args->filetype); + args->offset = xfs_dir2_byte_to_dataptr(offset); /* * Update the header and inode. @@ -575,6 +576,7 @@ xfs_dir2_sf_addname_hard( memcpy(sfep->name, args->name, sfep->namelen); xfs_dir2_sf_put_ino(mp, sfp, sfep, args->inumber); xfs_dir2_sf_put_ftype(mp, sfep, args->filetype); + args->offset = xfs_dir2_byte_to_dataptr(offset); sfp->count++; if (args->inumber > XFS_DIR2_MAX_SHORT_INUM && !objchange) sfp->i8count++; diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index 267d629a33d9..143de4202cf4 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -1038,7 +1038,7 @@ xfs_create( unlock_dp_on_error = false; error = xfs_dir_createname(tp, dp, name, ip->i_ino, - resblks - XFS_IALLOC_SPACE_RES(mp)); + resblks - XFS_IALLOC_SPACE_RES(mp), NULL); if (error) { ASSERT(error != -ENOSPC); goto out_trans_cancel; @@ -1264,7 +1264,7 @@ xfs_link( } error = xfs_dir_createname(tp, tdp, target_name, sip->i_ino, - resblks); + resblks, NULL); if (error) goto error_return; xfs_trans_ichgtime(tp, tdp, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG); @@ -3001,7 +3001,7 @@ xfs_rename( * to account for the ".." reference from the new entry. */ error = xfs_dir_createname(tp, target_dp, target_name, - src_ip->i_ino, spaceres); + src_ip->i_ino, spaceres, NULL); if (error) goto out_trans_cancel; diff --git a/fs/xfs/xfs_symlink.c b/fs/xfs/xfs_symlink.c index d8e120913036..27a7d7c57015 100644 --- a/fs/xfs/xfs_symlink.c +++ b/fs/xfs/xfs_symlink.c @@ -314,7 +314,8 @@ xfs_symlink( /* * Create the directory entry for the symlink. */ - error = xfs_dir_createname(tp, dp, link_name, ip->i_ino, resblks); + error = xfs_dir_createname(tp, dp, link_name, + ip->i_ino, resblks, NULL); if (error) goto out_trans_cancel; xfs_trans_ichgtime(tp, dp, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG); From patchwork Tue Jan 24 01:36:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 13113264 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 CF69BC54E94 for ; Tue, 24 Jan 2023 01:36:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232235AbjAXBgo (ORCPT ); Mon, 23 Jan 2023 20:36:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56626 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232302AbjAXBgm (ORCPT ); Mon, 23 Jan 2023 20:36:42 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3D3801BAC4 for ; Mon, 23 Jan 2023 17:36:41 -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 30O04h8a020122 for ; Tue, 24 Jan 2023 01:36:41 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2022-7-12; bh=j1UphUgrLxNzSWpMB/bI7vBqQ2f2Hy1w5Wg7M7MEFKI=; b=WI+5XoV+XT4wXHNBbFtJ7HO92k+ra3lp9SevvtDAly+ZdNU7Iule56BPU+tD5CBTm66M MyqOEMJdjJc4MYN9drcwk987r2g3GS42LMUhu6W86IPJsN6dwSR593swcIN7HuIqyHho Wp4dgzqnMsFaPrHRVRWtGNnb9+mKkBor+gFP7P+g4AbuIqD9VOhtxLJJuaglKw31tPwP 7PmogT1aMixnnxIqEzreKFB+eiKJuTOUnQ1b8TDtv6rxFsf9HfzMiELtADAZr54neiAs hA8LmnnI/qtXHTaDhNCF7px/LO7HTRoa5FTxNYncERlMsSGo57xnR7iPsVHskyINkE89 7A== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3n86ybcbhv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 24 Jan 2023 01:36:40 +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 30NNUYcV023170 for ; Tue, 24 Jan 2023 01:36:40 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2169.outbound.protection.outlook.com [104.47.58.169]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3n86g4akyb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 24 Jan 2023 01:36:40 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nNbI7xgP3mhldLaNuRIV+5Fsqass/RcULP6WaGroZduP0Ww53mda3NsmWWnck0QO1N/AMCaKKbfExYaf6bcNBWlcq5+tCQdaBcbbXl3Nh9nqaCUjNoOz57zCM5gl6TElxQ4keDc/KzBJI5nZiG886dungh7oOEiBZiOt/l64jNu8zhdwBgi2VfjbgOpldzNyT3sR9rNkpacPUdNJ8pU71fPekYpJXOwtwB/cFCQlQx3n2/fd0TeUbKngzQgck9XdC8Rb4DkvpStvxuL/GLQVHY1BkrdfHkoNzhIZM03ffGb47VD8/30W0fCeoV8hRL3HCmF0CF1l0B2cpYIlB2G77w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=j1UphUgrLxNzSWpMB/bI7vBqQ2f2Hy1w5Wg7M7MEFKI=; b=O7bzSSvUtevL8OzTnYb1xEl/Lq/Xd5RMY8bjmC5SJWX+lefReLgdlMS67SVj/canlzWLbvoo6evLmVUYs3cYR01nui5FU12JK8N6MMckNqhGP42ARhutP88oSnID4bygt7ETsPQU1IgbOl+VGB08+LD3oyg6ltQrpyd9yvkGd7ovZHyPdxb1rYcIoEbBt1W+nynJCUQzd2J1Zw3q+P5WV5W/ofsjqPQ0moHyvgEW4awnW9vMaOLMbhxi1AV1iJUJREmc9qjHp786CGz9bInJ3xWZ14y/cq3cOZf7lOL7McwlmBt96AMs18D21eMDBzBeFo7aFiBY5gr3yWN9iSpjgA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=j1UphUgrLxNzSWpMB/bI7vBqQ2f2Hy1w5Wg7M7MEFKI=; b=QTVi/9I/UfeQL2iVZ1zg7e+71shDiVYbxwk1fjgVuPh1s1xMZHdAendP63zvUT4nXcLzRQuZef5gKVLv0fQQldSvWzeHcwY+4NVrjGbUpmryqNcyaW3nojmgnKSPzCgqE5fDBNzhPOSQNdQlb0WITC6r/p5lbpdFglgz2bXcmLs= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by BLAPR10MB5041.namprd10.prod.outlook.com (2603:10b6:208:30e::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.17; Tue, 24 Jan 2023 01:36:38 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::eaff:9f55:4641:db38]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::eaff:9f55:4641:db38%4]) with mapi id 15.20.6043.016; Tue, 24 Jan 2023 01:36:38 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v8 09/27] xfs: get directory offset when removing directory name Date: Mon, 23 Jan 2023 18:36:02 -0700 Message-Id: <20230124013620.1089319-10-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230124013620.1089319-1-allison.henderson@oracle.com> References: <20230124013620.1089319-1-allison.henderson@oracle.com> X-ClientProxiedBy: BYAPR21CA0001.namprd21.prod.outlook.com (2603:10b6:a03:114::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_|BLAPR10MB5041:EE_ X-MS-Office365-Filtering-Correlation-Id: 4e4021a0-fb2d-4638-84f0-08dafdab6f6f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Nw+D2gWraZSOUonLe/FAAx6Qiky5sc8j2GrL0rbuC+AMzydvp0ya8vB6E8LxPxPV5ODEADY3W+9D5kk5KrsJtjXBbdPbVOzIgfYORctf8lhqwIMR9PS15+2hhqXgl9nyf81s1Ft7UarYbYs2oV05z+HvlO1j/EilMxQ1I6rZN9xyIrOfroEFnskfqE2wrMv6/VIfAgzXSSdn+U4hjVCmR5PwMvRc8i8ESWo7qmS2qCQM+BXuus0CQuWy2hm1OwMUd2OMQiNKBEL9pdGsyQ2vqQCw9IYQQZkXXVinh4aOu4NxMf9yRIvJpdCU6JegdOKWZ4M/oxkZ2Yfpe5Hy11Jg86j1E3E5ZWqd5ggKtMv6bAfg3dG9MkngRXs+UPSxCPTr1KiT7e8Xsj9+eGG8aSDPPqDvkxrAgrXjCL20/bZLVYL1Ko5vjBFOOqgkKjpuIeFvJoo8A0JTTDyYodJj8fj8jPiVzwtRuXwVByUstqHWW1mEQUnDGRrm3FpTkCKUGE12DgLO9Lyn3C753OpsPTkGGrx9XWy0KUvKD4TeHe4f3abj9as9n04NSxDnB+zjAWnvgSfyiz7HDH5hRV4vYclduXNweQU8T7K+rhxFFg3Or9TzM1tfKLWOdkXFDU6mvgclgqU2tqFOcn/N1gDSuk5aZg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(396003)(346002)(376002)(366004)(39860400002)(136003)(451199015)(6486002)(478600001)(6666004)(26005)(6506007)(9686003)(6512007)(186003)(2616005)(38100700002)(1076003)(316002)(86362001)(6916009)(41300700001)(83380400001)(8676002)(66946007)(66556008)(36756003)(66476007)(8936002)(5660300002)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: vvaEyNHoJVqummRtqi3xMWEUFlMP+TJmO3TqshVhYe6lM3eONAi3r4EMLQ3GL+7qVwhOzLEtoPgSMO5/Yv/fsxfSxhqyI11++xZVt9yyex8j6I1yzz5y5okEww2quGwWEOTT90E8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epsc/cb1diDZqOdqc7cs3JiWa/JdmLM1/W1i5es8ch92TOZOq+OwS6c2/sjBiskFheMfvn85Bn4VQ8W6fsIa/mN9seXxmsluxM9wukjqLlGK3wVRAEHmTytcujNZ1t/Ysb/EmLejdR7TIjeEBxcx6YOITygsnC8JmOBET7Sw/E+GiO9XI9LTkVxaks/nPg== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4e4021a0-fb2d-4638-84f0-08dafdab6f6f X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jan 2023 01:36:37.9191 (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: R7Gt2IhacTsscrDOX+zKy6Ttvngbdeseb3EiMifQzu6L6zycK6yLRkNiMhmE8W/4q+tVvx0iVkUL5Ok6IbiDa2nDmPyLXZ8ydFxH+Jjfqkw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLAPR10MB5041 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-23_12,2023-01-23_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 suspectscore=0 malwarescore=0 phishscore=0 mlxlogscore=999 adultscore=0 mlxscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301240010 X-Proofpoint-GUID: mieq1TnRL6RnmdQZjb1miwlq5Dz8JC1b X-Proofpoint-ORIG-GUID: mieq1TnRL6RnmdQZjb1miwlq5Dz8JC1b Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Allison Henderson Return the directory offset information when removing an entry to the directory. This offset will be used as the parent pointer offset in xfs_remove. Signed-off-by: Mark Tinguely Signed-off-by: Dave Chinner Signed-off-by: Allison Henderson Reviewed-by: Darrick J. Wong Reviewed-by: Catherine Hoang --- fs/xfs/libxfs/xfs_dir2.c | 6 +++++- fs/xfs/libxfs/xfs_dir2.h | 3 ++- fs/xfs/libxfs/xfs_dir2_block.c | 4 ++-- fs/xfs/libxfs/xfs_dir2_leaf.c | 5 +++-- fs/xfs/libxfs/xfs_dir2_node.c | 5 +++-- fs/xfs/libxfs/xfs_dir2_sf.c | 2 ++ fs/xfs/xfs_inode.c | 4 ++-- 7 files changed, 19 insertions(+), 10 deletions(-) diff --git a/fs/xfs/libxfs/xfs_dir2.c b/fs/xfs/libxfs/xfs_dir2.c index 69a6561c22cc..891c1f701f53 100644 --- a/fs/xfs/libxfs/xfs_dir2.c +++ b/fs/xfs/libxfs/xfs_dir2.c @@ -436,7 +436,8 @@ xfs_dir_removename( struct xfs_inode *dp, struct xfs_name *name, xfs_ino_t ino, - xfs_extlen_t total) /* bmap's total block count */ + xfs_extlen_t total, /* bmap's total block count */ + xfs_dir2_dataptr_t *offset) /* OUT: offset in directory */ { struct xfs_da_args *args; int rval; @@ -481,6 +482,9 @@ xfs_dir_removename( else rval = xfs_dir2_node_removename(args); out_free: + if (offset) + *offset = args->offset; + kmem_free(args); return rval; } diff --git a/fs/xfs/libxfs/xfs_dir2.h b/fs/xfs/libxfs/xfs_dir2.h index d96954478696..0c2d7c0af78f 100644 --- a/fs/xfs/libxfs/xfs_dir2.h +++ b/fs/xfs/libxfs/xfs_dir2.h @@ -46,7 +46,8 @@ extern int xfs_dir_lookup(struct xfs_trans *tp, struct xfs_inode *dp, struct xfs_name *ci_name); extern int xfs_dir_removename(struct xfs_trans *tp, struct xfs_inode *dp, struct xfs_name *name, xfs_ino_t ino, - xfs_extlen_t tot); + xfs_extlen_t tot, + xfs_dir2_dataptr_t *offset); extern int xfs_dir_replace(struct xfs_trans *tp, struct xfs_inode *dp, const struct xfs_name *name, xfs_ino_t inum, xfs_extlen_t tot); diff --git a/fs/xfs/libxfs/xfs_dir2_block.c b/fs/xfs/libxfs/xfs_dir2_block.c index 70aeab9d2a12..d36f3f1491da 100644 --- a/fs/xfs/libxfs/xfs_dir2_block.c +++ b/fs/xfs/libxfs/xfs_dir2_block.c @@ -810,9 +810,9 @@ xfs_dir2_block_removename( /* * Point to the data entry using the leaf entry. */ + args->offset = be32_to_cpu(blp[ent].address); dep = (xfs_dir2_data_entry_t *)((char *)hdr + - xfs_dir2_dataptr_to_off(args->geo, - be32_to_cpu(blp[ent].address))); + xfs_dir2_dataptr_to_off(args->geo, args->offset)); /* * Mark the data entry's space free. */ diff --git a/fs/xfs/libxfs/xfs_dir2_leaf.c b/fs/xfs/libxfs/xfs_dir2_leaf.c index 9ab520b66547..b4a066259d97 100644 --- a/fs/xfs/libxfs/xfs_dir2_leaf.c +++ b/fs/xfs/libxfs/xfs_dir2_leaf.c @@ -1386,9 +1386,10 @@ xfs_dir2_leaf_removename( * Point to the leaf entry, use that to point to the data entry. */ lep = &leafhdr.ents[index]; - db = xfs_dir2_dataptr_to_db(geo, be32_to_cpu(lep->address)); + args->offset = be32_to_cpu(lep->address); + db = xfs_dir2_dataptr_to_db(args->geo, args->offset); dep = (xfs_dir2_data_entry_t *)((char *)hdr + - xfs_dir2_dataptr_to_off(geo, be32_to_cpu(lep->address))); + xfs_dir2_dataptr_to_off(args->geo, args->offset)); needscan = needlog = 0; oldbest = be16_to_cpu(bf[0].length); ltp = xfs_dir2_leaf_tail_p(geo, leaf); diff --git a/fs/xfs/libxfs/xfs_dir2_node.c b/fs/xfs/libxfs/xfs_dir2_node.c index 5a9513c036b8..39cbdeafa0f6 100644 --- a/fs/xfs/libxfs/xfs_dir2_node.c +++ b/fs/xfs/libxfs/xfs_dir2_node.c @@ -1296,9 +1296,10 @@ xfs_dir2_leafn_remove( /* * Extract the data block and offset from the entry. */ - db = xfs_dir2_dataptr_to_db(geo, be32_to_cpu(lep->address)); + args->offset = be32_to_cpu(lep->address); + db = xfs_dir2_dataptr_to_db(args->geo, args->offset); ASSERT(dblk->blkno == db); - off = xfs_dir2_dataptr_to_off(geo, be32_to_cpu(lep->address)); + off = xfs_dir2_dataptr_to_off(args->geo, args->offset); ASSERT(dblk->index == off); /* diff --git a/fs/xfs/libxfs/xfs_dir2_sf.c b/fs/xfs/libxfs/xfs_dir2_sf.c index 44bc4ba3da8a..b49578a547b3 100644 --- a/fs/xfs/libxfs/xfs_dir2_sf.c +++ b/fs/xfs/libxfs/xfs_dir2_sf.c @@ -969,6 +969,8 @@ xfs_dir2_sf_removename( XFS_CMP_EXACT) { ASSERT(xfs_dir2_sf_get_ino(mp, sfp, sfep) == args->inumber); + args->offset = xfs_dir2_byte_to_dataptr( + xfs_dir2_sf_get_offset(sfep)); break; } } diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index 143de4202cf4..e5ed8bdef9fe 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -2508,7 +2508,7 @@ xfs_remove( if (error) goto out_trans_cancel; - error = xfs_dir_removename(tp, dp, name, ip->i_ino, resblks); + error = xfs_dir_removename(tp, dp, name, ip->i_ino, resblks, NULL); if (error) { ASSERT(error != -ENOENT); goto out_trans_cancel; @@ -3098,7 +3098,7 @@ xfs_rename( spaceres); else error = xfs_dir_removename(tp, src_dp, src_name, src_ip->i_ino, - spaceres); + spaceres, NULL); if (error) goto out_trans_cancel; From patchwork Tue Jan 24 01:36:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 13113265 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 040FDC25B50 for ; Tue, 24 Jan 2023 01:36:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232302AbjAXBgp (ORCPT ); Mon, 23 Jan 2023 20:36:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56648 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232299AbjAXBgo (ORCPT ); Mon, 23 Jan 2023 20:36:44 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 73A861258F for ; Mon, 23 Jan 2023 17:36:43 -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 30O04fTw022007 for ; Tue, 24 Jan 2023 01:36: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=A7c/ag05lDcclOjw/wtyCnf4/2HW5521laIEYPVOD18=; b=XkpIZo/SexbWiRhKywTawJHeyMpox2VExJxn5iYH3GuL8BwcsujRePZKK1AOW6UQsKGj 6gtsK5YyHyx3uWS15aKV+70/Yfhk45Peu8VsVxDttxe23w7aeRs1N3iDkUlloRM88bR3 /F7Brs+rCIdXy/9Yv90pJSwmz5DNCZaeSzTYRzii4hVFBc54sVZPxt/5Gm1cufeKB1WK p9jjNxCvmSHWzRy3ZnPKiOjexgfavNmNVZjgYkt4mCEF51sEd2/vPF25TyNNo/a0/hEo KRiABw42Z22i6ErqO1QubAz6lc3bjCI+0hLYQ2Fp+sp/pkiD3yi9gzF54vdpeEUjkk9v cw== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3n88ktv8cu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 24 Jan 2023 01:36:42 +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 30NN7Vvi023238 for ; Tue, 24 Jan 2023 01:36:41 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2169.outbound.protection.outlook.com [104.47.58.169]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3n86g4m62t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 24 Jan 2023 01:36:41 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PiRk/H+wiJbSzsDL7CZjrjqgnxWHzWCIpSICajJ+tNVyEFF23RiWVfSm1do1m16blM4t4mo0Xt3tuj6dHXnQEmq3iMB3uObmCz4agUv2posTSFd6GIP6mb/GuJTFRgOxw+xPleX2mKrrrXjeqDATOHauAdT3Yrib0PSSQ3Dp5kAEi685nqtYa7CYD5D5ai+FPDiExTZg1X4DYdVl3fhnbgH2seEp9Kl8ou49pqxnp84iMZ+XMCN2u+Zu/BUdBUdKyen4UP+ydRfn30MldhwIFlLlz8n1c83egZH0Qh5E9mg+QpqNFJxp8s32CYiGmVpuyiRQvlsvpfmFHsMSgna18Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=A7c/ag05lDcclOjw/wtyCnf4/2HW5521laIEYPVOD18=; b=Crjroehn/JgwLL/daEYe5HjKgdpYDAUNlg5p3MAZdI5qz1djMso6SBi4EW+K1ToBN+zvMnmKNBotSebhgd0tCv6mm1HCxhaMB/DFyVYGx3ELv6mrgoN8YXdXj8t9ced7eptGzmPezfA+hg53V6F+DeS32xh2LuijNLtxetgroVgFK9UzjU4Boey59JEp1fTlWP5ojOch9HJsOa4h/hSVdfnHX/jB1+IdveERvnqlPXAytYZaoTDPQMNmOn0vyb61/y0SpqPW97XKIodXf4xNX+TJjYv19WnNkzhRxhhQo2nFimn8rqkf5Sx4zwOFhSjC3NgLDJ9j8Es9w6HDJkc7pA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=A7c/ag05lDcclOjw/wtyCnf4/2HW5521laIEYPVOD18=; b=OePi781dZKaiDDVLOi6k8gl5gFJSl4M7EEwUbc2WljGWl8OIha73LbkuRRV/nfWRQsfIuwmWVVzpdypVgm4bRDi3cABOt61UpwwvfUqyqhhgo5FKGMMwBR63jattm6Cemb4nfh8EDS687uT22aL8fFWYip0PpNwkVWO5kU+jD74= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by BLAPR10MB5041.namprd10.prod.outlook.com (2603:10b6:208:30e::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.17; Tue, 24 Jan 2023 01:36:39 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::eaff:9f55:4641:db38]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::eaff:9f55:4641:db38%4]) with mapi id 15.20.6043.016; Tue, 24 Jan 2023 01:36:39 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v8 10/27] xfs: get directory offset when replacing a directory name Date: Mon, 23 Jan 2023 18:36:03 -0700 Message-Id: <20230124013620.1089319-11-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230124013620.1089319-1-allison.henderson@oracle.com> References: <20230124013620.1089319-1-allison.henderson@oracle.com> X-ClientProxiedBy: BYAPR21CA0022.namprd21.prod.outlook.com (2603:10b6:a03:114::32) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY5PR10MB4306:EE_|BLAPR10MB5041:EE_ X-MS-Office365-Filtering-Correlation-Id: b7bcd6c5-e395-408c-ff77-08dafdab7088 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: GRaaFfdvvti6JMjm3+2iPFiCLmJ0S7Z/WZtA5jLSvJCjV4bGF4ryU9J4d/8y8HFtNQVkA5dZ0TZyjEwkpgtWJ8HZ+6QZHIUYLAB+tuiEQnUMpn/iQWgMGST8dgSjCNGtdzZOiHf+n2I8/5RBuwletW7etqX4mbIJi1ZQGM/w+cmO612f3LW2uG/b6zHYWpQlYXB3A/1nGuLgp0Oi/cZ/E26gLz7zlhQ3wcRMbhUSwe6unGY+ztYd5YIFbPiqgdqjoqb9wHKFdGBxVUnxTu4XMTyh0MVenAIT2pBLtUy+QSqIuxIWZWFrO0YjhHCG9pQVorsC2XOzDAltK0hKdnNsaOc/8sbPz0pqkNjOH++eYpcEXN0gBnojqxnkQhf2uX7LSibAU4S4P5/CyAv8wwgtMWIGVTCTDdRSuKHoWgYZoIqgN+X0aDdMFRnLVI/dgdoKq2TywkHnLMK6NlWp6DSgQYZJcKIk+O9S8FdHm8mYqQHxcKtA7BaVjBkLC+s4/WX4I1q7/7yFKMjPYJnx7oDaZogxiyn+tSMMNwVRQjzTcrCO9YUc4oLvwfREAqcdAIx0J587qKzUbj/Ax7Hem09FAQVPmWjMNIcfAT350Cjk5A9it9USC28jZ97bw63k9d97bBvHas9FoYTznUhUeCy5dg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(396003)(346002)(376002)(366004)(39860400002)(136003)(451199015)(6486002)(478600001)(6666004)(26005)(6506007)(9686003)(6512007)(186003)(2616005)(38100700002)(1076003)(316002)(86362001)(6916009)(41300700001)(83380400001)(8676002)(66946007)(66556008)(36756003)(66476007)(8936002)(5660300002)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: uiJQgY77oArrJXe5R1BbBvTRz8+rufikMax+y2YigF5A9X/fVztnhZksPCYGpE7/noUzkFafuDXfLw3Ke8A1O6sdhLVqR/EXeC5NTi+i0YY7Ilf5ZEzwSrUNA79E8r5ybA5eJLL9/hA/mTTBHYaj67g56v1U3vPg7SQNGTYqrpvbCLs9j68E5zT4fZuzzTbPXUZbQ/6gWqxB07fYX88QQG3Jyp6SjqjmHAvRsRJ7LBR7kIqrGlLp3yxiccRbngkivw/L0RqqQziovpGc8qPIoc8LEO6r5bmA/IKNuH6TinM6f0JAjlDR/oFV4Tg5dBVv/flkfseXAPj6nggWHQCN+pA2VzzpcZO5ZxXxAlikFcMrtK4fGiBSQvqvYYZj2IWz0ZEhRFFvYXxwnaTwrqaM/up/tWkd5jWu0VlBU0L2PaVm6RSF01fZ1L48XZIv6dZmpKAoD25BviMWmJliqMdjManq9fP/g1xU6WbtD+1VogAL7iGhnOEJ/39NbS6a5KfGxaS01aZRPXG8EBUlAqBfb77WmMZh2aQt3RjPGyW9VXr4v91XZR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alHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: NH7ms6XOrFsxyKi43/cRt9he6V7woioy/JmlcqSxJWRqxyISGEILs7nHLia7wzGkkG8IIaoNesBRTLkPjMM9j5/0/O9PawaIhy3hvG+ivqA0pL1PhzuKpWkLAT5CkFGHrKbIsRYPUEkdCBRvXZDT624RlyuwLiZkSC4q/8/uX+jsWZiqQYVowv+yapQoDTEMZnCg9abaRd281JUsJxvlTD+gVQeK3uDQ6cuBZYwZ4fYbb06Um3uDXT0QULrFqBWGw01HkBojfA9brWay2joSW7iAdOk+DqCWKv7kNsz7Y1J6COrn/bVxrxrPsQ4ohBhcENQ9eKZfGrAY2OOd7DzwjDc6bYNBiVI2x1IPmR3hmGFiJPBF8uhUnCeiWZqBKhAiyoe6ZkoYFf5C2nXhVSGAEze78iBU+ugxtlpg4oLfSlI0rN9LwIaX7LNbjlgPRCQvse26Kg7+/Jh29cTkMkSiR3K77dwR4JKu40c94hqWbhZ+Ailgw9RA4113NDpQXFWLRPQyiaStoXKdt4H3favoW+qljwtwNbeTk4XoGu84e4plwxWDIsz3Wnq6/deEhZ4dN5pY4Ru8xGom9IHExLQEcsvUwueHPGcZEj1eTBYqSH3UsPX0ZmFtiPe15P/BQ9z9gpHt8Wt/dix41Dh8ICEszqiz2K8HF7gk87FbhuZoE6yA7b/jJVeidUVo7sTykDKPQ/iBpC5nEu1tTbNvqNWU4MCNvwjOWu4fFm9XQvF3DDQS3kUA0nNeauEXFnEPTp9ZpNxiM4TIbp0IQjqufQLw1g== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: b7bcd6c5-e395-408c-ff77-08dafdab7088 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jan 2023 01:36:39.7013 (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: tkYcwXs8JDgj5/An8Hinmj8r6LOmYsA9Xop2P2jDOiSfkGrC08amfa2/QMqTr8JBWCVE63A9jY+8OTkKe4/GKiqmgZQxbBUNyvWw2JOTz3A= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLAPR10MB5041 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-23_12,2023-01-23_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 spamscore=0 phishscore=0 suspectscore=0 malwarescore=0 adultscore=0 mlxlogscore=986 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301240010 X-Proofpoint-GUID: BA2siAKOzW9QS11aQHXUUuNHWdhqEfYA X-Proofpoint-ORIG-GUID: BA2siAKOzW9QS11aQHXUUuNHWdhqEfYA Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Allison Henderson Return the directory offset information when replacing an entry to the directory. This offset will be used as the parent pointer offset in xfs_rename. Signed-off-by: Mark Tinguely Signed-off-by: Dave Chinner Signed-off-by: Allison Henderson Reviewed-by: Darrick J. Wong --- fs/xfs/libxfs/xfs_dir2.c | 8 ++++++-- fs/xfs/libxfs/xfs_dir2.h | 2 +- fs/xfs/libxfs/xfs_dir2_block.c | 4 ++-- fs/xfs/libxfs/xfs_dir2_leaf.c | 1 + fs/xfs/libxfs/xfs_dir2_node.c | 1 + fs/xfs/libxfs/xfs_dir2_sf.c | 2 ++ fs/xfs/xfs_inode.c | 16 ++++++++-------- 7 files changed, 21 insertions(+), 13 deletions(-) diff --git a/fs/xfs/libxfs/xfs_dir2.c b/fs/xfs/libxfs/xfs_dir2.c index 891c1f701f53..c1a9394d7478 100644 --- a/fs/xfs/libxfs/xfs_dir2.c +++ b/fs/xfs/libxfs/xfs_dir2.c @@ -482,7 +482,7 @@ xfs_dir_removename( else rval = xfs_dir2_node_removename(args); out_free: - if (offset) + if (!rval && offset) *offset = args->offset; kmem_free(args); @@ -498,7 +498,8 @@ xfs_dir_replace( struct xfs_inode *dp, const struct xfs_name *name, /* name of entry to replace */ xfs_ino_t inum, /* new inode number */ - xfs_extlen_t total) /* bmap's total block count */ + xfs_extlen_t total, /* bmap's total block count */ + xfs_dir2_dataptr_t *offset) /* OUT: offset in directory */ { struct xfs_da_args *args; int rval; @@ -546,6 +547,9 @@ xfs_dir_replace( else rval = xfs_dir2_node_replace(args); out_free: + if (offset) + *offset = args->offset; + kmem_free(args); return rval; } diff --git a/fs/xfs/libxfs/xfs_dir2.h b/fs/xfs/libxfs/xfs_dir2.h index 0c2d7c0af78f..ff59f009d1fd 100644 --- a/fs/xfs/libxfs/xfs_dir2.h +++ b/fs/xfs/libxfs/xfs_dir2.h @@ -50,7 +50,7 @@ extern int xfs_dir_removename(struct xfs_trans *tp, struct xfs_inode *dp, xfs_dir2_dataptr_t *offset); extern int xfs_dir_replace(struct xfs_trans *tp, struct xfs_inode *dp, const struct xfs_name *name, xfs_ino_t inum, - xfs_extlen_t tot); + xfs_extlen_t tot, xfs_dir2_dataptr_t *offset); extern int xfs_dir_canenter(struct xfs_trans *tp, struct xfs_inode *dp, struct xfs_name *name); diff --git a/fs/xfs/libxfs/xfs_dir2_block.c b/fs/xfs/libxfs/xfs_dir2_block.c index d36f3f1491da..0f3a03e87278 100644 --- a/fs/xfs/libxfs/xfs_dir2_block.c +++ b/fs/xfs/libxfs/xfs_dir2_block.c @@ -885,9 +885,9 @@ xfs_dir2_block_replace( /* * Point to the data entry we need to change. */ + args->offset = be32_to_cpu(blp[ent].address); dep = (xfs_dir2_data_entry_t *)((char *)hdr + - xfs_dir2_dataptr_to_off(args->geo, - be32_to_cpu(blp[ent].address))); + xfs_dir2_dataptr_to_off(args->geo, args->offset)); ASSERT(be64_to_cpu(dep->inumber) != args->inumber); /* * Change the inode number to the new value. diff --git a/fs/xfs/libxfs/xfs_dir2_leaf.c b/fs/xfs/libxfs/xfs_dir2_leaf.c index b4a066259d97..fe75ffadace9 100644 --- a/fs/xfs/libxfs/xfs_dir2_leaf.c +++ b/fs/xfs/libxfs/xfs_dir2_leaf.c @@ -1523,6 +1523,7 @@ xfs_dir2_leaf_replace( /* * Point to the data entry. */ + args->offset = be32_to_cpu(lep->address); dep = (xfs_dir2_data_entry_t *) ((char *)dbp->b_addr + xfs_dir2_dataptr_to_off(args->geo, be32_to_cpu(lep->address))); diff --git a/fs/xfs/libxfs/xfs_dir2_node.c b/fs/xfs/libxfs/xfs_dir2_node.c index 39cbdeafa0f6..53cd0d5d94f7 100644 --- a/fs/xfs/libxfs/xfs_dir2_node.c +++ b/fs/xfs/libxfs/xfs_dir2_node.c @@ -2242,6 +2242,7 @@ xfs_dir2_node_replace( hdr = state->extrablk.bp->b_addr; ASSERT(hdr->magic == cpu_to_be32(XFS_DIR2_DATA_MAGIC) || hdr->magic == cpu_to_be32(XFS_DIR3_DATA_MAGIC)); + args->offset = be32_to_cpu(leafhdr.ents[blk->index].address); dep = (xfs_dir2_data_entry_t *) ((char *)hdr + xfs_dir2_dataptr_to_off(args->geo, diff --git a/fs/xfs/libxfs/xfs_dir2_sf.c b/fs/xfs/libxfs/xfs_dir2_sf.c index b49578a547b3..032c65804610 100644 --- a/fs/xfs/libxfs/xfs_dir2_sf.c +++ b/fs/xfs/libxfs/xfs_dir2_sf.c @@ -1107,6 +1107,8 @@ xfs_dir2_sf_replace( xfs_dir2_sf_put_ino(mp, sfp, sfep, args->inumber); xfs_dir2_sf_put_ftype(mp, sfep, args->filetype); + args->offset = xfs_dir2_byte_to_dataptr( + xfs_dir2_sf_get_offset(sfep)); break; } } diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index e5ed8bdef9fe..a896ee4c9680 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -2489,7 +2489,7 @@ xfs_remove( */ if (dp->i_ino != tp->t_mountp->m_sb.sb_rootino) { error = xfs_dir_replace(tp, ip, &xfs_name_dotdot, - tp->t_mountp->m_sb.sb_rootino, 0); + tp->t_mountp->m_sb.sb_rootino, 0, NULL); if (error) goto out_trans_cancel; } @@ -2644,12 +2644,12 @@ xfs_cross_rename( int dp2_flags = 0; /* Swap inode number for dirent in first parent */ - error = xfs_dir_replace(tp, dp1, name1, ip2->i_ino, spaceres); + error = xfs_dir_replace(tp, dp1, name1, ip2->i_ino, spaceres, NULL); if (error) goto out_trans_abort; /* Swap inode number for dirent in second parent */ - error = xfs_dir_replace(tp, dp2, name2, ip1->i_ino, spaceres); + error = xfs_dir_replace(tp, dp2, name2, ip1->i_ino, spaceres, NULL); if (error) goto out_trans_abort; @@ -2663,7 +2663,7 @@ xfs_cross_rename( if (S_ISDIR(VFS_I(ip2)->i_mode)) { error = xfs_dir_replace(tp, ip2, &xfs_name_dotdot, - dp1->i_ino, spaceres); + dp1->i_ino, spaceres, NULL); if (error) goto out_trans_abort; @@ -2687,7 +2687,7 @@ xfs_cross_rename( if (S_ISDIR(VFS_I(ip1)->i_mode)) { error = xfs_dir_replace(tp, ip1, &xfs_name_dotdot, - dp2->i_ino, spaceres); + dp2->i_ino, spaceres, NULL); if (error) goto out_trans_abort; @@ -3022,7 +3022,7 @@ xfs_rename( * name at the destination directory, remove it first. */ error = xfs_dir_replace(tp, target_dp, target_name, - src_ip->i_ino, spaceres); + src_ip->i_ino, spaceres, NULL); if (error) goto out_trans_cancel; @@ -3056,7 +3056,7 @@ xfs_rename( * directory. */ error = xfs_dir_replace(tp, src_ip, &xfs_name_dotdot, - target_dp->i_ino, spaceres); + target_dp->i_ino, spaceres, NULL); ASSERT(error != -EEXIST); if (error) goto out_trans_cancel; @@ -3095,7 +3095,7 @@ xfs_rename( */ if (wip) error = xfs_dir_replace(tp, src_dp, src_name, wip->i_ino, - spaceres); + spaceres, NULL); else error = xfs_dir_removename(tp, src_dp, src_name, src_ip->i_ino, spaceres, NULL); From patchwork Tue Jan 24 01:36:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 13113266 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 87880C54E94 for ; Tue, 24 Jan 2023 01:36:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232299AbjAXBgq (ORCPT ); Mon, 23 Jan 2023 20:36:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56664 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231610AbjAXBgp (ORCPT ); Mon, 23 Jan 2023 20:36:45 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 251E31ABCC for ; Mon, 23 Jan 2023 17:36:45 -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 30O04fTx022007 for ; Tue, 24 Jan 2023 01:36:45 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2022-7-12; bh=hVjRnCfspL4P7YZo4v7somjYUjK7m/v7/aZdoU4F3ps=; b=vO3eBIywM1oIe03wMMaUwejUpyKBO4TaniArZTGOtN3cobfmZfbFfnjea1CwB1DG8vXa WQPFH8Mw6V4On5Pn9SAgtZhGcPrxf1GTxnJBMkbvY5qjoa3Iamd423lt03yWz0Qc4wnD JZn/3qNC0l8w1rHAoFHadQavcx6qqfZxtuCfIdvnIX6+5axVyRjB4tdy89oyeEb2tyUY Il6sb72xjYFfzu9b1LWWNcMe4140fKRbGfSM94j4BGOFQJqKqa/fvFexILKzByQPS7xk ReBMkxndcfddFPjBPQ8gjiVvBzdC2CnA4R/ciRbCqR58ewiQRNRm84adDOW5U3VtdVfj Cw== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3n88ktv8cv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 24 Jan 2023 01:36:44 +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 30O1XqUf040224 for ; Tue, 24 Jan 2023 01:36:43 GMT Received: from nam02-sn1-obe.outbound.protection.outlook.com (mail-sn1nam02lp2042.outbound.protection.outlook.com [104.47.57.42]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3n86g4a82q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 24 Jan 2023 01:36:43 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bgF6FShOWeaoiFVnj12gClODQWffl9ErU0yBcWLDLOlF+5vmW1+9QDUMwsEOskBGK1gFp+622CZJD9wlEDry2R8yq/oyIsXxsbym/WHKSSKPcEOTyGAXcW+CtPWDdqQFmp6EynWJmBe95X+Rl4ChR7Dw4+lv+uHsUvj46IQDG1T4JQvwooQygzKhGzlkO0nj9QLhBHbBjrkK7sUx8OdEue+7HfhzbcUT2t3o3c2Vmdlgz9A5L/d2gEnVw4yZ5fj15M78isUHosuXzMcd8RAdP58jm1PZ5O6G00Fu6MxfSJsumXX4hlDNfsg7i5h6ZtYtkOEGjcX8VAUI8mTKvlRh9w== 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=MYqVOk4OQyURlX54Y2nOyO//0SRt4vlqjFtJeoV6HrILUjUrjiFW/Ez3p9w/yBJy2qJJVdehxOdfiWCsKED4QUhcXW7xbopzS5xjU7K7vDjeXrW5VfF1TVcgsXDyzNx+3sQ/bw/YN8i+ofl2fZg2fCeo0nTTGKa/0n0+ATUzUlcj5x1GdaMHsD0xc50JlN0AXftL60T3gT2XdEjWIL+CseOumko+k6+/EMTKuMDTESRB6UIRgc2F+k9ImPMPSQB1+Lc8kIPgwx3COZg2x0QWPuiXpGPq1x0JesbXQHg6qHeqRaDFbd3+lcqA4zaBORtx86WLTp/4daltduxDKyjsEQ== 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=aHECNxwOX4tF7s1T3wo9YpB/E0rOCI4chROFifaFtVAtitti9lGcq6r4cBEREHJD+WocFwpFvWVnZykfD/w8LJ6B+FILJuKOHzjmR5HyaLCi4Ojq0tSsxjzrOitzPi+Vj7Hrff4rtuBcJ6NVeN/gdVZ2rQSD7hlNCosDRUghlbM= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by SN7PR10MB7074.namprd10.prod.outlook.com (2603:10b6:806:34c::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.8; Tue, 24 Jan 2023 01:36:42 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::eaff:9f55:4641:db38]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::eaff:9f55:4641:db38%4]) with mapi id 15.20.6043.016; Tue, 24 Jan 2023 01:36:41 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v8 11/27] xfs: add parent pointer support to attribute code Date: Mon, 23 Jan 2023 18:36:04 -0700 Message-Id: <20230124013620.1089319-12-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230124013620.1089319-1-allison.henderson@oracle.com> References: <20230124013620.1089319-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_|SN7PR10MB7074:EE_ X-MS-Office365-Filtering-Correlation-Id: 011794bf-6f5e-4983-2ee9-08dafdab71a2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Bb7inHkjudLKsadOALf47RXsk28G+LfF2FV/qumX3ZgjNPWveKl50EvSD505rNeoQPixyiTgAy01wxfLgV506AP5JWft6rcdlH2y/mwYXjbyu1xZ56fuVIRG+3Fwr6RJ1WsiSbXaEWXgTFqShCg8KyDQrHcP62IHmrATbtQeziyUm88b+8EbuIfFf1OcqCer8+VnoGq4M3gXZeq9+sP7/o1NTsDiKEjhSuWgQUS4Tg5frXBg4OUI5eBCOuj07E+5a0Gxawiq30zvyGlrCIopRXSm2XQYSEIQfs0jucIgmkL1aZ/nirXUGxFvbIDYVsWSx31X+4rCu+6h6Bp7b7OtbAyv8QNlsj9dEDPgADd74/IdYXIKKKlB4NCzO22Cy54dEWxBegGEsxNQnFsveG2ADqr5BHLc6+b2TszulJ8VO8XKLVD674i/q/InMBGVuJ7VCQmOwjJCOQp7/V6ixfao9TYdPWEutdJ0yCP53LWGtE/f4ezbtVMx0YeEX0lkb8uXS2PMftwqI/zzZrLK9XgeezbDIGkYZGzWPxxsZsPgAZZD2vJOMn/h2BeXMIfZ3FQYqHI58b5w8tsbEX9dwxEF3diPNjf4fWtt5dOjBHUhxZOgYJddfSQB9Uv3tiTbFGBRmhs0UEh+vzgDRQsRcoCMgg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(396003)(376002)(136003)(346002)(366004)(39860400002)(451199015)(66556008)(66476007)(83380400001)(6916009)(8676002)(66946007)(41300700001)(86362001)(36756003)(1076003)(316002)(2616005)(2906002)(38100700002)(5660300002)(8936002)(6512007)(6486002)(26005)(9686003)(186003)(478600001)(6506007)(6666004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Xbnl3ojEhQr8eeEylpeK+aolSTxJIL3J3kaRhx8RcLJrauJDFboBkhlMjVyENkDqo01p1CGvjjbwUWmUmDxhduq6rCDN+/EL7OkZFViJMEKCbTUU+dV865EOB+zTU5h6P2Z0KLQtn4PcBhIEoZDRZpqSu3vLREdLAsoMmwpfubGtMW+XjRXOuydIJNCbf6JZVJ01XRuEv0zdsKB+4LYhQvEVkXvZse2oqnpb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OFWGg6bBfsm4fj1ZD0pqeMR+rYMXW8ozYrEcCYYdWAS9aQbEpJbeynyfy2q3xYsaEQtzgz3fSBi2jQkdDIlTA63f+ZPMepo+gJysrsT0rg== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 011794bf-6f5e-4983-2ee9-08dafdab71a2 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jan 2023 01:36:41.5441 (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: GNhFcpR6y2fsnP1+NMuAd6FGekkc0lmv3IvXMK1g10AFMzee239YZAnxFMCzDbEx0d7twG+O4Tb35NNJKBHVkJ088IyXW6GjdxYjrwif7Pk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR10MB7074 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-23_12,2023-01-23_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 bulkscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 spamscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301240010 X-Proofpoint-GUID: 3I0i_4Q2l3EacaPmO1HX9xHlUWE7em19 X-Proofpoint-ORIG-GUID: 3I0i_4Q2l3EacaPmO1HX9xHlUWE7em19 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 Tue Jan 24 01:36:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 13113267 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 98B5AC05027 for ; Tue, 24 Jan 2023 01:36:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231635AbjAXBgr (ORCPT ); Mon, 23 Jan 2023 20:36:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56680 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231838AbjAXBgq (ORCPT ); Mon, 23 Jan 2023 20:36:46 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4F4811ABD9 for ; Mon, 23 Jan 2023 17:36:45 -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 30O04VW5021126 for ; Tue, 24 Jan 2023 01:36:45 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2022-7-12; bh=u8ANFXJemEPEl5G2uQUXpknnREMAMf1WLaiUz9lWhI8=; b=qrjaC6on7P1f1IIFAufUalKhEDkqTKv80LdtMA/ewIGCdAr1zjuoMkeRIRybJQwTp74h uKXWDnb1FKJOGRt4RmujCyt2KWx4X+vmg+y69MgtWADLiQf9ltFQxIrjfhT9ADhDXZMk 3e9tZpVK8ep/UTI4NFohCvA+bZWYsJbe5VbezHfTBOrj63yt7NS+ITfQTwxnj12g7Ahp DBG5902Qg+IpThRuHOOYyGBild1J007845DaACljk6EB4GjjFWWm7Ri5NgsEZv9iowCz ZYWVZWA3j3C1hYaF59Sv1Zzq5gnWtMTdf0/zQxaQOv7LT5m80GxQhmtXuUvlVBpQQ7Gu 8A== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3n87xa4a1e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 24 Jan 2023 01:36:44 +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 30O1XqUg040224 for ; Tue, 24 Jan 2023 01:36:44 GMT Received: from nam02-sn1-obe.outbound.protection.outlook.com (mail-sn1nam02lp2042.outbound.protection.outlook.com [104.47.57.42]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3n86g4a82q-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 24 Jan 2023 01:36:44 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZmrI2kMrZ5DMlBFhZ1X8S52H+MFgZb6Fd+MRqpNzTk46NSS+6wgJrJbkIFCGXajY6FF32i0Z7Oh3KidcfCM9Ul7Sqa71XFAlP77uYnJTnt0QkARSacNdqRFPjpa5ubusLMKzy159kuZ7tdYEIYE+hOPnYjZSMzA1XtQMsuIawJEmY+Dpyz95cxGRjPKf+m1PiMpT3u/Hicw+ubJ3/irVN2zGKSZ6kE+w3qIZT7uyYBWQjhGXt0ikQXJKdKogW84vBJor4jUR4/JgIZtoQQP3ah2c7A3uyYy3qrmurUVnmC8GPVl+N/aVyCA4BwZkNjEe2xX8FMJnXhxGFzgAdjw4uQ== 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=JcSBPz5U08Q2oKhLaqTl4S0NZg8Ya1HspHhuStjol1F3usmSm3h6fvezvVr3berfj2vQjYMLwWLA51RUK1TIHmlO1JEkVhdnwhpugNwCph54nmdFHd2ia6WFevcfW3g9z4cw80sYRa2VVo6903C/zaCKCrQTU+PrroCghpSdvsBaoOBTcQZ2gRhCmVprlcdDk8YXrejUoDZCFpiWbfCddCN2VIG/44SBKepBYrSw4mpnesWpYmfGViciaoRWXFMm4uwV1jcVeZBJ0TlJZ0ImFILyJw+Igl7Te9ZQl6+cP/VFGRPNf90qn0X5Awo5khg3Y7fmt0ugwnqz7ZN8zcD6fw== 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=BWkF25LDnv48zCsnYJpOOfnSMG19DkefbbQgH+0kvFI4SvbGH8GvxIic+4TxrisST7EZfJCHUiwsNCJnRIYopbIuOqWHuP9rH8Ypex3oReFzvboQ1o7z5cUnwIRgOle3k6Q1/mF3r1UgfSLHNPw5yDpYRuHokeTTYHpEg/+SJe8= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by SN7PR10MB7074.namprd10.prod.outlook.com (2603:10b6:806:34c::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.8; Tue, 24 Jan 2023 01:36:43 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::eaff:9f55:4641:db38]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::eaff:9f55:4641:db38%4]) with mapi id 15.20.6043.016; Tue, 24 Jan 2023 01:36:43 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v8 12/27] xfs: define parent pointer xattr format Date: Mon, 23 Jan 2023 18:36:05 -0700 Message-Id: <20230124013620.1089319-13-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230124013620.1089319-1-allison.henderson@oracle.com> References: <20230124013620.1089319-1-allison.henderson@oracle.com> X-ClientProxiedBy: BYAPR04CA0026.namprd04.prod.outlook.com (2603:10b6:a03:40::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_|SN7PR10MB7074:EE_ X-MS-Office365-Filtering-Correlation-Id: ce6b838b-fb75-4c2f-8f83-08dafdab726f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: WwxD1m2DiJUvYv+hW2bFOUnS6hRCfoucsCm46TB3nvBegmv3kaboIolj9q91BEOjldkWfDOFwUUR3ZXFFVq23k2xNS+NEypPDlRpwghNYDeP+crQrqX0JvGo2UxRfzC6vYSGFLfzASwto2DbAZymVzQSBPg5VDrbYpL8dy38nSqA63aOcjIIzQXtdl13kyz+R/bRj+iRh5sD13lRkgHjOLk8zS+xAMVv9LVB1YqqPjYFrNkleTboZNAkmk2xwnC4MnY1hDHnJ6aNt/JHCGBf9jj1sLUCEbMAVLWOATdT8oTkyynYeCqYtPN11J9T1OMv5S9Ce+ZzVFwdxhv1vklnwW36nF5sfanbexqWeRMbZ2IYmRsS7Mg8ZZuQz/bXl5v20WimYT4X9NNncVSEVaVx9D1wIEyp5GjWsjNqLp4bhT/gOWnrrkfOzlashSLZ12uOS5i2op0hzvkB4rfWARK87GhpkhxUahe/ZyF7XIYMFz0bxP0CHUMuPTcXy//yA/a3xuhLfmEa1pj+hCM9aWb13Pklbz9D6hokeAnjO6TLRJAiS+vgBlVGnFVU0o3zJsnmGi2v0rlhXe04ZY1m3iWGWLRRC8Cd+qBaKO3iYoiTJROW1YSZexw4Feva+KOJCSPhklLG8ZHBo4/PnTuVeCXdOA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(396003)(376002)(136003)(346002)(366004)(39860400002)(451199015)(66556008)(66476007)(83380400001)(6916009)(8676002)(66946007)(41300700001)(86362001)(36756003)(1076003)(316002)(2616005)(2906002)(38100700002)(5660300002)(8936002)(6512007)(6486002)(26005)(9686003)(186003)(478600001)(6506007)(6666004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: vCeF4N9WttlICtsE0WOxplCg6UNX0wsImlFv4VDFqP7IrkA3aCciPmutOB/w6z77epYEZOMWlj+N8tXpK3u+SWp+LOZq4KCYYDAB1cFaRGCdvogfrToLRk/lCPBvPZXWND+woSfN6030xK+LYtgE1Df6czl97iLWAWwvdgWIdYuLSClHf01hL1bYUrX7I98sjaCfOLbXfa12LiRsu1j6oj/NMw84tblczbvbRJmZKzTUyspQyeIGnGMqS/ASOdNCyZrwBwAc1rPVjazWcNbg6Q+6vKHsErkTDuykHdzAsulX3r1NttcKMF5CpOG23giNhj2iFxNEtwjoL+nwS5wM9TvCOdt34RddcGIJcsRR47ztyeDoZ7a3WHB6zr94VyPdEmEEA1XDWcf2eKQIXYVxJUU87t/ZMtAHp5vF79JRvi1/B8P5te6RI9iDOY329p8GMkjbjnfYqhKxMZ6Lo65g81DqgpmScFlH1x3Lan5pmTegkDGhdPNFncMrFbCLw4uxF2KE55wzPoB6gQXsg8uAxxTa8dpVx2KwWIM1yM6k7RKP9ZGquFMjWq9SB5EaAQS91qVUnJLWzbuUxtxrfIjKDAhmLxfOSdPOGLdGijy6siHUynIzULpiOzZMZcfbtrfiW+3l71dwg0UFrQVBuyT34/63+HeVEptSBxewBbxyRFBqQzuu2dW4eQ5omB/gqL01UdGN14oe0IHIP54609/EWBmVj3obGNEVZeIokDh6W8uYz11Dy94UD3Dx5bvtQeRIHr7bLJ6K8rdwxW4fqzO0oZAV8ceEf5fcCwDee5675vaf8ADa2xUxbpAmogTuwlXtIhnMiXVDVJ27caAN+hI1B65yie5Xb6CAe+N6Sz/GOET7YHPsoAz/MBUMpVX2C7oQPwBHvIvM7N9HGIOJBa4WhfenwrQX7JFRuC5xGzzfircgSY6w0wmqtKJ+5vgmcB8/MVj+bfUAZnxN1MZH8oyJFFkz8vOZG39XLTiVpuWU7gBt6dKsyaQN1MU4ww73nEwyp8eys5cpWCjTrwT0YU+VZuO/mH1HmJJjQP62Cx27dptfla7H8iSSVThjjxyeWono8wcCZYaJ5X1tavVMvMcKQ1SNw7VI/f75DdiHU7NpOLVglI+RVuf6+w1ezek38y3zEjtBPDY5g8v924C6pQNYr74SXl5ytVqgysDk+hAos/+jyYa1LBFHrh4dGPta4fFWaLlOOS3/0Wu7Bl4Pcp15XSDqXFY4qhYg165FDnEG4Zc2Y+cey5WYuw5Yf1L9noGWRtSpc+HYD9nyUYCpP48reIieJDfgHW5uBE6dDsGipK82mnE9/40n4ZtbLW8qceqI3BRxywFQ8akKW5yaAwrldQ1m9+acLPXNzYO0W4qrrfKEMq3MkJgRR0hn8rBa4uouKEBTE6P7g6JW6JpLiAZHeyPJeRIDYiKtEgUz+UDZw4MQlqTHmYs6jn7An0f224SUjYxtSxrzSoBk17jX/LZdRxibNuows3MYeIgY8gKJEgW9rWnBmc/9RCov3U/5vmh9OnIz3jbMilOFjW6pk2UcolrMzDyMYe4RkPIbOUnmtQ5iSua7OBPYSsSv0egqFvn4JOvppkdQAvmWjZfyyONhLw== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: +DIQRLYlxXdv9KFgNZbhK04UKWlQyxQLlTVkNLfH6k1TB4B6V0URWCwci8ClnY1A6FRDEKp1gypIasc3qD6caD7i7NfOJqlhkPmasp6q22sGiTl0bcm/F0yssCd72YkwKDabQuj8N57XyKN/HLsx2+F8yqnMqL8h24B0/wP1unshW+4qIT3CZCEa1xCLQ4dBnOvdxb1tlSwF+ccrU2usD8Rf2yVJLfbbEKQWoJeD/Z9ZQBg04g9PKyWQNXODL640yq16ptFthEWb4s/jGXf9LX9doZE+egPi4PZT1TJnnbT18CFHQYZu3jMIVf9ZhBtMfKFvXdwOHc3KoGIV6JI+LZudwaMGoNkOupKxVyBC7WBE82zlvhTSpInNGMRWiNwwK0sXkkjqupxqM9K2JW2zYZ1Xl8SzxflcBmS2XnRYRYGBD/Tm4/R4s+qsDlrNgYjy/lKAaIY7MIMT0IYyW1J5l1ZAcY0zVKdtoRfLOc+0bR9EBp2efAvCBUL4cC14hTht/BBiUhasNUf3dZG/IuiRxqST4qc+jZYqqaXk0mK2nSCoz/hAkQJkB3195lJvb4Na5wzpRjlu7+Bz0CvNonf8UQlhMMjh2ux1QRjdn1Oc7so2ijtT+TjKkPD6IVz91rQfRZ6BLk9WAmX6tmI7DysNbIQLi2tCp1Hn0FHjHMyuwQ9/1lqAORIq0hzibdvhYc0jVRSUKKvh1ZqtEV1AUrUkjPCaa7bAR0p6CD9k22EDChhYfBtOF0/MDSQ21g4IqBrC8uARad/0T6RdJ1nDXs1ojA== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: ce6b838b-fb75-4c2f-8f83-08dafdab726f X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jan 2023 01:36:42.8901 (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: efXQMPTZxnDWRY2Zjb41cY5T8fyNudx0Mp7+NyHbnKvrSQsPkRlBLKb8dQMbWyo1fxkqnYBCPmAp7GHRmj8DupVrR4gWrPq/tKi4BAIouns= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR10MB7074 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-23_12,2023-01-23_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 bulkscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 spamscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301240010 X-Proofpoint-GUID: QrqvlUsJluCO2zPXvGutVoKxW3cVmdAO X-Proofpoint-ORIG-GUID: QrqvlUsJluCO2zPXvGutVoKxW3cVmdAO 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 Tue Jan 24 01:36:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 13113268 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 52D93C05027 for ; Tue, 24 Jan 2023 01:36:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231666AbjAXBgt (ORCPT ); Mon, 23 Jan 2023 20:36:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56706 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231610AbjAXBgs (ORCPT ); Mon, 23 Jan 2023 20:36:48 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AED801ABFA for ; Mon, 23 Jan 2023 17:36:47 -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 30O04YLw013521 for ; Tue, 24 Jan 2023 01:36:47 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=IDyIZRhNp5heyfjutD+90eq8Pj+7j0AYbaGnz7pfGNzWT/KCdBjAyTXCoQr+n4PmanaS WVcRLunis6Bqwtp28f5Mco5Ifu8QDMlW7YI6acDH1T4Yoo+MjOpInRW1OmSixvxASHoz h6G2jUF6YrU/UX3Uiio5y20dOGrfN3LVIQNhtKaSkpE966bNwRSahX9sFxXWSoXLjmAU I1UWmzJQPaPDWEZMKDh80lmLoxuh1oALVyLtIoT2CbXkNVcPPnFcE0XqWPyxUZXFNGzJ 3IhlQ2MhOMqeRFG3MA5GH1avgfuSoKYp5x4q9I4tXtLz6PXeQxTKPd1h4mmpRicaGbNu zg== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3n86fccbxv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 24 Jan 2023 01:36:46 +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 30O1V73s040249 for ; Tue, 24 Jan 2023 01:36:46 GMT Received: from nam02-sn1-obe.outbound.protection.outlook.com (mail-sn1nam02lp2043.outbound.protection.outlook.com [104.47.57.43]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3n86gb4b1u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 24 Jan 2023 01:36:46 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PcCSpo3sFt4gEpvbfUWi3ICGZ85c2XEaH4LSdHP+gLayYKf8sUp26br7lHXUqINtBs5aIdWXUcqZSEEUEwWMiil6BosjYvHjyOrtLp3n2yYldfDpHl8wj6wiDy6sX8S5P8aNQQZo2AbVnNg7hfECD1XzSp8MFw2vz8LJrGLRavkLQMQnl9jFKiPyE8cGS0Wz9FvSPI0E7Saeszryf4gbzRbr9VaM+Z5Uc5Efrfps9jL8hYrg0/9ngHG/jUBUZakRBa5jnNtxlMlUoUG0c0F6Eno0U5dHzqMIDaUSeUSsqA6J4AKvJgzAz7Tq3Pg2NgaZVlV/wl5x0zCJTlotS6J7dg== 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=MF3F8+7hvZpzXVE2ekwq1nrtcG3MDeuxKx8wNGoboBHHeELaZsavHs+kLOUJlAEJPKaTpDUIS97Y0uD1SweUnGlWFgvUyF/C396wcBo/tLPGP/xjXTLlwd4yjwDE0ZdE/JPjeIThMRv2QVgsRYF37R0eoe5U8BligwP/36bRHBwL1Dae02aUmvFzy9g3heKRIW/jKMOHW+aQbapppHq3Rt/Nc96ABlCWwQbWNlO536TJJpf6wTQOKMdU2IYFhNJGpRdQEosBXjQlMkzMF0wPFUA5UAFTTClKPowrraZB30Qr35PdiwFKP3yZ0Ikr2wmrg+JHTIE7AmcXDXowTMmN+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=6GP8mJBw+M/AN5gzsRzuXZkkeJob7qVdrYUi7TC2yiA=; b=nWMoomKVkrHDOR6zL1/4n5AUouK0xypCIs/a8hQ7XjDZt8nkcl+2OBoxQnoxOnWhYUNqQpP/Xr9A2fTW039HMLOrkQxY3EI8RLK87h+nLYZXxqkza6mdeCG4l7YvArdhPdnmZL8nUR1Q+xobtd1b41vEPfLHU5SkCpueFar54Z8= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by SN7PR10MB7074.namprd10.prod.outlook.com (2603:10b6:806:34c::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.8; Tue, 24 Jan 2023 01:36:44 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::eaff:9f55:4641:db38]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::eaff:9f55:4641:db38%4]) with mapi id 15.20.6043.016; Tue, 24 Jan 2023 01:36:44 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v8 13/27] xfs: Add xfs_verify_pptr Date: Mon, 23 Jan 2023 18:36:06 -0700 Message-Id: <20230124013620.1089319-14-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230124013620.1089319-1-allison.henderson@oracle.com> References: <20230124013620.1089319-1-allison.henderson@oracle.com> X-ClientProxiedBy: SJ0P220CA0001.NAMP220.PROD.OUTLOOK.COM (2603:10b6:a03:41b::7) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY5PR10MB4306:EE_|SN7PR10MB7074:EE_ X-MS-Office365-Filtering-Correlation-Id: 3207fb2a-f2a4-4691-cc06-08dafdab7337 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: L3QnD43CHreYp2++GT4zUJtm2bP0vHPKnI8IUeF0oEqAdbtnsG2b6MxGwFvBI4MeIamIdQmHzwg5gwKvHXQsrU8Y8n9yGFEcW0CfIzsePgGY6aLGAi90Xyhy0MQmAYsQ1K3CD8PySbSw4lDIn3vwWENa5VlhmuAoTWPdvrsdTU8K9fqKHuMXM7BrsxxjUWOiB2E73hvGZzqQGazugEi2XQbEhx85fVQIx3HMwbLinoLcLc65ZS1r68YV7w5HA2s1EObbz77SB3qZGJ3DW/zcdX/rsoUxhCDEHK87BwVnkng19ysQKFWNQwPQ9/Cf63+s+G59l7r+K27Q/6PT5f2sbIbD/wrgW9b3iIyELapS3psTLn4lyP7vDxoH9c1Oc1eI265/LA4RUvpc2rZq34Q5Fg7E7Z11lUPlQPqgybpeCgYY7dKpWY9bgeN0PdNxydhLw/1ZY75LWOHhZ9ioz6yVECANX9+xvJaVQNgIze1LwE5/n36PjVJM1zE2tkcwQiFUK9f5eNOcqbTNc5SNJ4tZky8aBf9WBVwvxW9cEg2ChWkhNanijVaTHPkAODkzE8hyX5CZkX890ZpbFMGbZSL+zMKfib+KbfJAy5IL9hw1XH7R2fx945si2P7uY0ELFvCbx33yHaFb62ZnsFGMDsSNig== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(396003)(376002)(136003)(346002)(366004)(39860400002)(451199015)(66556008)(66476007)(83380400001)(6916009)(8676002)(66946007)(41300700001)(86362001)(36756003)(1076003)(316002)(2616005)(2906002)(38100700002)(5660300002)(8936002)(6512007)(6486002)(26005)(9686003)(186003)(478600001)(6506007)(6666004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Ugl8Fxp27ndw4Ijptm/0t5QOfoj3euY8ACVOVU/DbyOkjDcmwABRuuBunFNQxLo3jqwH7p3Sx/X8rT8G3d+zbjORkWdkkE9rdozDP96Aq132A8MkBBkeNNd38YoJafgXdpglBAMEGz+9oSwmDDXU9f+XzIu5lf3YoHQw500YXuce+xlZFHQtcRYn2cnC7gWUDg5x3coxA953JRpta/XAFIzQCJgDcp55W4Kb0K3LN+vKEccUuWCknXyAGotcYDvgPjb2b2wFz4Fkkmon9sZE3UJV7BB3bJnnaxUMYlB76T2RuBaBfQzQbVQv8D5m0j9qkUJtZzr7RqU9cLw21lQcGRGYhfjryiiuzbb0D1pw+D40rfXFcVNrznuFkCElCYrNUBYTOplUeVDsT51LZHXHtU9TgBEwQ0tRCIYbRlyHMyfJj1oY8XVrRzGZxXujSq5ZPUM7SfL11g599b59oCe82LLMPzIX3XmlwCwVQYsrP8SGuZNa0WWfj1ShZvkZND8k2DiUpnGPZhMnq7BnxdD1zA2+2h0NrEXoysFgn/4eX0HSqUsjJd8r+ICmo0jumD48810vmRlm2ooy0QOosT8NL95SJXdlA4Rv9TnD/+y5GRqDELfZUXF+0jLAg5mnZk3lIuy5YWpTnK6+BvnpjUmGUJ+IsbkPRe7SzPy4Zg/Ugff3IQL2KVB2UnPdSFvjb8WTFcIWwyY2+dgt3V99wXDIIUOd9DiT01hIreEDChSQSd8p0zv/RmRQHgP5MgqhvRF6IfLRiP3FPh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nzapao7idbFOfaYv1dwx6M+K11guk1auNwfnbbiB7W6irj863mxdhe7TcLg9ajdUmGowJqhzkqs4tuAAsl8nEBpQ6O7RZw9jph8UNvr3wXzFd6D13Y0c+rN26lqI3t73IwFrOQXmIh95nttiJscfAGC0dZUTIGg32WVuau9KjJWqKZZCNaTlmFhj1UgJTX8w18gegBZJjZ6pHbvkIxYqwbWHAgtLn2Dr9FOGDf35Aoz5wmHD3YkuT10DhFqzyECClCsZNgihJSwnCS3WJ2e5a9zm2I2hPkCtPmE5mR1sJ7moFvHcxImj3k6dB+a0CSJdSZJH57geHkNNX6thQp/OzUf72rprA19/bTqRM7+b3z/5T++iBhRPLJKYNfLpGTjM97QmrCTFmny3IHrimCVF8R+CvyJOLEDsuN2eb0BSVEwJ/nhRwnEw3SqLqU8vOtvCSuYC81Alf2mpjrTPzxUvgcJD8Hk2mCrN/5lteY32WQU1t/PZUullj7E6JHTstLUbNpK0bO8d70xMXu3/uCC1bFa8rDJkNpSYbSi1OqLvzsVyyVXwg5FjH7ld6PEWLT8FjHhhchoYPkEFM7fm9zDnp6Xu8FrZ/4/6J+mLWkgxXgjHN3Ol1kmm2YcrtJp/1w3HXp/60w== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3207fb2a-f2a4-4691-cc06-08dafdab7337 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jan 2023 01:36:44.2975 (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: M+VSWq5QOdS81xaBki1mzY6dtIp9IeBdNK6RE63p4CH53ysIiT7tmcHglOthALPU6IKLlsvvvAIxTB6epNgk7RMH+C1i5uMVhdsGjfW4I14= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR10MB7074 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-23_12,2023-01-23_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 mlxscore=0 spamscore=0 bulkscore=0 mlxlogscore=999 malwarescore=0 adultscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301240010 X-Proofpoint-GUID: TfMeJR1jiam_deo1aSlSY-pq5m8rF5x4 X-Proofpoint-ORIG-GUID: TfMeJR1jiam_deo1aSlSY-pq5m8rF5x4 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 Tue Jan 24 01:36:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 13113269 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 8BD01C25B50 for ; Tue, 24 Jan 2023 01:36:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232388AbjAXBg4 (ORCPT ); Mon, 23 Jan 2023 20:36:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56728 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232437AbjAXBgz (ORCPT ); Mon, 23 Jan 2023 20:36:55 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C9FCD1A4AE for ; Mon, 23 Jan 2023 17:36:49 -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 30O05mb4022530 for ; Tue, 24 Jan 2023 01:36:49 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=kR1s780UEbHZuyGsEUEQgPxTXBvvk5HGS/bhflxe5J8uukfMBYr7D9YMbkFAtc27QKlD yZyat1x+zkA4/xCRbqgiul/ZR1k5o4gdgYmxjYu6tDjVdOerm5PgTPXmdGrcAq/blK58 x1C4msJpKp7yGKvMV9WEF5gxKB9EPnDDuYGPF+7AnANT4CI3wLrJ+pW6MxiqX1xOpnDT +3Ldx3SFRghkqZ4rNhSToY2kTW3h87ExxUN4U9hayJBZ0oTqdDV5MkGXasd+XezC/9Qo wnc2LKXbyVsD1MEBetdOtHTMPJIh8E7T1L74sb4298SFwkaBE6Y1hKC0n3HHN386FSej 9g== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3n87nt4a3b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 24 Jan 2023 01:36:48 +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 30NNUu5q023145 for ; Tue, 24 Jan 2023 01:36:47 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2042.outbound.protection.outlook.com [104.47.66.42]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3n86g4am2g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 24 Jan 2023 01:36:47 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gmGceSeBZaIRdD29tFgw5cjywlpqoOvyX0iPMAJIa/5r+A1BHLWnpc5fGVwIV13lCTqTlNYIx/a0nz5r84PLeNv1k/0BCQsrlVbF8vMc8XVxDZKp1roh29Oc3XrEadf/BcvtoIl9eFao1OiA2lEhJxR9jRSVZfG1hkEKBGaLB5FXjTZYHUNCgytAgdlLC41Lx4Lm1MffW2lmHJcbQhoxMariesxM2l86Ll0NjLmh+xOqRq+3LeKbjzyxWtSUJlgjB1sTVRzyfQON32qbH+LqabnRDc5wQG+tNOLebyH5MdWMHK8Y0vrKmfglcxJf1R0WXwnyl/hG3I8QOs/Eh7OFEg== 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=ZJVi9aAd6F7+fOOL2eqem6EckW6CDSNfwxLluCsJwoEGdaOQfnIazX53K1vJ+W6GFASE5AKeSE50aJYwbzsM7+387awmwC3fEOezM2AGT8HShP809i5E+9G34e6Ka9VKyPxFvT8pSUxbABYF2x0ryzbD2ZAsejd2hATmD9J/xeNIyGKR0I8KsfyArQH9zJPPXJ2s4dYd2elkVWi3fTjxYKyzNlZd5+cHMjFAt7F9kPSJTy85vd9L4NzsN0L61yMqF573XYoau+q7E5bVfPXEvXruNpy6WVJluxQTZ2eC4sGMs1I4h7CZ5lXmaLsMAoAn34RA8z1kefgKtwFBqZTzEg== 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=kIobkbqKgwSBS5dBuCxuHcBDIdv4SipIxlMftouKRKOS2oqE+pTrCS7ywA4Bfx4PxpfuRnoT+69OBLIeAjPMwMUY10holY9LpDiDLsjdLody2UBQOn1T7cBAcHAczekJF9Sush8Jl12Aatqd+MrHJxv6HienWlfWVMxLtdRodTM= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by SN7PR10MB7074.namprd10.prod.outlook.com (2603:10b6:806:34c::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.8; Tue, 24 Jan 2023 01:36:45 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::eaff:9f55:4641:db38]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::eaff:9f55:4641:db38%4]) with mapi id 15.20.6043.016; Tue, 24 Jan 2023 01:36:45 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v8 14/27] xfs: extend transaction reservations for parent attributes Date: Mon, 23 Jan 2023 18:36:07 -0700 Message-Id: <20230124013620.1089319-15-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230124013620.1089319-1-allison.henderson@oracle.com> References: <20230124013620.1089319-1-allison.henderson@oracle.com> X-ClientProxiedBy: SJ0P220CA0018.NAMP220.PROD.OUTLOOK.COM (2603:10b6:a03:41b::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_|SN7PR10MB7074:EE_ X-MS-Office365-Filtering-Correlation-Id: 7cbcd59a-2d83-43ba-da56-08dafdab741c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: GGRpg48LMEFPXX1h/bV8pK3kUBBcfnULOx1Z8mAaGhz+QMOJd2z8re0xajpPzdBG1Mlp2W+FXiZ4PXGBHQVRfqZqxSvlau6T8/KAGc6cIf2TjhceltPEikqQTAZ6Jm5KPX1Z2b0jGOApeBQh4JS1FZap06WyEgaHqmEJ6UNHnOCQK0nG0O9w9rVlLZ1JsmIkl4ePvEKAxhhAWKCFuoP5R71GbNFCI9kGWkkpOezPq3H6pvJtDyUoxkqf0sP/nSpjhx6ZnxuBsM9WtUNLpmbMtWJ7ARsxsv6xanra5RN8VQYDdh0SPW8gylycmKHqmBbyr+hggQ+CsQY6WLG/0oFbdTqChU3YW5JA762m+ESeJnGOHHKu5imKyp9qc+ccJrbGjO6PJjmxndpglzFNOGa5PD4u29KpITMas9CsPGEDigktM2pepGi3GRZTk4XXC4srxsPffMu6WHCy3OB++53AIeZXahrjzzETOtyz7e3iP4LhyrVpfEa2fxapiEeX24kq+zB7t7zMDZ5qCOUL6cy8uzAtLPJrFjgzd7GQE2546ks6u4OclNH0gNcA/WbqpwOerXw58+YrNilkO8CUFzOjKyM2u5Gu8eppOF93G6jDqLmEjX6WcHElBliCCJtWRUDykiZbwLCOG2E5XeLvYGMVag== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(396003)(376002)(136003)(346002)(366004)(39860400002)(451199015)(66556008)(66476007)(83380400001)(6916009)(8676002)(66946007)(41300700001)(86362001)(36756003)(1076003)(316002)(2616005)(2906002)(30864003)(38100700002)(5660300002)(8936002)(6512007)(6486002)(26005)(9686003)(186003)(478600001)(6506007)(6666004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: zSaolrN7wqWIo3rTJ4DXfEBd1Yx2KRBdNoTuq7QPQIOJfc+nqVgs/vIFoLNAHMox23jGqItv0/HjTeyubUkXL9zDu4QPRMDOdHG0rtwcHDoa6ja0UzZyvXWmihY+afSclJe6vOF+AhJu5bmGzRw80LGt7tpMQ05LYVKxQvZItbkq/DZ8bSMf54g6ElE7XRVQUgEHrmZ3pqEypF2kZewx9RtdgUJM2KiDIJC4LchVqAIfeR0wnaqZtp5CO0beBoxDOflHr6eHnDCNBL+aLb27JrWLV+493wjFfQtgntz96ctwKtT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Pw4kQq11+iEpegNwAXX2aW5Gc+6UXqpg== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7cbcd59a-2d83-43ba-da56-08dafdab741c X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jan 2023 01:36:45.7016 (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: pk4UD6EkwJQyQ3YhhcAnXMm7usBRrETrY5NadVQR1S29sFBaCd7w4RMuva3lARP8AN6CPgi0IR9mcZ0JmLvLKC8HmRjHyWsfdwviYzas1yM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR10MB7074 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-23_12,2023-01-23_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 suspectscore=0 malwarescore=0 phishscore=0 mlxlogscore=999 adultscore=0 mlxscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301240010 X-Proofpoint-ORIG-GUID: vBRTl0gPJOZhj4FnnQHBpac-oCgP746Y X-Proofpoint-GUID: vBRTl0gPJOZhj4FnnQHBpac-oCgP746Y 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 Tue Jan 24 01:36:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 13113273 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 C05E9C54E94 for ; Tue, 24 Jan 2023 01:36:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232397AbjAXBg6 (ORCPT ); Mon, 23 Jan 2023 20:36:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56758 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232479AbjAXBgz (ORCPT ); Mon, 23 Jan 2023 20:36:55 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9DB181258F for ; Mon, 23 Jan 2023 17:36:51 -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 30O04KGc013028 for ; Tue, 24 Jan 2023 01:36: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=ZpypPa8m7ksKuIgB7hynZSe5tkRIFntXd820eDNagkA=; b=LHulM3x45Mjp+4GzdmNm5hj5krI5UeIafu8IgPfYCTyHKPcP8PkFaJM8X4AtTwBnWk4V DZPLR0BahFpTae986s/sitc06F2sp8rGA+7Jqpty9k97h1W/0SJcpDhD2ps4FOZFxBFh qo5Ag7UYB+Bx7UAxRsO0iEo8ZrD5T2YnHPMgx+KdfO0JYw/Ia8Z93xhcRRMXg2s6dAN5 3iOvscKpRoaMYB6Za0ZFgH0AlbB7yxlpeM9wzrympFSgWu4NrcRFQIzEKBLno+TOSVaf tIsC8nOQbrrLB4nGV+S7YXvxgnwVsRpRYRBIHknFmf1uT3EaKYQr0eLDPgZE+ZMQ1fSa Sw== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3n86fccbxy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 24 Jan 2023 01:36:50 +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 30NNYBNM001108 for ; Tue, 24 Jan 2023 01:36:49 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2043.outbound.protection.outlook.com [104.47.66.43]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3n86gakvrn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 24 Jan 2023 01:36:49 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nNyGKNUlOELPc0zpWIL3XNxusypfoI+XEmv+D7syTgdaH4F81NRwP5MNP2m0/ZHDDrCsTO15l+/EWRtTSnCEA/N3/mAIA5R0rW4YLCL8UbjpVkprC9k+2OZo8yqtsu9sDZPKGEDBJu5l7mYewqkjHNWPUkVrQ6C0JuQUV40gvrvDMh58P2TB7WzvR+nxLxqUHwCHxsPAXdiAsu6kq3M8iIkz+ErceT3u8mgG2MLzRxp7aLUL0rO3KsXFVVGCqmeMIlr1KfygDEEM9L9yMw2hjJDunD5O8QFElMfcWNHwe8xbJDYVbBGc/2a92M8B47Ft4wg6fW58leR+BPB38UELCw== 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=ZpypPa8m7ksKuIgB7hynZSe5tkRIFntXd820eDNagkA=; b=hXA2yKLJYZ3sBDgMIDiLauZGjGP2w0irLxHFbylYRQY9LYKQpgeR3M9TH3ZZWHNpHrUZGzEgAHN6Ct4kH4z0hTY2ZR2qDH/zmsPqhhjhcCFBn2IiBIvhjRCMFMQN7Ur37BYN8CWiGIKgp8zl7O6IFBT2IPELeSg86lqrJTVa4PsFMf1J0pe5vWfNDJbXaDSIXqbU+Qw09+dlfqrHyfBwMsADXCRynthWTi6PvN0bddmGLDYIot0y0M5rvBS381srlofbOES31ugVXprHXjosG+o6OsDFDe8ZpmlO46UXHKRVZICJE1lT92GoR/FvEUUI5QBPyoGNoK5gG0y7odgBXg== 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=ZpypPa8m7ksKuIgB7hynZSe5tkRIFntXd820eDNagkA=; b=mW2DbMUwN0ZdLccJm6XmaXunTg0WjhH3DPSJFOpJdq93KbBU0QurL8nFIuHUC5i8i+ol5rVJpwHL3owGO92269EOsATiMR2Cig4FmxzXQK0CD/QZp5SQ8DEjGCmpupVR8uRPgBDL6uaUuUq+KJ3mDC+ke45o7r9TMKDxJdtXZRQ= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by SN7PR10MB7074.namprd10.prod.outlook.com (2603:10b6:806:34c::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.8; Tue, 24 Jan 2023 01:36:47 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::eaff:9f55:4641:db38]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::eaff:9f55:4641:db38%4]) with mapi id 15.20.6043.016; Tue, 24 Jan 2023 01:36:47 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v8 15/27] xfs: parent pointer attribute creation Date: Mon, 23 Jan 2023 18:36:08 -0700 Message-Id: <20230124013620.1089319-16-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230124013620.1089319-1-allison.henderson@oracle.com> References: <20230124013620.1089319-1-allison.henderson@oracle.com> X-ClientProxiedBy: BYAPR11CA0069.namprd11.prod.outlook.com (2603:10b6:a03:80::46) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY5PR10MB4306:EE_|SN7PR10MB7074:EE_ X-MS-Office365-Filtering-Correlation-Id: 0d286061-0388-4109-2024-08dafdab74ec X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5E/pxSCSAP7Dc73/WcUiDHqCNbgMmOERMKgDcb0QlTJoKVT5U8aBo+eGnpcGM/wZY8nZft+p0IsBUwUpoNG3POP4Wg8HsoxDkX8o3NX2KHuwThCR3wc4cn8mpE7fpL7Dx7FTzC3BK6ImJSzJlof1jTMLpaxHnl/FRCGfPWMbMuMNq/VelkmOejhIKYtiq/ErqZtFQ6MMJFrQm+EFVdnd/E44Z+0zrh+5ajvc7L/NUmbxXuhGpFNxVBAAGU0Ql4zkxB1Ak7KIP4omeZa6wa7MgV9q0mjNm3OpCWo/uGbuZIwZh40AOYZ1E81ws/0X2Js16TwAkXhKfAOtWZ/+V93dbsLLx7tiZxx+DZhUKwoH4viCQnmBQgWR60jombZyZb5TYn27aEtXiYn05DqFZp7pQp62LgM+fx7qjKlN8wX94A0I0X5S8oIdLH6yrrX/jUxuaCfRvN4tB5KlB6zaTRvpKFAm7WhHnaJkh9k1+88c0LkJ/eNgcLSDOdfLH0uh+6n+gyzuA1fnsaa4ugiLvzjZSuErxFO9hhdoQXUQxyaIrudboTsa6WPQ086bh7arJMQjfrdFhSg+xO8fNypeFieWI3E2DhJ0NOHKOdP/OpZvrMYfpLIe4I/KWOMRQRRaHo80wqbvRJLbTsb5jYZ+nuy11A== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(396003)(376002)(136003)(346002)(366004)(39860400002)(451199015)(66556008)(66476007)(83380400001)(6916009)(8676002)(66946007)(41300700001)(86362001)(36756003)(1076003)(316002)(2616005)(2906002)(30864003)(38100700002)(5660300002)(8936002)(6512007)(6486002)(26005)(9686003)(186003)(478600001)(6506007)(6666004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 5H7+cRoiavhe0htY7jeebw+msHt1DhlNX0MbIU/drjeUDGevRceMr3d+F+9aKAay7SfuEMuYYW4KgWHcn94vZIN/niDkH5ab86piGdR7VRdccXlkA3OnqeRPe/hSdAV1RGcmV47L0gQCiBGZ7rFVFhDEIqbOVca56eEYNYpFkEtsCsogumky7aHFE5LVmE0nI0Am81LVDq9DeXnGyhByPZx8o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9i6QxOK9WLDZ/obfbQ3K2+zHl7x8I0EUzLXEk9BK9gHx/v8VAfwkByyOmNd8q/NZ5Scjnl8YasChLiDyYaW5zm2p5jwRWDnRAYaFZQ== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0d286061-0388-4109-2024-08dafdab74ec X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jan 2023 01:36:47.0931 (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: lRLIwqDzL34sgzX/5JTKoQO4g73xqn8soF/1J5RanhBTSOzkPzaCzEBXkgm1z9ZPeqTXQ+9PEt2a4gpyJkDH7YmO+NaItHciv7VVkpjz38w= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR10MB7074 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-23_12,2023-01-23_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 phishscore=0 mlxlogscore=999 adultscore=0 mlxscore=0 suspectscore=0 spamscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301240010 X-Proofpoint-GUID: AznpZ0EVemGtJgmx0_BS6aE_1BDjMcZI X-Proofpoint-ORIG-GUID: AznpZ0EVemGtJgmx0_BS6aE_1BDjMcZI Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Allison Henderson Add parent pointer attribute during xfs_create, and subroutines to initialize attributes Signed-off-by: Dave Chinner Signed-off-by: Allison Henderson --- fs/xfs/Makefile | 1 + fs/xfs/libxfs/xfs_attr.c | 4 +- fs/xfs/libxfs/xfs_attr.h | 4 +- fs/xfs/libxfs/xfs_parent.c | 149 +++++++++++++++++++++++++++++++++++++ fs/xfs/libxfs/xfs_parent.h | 34 +++++++++ fs/xfs/xfs_inode.c | 64 ++++++++++++++-- fs/xfs/xfs_xattr.c | 2 +- fs/xfs/xfs_xattr.h | 1 + 8 files changed, 247 insertions(+), 12 deletions(-) diff --git a/fs/xfs/Makefile b/fs/xfs/Makefile index 03135a1c31b6..e2b2cf50ffcf 100644 --- a/fs/xfs/Makefile +++ b/fs/xfs/Makefile @@ -40,6 +40,7 @@ xfs-y += $(addprefix libxfs/, \ xfs_inode_fork.o \ xfs_inode_buf.o \ xfs_log_rlimit.o \ + xfs_parent.o \ xfs_ag_resv.o \ xfs_rmap.o \ xfs_rmap_btree.o \ diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c index 711022742e34..f68d41f0f998 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -886,7 +886,7 @@ xfs_attr_lookup( return error; } -static int +int xfs_attr_intent_init( struct xfs_da_args *args, unsigned int op_flags, /* op flag (set or remove) */ @@ -904,7 +904,7 @@ xfs_attr_intent_init( } /* Sets an attribute for an inode as a deferred operation */ -static int +int xfs_attr_defer_add( struct xfs_da_args *args) { diff --git a/fs/xfs/libxfs/xfs_attr.h b/fs/xfs/libxfs/xfs_attr.h index b79dae788cfb..0cf23f5117ad 100644 --- a/fs/xfs/libxfs/xfs_attr.h +++ b/fs/xfs/libxfs/xfs_attr.h @@ -544,6 +544,7 @@ int xfs_inode_hasattr(struct xfs_inode *ip); bool xfs_attr_is_leaf(struct xfs_inode *ip); int xfs_attr_get_ilocked(struct xfs_da_args *args); int xfs_attr_get(struct xfs_da_args *args); +int xfs_attr_defer_add(struct xfs_da_args *args); int xfs_attr_set(struct xfs_da_args *args); int xfs_attr_set_iter(struct xfs_attr_intent *attr); int xfs_attr_remove_iter(struct xfs_attr_intent *attr); @@ -552,7 +553,8 @@ bool xfs_attr_namecheck(struct xfs_mount *mp, const void *name, size_t length, int xfs_attr_calc_size(struct xfs_da_args *args, int *local); void xfs_init_attr_trans(struct xfs_da_args *args, struct xfs_trans_res *tres, unsigned int *total); - +int xfs_attr_intent_init(struct xfs_da_args *args, unsigned int op_flags, + struct xfs_attr_intent **attr); /* * Check to see if the attr should be upgraded from non-existent or shortform to * single-leaf-block attribute list. diff --git a/fs/xfs/libxfs/xfs_parent.c b/fs/xfs/libxfs/xfs_parent.c new file mode 100644 index 000000000000..cf5ea8ce8bd3 --- /dev/null +++ b/fs/xfs/libxfs/xfs_parent.c @@ -0,0 +1,149 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2022 Oracle, Inc. + * All rights reserved. + */ +#include "xfs.h" +#include "xfs_fs.h" +#include "xfs_format.h" +#include "xfs_da_format.h" +#include "xfs_log_format.h" +#include "xfs_shared.h" +#include "xfs_trans_resv.h" +#include "xfs_mount.h" +#include "xfs_bmap_btree.h" +#include "xfs_inode.h" +#include "xfs_error.h" +#include "xfs_trace.h" +#include "xfs_trans.h" +#include "xfs_da_btree.h" +#include "xfs_attr.h" +#include "xfs_da_btree.h" +#include "xfs_attr_sf.h" +#include "xfs_bmap.h" +#include "xfs_defer.h" +#include "xfs_log.h" +#include "xfs_xattr.h" +#include "xfs_parent.h" +#include "xfs_trans_space.h" + +/* + * Parent pointer attribute handling. + * + * Because the attribute value is a filename component, it will never be longer + * than 255 bytes. This means the attribute will always be a local format + * attribute as it is xfs_attr_leaf_entsize_local_max() for v5 filesystems will + * always be larger than this (max is 75% of block size). + * + * Creating a new parent attribute will always create a new attribute - there + * should never, ever be an existing attribute in the tree for a new inode. + * ENOSPC behavior is problematic - creating the inode without the parent + * pointer is effectively a corruption, so we allow parent attribute creation + * to dip into the reserve block pool to avoid unexpected ENOSPC errors from + * occurring. + */ + + +/* Initializes a xfs_parent_name_rec to be stored as an attribute name */ +void +xfs_init_parent_name_rec( + struct xfs_parent_name_rec *rec, + struct xfs_inode *ip, + uint32_t p_diroffset) +{ + xfs_ino_t p_ino = ip->i_ino; + uint32_t p_gen = VFS_I(ip)->i_generation; + + rec->p_ino = cpu_to_be64(p_ino); + rec->p_gen = cpu_to_be32(p_gen); + rec->p_diroffset = cpu_to_be32(p_diroffset); +} + +/* Initializes a xfs_parent_name_irec from an xfs_parent_name_rec */ +void +xfs_init_parent_name_irec( + struct xfs_parent_name_irec *irec, + struct xfs_parent_name_rec *rec) +{ + irec->p_ino = be64_to_cpu(rec->p_ino); + irec->p_gen = be32_to_cpu(rec->p_gen); + irec->p_diroffset = be32_to_cpu(rec->p_diroffset); +} + +int +xfs_parent_init( + struct xfs_mount *mp, + struct xfs_parent_defer **parentp) +{ + struct xfs_parent_defer *parent; + int error; + + if (!xfs_has_parent(mp)) + return 0; + + error = xfs_attr_grab_log_assist(mp); + if (error) + return error; + + parent = kzalloc(sizeof(*parent), GFP_KERNEL); + if (!parent) + return -ENOMEM; + + /* init parent da_args */ + parent->args.geo = mp->m_attr_geo; + parent->args.whichfork = XFS_ATTR_FORK; + parent->args.attr_filter = XFS_ATTR_PARENT; + parent->args.op_flags = XFS_DA_OP_OKNOENT | XFS_DA_OP_LOGGED; + parent->args.name = (const uint8_t *)&parent->rec; + parent->args.namelen = sizeof(struct xfs_parent_name_rec); + + *parentp = parent; + return 0; +} + +int +xfs_parent_defer_add( + struct xfs_trans *tp, + struct xfs_parent_defer *parent, + struct xfs_inode *dp, + struct xfs_name *parent_name, + xfs_dir2_dataptr_t diroffset, + struct xfs_inode *child) +{ + struct xfs_da_args *args = &parent->args; + + xfs_init_parent_name_rec(&parent->rec, dp, diroffset); + args->hashval = xfs_da_hashname(args->name, args->namelen); + + args->trans = tp; + args->dp = child; + if (parent_name) { + parent->args.value = (void *)parent_name->name; + parent->args.valuelen = parent_name->len; + } + + return xfs_attr_defer_add(args); +} + +void +xfs_parent_cancel( + xfs_mount_t *mp, + struct xfs_parent_defer *parent) +{ + xlog_drop_incompat_feat(mp->m_log); + kfree(parent); +} + +unsigned int +xfs_pptr_calc_space_res( + struct xfs_mount *mp, + unsigned int namelen) +{ + /* + * Pptrs are always the first attr in an attr tree, and never larger + * than a block + */ + return XFS_DAENTER_SPACE_RES(mp, XFS_ATTR_FORK) + + XFS_NEXTENTADD_SPACE_RES(mp, namelen, XFS_ATTR_FORK); +} + diff --git a/fs/xfs/libxfs/xfs_parent.h b/fs/xfs/libxfs/xfs_parent.h new file mode 100644 index 000000000000..9b8d0764aad6 --- /dev/null +++ b/fs/xfs/libxfs/xfs_parent.h @@ -0,0 +1,34 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2022 Oracle, Inc. + * All Rights Reserved. + */ +#ifndef __XFS_PARENT_H__ +#define __XFS_PARENT_H__ + +/* + * Dynamically allocd structure used to wrap the needed data to pass around + * the defer ops machinery + */ +struct xfs_parent_defer { + struct xfs_parent_name_rec rec; + struct xfs_da_args args; +}; + +/* + * Parent pointer attribute prototypes + */ +void xfs_init_parent_name_rec(struct xfs_parent_name_rec *rec, + struct xfs_inode *ip, + uint32_t p_diroffset); +void xfs_init_parent_name_irec(struct xfs_parent_name_irec *irec, + struct xfs_parent_name_rec *rec); +int xfs_parent_init(xfs_mount_t *mp, struct xfs_parent_defer **parentp); +int xfs_parent_defer_add(struct xfs_trans *tp, struct xfs_parent_defer *parent, + struct xfs_inode *dp, struct xfs_name *parent_name, + xfs_dir2_dataptr_t diroffset, struct xfs_inode *child); +void xfs_parent_cancel(xfs_mount_t *mp, struct xfs_parent_defer *parent); +unsigned int xfs_pptr_calc_space_res(struct xfs_mount *mp, + unsigned int namelen); + +#endif /* __XFS_PARENT_H__ */ diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index a896ee4c9680..9e195d0e6abc 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -37,6 +37,8 @@ #include "xfs_reflink.h" #include "xfs_ag.h" #include "xfs_log_priv.h" +#include "xfs_parent.h" +#include "xfs_xattr.h" struct kmem_cache *xfs_inode_cache; @@ -946,10 +948,32 @@ xfs_bumplink( xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); } +static unsigned int +xfs_create_space_res( + struct xfs_mount *mp, + unsigned int namelen) +{ + unsigned int ret; + + ret = XFS_IALLOC_SPACE_RES(mp) + XFS_DIRENTER_SPACE_RES(mp, namelen); + if (xfs_has_parent(mp)) + ret += xfs_pptr_calc_space_res(mp, namelen); + + return ret; +} + +static unsigned int +xfs_mkdir_space_res( + struct xfs_mount *mp, + unsigned int namelen) +{ + return xfs_create_space_res(mp, namelen); +} + int xfs_create( struct user_namespace *mnt_userns, - xfs_inode_t *dp, + struct xfs_inode *dp, struct xfs_name *name, umode_t mode, dev_t rdev, @@ -961,7 +985,7 @@ xfs_create( struct xfs_inode *ip = NULL; struct xfs_trans *tp = NULL; int error; - bool unlock_dp_on_error = false; + bool unlock_dp_on_error = false; prid_t prid; struct xfs_dquot *udqp = NULL; struct xfs_dquot *gdqp = NULL; @@ -969,6 +993,8 @@ xfs_create( struct xfs_trans_res *tres; uint resblks; xfs_ino_t ino; + xfs_dir2_dataptr_t diroffset; + struct xfs_parent_defer *parent = NULL; trace_xfs_create(dp, name); @@ -988,13 +1014,19 @@ xfs_create( return error; if (is_dir) { - resblks = XFS_MKDIR_SPACE_RES(mp, name->len); + resblks = xfs_mkdir_space_res(mp, name->len); tres = &M_RES(mp)->tr_mkdir; } else { - resblks = XFS_CREATE_SPACE_RES(mp, name->len); + resblks = xfs_create_space_res(mp, name->len); tres = &M_RES(mp)->tr_create; } + if (xfs_has_parent(mp)) { + error = xfs_parent_init(mp, &parent); + if (error) + goto out_release_dquots; + } + /* * Initially assume that the file does not exist and * reserve the resources for that case. If that is not @@ -1010,7 +1042,7 @@ xfs_create( resblks, &tp); } if (error) - goto out_release_dquots; + goto drop_incompat; xfs_ilock(dp, XFS_ILOCK_EXCL | XFS_ILOCK_PARENT); unlock_dp_on_error = true; @@ -1020,6 +1052,7 @@ xfs_create( * entry pointing to them, but a directory also the "." entry * pointing to itself. */ + init_xattrs = init_xattrs || xfs_has_parent(mp); error = xfs_dialloc(&tp, dp->i_ino, mode, &ino); if (!error) error = xfs_init_new_inode(mnt_userns, tp, dp, ino, mode, @@ -1034,11 +1067,11 @@ xfs_create( * the transaction cancel unlocking dp so don't do it explicitly in the * error path. */ - xfs_trans_ijoin(tp, dp, XFS_ILOCK_EXCL); - unlock_dp_on_error = false; + xfs_trans_ijoin(tp, dp, 0); error = xfs_dir_createname(tp, dp, name, ip->i_ino, - resblks - XFS_IALLOC_SPACE_RES(mp), NULL); + resblks - XFS_IALLOC_SPACE_RES(mp), + &diroffset); if (error) { ASSERT(error != -ENOSPC); goto out_trans_cancel; @@ -1054,6 +1087,17 @@ xfs_create( xfs_bumplink(tp, dp); } + /* + * If we have parent pointers, we need to add the attribute containing + * the parent information now. + */ + if (parent) { + error = xfs_parent_defer_add(tp, parent, dp, name, diroffset, + ip); + if (error) + goto out_trans_cancel; + } + /* * If this is a synchronous mount, make sure that the * create transaction goes to disk before returning to @@ -1079,6 +1123,7 @@ xfs_create( *ipp = ip; xfs_iunlock(ip, XFS_ILOCK_EXCL); + xfs_iunlock(dp, XFS_ILOCK_EXCL); return 0; out_trans_cancel: @@ -1094,6 +1139,9 @@ xfs_create( xfs_irele(ip); xfs_iunlock(ip, XFS_ILOCK_EXCL); } + drop_incompat: + if (parent) + xfs_parent_cancel(mp, parent); out_release_dquots: xfs_qm_dqrele(udqp); xfs_qm_dqrele(gdqp); diff --git a/fs/xfs/xfs_xattr.c b/fs/xfs/xfs_xattr.c index 10aa1fd39d2b..3644c5bcb3c0 100644 --- a/fs/xfs/xfs_xattr.c +++ b/fs/xfs/xfs_xattr.c @@ -27,7 +27,7 @@ * they must release the permission by calling xlog_drop_incompat_feat * when they're done. */ -static inline int +int xfs_attr_grab_log_assist( struct xfs_mount *mp) { diff --git a/fs/xfs/xfs_xattr.h b/fs/xfs/xfs_xattr.h index 2b09133b1b9b..3fd6520a4d69 100644 --- a/fs/xfs/xfs_xattr.h +++ b/fs/xfs/xfs_xattr.h @@ -7,6 +7,7 @@ #define __XFS_XATTR_H__ int xfs_attr_change(struct xfs_da_args *args); +int xfs_attr_grab_log_assist(struct xfs_mount *mp); extern const struct xattr_handler *xfs_xattr_handlers[]; From patchwork Tue Jan 24 01:36:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 13113272 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 552FCC54EED for ; Tue, 24 Jan 2023 01:36:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232437AbjAXBg6 (ORCPT ); Mon, 23 Jan 2023 20:36:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56748 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232516AbjAXBgz (ORCPT ); Mon, 23 Jan 2023 20:36:55 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A09611ABD9 for ; Mon, 23 Jan 2023 17:36:51 -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 30O04YfL021740 for ; Tue, 24 Jan 2023 01:36: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=WYKMuhe4vP7BDr+mkp//BTZ8PM6zP7jTWKoGz8CxKas=; b=k+/fpWkm8vDE5xvsZ5t85ZOdEWwRiHDW2QLnjeiBtdUG5fQxBvUmHh2WlQNMFoi6ZWyL N4Wu6h5gD2t0/ZFJmsDHTLS2DM4AQ1ztWWI4AgZnQ3eG8j4o5Ra/2Tn6uEyMxR2I5Sff sYkecttadJjoS6v7736QsNJDiWCy163jeJ2Rpg24kndXFavq+9VW6BrAx2/GTiRo2oo5 7hm/ruGo3FObMgiSSqDVsQ+FWBYquGrRBO7ECepbxNs8j2m0QKH4Zw1a2fIFwJayFbMe WW69+NaW8AFBPAUmwDzpJGM5/K4wP1vGKLmrPxUPs7b1R1D1lDWgpydRZ3fqiv0ynQ4z 1Q== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3n883c4afs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 24 Jan 2023 01:36:50 +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 30NNYBNN001108 for ; Tue, 24 Jan 2023 01:36:50 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2043.outbound.protection.outlook.com [104.47.66.43]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3n86gakvrn-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 24 Jan 2023 01:36:50 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kA53EQCFq6eVsJApcnBEdLHk+snkD5WuhGGCI9CKbmZsBI4CyI5tRhWTG9jgMkHPuCnoiirQZNt0QDOxgcJtqMKSaqQDgHKn+ppYLw1COxLFr42l8lf5M9J67IjDkrb+ePYHpRep7Zm81H+Mzon5qCUUIxBPL21kRs9XWRSGw7NWeyKPuIJGPzg02VAMnsdAK6ybSLNP9rxhdv8/HZgWXMcPhGyFi6bmA+FFKoEhxWtcVpS9Y4w5V0G9Dvf87YxiSwsBhlelABCODsplc6ZuyucXgnukp/PTyzBJwZCvf7S73oGFN1M4TFejEXBQ8xaa0QBqmbmHdJcecJYHcZEEIA== 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=WYKMuhe4vP7BDr+mkp//BTZ8PM6zP7jTWKoGz8CxKas=; b=WqoSythuI8CUklFhHfju9XsiC16iWbPGe5Bcgw2Sh3PPMaTPTJXb48j7wWLbeVDcjBSii4bw1QnVL+lnlXoEBwAdgoxeM4UiYyf65lRDdbHNMhR+AT7v1nW9uVNLPKJ/JbFs6AUFksSzd62ubr0XVy2JGxiLccf6/p92cpjObsd25Kl7cbxFz1kgeeQZgzD+M3yQ+iGQ2s332Mj2vivcY5XVBiqa5PVgCHnOXSk5oOFS9S2ZV6lMgF3xp9kpCZK1TA0lVwkbrWVoa2JMiNvTVbnsrOVTdTMHAmG+f5MrABEzDUrA6qSF37xm1Vmxj4LKLAXDJX9N+Ds96zM0MrQ27w== 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=WYKMuhe4vP7BDr+mkp//BTZ8PM6zP7jTWKoGz8CxKas=; b=EmuuiTzotxKlIDg263vjcFaKghj3O7gOeQY2PCAnPOHKYsvpikjlqdYSl0pPbv1ExflIGaUp9D7uJAfdhRcf3CJ7tVe//wpn1Nw6KBUlTtP9vdKexfbJsE/5+Top3cwQmaLVurwaSXKXpnza40dFgo8cwqrw+ZKAUyRSCgBnZ9Y= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by SN7PR10MB7074.namprd10.prod.outlook.com (2603:10b6:806:34c::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.8; Tue, 24 Jan 2023 01:36:48 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::eaff:9f55:4641:db38]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::eaff:9f55:4641:db38%4]) with mapi id 15.20.6043.016; Tue, 24 Jan 2023 01:36:48 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v8 16/27] xfs: add parent attributes to link Date: Mon, 23 Jan 2023 18:36:09 -0700 Message-Id: <20230124013620.1089319-17-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230124013620.1089319-1-allison.henderson@oracle.com> References: <20230124013620.1089319-1-allison.henderson@oracle.com> X-ClientProxiedBy: SJ0P220CA0014.NAMP220.PROD.OUTLOOK.COM (2603:10b6:a03:41b::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_|SN7PR10MB7074:EE_ X-MS-Office365-Filtering-Correlation-Id: 008364a1-b111-4b09-d8d2-08dafdab75c7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: AMDDuzYnYisrsxsS513eGdLs8NLrktYtzEKb+gI1wAXOiv8wN59/z0qust+jSGUMycOCAvuQg+8czFYcVjxIcc8CA3/f9STcR6N3sWhcfYXrRpjrGuJMtTKpAlWfSNDPLAOROooZ6u2Gjwk9pQ3n+lWKae9qG88EyEeQ7Z1VLLwJXfJpvqGHc0W4izx1t5DrnWd28kYEwXrw0+ASwRU8WKyLiBP9eK3sezQ6ca4pq27wymviBgMRZYDDuZt+e8F5GwX/QKRVRMrBHiLiodwm1TJMQsU/G6PhV2YTTOxRjujCNIe0b/kyR/X5wPoAjKqLHdnkKW4FWoX7ingB3wyFCahghO+4JsIsImlnOU36iiHqg2GlgkuCT7yOZwwN00uyK9ft3Yiep3vy+2oFZyi10GRXWPZ5F23loKm/0Uod4usGl+uco4x7YPLTYZqI1ILw9pK8+E7JAp5Vmzdev5WCIqOqFqPHbmREfzxDglwlAuY4ojBBQGqKHf+ugeqr4yIBsT5nR/BIILPt7W6zccq+jFFEXTx4GG7e66/IPJRfhAQokbo/hrRVokQLB19gMvt0FR84gUfsXmzxyPYDllA/CnA3o9utiKP80K6WmEvtrlj4Ev80/76G25qucqIGBqkcrSpK687r6rSb00uCrsYgMw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(396003)(376002)(136003)(346002)(366004)(39860400002)(451199015)(66556008)(66476007)(83380400001)(6916009)(8676002)(66946007)(41300700001)(86362001)(36756003)(1076003)(316002)(2616005)(2906002)(38100700002)(5660300002)(8936002)(6512007)(6486002)(26005)(9686003)(186003)(478600001)(6506007)(6666004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: hPM2mRkVcleFSkzT1Mf88kca0cE/uuwk1rBknISjL6GiZDkz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MAcbVvLxq/DgbfwWm1F5pG6kqJfbmCBV7dEYHfmXr13VFTbQXb4dymmLp1ab+bGMn6xS0rLOtRE1g5F9Hg41YC1BekApZbvsy0JxiT1OBukUA8S4XZg7llghzdbXwkiGfy1lwU1WM33rH9RUzgipBBQ4/zlj6sUTYiCTuTwJZGL0wZlTbBTISRd+pQ/13g5MCDv1QWglrNOa2lCIde0VWm9rTcuyy6MPOzTxdDSdDDgBbprmhp2FkKTJpI2W6LYzKUsCmnp5KqHmrLK8+Q== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 008364a1-b111-4b09-d8d2-08dafdab75c7 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jan 2023 01:36:48.5175 (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: 8ff2dWCT9ouuaUEuNLzL9ZeEX6XZtC90qCv7MYcGFlmtyuVYDhpt6qPXzuobkkm7sWFZtrD+7ZxjR3z0L22dkVQdgygh2Qo4U3BSvx/ncQs= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR10MB7074 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-23_12,2023-01-23_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 phishscore=0 mlxlogscore=999 adultscore=0 mlxscore=0 suspectscore=0 spamscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301240010 X-Proofpoint-ORIG-GUID: Yn0wK0t_XDCxFtqOqYVPM9llLqPvXmkR X-Proofpoint-GUID: Yn0wK0t_XDCxFtqOqYVPM9llLqPvXmkR Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Allison Henderson This patch modifies xfs_link to add a parent pointer to the inode. Signed-off-by: Dave Chinner Signed-off-by: Allison Henderson Reviewed-by: Darrick J. Wong --- fs/xfs/libxfs/xfs_trans_space.h | 2 -- fs/xfs/xfs_inode.c | 52 ++++++++++++++++++++++++++++----- 2 files changed, 45 insertions(+), 9 deletions(-) diff --git a/fs/xfs/libxfs/xfs_trans_space.h b/fs/xfs/libxfs/xfs_trans_space.h index 87b31c69a773..f72207923ec2 100644 --- a/fs/xfs/libxfs/xfs_trans_space.h +++ b/fs/xfs/libxfs/xfs_trans_space.h @@ -84,8 +84,6 @@ (2 * (mp)->m_alloc_maxlevels) #define XFS_GROWFSRT_SPACE_RES(mp,b) \ ((b) + XFS_EXTENTADD_SPACE_RES(mp, XFS_DATA_FORK)) -#define XFS_LINK_SPACE_RES(mp,nl) \ - XFS_DIRENTER_SPACE_RES(mp,nl) #define XFS_MKDIR_SPACE_RES(mp,nl) \ (XFS_IALLOC_SPACE_RES(mp) + XFS_DIRENTER_SPACE_RES(mp,nl)) #define XFS_QM_DQALLOC_SPACE_RES(mp) \ diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index 9e195d0e6abc..ccc61cf0f9c6 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -1249,16 +1249,32 @@ xfs_create_tmpfile( return error; } +static unsigned int +xfs_link_space_res( + struct xfs_mount *mp, + unsigned int namelen) +{ + unsigned int ret; + + ret = XFS_DIRENTER_SPACE_RES(mp, namelen); + if (xfs_has_parent(mp)) + ret += xfs_pptr_calc_space_res(mp, namelen); + + return ret; +} + int xfs_link( - xfs_inode_t *tdp, - xfs_inode_t *sip, + struct xfs_inode *tdp, + struct xfs_inode *sip, struct xfs_name *target_name) { - xfs_mount_t *mp = tdp->i_mount; - xfs_trans_t *tp; + struct xfs_mount *mp = tdp->i_mount; + struct xfs_trans *tp; int error, nospace_error = 0; int resblks; + xfs_dir2_dataptr_t diroffset; + struct xfs_parent_defer *parent = NULL; trace_xfs_link(tdp, target_name); @@ -1275,11 +1291,17 @@ xfs_link( if (error) goto std_return; - resblks = XFS_LINK_SPACE_RES(mp, target_name->len); + if (xfs_has_parent(mp)) { + error = xfs_parent_init(mp, &parent); + if (error) + goto std_return; + } + + resblks = xfs_link_space_res(mp, target_name->len); error = xfs_trans_alloc_dir(tdp, &M_RES(mp)->tr_link, sip, &resblks, &tp, &nospace_error); if (error) - goto std_return; + goto drop_incompat; /* * If we are using project inheritance, we only allow hard link @@ -1312,7 +1334,7 @@ xfs_link( } error = xfs_dir_createname(tp, tdp, target_name, sip->i_ino, - resblks, NULL); + resblks, &diroffset); if (error) goto error_return; xfs_trans_ichgtime(tp, tdp, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG); @@ -1320,6 +1342,19 @@ xfs_link( xfs_bumplink(tp, sip); + /* + * If we have parent pointers, we now need to add the parent record to + * the attribute fork of the inode. If this is the initial parent + * attribute, we need to create it correctly, otherwise we can just add + * the parent to the inode. + */ + if (parent) { + error = xfs_parent_defer_add(tp, parent, tdp, target_name, + diroffset, sip); + if (error) + goto error_return; + } + /* * If this is a synchronous mount, make sure that the * link transaction goes to disk before returning to @@ -1337,6 +1372,9 @@ xfs_link( xfs_trans_cancel(tp); xfs_iunlock(tdp, XFS_ILOCK_EXCL); xfs_iunlock(sip, XFS_ILOCK_EXCL); + drop_incompat: + if (parent) + xfs_parent_cancel(mp, parent); std_return: if (error == -ENOSPC && nospace_error) error = nospace_error; From patchwork Tue Jan 24 01:36:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 13113270 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 35E54C54EB4 for ; Tue, 24 Jan 2023 01:36:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231838AbjAXBg5 (ORCPT ); Mon, 23 Jan 2023 20:36:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56762 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232470AbjAXBgz (ORCPT ); Mon, 23 Jan 2023 20:36:55 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 490D91ABE6 for ; Mon, 23 Jan 2023 17:36:54 -0800 (PST) Received: from pps.filterd (m0333521.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 30O04h8d020122 for ; Tue, 24 Jan 2023 01:36:54 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2022-7-12; bh=/ZHnu17wX0EAsrcsvCpkMDiXHfRRSu/Q4x3Y74OEdMM=; b=wDwkP2LmPnrEmFQ3RunzQcI5aT3QsDhVpApQ/FNLTl812ozzIJm1iwTh10B7OUUrn9yB wD2c3+ZKf9zx/7T2WTQfyfvoVizxBvnLD34/h5BHU37OsZi7FuMJknoNDDAJ5bIikcfv ecsF3syFYVdGNRyhzYm8X9OYSyele9m3tPazi3MMaDE2NCdmfDnWPRFdOm3en0t26fFq hT+8zcdPGQdVWuA4qjyqQhmPIAtgRcPuQFf8tiOwuQkGcVS5/4ZUCFa2zVtfPcLRwBOl AIcyCDCwsEHkdPNnq93MtTKzDmfysnUkvEghX7JZMGJekX24YnhDXI4MMO40QZ06gL8k ew== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3n86ybcbj2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 24 Jan 2023 01:36:53 +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 30O0xVZP001093 for ; Tue, 24 Jan 2023 01:36:52 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2049.outbound.protection.outlook.com [104.47.66.49]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3n86gakvsj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 24 Jan 2023 01:36:52 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=V8Y1rfeZs2R/3lFYgxaQB2KZp0pw5g6uNWs+TPJZesjVcCCWXVKcf8bWFZ3sX4HOHZ8GPQk01438pI+bTWdYbZ6LNzQBDzlGAcgc669AICNTIk1HWF5L4w2oiSdJwQ7yTUpZWO+4WpcJpMricWKKTOyAad9M+yGNL6Xy+xuUu+C/DEGwUpcXT9D8rIk9xIFvs3fo+YscbXxAEN9tOWCjHcIKjN1joZQKMFikzdoqHGXbIJyDM0KEPHG1+ZFgrKUYPsRgBPKkqUMC4gA4yq8zpt5Z23SlQ9LVnl9pjBQphntFJAhjVYU4iIlSES6FyDjMGq0JNmWi2Zg2162fP8sApw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=/ZHnu17wX0EAsrcsvCpkMDiXHfRRSu/Q4x3Y74OEdMM=; b=PPRS3Z+ahywsec8QfJjT7GNuuAOW9kyvyY93vTwPFVi1tv2rDEmfoefNSIALVk5i3u4KoinYS4c2VlgFJiD7KkwdBeXBvfixSC9JX/UC4eDCd0DWvtKAjc+IKyv9mriVT3oX18FJzH6ffKDFG8/wYkRlJxkG6GVnfmipe289DdpORetirfHoEgDE9fkIjWCa8Ag/Ge071PS1kRzHN2kCkXMTAu0RC0CIXQ7HC5Nw2TStcw6T9XEVzPBMAs9OdEED0kPYCs1qE/9okGyCv1I3rl6pLvwkgXcaWw1My3RwQB+NDnAG32jnbOvMiw5yDzbeGS4EouN3l+vcfB9+Ux9aug== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=/ZHnu17wX0EAsrcsvCpkMDiXHfRRSu/Q4x3Y74OEdMM=; b=Ha156mwYkE3CxjxeJCj70HBfCwA0/QjFZAvZAtU0a7QjGvrFePW8HioEMfd1WudFd7dX6PkZeC5iglTINX4x59xekQI3iocYwilgvD4g8LyIGC1H6pNvRfEICd7646yTCSdwLlIXfQNvOFYX3Pg9PEoBuYs/cwXk+yWwJhXFRrc= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by SN7PR10MB7074.namprd10.prod.outlook.com (2603:10b6:806:34c::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.8; Tue, 24 Jan 2023 01:36:50 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::eaff:9f55:4641:db38]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::eaff:9f55:4641:db38%4]) with mapi id 15.20.6043.016; Tue, 24 Jan 2023 01:36:50 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v8 17/27] xfs: add parent attributes to symlink Date: Mon, 23 Jan 2023 18:36:10 -0700 Message-Id: <20230124013620.1089319-18-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230124013620.1089319-1-allison.henderson@oracle.com> References: <20230124013620.1089319-1-allison.henderson@oracle.com> X-ClientProxiedBy: SJ0P220CA0013.NAMP220.PROD.OUTLOOK.COM (2603:10b6:a03:41b::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_|SN7PR10MB7074:EE_ X-MS-Office365-Filtering-Correlation-Id: d1b58d50-dfa1-4062-d70d-08dafdab76b3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: yCSJtIBWrY1wetNn+3W5MaQTsIyzgbYHzbCZe9IMqUro5nr1ojrxKiVBfeISIYU90rpTG1dEYezrKkXf0K4EP6K8zLov3iG9f0jHs7xLAIdR4i5Fd3dpFPUQ6iM5m69ZSb1OzueIab0AmbXQ04/TpwBtGIKQxVo6xvl55iQ8bc4Z+avvchqSkguFvvhJvAq+4Jc4Y50nkJJ145Qu8/ygv7ElRZ4h3uw5oX6oo9F5FnBv4ZfEmwLZOjINuPOnTCInM+CKhPfLbTC0QR/OxIFpVDwYlD0uxdaSq+ogkYXJG4cvXj0NxAJqCu0afB4CvEpsRQi32pfvz1ncdXp/H1+u7SZvTiWN5HPt8GuA+QN9XHxRZ+dVyPz/VlTtnC4Lj238gws+XYW7rZSN7+aWKU6L9GPGXepqY3g03OQc3auZEXQj7dzCF1OIAyVi+y4BwC7GO9ibFQKh9bLlIpCL4QzhluUyGacD8TZwGwdTjtK9OxLMVqUaQcW5tX4raxCZSCMycpri07C6ANwMWX1GCuAV8I55L9pdivzRq5ZhQoYpuo2IEytFC0o97odXbauP9dR/GMjFxBDcupD3MEg0mob1vh3mAZ0XjCbnfsidjYvyesDEfkgV1KIJR+rLs65o1SZIKEHEX5kGCmBB3LsIdt3NHw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(396003)(376002)(136003)(346002)(366004)(39860400002)(451199015)(66556008)(66476007)(83380400001)(6916009)(8676002)(66946007)(41300700001)(86362001)(36756003)(1076003)(316002)(2616005)(2906002)(38100700002)(5660300002)(8936002)(6512007)(6486002)(26005)(9686003)(186003)(478600001)(6506007)(6666004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: cAKI9Hddf0WY5YUEtzP49FnPY5Bdyc9sHubH1ScuguHSQGrWZAgY4bhfrWftX1dSOp7ylTJuUJLrQZW16N3DCub2LzrIOXoqf+eNH11FMKAvAMq8K2IeTIz4oAmtV5WtyPuu+EdbHT+Qkd8ox2m+q4dhNjPeGtKni+E2s8tE6ZTofPdfqpoTrS990upBmp4Dy6+5UrcWmNB34NixfMJGw4EDRphJ1FZztbBDglTQkbD2kbTovch1m7R336PGob3RNMWmmUw8HwVjXCKZ24zheDnhaSgFRCRsiMs9VzO+ZSUe7ZAtpJoqHoDosvYQWTHFpBW2hmlWcGcKMmvVFBfJInQmWalD8qFIXByPp+AU90W/KM1/TaOvnvpqDUAxPVEt7OTkny3u+th+5C81ffQjpbM9djwCjvzc06Uo98MM/BXBiLZM6DiDs/eg6zsaG63BNTCwV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8iBYyQtqkl3XYc7wVcMQt0oq1RV81JAJsgfEGE3eQUc8zi0eqI4XTC9LgPejmd5vqh0YiFiLPWkSwfSMSeOp843qfqQhVRyg== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: DDtH8fekD1Y/Vq5km3IBWbP4mYZjgBMSOQxPOt2CzQSSYGzYOYJ9GADX9zALopDp+cSYX6oYzGAWWtXJ9kVrnXy4uf+Lg9Cm6hJiPs9x1HnH+F8HcO3S0RqJrWWhrspu6aGoZd+idolwrNJHcKthh03EsoIL8mu+Z1Qq4Uex7P0+AVNnnutwUueU2aB/6Azslv/6LPKB7wMJ5Kj0TV8xpLrrDD5/l+yWm3mtGEMBBEuCJD1Yqm/REdtbeg5eBVYJe3U8WOert1joP6OnHXVm1PFnKXh+OHJpo440o2fjlwjAcsw8PxJ78I0Yip87LH3Vvxsa7FoBadte35L8ueWn1kYPw/ePm6JUgm6tWXSkxlIGgTacClld9Jn/GqTrmM904Xal6run0h+v5FI5WxCT74DZa4846r3Kef9E2dptxzynmtE8gLiZNYC5at3ergsalEjAEcPrGj9mqEPMTztPNhTQQJe/L7hpDwlbtrbQkhdmgTu844ElwHJXsKw/+vdLO9W5RzcQ9/lIZ1ePUrYT74/nrll81UufL2d/b+3tJDUC57X+lHoD7a6TLUUjjOqxdVpr++U3xX0Ipf5l5vFGYpWyOMngmBquJ0U8DJVACZ8qxnAOUjUXPZhMtX4Hw/7TlSDi8hJS6jCyEfYoGdbyIKdVIh0uiFZXz4kiM9/t1Tl5yKYWdhtSeJwM7yPMqiipCUwb14qsjIfX6yrqNj/MXtjXNyGfO+ztv45Oxp45UlWexb2dubBCpRz+K9CQXSB3KFXEi4JBT/yMqcS6z5t06g== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: d1b58d50-dfa1-4062-d70d-08dafdab76b3 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jan 2023 01:36:50.0797 (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: TrhtEfP+QgLtt15s8q27+HDjXCY6tHA4MIk/vwds2W0YYuwyaMPeJWfXiGqL+xUs1svjCSQMpJO98eBD091HSeIUb/oZWxpbAkult5ccJO4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR10MB7074 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-23_12,2023-01-23_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 phishscore=0 mlxlogscore=999 adultscore=0 mlxscore=0 suspectscore=0 spamscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301240010 X-Proofpoint-GUID: y_SGsDgYE8Hm8WlAFzTX6TBLckQvXiZD X-Proofpoint-ORIG-GUID: y_SGsDgYE8Hm8WlAFzTX6TBLckQvXiZD Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Allison Henderson This patch modifies xfs_symlink to add a parent pointer to the inode. Signed-off-by: Allison Henderson --- fs/xfs/libxfs/xfs_trans_space.h | 2 -- fs/xfs/xfs_symlink.c | 54 ++++++++++++++++++++++++++++----- 2 files changed, 47 insertions(+), 9 deletions(-) diff --git a/fs/xfs/libxfs/xfs_trans_space.h b/fs/xfs/libxfs/xfs_trans_space.h index f72207923ec2..25a55650baf4 100644 --- a/fs/xfs/libxfs/xfs_trans_space.h +++ b/fs/xfs/libxfs/xfs_trans_space.h @@ -95,8 +95,6 @@ XFS_DIRREMOVE_SPACE_RES(mp) #define XFS_RENAME_SPACE_RES(mp,nl) \ (XFS_DIRREMOVE_SPACE_RES(mp) + XFS_DIRENTER_SPACE_RES(mp,nl)) -#define XFS_SYMLINK_SPACE_RES(mp,nl,b) \ - (XFS_IALLOC_SPACE_RES(mp) + XFS_DIRENTER_SPACE_RES(mp,nl) + (b)) #define XFS_IFREE_SPACE_RES(mp) \ (xfs_has_finobt(mp) ? M_IGEO(mp)->inobt_maxlevels : 0) diff --git a/fs/xfs/xfs_symlink.c b/fs/xfs/xfs_symlink.c index 27a7d7c57015..92d69b3ca28d 100644 --- a/fs/xfs/xfs_symlink.c +++ b/fs/xfs/xfs_symlink.c @@ -23,6 +23,8 @@ #include "xfs_trans.h" #include "xfs_ialloc.h" #include "xfs_error.h" +#include "xfs_parent.h" +#include "xfs_defer.h" /* ----- Kernel only functions below ----- */ int @@ -142,6 +144,23 @@ xfs_readlink( return error; } +static unsigned int +xfs_symlink_space_res( + struct xfs_mount *mp, + unsigned int namelen, + unsigned int fsblocks) +{ + unsigned int ret; + + ret = XFS_IALLOC_SPACE_RES(mp) + XFS_DIRENTER_SPACE_RES(mp, namelen) + + fsblocks; + + if (xfs_has_parent(mp)) + ret += xfs_pptr_calc_space_res(mp, namelen); + + return ret; +} + int xfs_symlink( struct user_namespace *mnt_userns, @@ -172,6 +191,8 @@ xfs_symlink( struct xfs_dquot *pdqp = NULL; uint resblks; xfs_ino_t ino; + xfs_dir2_dataptr_t diroffset; + struct xfs_parent_defer *parent = NULL; *ipp = NULL; @@ -202,13 +223,21 @@ xfs_symlink( /* * The symlink will fit into the inode data fork? - * There can't be any attributes so we get the whole variable part. + * If there are no parent pointers, then there wont't be any attributes. + * So we get the whole variable part, and do not need to reserve extra + * blocks. Otherwise, we need to reserve the blocks. */ - if (pathlen <= XFS_LITINO(mp)) + if (pathlen <= XFS_LITINO(mp) && !xfs_has_parent(mp)) fs_blocks = 0; else fs_blocks = xfs_symlink_blocks(mp, pathlen); - resblks = XFS_SYMLINK_SPACE_RES(mp, link_name->len, fs_blocks); + resblks = xfs_symlink_space_res(mp, link_name->len, fs_blocks); + + if (xfs_has_parent(mp)) { + error = xfs_parent_init(mp, &parent); + if (error) + return error; + } error = xfs_trans_alloc_icreate(mp, &M_RES(mp)->tr_symlink, udqp, gdqp, pdqp, resblks, &tp); @@ -233,7 +262,7 @@ xfs_symlink( if (!error) error = xfs_init_new_inode(mnt_userns, tp, dp, ino, S_IFLNK | (mode & ~S_IFMT), 1, 0, prid, - false, &ip); + xfs_has_parent(mp), &ip); if (error) goto out_trans_cancel; @@ -244,8 +273,7 @@ xfs_symlink( * the transaction cancel unlocking dp so don't do it explicitly in the * error path. */ - xfs_trans_ijoin(tp, dp, XFS_ILOCK_EXCL); - unlock_dp_on_error = false; + xfs_trans_ijoin(tp, dp, 0); /* * Also attach the dquot(s) to it, if applicable. @@ -315,12 +343,20 @@ xfs_symlink( * Create the directory entry for the symlink. */ error = xfs_dir_createname(tp, dp, link_name, - ip->i_ino, resblks, NULL); + ip->i_ino, resblks, &diroffset); if (error) goto out_trans_cancel; xfs_trans_ichgtime(tp, dp, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG); xfs_trans_log_inode(tp, dp, XFS_ILOG_CORE); + if (parent) { + error = xfs_parent_defer_add(tp, parent, dp, link_name, + diroffset, ip); + if (error) + goto out_trans_cancel; + } + + /* * If this is a synchronous mount, make sure that the * symlink transaction goes to disk before returning to @@ -339,6 +375,7 @@ xfs_symlink( *ipp = ip; xfs_iunlock(ip, XFS_ILOCK_EXCL); + xfs_iunlock(dp, XFS_ILOCK_EXCL); return 0; out_trans_cancel: @@ -362,6 +399,9 @@ xfs_symlink( xfs_iunlock(dp, XFS_ILOCK_EXCL); if (ip) xfs_iunlock(ip, XFS_ILOCK_EXCL); + if (parent) + xfs_parent_cancel(mp, parent); + return error; } From patchwork Tue Jan 24 01:36:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 13113274 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 B4865C25B50 for ; Tue, 24 Jan 2023 01:37:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232470AbjAXBhA (ORCPT ); Mon, 23 Jan 2023 20:37:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56786 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231610AbjAXBg5 (ORCPT ); Mon, 23 Jan 2023 20:36:57 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C69981A4AE for ; Mon, 23 Jan 2023 17:36:55 -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 30O05r8d022928 for ; Tue, 24 Jan 2023 01:36:55 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2022-7-12; bh=B6+3UQsU0sw9d77q0+WDjNDgq1Sdd1q73pA+X+HdgOQ=; b=l88B4cWew2cUvbZVq80GDyWLY0UBnPBVly71CqgxoyGG11twIuFFoM1BY2cb9HcKLngE J6EkB33zTz10zt/54z0u420+i5FEHre9mVMiruJEZdo7qF3c94mp0ECEUrRWvglM2hxK wZNzM14LoJYaL8n/lEMtgIYDLGmfIs5FkGiKITdnxa/4DXX4gQqX2CXOB+BRNe6IgxaX SLtDcgvKXFVLS+dbPb/oU+FbGjoKMfl7T8sRwUoBhWFS6vDL+RgWJgT7iLvwz+ep0KVf cmLSlTd3dnqs91/pbD0Pplz1tM5jilGikTGQ4/q+hC2N9DxvEkXPUypqmwiPLkwCUgAr 4w== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3n87xa4a1n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 24 Jan 2023 01:36:55 +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 30NNPUWH001439 for ; Tue, 24 Jan 2023 01:36:54 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2046.outbound.protection.outlook.com [104.47.66.46]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3n86gakvta-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 24 Jan 2023 01:36:53 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=e5WyHSjUadoQTD4RaU7roeL+0noANbIgtren8ekWOeYQqOo0rUw2UQfJI6oNZw+5u5RF1gUiHCJdWlgOOrkZTp4th49RJ91EA6DwTCCFO5BTMbw8pvzYe/vQpl47dL7mm8Yo6FKPLacGN07zDPv+ji7DS7GpsLaNHLYh7K6OdVsulS5D687MBWAVQ9U7pgJ9d3lrPK1iU3L2sFbSSMnUlp3kob5OtzviWF451dHeDS1MgNe5vS6GN8vKk+gYyyVWf+Oo7T+mDFsReV3JFVuBjH86ruMDNim4mPkkpJnLq2/ls1DypkK4esZsHHFwD0wdHrDmFuEln4J6a2w4HvdZWg== 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=B6+3UQsU0sw9d77q0+WDjNDgq1Sdd1q73pA+X+HdgOQ=; b=D5Axz7jYtxlgaRkZz+qXV+1PLgdqX98w6dVg4zzOfn1Cbn1JWwjqJFUjr/lWlFTU5RVnsz16q9lsfQ94lNJC89wwEifIlD4XNARSz+qxSZ6cQ3iG4un9OjMbodzlZZY4pd6kqAtcrPx6FD4Yo+3eEa7SFPjjWsOCMimfblQa8gcGoB+r5wem0VBW5Ipaxx0E6aHAWwTPxl+ASaVghuCGtpFw8bPAoe2VC78g178Hn94TwvgQQ+0+6D8LXPVGOvD17tnd/0HpWnNyYDCT6siaDSRV8bqg5D1aodjP73/wp5KhG8VzACBmiki/0sLT8bGW0IYHteEZZUksYxLu4kRX+A== 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=B6+3UQsU0sw9d77q0+WDjNDgq1Sdd1q73pA+X+HdgOQ=; b=asF37rebY3bUyHgXZinFvp+pzQbo0WyEBbFOpY82c+r9QFOoE/S+ZUzsjjug6HrMQjpGPyxjqLWb3S5LrOEql7ERpTbmtd33bNr0v3i5X+V3DqIYVieDPxl3+wlyHkAK8NNPlNgsmfFzPGkVudX6ZNx4wov9OYyobJ7KIxI900M= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by SN7PR10MB7074.namprd10.prod.outlook.com (2603:10b6:806:34c::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.8; Tue, 24 Jan 2023 01:36:51 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::eaff:9f55:4641:db38]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::eaff:9f55:4641:db38%4]) with mapi id 15.20.6043.016; Tue, 24 Jan 2023 01:36:51 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v8 18/27] xfs: remove parent pointers in unlink Date: Mon, 23 Jan 2023 18:36:11 -0700 Message-Id: <20230124013620.1089319-19-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230124013620.1089319-1-allison.henderson@oracle.com> References: <20230124013620.1089319-1-allison.henderson@oracle.com> X-ClientProxiedBy: SJ0PR05CA0145.namprd05.prod.outlook.com (2603:10b6:a03:33d::30) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY5PR10MB4306:EE_|SN7PR10MB7074:EE_ X-MS-Office365-Filtering-Correlation-Id: d3072039-dae6-41a6-9d96-08dafdab77ab X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ZNQP3//M2OfjOm941uMbeHacRHYmdnf87yIt8Y/Qx0CrDal1PzMez0FJdFKxeMf5gu6h1h/JkiTGyeZOtWGiOooIYyM/YhZc6fiHE5VzMuMZvlQNEcE8vrGSzvhTd5T3wsGXrUkmgnqd4qYCMKpMiZItJhGGggpKH+3YfQ/7aiOJMpWFtQ1BjxFceXv8SDb/ZWqmD4GT4RFc6URuIyrKk+cx2TxQS59hEpYoDJ7b+Wo/2k843ricm2963EKAPvBEDrcpHeQEahqpylLDMoHlWqi4d5irKCUJMsYWZBvMC4WaBhCJf69AcinhsesRr5CyHc4lBg9zE7yRQw+n0Qz2W4+/PH6vZePhnbJS8qsT2G3Wjh4exbeFpcmnhy3y+Bm2hvyGugpkiCSDx1MXP9FYDOE7DQo0iUOvxxuUorOo4uYsAla8KkxFJ/Pn6MOTktZchvxgrb8ani+B/T1R9GReow6srh57OiSfeBY0dCXil797MZc6A4lLg2l13ZH1Zxx9ze+EFVt9FPft0UN9/2czSjvjTkNFe1laakg/Q242+6B6zTFB2D1trg55otBLU4bV/9AID1GjKg8ywFHQEJzTAm8cfmxrSj7TYwMpbhC+drSkTKKwvRGKgE7opHTIY5zeA2sq2COoNSTXJ9volhNz0A== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(396003)(376002)(136003)(346002)(366004)(39860400002)(451199015)(66556008)(66476007)(83380400001)(6916009)(8676002)(66946007)(41300700001)(86362001)(36756003)(1076003)(316002)(2616005)(2906002)(38100700002)(5660300002)(8936002)(6512007)(6486002)(26005)(9686003)(186003)(478600001)(6506007)(6666004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: EF5npTyFzccytFTG+P5o07C+LF2gFiYVJWIwjC+JknFS+QblFkxDUeDaxC9bJGA1zSGYjZjJZSLW8QuPL5h8Es7a4xkw9WifNgHVFzYPZOcR6xxRGXRM4y5jkB7HbPWEAqxLFpiYYzred8iCANEdrSXf9b18LFkvY95Vz6UMj0FFou/cVzpB99LL9TeMqb6KJg0JInkJPqVTnVUvIKS7SAmu1Bm9mjJWnzI+cNeUUtJHLWCKRSGbtbNCBy5VmBMEdT34/LRNpIy0zCMA7moo+dWkB9eFcnNnlI0a/G41mONaoqmG7gIKIIN04HBZnThWeR6IdTX/d7svVHx1ICzPV5eyaSPbjxVTjucMScs1ipDTenWdOsIHhVBNjcySOQhkglA36cw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xWHvyRMAH/izF7+PyB5jG9SQm3D2wLRNCKGCnR8ZVcfM2WCNAJexsoRUAiLKwDzTJ/hbdowuWt30YbE51nQqjFk5cbrw2QfQzh4+ueWkX1OiZ5wKcCXs3vRQYkuu9pZx3Fmk5DMJ5NxoxFdkJyu3R3mcL6CiYeoQ== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: pghitven0Xb7aqCMs1iTIrQb1kpt7pW1UMQMfww0inssOC/FF0m54q9PPvygaJ7e1VY90khZ0ra4+B7QrySnaAI/k5OAVGoV2ZbSAeKZUqIiy3dMJ99uP/yOSgc75f1Kt6FisORhjC5PxErx7E5ns3hqGDi5qe4/BArTW3YguPoXtChQKIevN2Jjn/hczg9PF/SjgwHDTWqdG8txyRw82rVGSPHPAqutUanReoeH/JeIJZxtiNdTIXgP/iY8U/tkeU7enqHKuL7EleKNEESVDt7ZJWNMoXMdWwDhfx2bfqmqTFyuhi6JxmfyQl3VxsHD/XZaiyVVr4FuwT7ZQtji4djXGhlp/CFJXVR22RxIoUkQiZD0bh3xajah8ZkuyWPSdcT3H8ooVvgV71tpjipupCW9mz9DrDc3al+IXMhuGA4NWVHiFa2rrVyIyZHVN0Qyb+X5/TThYGxF+29aYyKeG7klEjitsq37etGG1XCil0XZqqlgrUgDIVhIMMFPDXosFCxYzIU5kckuN8ZkGXvypzowfnVobf/3aptqXmJbtq+CcsN94LmBB6708CQh/qTljHQXNC/YpjnAVoPIdqYLfgdyBDnlPu5H91RI/141bWPLvn/ETur27z0ZJPyaxNuTEgZwvu+29CY8hGtX7g9AzzKBmMPHso9N0myvZ4nDXmoG4F12t+Ladi3FgrWoSioU4t0v3fDWQA+nR2gbBuR3/6xoYz0IdDddTju0OkR4rdYMHmlQoHC35VRUxJIrBWC4ftp/faSGTRvUsdI2bZ1DMA== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: d3072039-dae6-41a6-9d96-08dafdab77ab X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jan 2023 01:36:51.7347 (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: pWdJZDPReekGV05oRw1dAYF+AO1tS9eLWtteGuBB8oXaKuoDPS7hH/ot6kU2JyefpRhpbqAs6IFNFzEZSoVRssOpaAKSU3nbQoXkIlrxbHE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR10MB7074 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-23_12,2023-01-23_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 phishscore=0 mlxlogscore=999 adultscore=0 mlxscore=0 suspectscore=0 spamscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301240010 X-Proofpoint-GUID: aXmO0zk8rZj9UZKV2vTgAT8nmIXO9NrK X-Proofpoint-ORIG-GUID: aXmO0zk8rZj9UZKV2vTgAT8nmIXO9NrK Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Allison Henderson This patch removes the parent pointer attribute during unlink Signed-off-by: Dave Chinner Signed-off-by: Allison Henderson Reviewed-by: Darrick J. Wong --- fs/xfs/libxfs/xfs_attr.c | 2 +- fs/xfs/libxfs/xfs_attr.h | 1 + fs/xfs/libxfs/xfs_parent.c | 17 +++++++++++++ fs/xfs/libxfs/xfs_parent.h | 4 +++ fs/xfs/libxfs/xfs_trans_space.h | 2 -- fs/xfs/xfs_inode.c | 44 +++++++++++++++++++++++++++------ 6 files changed, 60 insertions(+), 10 deletions(-) diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c index f68d41f0f998..a8db44728b11 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -946,7 +946,7 @@ xfs_attr_defer_replace( } /* Removes an attribute for an inode as a deferred operation */ -static int +int xfs_attr_defer_remove( struct xfs_da_args *args) { diff --git a/fs/xfs/libxfs/xfs_attr.h b/fs/xfs/libxfs/xfs_attr.h index 0cf23f5117ad..033005542b9e 100644 --- a/fs/xfs/libxfs/xfs_attr.h +++ b/fs/xfs/libxfs/xfs_attr.h @@ -545,6 +545,7 @@ bool xfs_attr_is_leaf(struct xfs_inode *ip); int xfs_attr_get_ilocked(struct xfs_da_args *args); int xfs_attr_get(struct xfs_da_args *args); int xfs_attr_defer_add(struct xfs_da_args *args); +int xfs_attr_defer_remove(struct xfs_da_args *args); int xfs_attr_set(struct xfs_da_args *args); int xfs_attr_set_iter(struct xfs_attr_intent *attr); int xfs_attr_remove_iter(struct xfs_attr_intent *attr); diff --git a/fs/xfs/libxfs/xfs_parent.c b/fs/xfs/libxfs/xfs_parent.c index cf5ea8ce8bd3..c09f49b7c241 100644 --- a/fs/xfs/libxfs/xfs_parent.c +++ b/fs/xfs/libxfs/xfs_parent.c @@ -125,6 +125,23 @@ xfs_parent_defer_add( return xfs_attr_defer_add(args); } +int +xfs_parent_defer_remove( + struct xfs_trans *tp, + struct xfs_inode *dp, + struct xfs_parent_defer *parent, + xfs_dir2_dataptr_t diroffset, + struct xfs_inode *child) +{ + struct xfs_da_args *args = &parent->args; + + xfs_init_parent_name_rec(&parent->rec, dp, diroffset); + args->trans = tp; + args->dp = child; + args->hashval = xfs_da_hashname(args->name, args->namelen); + return xfs_attr_defer_remove(args); +} + void xfs_parent_cancel( xfs_mount_t *mp, diff --git a/fs/xfs/libxfs/xfs_parent.h b/fs/xfs/libxfs/xfs_parent.h index 9b8d0764aad6..1c506532c624 100644 --- a/fs/xfs/libxfs/xfs_parent.h +++ b/fs/xfs/libxfs/xfs_parent.h @@ -27,6 +27,10 @@ int xfs_parent_init(xfs_mount_t *mp, struct xfs_parent_defer **parentp); int xfs_parent_defer_add(struct xfs_trans *tp, struct xfs_parent_defer *parent, struct xfs_inode *dp, struct xfs_name *parent_name, xfs_dir2_dataptr_t diroffset, struct xfs_inode *child); +int xfs_parent_defer_remove(struct xfs_trans *tp, struct xfs_inode *dp, + struct xfs_parent_defer *parent, + xfs_dir2_dataptr_t diroffset, + struct xfs_inode *child); void xfs_parent_cancel(xfs_mount_t *mp, struct xfs_parent_defer *parent); unsigned int xfs_pptr_calc_space_res(struct xfs_mount *mp, unsigned int namelen); diff --git a/fs/xfs/libxfs/xfs_trans_space.h b/fs/xfs/libxfs/xfs_trans_space.h index 25a55650baf4..b5ab6701e7fb 100644 --- a/fs/xfs/libxfs/xfs_trans_space.h +++ b/fs/xfs/libxfs/xfs_trans_space.h @@ -91,8 +91,6 @@ XFS_DQUOT_CLUSTER_SIZE_FSB) #define XFS_QM_QINOCREATE_SPACE_RES(mp) \ XFS_IALLOC_SPACE_RES(mp) -#define XFS_REMOVE_SPACE_RES(mp) \ - XFS_DIRREMOVE_SPACE_RES(mp) #define XFS_RENAME_SPACE_RES(mp,nl) \ (XFS_DIRREMOVE_SPACE_RES(mp) + XFS_DIRENTER_SPACE_RES(mp,nl)) #define XFS_IFREE_SPACE_RES(mp) \ diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index ccc61cf0f9c6..f593f0c9227c 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -2471,6 +2471,19 @@ xfs_iunpin_wait( __xfs_iunpin_wait(ip); } +static unsigned int +xfs_remove_space_res( + struct xfs_mount *mp, + unsigned int namelen) +{ + unsigned int ret = XFS_DIRREMOVE_SPACE_RES(mp); + + if (xfs_has_parent(mp)) + ret += xfs_pptr_calc_space_res(mp, namelen); + + return ret; +} + /* * Removing an inode from the namespace involves removing the directory entry * and dropping the link count on the inode. Removing the directory entry can @@ -2500,16 +2513,18 @@ xfs_iunpin_wait( */ int xfs_remove( - xfs_inode_t *dp, + struct xfs_inode *dp, struct xfs_name *name, - xfs_inode_t *ip) + struct xfs_inode *ip) { - xfs_mount_t *mp = dp->i_mount; - xfs_trans_t *tp = NULL; + struct xfs_mount *mp = dp->i_mount; + struct xfs_trans *tp = NULL; int is_dir = S_ISDIR(VFS_I(ip)->i_mode); int dontcare; int error = 0; uint resblks; + xfs_dir2_dataptr_t dir_offset; + struct xfs_parent_defer *parent = NULL; trace_xfs_remove(dp, name); @@ -2524,6 +2539,12 @@ xfs_remove( if (error) goto std_return; + if (xfs_has_parent(mp)) { + error = xfs_parent_init(mp, &parent); + if (error) + goto std_return; + } + /* * We try to get the real space reservation first, allowing for * directory btree deletion(s) implying possible bmap insert(s). If we @@ -2535,12 +2556,12 @@ xfs_remove( * the directory code can handle a reservationless update and we don't * want to prevent a user from trying to free space by deleting things. */ - resblks = XFS_REMOVE_SPACE_RES(mp); + resblks = xfs_remove_space_res(mp, name->len); error = xfs_trans_alloc_dir(dp, &M_RES(mp)->tr_remove, ip, &resblks, &tp, &dontcare); if (error) { ASSERT(error != -ENOSPC); - goto std_return; + goto drop_incompat; } /* @@ -2594,12 +2615,18 @@ xfs_remove( if (error) goto out_trans_cancel; - error = xfs_dir_removename(tp, dp, name, ip->i_ino, resblks, NULL); + error = xfs_dir_removename(tp, dp, name, ip->i_ino, resblks, &dir_offset); if (error) { ASSERT(error != -ENOENT); goto out_trans_cancel; } + if (parent) { + error = xfs_parent_defer_remove(tp, dp, parent, dir_offset, ip); + if (error) + goto out_trans_cancel; + } + /* * If this is a synchronous mount, make sure that the * remove transaction goes to disk before returning to @@ -2624,6 +2651,9 @@ xfs_remove( out_unlock: xfs_iunlock(ip, XFS_ILOCK_EXCL); xfs_iunlock(dp, XFS_ILOCK_EXCL); + drop_incompat: + if (parent) + xfs_parent_cancel(mp, parent); std_return: return error; } From patchwork Tue Jan 24 01:36:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 13113271 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 1F949C05027 for ; Tue, 24 Jan 2023 01:37:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230315AbjAXBg7 (ORCPT ); Mon, 23 Jan 2023 20:36:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56784 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232446AbjAXBg4 (ORCPT ); Mon, 23 Jan 2023 20:36:56 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C54871A483 for ; Mon, 23 Jan 2023 17:36:55 -0800 (PST) Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 30O04HJj016587 for ; Tue, 24 Jan 2023 01:36:55 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2022-7-12; bh=UojYfovIOMxEVbXz2q9zgrlM284fM2bX8USyuISAM6c=; b=BHdFxDujyKvNUj+KGxLhfMhKlD1q5fDvXNV8fV2VMre5dU1/AFUwxrHVKw2o0DtUJx1l su0zJTNvfyi22klFHdNrHm6qZXEXed1VZJwATg7dj62g7Zi4lDcrtCtdoMdpCMgLzgW3 Ma1++mi265nBf+q+VbleLO4NSyt/9i7z9+dXHGIfCEwDynZyyo9IgFg9m82SDmFdoovN pxq2ZrIprI9VCoj71kN2Ljd5vmt9A1X64tCl0qA/GgmUoQ1qX7V2rbDsz607w6Fbq4mg FoCVv6uyC4tY3aPh2AmfJjqBxhRtakZcT0D+aSR18A5fN4spmESj58AHtXeDlpbztra4 ow== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3n87nt4a3f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 24 Jan 2023 01:36:54 +0000 Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 30NNPUWI001439 for ; Tue, 24 Jan 2023 01:36:54 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2046.outbound.protection.outlook.com [104.47.66.46]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3n86gakvta-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 24 Jan 2023 01:36:54 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FvwvSMz6I+X+WLP7ySLrxd52ohALUavIQSddLUjHke9DWB3ymZaEF31PAxalc1lpz+52/8S5h2yky/D/HVC1UyGIQ9wQkktDskoP3bzC0dTGo2AEq8bkkSg6o1dN6tsJsPvoeRdFHo4tN0iY1iQ2sVC6FcKUU3/cOjh/RBTEnYxG+FL1d/3XropyzheYb43wo4pc57d5scSTcId68CVF1+BIi+jHkgXgXvUSpJwmE5rxGB1dAPievEy7uwBf0F64eymJhLwQUPpBJGR9fa0+zmgs+TKEX2ePzlvhn520r44Oaczjagot/oLsjL3n0Jj7Vr3HpXtREiD6sZIivSVu1A== 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=UojYfovIOMxEVbXz2q9zgrlM284fM2bX8USyuISAM6c=; b=S/FnEr4DJW/1XqJCyo9cNCtv2pHdQeZxPdnym5Y1ePmpNJYbNMmtjwD/pCwIOCEhCXd6EoIfjhNPLrUH9Up1m6mRVo65jxow7WmJbPSuNY625W4zYvDO4zwLox8rhfV/VwfVFWanIsj9nk+kKNzJOdsGrZixXx1jmed18ELQQeBwDmdpIxRRgeVlsnfSEMp928N3v3EuH5NplmXw/5zM11FYGsi8vOtcikcmxYwAlwy0D8PIXQA6T2bIBnq+b4m84NwMtyumhYzqNMfkG8DJ+M+2eV2lFbNujnHerAOhpGVH+GzDhZBwRImYIWVtxIMT5XeILCgoqn9268Ct6BKXOw== 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=UojYfovIOMxEVbXz2q9zgrlM284fM2bX8USyuISAM6c=; b=qiEsNT7Lg9XOC4DZHRCoin54YJUdnD5nS5otRUh0+PaupTgMmRuediCLZG6B7kf97/VSRfxWV+YZDNMh3yGxZSjudQIERFp4+zOBzGvnqriQKeyCW3oGlDd9pO/zXd8tKFOuM7UGqYJ+Kce8xeJxPkawYf8JgFOD1oh4eVnVWgI= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by SN7PR10MB7074.namprd10.prod.outlook.com (2603:10b6:806:34c::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.8; Tue, 24 Jan 2023 01:36:53 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::eaff:9f55:4641:db38]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::eaff:9f55:4641:db38%4]) with mapi id 15.20.6043.016; Tue, 24 Jan 2023 01:36:53 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v8 19/27] xfs: Indent xfs_rename Date: Mon, 23 Jan 2023 18:36:12 -0700 Message-Id: <20230124013620.1089319-20-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230124013620.1089319-1-allison.henderson@oracle.com> References: <20230124013620.1089319-1-allison.henderson@oracle.com> X-ClientProxiedBy: SJ0PR05CA0147.namprd05.prod.outlook.com (2603:10b6:a03:33d::32) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY5PR10MB4306:EE_|SN7PR10MB7074:EE_ X-MS-Office365-Filtering-Correlation-Id: c905d523-3f47-436a-98be-08dafdab787d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: p6JDxGUdGSiNCXS934DmX0zu36dxBP5tKaWnz/LmhqY3UWckdPDueHMcYG9AXTdQA/4SlAiXo3BjADbCxDjAHtZXllNubAiU0ZTOzkRstoMTwLJnyBRn+PzsJhVB5bJ6VVrHPCy62DKVJOJFftgqcKI4n7lS3GHK3aoxV6db8/2CwbtgUW0XuNdqY16GhRHxUMMXyU6Q5W3Sf49vHi02LBsM1glJTPpNQ5u53eDUEIc9a5zHbr/1Lt2xHua12EQrB+Pwb+j8TlKt/j2gDanHW2A6xcZlsPS3u8LtO6JaKpt0LDyJqI170T5ENAkZZhpsCRmWcZkHXLLGqATOh3MM0VL8HfoEVQGQbuCGTN07+o9wK76EES29m4mp85ym4X9HItR2oPzHC6mBuHFdn0Bs0cKZqm3fPc90/07K8NgbwL6v/4yQJN91DzXGgCfFketK7bWmMGUsi6MbShsdEkFvF3PgCi4iO+CWw9rw7CRU7uW6tappOxoJ5ar5S1jBzq+SkgKJw1Ig99EGjOx9BefGT52+tIjiCKiz2YmdQuX1gmbarZzs2V7dLbQnUQ3Qtu1E/3pXQ3XbW3Ly0AByzvw77o221xJ7wbMkziItVWEB5f5nMMf11dntGDxVRXHZhY5z/w3l1LGvQhWrgka4JYgEqg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(396003)(376002)(136003)(346002)(366004)(39860400002)(451199015)(66556008)(66476007)(83380400001)(6916009)(8676002)(66946007)(41300700001)(86362001)(36756003)(1076003)(316002)(2616005)(2906002)(38100700002)(5660300002)(8936002)(6512007)(6486002)(26005)(9686003)(186003)(478600001)(6506007)(6666004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: GQoq+HvQDg86uu0F0UZCrjQvrsiNuI/mN4uibtuZjuS9wmz9JBubFofvvc4iaBpuJRsjqOzybx1YypaXFCqNVDLVE4cnlnyyb5hTDAkWm/4+SJspNkN+skZq93sMBEdNUFHftwdoy4RLLgr6n6AKI/ApTjxt4mnLM9sV+/jhObufWjR3OPdQp/sdg2ebBnj9Zmv5/OJtVX4sZlmqjzA0ga9MgvwsfUVRON7K3JlYymLdYpb0vj6HYAqV9m+L7NThCiHogdWFW1q4g9C924s3UXrH7Su1rrROu6I7oRYtnVnrsPoAK+4DmfTH4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R2/npHmYsYATMLQm7nfMclBRg== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: c905d523-3f47-436a-98be-08dafdab787d X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jan 2023 01:36:53.0640 (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: m6KaAjEIte6+HCQycmTDkHR1E+qyLK0edBDkJXx/eLu9WA9GSiI/xI6d0ZpfgXEGGUH7fLN2aYL5h78SMWKwMUyla/tp1vdhzTlNB9amT9I= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR10MB7074 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-23_12,2023-01-23_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 phishscore=0 mlxlogscore=999 adultscore=0 mlxscore=0 suspectscore=0 spamscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301240010 X-Proofpoint-ORIG-GUID: L_ht6_PA1WMAKWIRPSeOGV5boy3CUYaZ X-Proofpoint-GUID: L_ht6_PA1WMAKWIRPSeOGV5boy3CUYaZ 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 f593f0c9227c..f07720ffe977 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -2898,26 +2898,27 @@ xfs_rename_alloc_whiteout( */ int xfs_rename( - struct user_namespace *mnt_userns, - struct xfs_inode *src_dp, - struct xfs_name *src_name, - struct xfs_inode *src_ip, - struct xfs_inode *target_dp, - struct xfs_name *target_name, - struct xfs_inode *target_ip, - unsigned int flags) -{ - struct xfs_mount *mp = src_dp->i_mount; - struct xfs_trans *tp; - struct xfs_inode *wip = NULL; /* whiteout inode */ - struct xfs_inode *inodes[__XFS_SORT_INODES]; - int i; - int num_inodes = __XFS_SORT_INODES; - bool new_parent = (src_dp != target_dp); - bool src_is_directory = S_ISDIR(VFS_I(src_ip)->i_mode); - int spaceres; - bool retried = false; - int error, nospace_error = 0; + struct user_namespace *mnt_userns, + struct xfs_inode *src_dp, + struct xfs_name *src_name, + struct xfs_inode *src_ip, + struct xfs_inode *target_dp, + struct xfs_name *target_name, + struct xfs_inode *target_ip, + unsigned int flags) +{ + struct xfs_mount *mp = src_dp->i_mount; + struct xfs_trans *tp; + struct xfs_inode *wip = NULL; /* whiteout inode */ + struct xfs_inode *inodes[__XFS_SORT_INODES]; + int i; + int num_inodes = __XFS_SORT_INODES; + bool new_parent = (src_dp != target_dp); + bool src_is_directory = + S_ISDIR(VFS_I(src_ip)->i_mode); + int spaceres; + bool retried = false; + int error, nospace_error = 0; trace_xfs_rename(src_dp, target_dp, src_name, target_name); From patchwork Tue Jan 24 01:36:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 13113275 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 AD0E4C61D97 for ; Tue, 24 Jan 2023 01:37:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231610AbjAXBhA (ORCPT ); Mon, 23 Jan 2023 20:37:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56818 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232446AbjAXBg7 (ORCPT ); Mon, 23 Jan 2023 20:36:59 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 79A9B1A483 for ; Mon, 23 Jan 2023 17:36:58 -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 30O04KGd013028 for ; Tue, 24 Jan 2023 01:36:57 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2022-7-12; bh=ZvAa1vpgiHUG/GPI0BrfiHFa2bGfSqyKqQb6WkHQ6+U=; b=N75BtUcuX8GwqsWh+Jj0e7XNunqsyuN5P0oa1mNq5B6W241Oj1M9d4AYgKl+Qw109NF5 1NtDESuTXD/jbIhDxtJxHeg7gYtk1Ks9QpgSoWN8O4lpciFUxFLbl6UQPltDL/v/wBPX 0v2LFu1LnNA4rdMXDe/3rHsgFl7WptnPrwMo0iarrV8zmw49wKppIULFlockNdIu2BZE pJEW4nGdfM1n5oHKQmO0XC/3HvEuJBb5hzIJ4LbPEROB03fFNLKg7vBV6K8BQLapnPwG Ib928NpM20tqxYF+Ob46anQ2focZFTKqKeudwKy1IGOz9rvZlqVWt+BtnfSjf0hs2t4N VA== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3n86fccby5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 24 Jan 2023 01:36:57 +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 30NN5GwS040221 for ; Tue, 24 Jan 2023 01:36:56 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2044.outbound.protection.outlook.com [104.47.66.44]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3n86g4a87u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 24 Jan 2023 01:36:56 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lpBEtHnRdJSLalcwsReQ6hWHWkx9fK4TOxllIeaEcW2kWoziInUCfSjPENBL4S7AGNGg1zqvyzoM3ZavdVR5EWyIIki0gPoiZ2mm/HEVIBSkKb3dq/HoEJbwNNGr1Zu4vJlSxei1Lw9e/pyfxSYsRTdA54ZUpM1N66y4dza4qUsw1heZ9d0djkgo2Gxg2qW57+gmCqNVmj8Cq5SGw/ihP9ZkOrKQOe3y1NDSO33P1HqJ9/Hj8NdFZb8ydP4TpJOcXTKaMWK5GCXcwl7gG0DqvUa3lA8Rmb6ZIGjjMCVqpzLPJ65Y3DMuL8isaCXxpYAbtAqgU4Yv3i+XJ0TEwuNGuw== 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=ZvAa1vpgiHUG/GPI0BrfiHFa2bGfSqyKqQb6WkHQ6+U=; b=L83I2HJEG4W4WTH0ZPzl2ao+NRkFe81CO4Rb37zuTc7eU0JutfVi5Lw1uh1+BBUVhj7QGF0/hFS/SWemerVoL4/posGj6NwvjrYVUJu6m/0ISdj+gRVb92473iy75ll2tozBwo/UySV7YL6NDQ/brJoEcNZSz4IwN5hLzjp4tiAa4gBfYZCJbjNPOtuZGB0gyF39JBboQVIZutaF1ErUyNDOX//nQy7sToV8QrzDMW0kN2VYFhk67WfJ4NwX6T2yVwLgQrSe9i6GrAx30QkjXbcu1y0JuYFq4VHigVWuRrIc9w2+ZYTBX5lhM3gq+ffdDeuqlExLNq7xBQhprQ1gOA== 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=ZvAa1vpgiHUG/GPI0BrfiHFa2bGfSqyKqQb6WkHQ6+U=; b=rJf29JHr0ZR6l1nooAjYFiyJSi1L/0240T41dVCXlUr0Ki+XVjt6PIL0VjLuEVfSV3sMErYL9gx4ALitUyc/PuN6WW1DEsHvop5dG9lot+ObE3LI48XPaleURXsGj/IFHoYKKiDyWckvzAGzItvj5bXHyvpudmIaW/bQnhPI8B4= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by SN7PR10MB7074.namprd10.prod.outlook.com (2603:10b6:806:34c::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.8; Tue, 24 Jan 2023 01:36:54 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::eaff:9f55:4641:db38]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::eaff:9f55:4641:db38%4]) with mapi id 15.20.6043.016; Tue, 24 Jan 2023 01:36:54 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v8 20/27] xfs: Add parent pointers to rename Date: Mon, 23 Jan 2023 18:36:13 -0700 Message-Id: <20230124013620.1089319-21-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230124013620.1089319-1-allison.henderson@oracle.com> References: <20230124013620.1089319-1-allison.henderson@oracle.com> X-ClientProxiedBy: SJ0PR05CA0150.namprd05.prod.outlook.com (2603:10b6:a03:33d::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_|SN7PR10MB7074:EE_ X-MS-Office365-Filtering-Correlation-Id: 9ec70d14-8599-4342-f2bd-08dafdab7970 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: n9l8svYI4MJe3hDXyngPVRSHXBsD0+82DJXaFifcWp0wcgLcAEx8iBNuzBfglelBBKXJP3ydMxHbWbFPjK7YLUD0noNu/UhFwwk97RKtICifiWuBGzltUnKtR5W/DHwf3jW0gSs62yhkZWoE2FsP2us4NABCP2010jnLvQy6b6cXMZRiTHAGYrlpf7nukuXgqo8R6NX4G/D162VBIfZQRzFc6DIW42EPKCocHb9kf07DCcbBUc8llXdx6yaxFpPaxo/t+Xlg35S6xFyGxSSSNtFAmGvsYd6WroDz3iey2trR/PMqM/b+Aly+wEV/jLTNJmyqCirsW7QtVmd/xA/QW/8vzrumnj1kRRkgNTV6oyNfAbxBSYfQ9LUuBw8H2V+CmyLA032ytdn3WUg1ermhkTIfOX4JVQelA3UVYHTN60retJH9UVtvreJXU5Uzp8gZfl8TPOvoJYqpGfmko564dJaIIdp93xy4HwhGPrP/Y6zDMFh+5+j7FpbYzDkKG17Rl37upeybat9uw/+Wfs33cjeryzJYgHC10uj6qLRdrJeHNf96HZ0huWMwgosW6JqGSlNC4TCpsY4QSbIWWSjj25TVjLfj2aK6fGiNdBk93e9yMdNjhCZBcnLAxcqn7fQRya5XEmIzlVl/+OJbTkM8kQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(396003)(376002)(136003)(346002)(366004)(39860400002)(451199015)(66556008)(66476007)(83380400001)(6916009)(8676002)(66946007)(41300700001)(86362001)(36756003)(1076003)(316002)(2616005)(2906002)(38100700002)(5660300002)(8936002)(6512007)(6486002)(26005)(9686003)(186003)(478600001)(6506007)(6666004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: xCV9WcsuSIe2vI7M0yLXjO7a9LbVUrRsB82J8W6DEAafGSaD2ugeUe580/2vN30ymctzuQZH/LFVkibwzdYJI9t8OOnC4dgleMa5gU1PQ3bSAx7tpUqEnVlIcpXKXWRPB7St+7djJp34vQ3oyiTs4XijD/ehgd7t4Z252gW+emeQ22nCU8wknjGtHG/l/4S0VSpltxsWJNjwlrk2srA4v1OJxVJbOXOxs/wbKgQBGxqalZtiDo8QncMaE1d4dFxNQZ5jrpjO9M4kmrIrEWQrNUa03QpPMGIuvp0iN9Z8dzaIXOP+1CZALXbeEgv2STkwutIWQuWabmQDNbWRrp437qnZTh++RB7jIis9XdUS70xAidX+TXXqAt0vGeQfA9kOWqVWh9YmQpH00S2pepP1cz2ZjOhCEKyOekKZHZzjqTJZZOfIhC8to52ZsPRKeZMg5TZgISLtb8VI8LeZhFn0hyZCqdhbFlaZmezpiNKaRRyOREn7dfH31ZFy2Ba0OQq/m+6gtAzKyidOQEiCFwKE8k4eoxc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X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 8bkS8PdQuzgw3/nLngqOajUhx+DaeTEDBakKCbjhvqCNLomjndsUvFsTiCjGiKh2PNMWnoYzc85mq8w6db38c6gyM16r+9kcd3NtZ0AMW3ZWsxAC47A2e6zz0zeKy1DRd+ZaJYDP8P3F4KPim7jRCFWSIbAQGsUU5aiFC+4VQwc2STVXhRKtF8gKU7nu5TgRyH9cBQjQkw0IkehalNaNu1iTG/pWKOIpRrWbhmblnKUIKODYI5dT0+tnYA6rDWDMV6tqaW2skMmTqyDU7hENryKkyDpeqr8VFsxjmIH4qWYkgbotrEiK/XMHPTnj+MATQSYzS+Ucq0jb+dYYH/2s+85Ag8EQqzniv/4PMlzDyoih5DJ007B854cSHiMNwj7kcE3eZnfZxlsmz8PCGaGakAt7CG6LD+/hG5AbgHsXa3uxUP9GxRf3XANTTJ16kLGGd29X3iO+4RV/Y8lN0IwmacqzU5ZC0sZtWPNgp/6nbI8BAGETO2k82eZjyBgkT1OmeZbOglL4ZAv0LrqqwJOqaeWgE0ZQm/YkPg2oKou5oz4dwqIkky57IhqdSKJcXWswVJadUBDgunEbrMjDhcxjyWLnSUdsuz2CLBI9Ei/tmj/tAkg+Sj4yzlFJ7cbB7ilzIXrBxjMcxgKKmXU5BtOjqDVvHPNl+cFalKmytmi2vg8J3cZL4G9ISI34pWXX6YOX9BM1ASVRLghGW3/vs85MMalID0oPLi++fYNkID8T6XPRnqHKlURseErmJVdicS4g/7voidBpE2xlZ6DnxMOCRg== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9ec70d14-8599-4342-f2bd-08dafdab7970 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jan 2023 01:36:54.6588 (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: 6xYkzbT25TGFFqTg82ojBYKFJNgQ4OYUk4GPzoVjvDUlLPDE0qgcQwKTqrYbNLAm9jvXoBxmWe78/cNIXIvCj5ZYq5p8bE8Toq7OWM4SFQM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR10MB7074 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-23_12,2023-01-23_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 bulkscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 spamscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301240010 X-Proofpoint-GUID: MPoP9XXx5tcnoxGf5TE96KKKszuP8iTG X-Proofpoint-ORIG-GUID: MPoP9XXx5tcnoxGf5TE96KKKszuP8iTG Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Allison Henderson This patch removes the old parent pointer attribute during the rename operation, and re-adds the updated parent pointer. In the case of xfs_cross_rename, we modify the routine not to roll the transaction just yet. We will do this after the parent pointer is added in the calling xfs_rename function. Signed-off-by: Allison Henderson --- fs/xfs/libxfs/xfs_attr.c | 2 +- fs/xfs/libxfs/xfs_attr.h | 1 + fs/xfs/libxfs/xfs_parent.c | 31 ++++++++++++ fs/xfs/libxfs/xfs_parent.h | 6 +++ fs/xfs/libxfs/xfs_trans_space.h | 2 - fs/xfs/xfs_inode.c | 89 ++++++++++++++++++++++++++++++--- 6 files changed, 122 insertions(+), 9 deletions(-) diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c index a8db44728b11..57080ea4c869 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -923,7 +923,7 @@ xfs_attr_defer_add( } /* Sets an attribute for an inode as a deferred operation */ -static int +int xfs_attr_defer_replace( struct xfs_da_args *args) { diff --git a/fs/xfs/libxfs/xfs_attr.h b/fs/xfs/libxfs/xfs_attr.h index 033005542b9e..985761264d1f 100644 --- a/fs/xfs/libxfs/xfs_attr.h +++ b/fs/xfs/libxfs/xfs_attr.h @@ -546,6 +546,7 @@ int xfs_attr_get_ilocked(struct xfs_da_args *args); int xfs_attr_get(struct xfs_da_args *args); int xfs_attr_defer_add(struct xfs_da_args *args); int xfs_attr_defer_remove(struct xfs_da_args *args); +int xfs_attr_defer_replace(struct xfs_da_args *args); int xfs_attr_set(struct xfs_da_args *args); int xfs_attr_set_iter(struct xfs_attr_intent *attr); int xfs_attr_remove_iter(struct xfs_attr_intent *attr); diff --git a/fs/xfs/libxfs/xfs_parent.c b/fs/xfs/libxfs/xfs_parent.c index c09f49b7c241..954a52d6be00 100644 --- a/fs/xfs/libxfs/xfs_parent.c +++ b/fs/xfs/libxfs/xfs_parent.c @@ -142,6 +142,37 @@ xfs_parent_defer_remove( return xfs_attr_defer_remove(args); } + +int +xfs_parent_defer_replace( + struct xfs_trans *tp, + struct xfs_parent_defer *new_parent, + struct xfs_inode *old_dp, + xfs_dir2_dataptr_t old_diroffset, + struct xfs_name *parent_name, + struct xfs_inode *new_dp, + xfs_dir2_dataptr_t new_diroffset, + struct xfs_inode *child) +{ + struct xfs_da_args *args = &new_parent->args; + + xfs_init_parent_name_rec(&new_parent->old_rec, old_dp, old_diroffset); + xfs_init_parent_name_rec(&new_parent->rec, new_dp, new_diroffset); + new_parent->args.name = (const uint8_t *)&new_parent->old_rec; + new_parent->args.namelen = sizeof(struct xfs_parent_name_rec); + new_parent->args.new_name = (const uint8_t *)&new_parent->rec; + new_parent->args.new_namelen = sizeof(struct xfs_parent_name_rec); + args->trans = tp; + args->dp = child; + + ASSERT(parent_name != NULL); + new_parent->args.value = (void *)parent_name->name; + new_parent->args.valuelen = parent_name->len; + + args->hashval = xfs_da_hashname(args->name, args->namelen); + return xfs_attr_defer_replace(args); +} + void xfs_parent_cancel( xfs_mount_t *mp, diff --git a/fs/xfs/libxfs/xfs_parent.h b/fs/xfs/libxfs/xfs_parent.h index 1c506532c624..9021241ad65b 100644 --- a/fs/xfs/libxfs/xfs_parent.h +++ b/fs/xfs/libxfs/xfs_parent.h @@ -12,6 +12,7 @@ */ struct xfs_parent_defer { struct xfs_parent_name_rec rec; + struct xfs_parent_name_rec old_rec; struct xfs_da_args args; }; @@ -27,6 +28,11 @@ int xfs_parent_init(xfs_mount_t *mp, struct xfs_parent_defer **parentp); int xfs_parent_defer_add(struct xfs_trans *tp, struct xfs_parent_defer *parent, struct xfs_inode *dp, struct xfs_name *parent_name, xfs_dir2_dataptr_t diroffset, struct xfs_inode *child); +int xfs_parent_defer_replace(struct xfs_trans *tp, + struct xfs_parent_defer *new_parent, struct xfs_inode *old_dp, + xfs_dir2_dataptr_t old_diroffset, struct xfs_name *parent_name, + struct xfs_inode *new_ip, xfs_dir2_dataptr_t new_diroffset, + struct xfs_inode *child); int xfs_parent_defer_remove(struct xfs_trans *tp, struct xfs_inode *dp, struct xfs_parent_defer *parent, xfs_dir2_dataptr_t diroffset, diff --git a/fs/xfs/libxfs/xfs_trans_space.h b/fs/xfs/libxfs/xfs_trans_space.h index b5ab6701e7fb..810610a14c4d 100644 --- a/fs/xfs/libxfs/xfs_trans_space.h +++ b/fs/xfs/libxfs/xfs_trans_space.h @@ -91,8 +91,6 @@ XFS_DQUOT_CLUSTER_SIZE_FSB) #define XFS_QM_QINOCREATE_SPACE_RES(mp) \ XFS_IALLOC_SPACE_RES(mp) -#define XFS_RENAME_SPACE_RES(mp,nl) \ - (XFS_DIRREMOVE_SPACE_RES(mp) + XFS_DIRENTER_SPACE_RES(mp,nl)) #define XFS_IFREE_SPACE_RES(mp) \ (xfs_has_finobt(mp) ? M_IGEO(mp)->inobt_maxlevels : 0) diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index f07720ffe977..a24043804c33 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -2867,7 +2867,7 @@ xfs_rename_alloc_whiteout( int error; error = xfs_create_tmpfile(mnt_userns, dp, S_IFCHR | WHITEOUT_MODE, - false, &tmpfile); + xfs_has_parent(dp->i_mount), &tmpfile); if (error) return error; @@ -2893,6 +2893,31 @@ xfs_rename_alloc_whiteout( return 0; } +static unsigned int +xfs_rename_space_res( + struct xfs_mount *mp, + struct xfs_name *src_name, + struct xfs_parent_defer *target_parent_ptr, + struct xfs_name *target_name, + struct xfs_parent_defer *new_parent_ptr, + struct xfs_inode *wip) +{ + unsigned int ret; + + ret = XFS_DIRREMOVE_SPACE_RES(mp) + + XFS_DIRENTER_SPACE_RES(mp, target_name->len); + + if (new_parent_ptr) { + if (wip) + ret += xfs_pptr_calc_space_res(mp, src_name->len); + ret += 2 * xfs_pptr_calc_space_res(mp, target_name->len); + } + if (target_parent_ptr) + ret += xfs_pptr_calc_space_res(mp, target_name->len); + + return ret; +} + /* * xfs_rename */ @@ -2919,6 +2944,11 @@ xfs_rename( int spaceres; bool retried = false; int error, nospace_error = 0; + xfs_dir2_dataptr_t new_diroffset; + xfs_dir2_dataptr_t old_diroffset; + struct xfs_parent_defer *new_parent_ptr = NULL; + struct xfs_parent_defer *target_parent_ptr = NULL; + struct xfs_parent_defer *wip_parent_ptr = NULL; trace_xfs_rename(src_dp, target_dp, src_name, target_name); @@ -2942,10 +2972,26 @@ xfs_rename( xfs_sort_for_rename(src_dp, target_dp, src_ip, target_ip, wip, inodes, &num_inodes); + if (xfs_has_parent(mp)) { + error = xfs_parent_init(mp, &new_parent_ptr); + if (error) + goto out_release_wip; + if (wip) { + error = xfs_parent_init(mp, &wip_parent_ptr); + if (error) + goto out_release_wip; + } + if (target_ip != NULL) { + error = xfs_parent_init(mp, &target_parent_ptr); + if (error) + goto out_release_wip; + } + } retry: nospace_error = 0; - spaceres = XFS_RENAME_SPACE_RES(mp, target_name->len); + spaceres = xfs_rename_space_res(mp, src_name, target_parent_ptr, + target_name, new_parent_ptr, wip); error = xfs_trans_alloc(mp, &M_RES(mp)->tr_rename, spaceres, 0, 0, &tp); if (error == -ENOSPC) { nospace_error = error; @@ -3118,7 +3164,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; @@ -3139,7 +3185,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; @@ -3212,14 +3258,38 @@ xfs_rename( */ if (wip) error = xfs_dir_replace(tp, src_dp, src_name, wip->i_ino, - spaceres, NULL); + spaceres, &old_diroffset); else error = xfs_dir_removename(tp, src_dp, src_name, src_ip->i_ino, - spaceres, NULL); + spaceres, &old_diroffset); if (error) goto out_trans_cancel; + if (new_parent_ptr) { + if (wip) { + error = xfs_parent_defer_add(tp, wip_parent_ptr, + src_dp, src_name, + old_diroffset, wip); + if (error) + goto out_trans_cancel; + } + + error = xfs_parent_defer_replace(tp, new_parent_ptr, src_dp, + old_diroffset, target_name, target_dp, + new_diroffset, src_ip); + if (error) + goto out_trans_cancel; + } + + if (target_parent_ptr) { + error = xfs_parent_defer_remove(tp, target_dp, + target_parent_ptr, + new_diroffset, target_ip); + if (error) + goto out_trans_cancel; + } + xfs_trans_ichgtime(tp, src_dp, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG); xfs_trans_log_inode(tp, src_dp, XFS_ILOG_CORE); if (new_parent) @@ -3234,6 +3304,13 @@ xfs_rename( out_unlock: xfs_iunlock_rename(inodes, num_inodes); out_release_wip: + if (new_parent_ptr) + xfs_parent_cancel(mp, new_parent_ptr); + if (target_parent_ptr) + xfs_parent_cancel(mp, target_parent_ptr); + if (wip_parent_ptr) + xfs_parent_cancel(mp, wip_parent_ptr); + if (wip) xfs_irele(wip); if (error == -ENOSPC && nospace_error) From patchwork Tue Jan 24 01:36:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 13113277 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 2E626C05027 for ; Tue, 24 Jan 2023 01:37:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232519AbjAXBhF (ORCPT ); Mon, 23 Jan 2023 20:37:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56854 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232446AbjAXBhD (ORCPT ); Mon, 23 Jan 2023 20:37:03 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 748C81ABFA for ; Mon, 23 Jan 2023 17:37:00 -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 30O04lcx018879 for ; Tue, 24 Jan 2023 01:36:59 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=SZuvOWx9oe2yo3gJy7a41A0MryTdn5owTk5HVwD2v2U=; b=YoogCBkWpVoS1+09ZM4z/54sVwr2g9bn5JenW3By7Zt5b4oWeaYl2wZVMdQb+GderNIF QemMQYR4KK8tSMKv/8xPu0X6ayZmWhyIlra1IS9Qm5rInBOeeQSXjrmg4M5o5QmS/hJ3 fth67sXSY2IE73AjKQr3sMLd6V0zUpS2DVY9K7wLaZgg44FflfAbazRyL4Gpr+OJn79R /TmGGwy6APLY8eXfIpm4mvdL3WYD96VyL6qzN+EYlpYyrbT/OPCCWrR6mayasuneGbnJ eg+5/3cFjYOQ2kJ936zJqAX4zxPiaowD6gq/JjH9XP/eJaxLvcFJx9kvU6dJMDh1OZhk VA== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3n87nt4a3m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 24 Jan 2023 01:36:59 +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 30O1ITra039678 for ; Tue, 24 Jan 2023 01:36:58 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2047.outbound.protection.outlook.com [104.47.66.47]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3n86gb4b63-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 24 Jan 2023 01:36:58 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VmdRnJT6HgrxA69oAwPxLhDZZigxu8AIG2FkcYaTMHwni+C6pwZ10jNpqdp+nAE/BMCk4KYfOTyTPOt3DPfzUqHx/6R7n1hndicUM1CExfEHJCumHuv5V5cBtfB2dSvwN0t9Jr1i3XZ1zYhyQNtHFuUevm0bNVfYKRuXRswIpNrgmFpdaNfsdMLpPNRdSTREiTR7JcGKP1DIQeGwwlVN1OET+J7nJjcC44brIoktJ1R7dslTq8U+WUVovCbvIvW7y0pRr+vtghUtJMDdgbToAYJeczNzpbMXmUN/6oLKxtAgBNNMPK84O3e+Wouu2FdKno0eQAhUREwLkJL7lo9n+w== 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=SZuvOWx9oe2yo3gJy7a41A0MryTdn5owTk5HVwD2v2U=; b=fqHR8VOE5E+Revuxxgqs/9sM76CDg+ACmmqkulR8n1uaaR3dz1/rDpQGrsG0hyamNEthBhMjyfp0G5YmtFbIX4tseRnwb+oansp+Pe8GsLH2S2c2wvJTC7ul+q3TgS993i9ehxsH+NYl6uQaOqM3geMdLBRVzxbqFp/kQqn5TaNlaeSZvxqkPlPPt2weihhB3sER/z/ad99z+zJLiNi3nUoTr97sYQlAwE9GvYrQMD073Rf7P9AfPc+7OxLfKqsw1lspVV8HqtSNhufdk/7m5KTtH+9/O2d1UMZ/5ZPceXoM8xqUXf4KfhululuEj/MQa9Fk4PwL8Yi4Hg3eu1BqnQ== 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=SZuvOWx9oe2yo3gJy7a41A0MryTdn5owTk5HVwD2v2U=; b=pTAHI/cXHm2MHrXTbA288QhG1ZiT2m0jVYTUrshk+6Mg1pPndcsjsND9LLVAFJG8M+Aesm4ZfoAGc9oZ/cKSjFavI5WnIR1VEGzmQk8A6sQ1p1vtVNFcRF62Q1lYGhhcyQabe333BmLqlsZTw/l/MZzaNV/Yu7Ng9czBwsS1b58= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by SN7PR10MB7074.namprd10.prod.outlook.com (2603:10b6:806:34c::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.8; Tue, 24 Jan 2023 01:36:56 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::eaff:9f55:4641:db38]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::eaff:9f55:4641:db38%4]) with mapi id 15.20.6043.016; Tue, 24 Jan 2023 01:36:56 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v8 21/27] xfs: Add parent pointers to xfs_cross_rename Date: Mon, 23 Jan 2023 18:36:14 -0700 Message-Id: <20230124013620.1089319-22-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230124013620.1089319-1-allison.henderson@oracle.com> References: <20230124013620.1089319-1-allison.henderson@oracle.com> X-ClientProxiedBy: SJ0PR05CA0144.namprd05.prod.outlook.com (2603:10b6:a03:33d::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_|SN7PR10MB7074:EE_ X-MS-Office365-Filtering-Correlation-Id: 8b7a6e8f-3809-4e04-34fc-08dafdab7a6d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: gOI7ppQFH8+zFCD02NJFubkGwqVmVj809Z/xCbphpmtAaTvNdrNJUcl5TW6BAEtdN4BnG+KSSuBmAbhTkOQzPT2x4lI/zOu9hG9JxWyuAu0YCcqZ85jLwE1vx9u4im70gbodobrkRUPfbIopWmAD51LjDkG0DzVwivyZ2NaWmvOVTT9sJgRL80n8KuuwhfDrNhGKPyQm8FXKGgUyFGiMONGOgAzQrQXXBJzcCxuirDgR/v7UpWzym2+wKo2KSmTD7nguiB/xjOVd51AOAq532LAWFRc7EJWMBHmB6NoEk5KIyTfrIJPiZefhW9g0zc+tBN9TI2LH/p6TJcKOjq0xxh7DToS/6obslreQE2eEFWQ+q4THUvVds9Q3ZM+WW2N1dOBlZLiWCw0asDHSK/rCaLapiG+7ceP37zgbfAqaPOfbwNUsADOJLs6P3gpNx9YwzhtgiCjKWKJw7YUI93bXl/q8fr4EPM4z1zMP/GzqknF3hUGB1VgGNcFdWkaV1dHfJi62o8ollT8Kx+TFR9fr1qT3A3Cj1QSC4GHFKHm9r1EGJdd56X0M+JFDEy02S1/BI05C0xwkpDZBVbs/mZIcky1cJbNe0/xSXEGXEi+bsPfvdnJNKwUd1AstOtWFVT5VskKvP0vrPGFt8EdyI8jagA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(396003)(376002)(136003)(346002)(366004)(39860400002)(451199015)(66556008)(66476007)(83380400001)(6916009)(8676002)(66946007)(41300700001)(86362001)(36756003)(1076003)(316002)(2616005)(2906002)(38100700002)(5660300002)(8936002)(6512007)(6486002)(26005)(9686003)(186003)(478600001)(6506007)(6666004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: vrrDl+rXhhiVmDt/W7n8WTp/KO7CASY0l7AJHLx13b3WxKySjg0h4VeB1U/cZGngdrlAZYbcB9qS8cb836o5wbP4NkxBcj4qnOoDXhKKSgxRjZ2l+1zfnOogCJ6sd9MV+dTz8T5udUvIeRbJQCJf5xAt7MWmGo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nKGGaMtQJEZSVDL0YlX7U1uWvXKyD1gNaq5ieUP8D4rd620xeC6HSm3W51dEzNbEtSVLOrWqdcl8u9y7pE/k8elJo/RBUo/X8wmdp4f3oXVx+CPw7x1ppkc2sXNEcM2lhTHPCq0iuFXV91TSdyfaQ== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8b7a6e8f-3809-4e04-34fc-08dafdab7a6d X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jan 2023 01:36:56.4539 (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: kHYkqewRmEUgkNtDT71tjTHX8CUDG35K79hUzkOx4fcSnoR3NzBs0HqwhEYXljv2lRjLLQNOWOKE9JDOrYU7Yruw4PaHvBE1+eVy4zVDr5Y= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR10MB7074 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-23_12,2023-01-23_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 mlxscore=0 spamscore=0 bulkscore=0 mlxlogscore=999 malwarescore=0 adultscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301240010 X-Proofpoint-ORIG-GUID: SNg9JNBVM-ToNhWriI_3WdAPKeDzAcFs X-Proofpoint-GUID: SNg9JNBVM-ToNhWriI_3WdAPKeDzAcFs Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Allison Henderson Cross renames are handled separately from standard renames, and need different handling to update the parent attributes correctly. Signed-off-by: Allison Henderson --- fs/xfs/xfs_inode.c | 64 ++++++++++++++++++++++++++++++++++------------ 1 file changed, 48 insertions(+), 16 deletions(-) diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index a24043804c33..54cfc1a6d629 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -2745,27 +2745,40 @@ xfs_finish_rename( */ STATIC int xfs_cross_rename( - struct xfs_trans *tp, - struct xfs_inode *dp1, - struct xfs_name *name1, - struct xfs_inode *ip1, - struct xfs_inode *dp2, - struct xfs_name *name2, - struct xfs_inode *ip2, - int spaceres) -{ - int error = 0; - int ip1_flags = 0; - int ip2_flags = 0; - int dp2_flags = 0; + struct xfs_trans *tp, + struct xfs_inode *dp1, + struct xfs_name *name1, + struct xfs_inode *ip1, + struct xfs_inode *dp2, + struct xfs_name *name2, + struct xfs_inode *ip2, + int spaceres) +{ + struct xfs_mount *mp = dp1->i_mount; + int error = 0; + int ip1_flags = 0; + int ip2_flags = 0; + int dp2_flags = 0; + int new_diroffset, old_diroffset; + struct xfs_parent_defer *parent_ptr = NULL; + struct xfs_parent_defer *parent_ptr2 = NULL; + + if (xfs_has_parent(mp)) { + error = xfs_parent_init(mp, &parent_ptr); + if (error) + goto out_trans_abort; + error = xfs_parent_init(mp, &parent_ptr2); + if (error) + goto out_trans_abort; + } /* Swap inode number for dirent in first parent */ - error = xfs_dir_replace(tp, dp1, name1, ip2->i_ino, spaceres, NULL); + error = xfs_dir_replace(tp, dp1, name1, ip2->i_ino, spaceres, &old_diroffset); if (error) goto out_trans_abort; /* Swap inode number for dirent in second parent */ - error = xfs_dir_replace(tp, dp2, name2, ip1->i_ino, spaceres, NULL); + error = xfs_dir_replace(tp, dp2, name2, ip1->i_ino, spaceres, &new_diroffset); if (error) goto out_trans_abort; @@ -2826,6 +2839,18 @@ xfs_cross_rename( } } + if (xfs_has_parent(mp)) { + error = xfs_parent_defer_replace(tp, parent_ptr, dp1, + old_diroffset, name2, dp2, new_diroffset, ip1); + if (error) + goto out_trans_abort; + + error = xfs_parent_defer_replace(tp, parent_ptr2, dp2, + new_diroffset, name1, dp1, old_diroffset, ip2); + if (error) + goto out_trans_abort; + } + if (ip1_flags) { xfs_trans_ichgtime(tp, ip1, ip1_flags); xfs_trans_log_inode(tp, ip1, XFS_ILOG_CORE); @@ -2840,10 +2865,17 @@ xfs_cross_rename( } xfs_trans_ichgtime(tp, dp1, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG); xfs_trans_log_inode(tp, dp1, XFS_ILOG_CORE); - return xfs_finish_rename(tp); + error = xfs_finish_rename(tp); + goto out; out_trans_abort: xfs_trans_cancel(tp); +out: + if (parent_ptr) + xfs_parent_cancel(mp, parent_ptr); + if (parent_ptr2) + xfs_parent_cancel(mp, parent_ptr2); + return error; } From patchwork Tue Jan 24 01:36:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 13113276 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 98776C25B50 for ; Tue, 24 Jan 2023 01:37:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232479AbjAXBhE (ORCPT ); Mon, 23 Jan 2023 20:37:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56856 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232339AbjAXBhD (ORCPT ); Mon, 23 Jan 2023 20:37:03 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2ACBC1ABD9 for ; Mon, 23 Jan 2023 17:37:01 -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 30O04UI7021115 for ; Tue, 24 Jan 2023 01:37: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=lIC8fdeyODQX4149WUoke6Xnl+AOfMDBbJODIBnqukw=; b=MmcTiS6LNlsK2nLlgjz3iJnVXUEtY02SM291h1WcZsoJ421fSARiFxfGMrzP8g8FJobF V+CjBlCWT3n+ee2lFT0+cID7idOi6gs/AB+FAf50mRF2MLOoXMAfSkXGtVH7u3ZOm59n HgmPSdMCpdFNtL/MCYbg8VRPcBUmOEuaFmI0bu2+pj6nxELMUhLGp58u05L0jgck7jOx inY+T6G0Bbozza8b3jVYZlrEPolh94oCnxy2wq0GldiYbsINvqexFy82hJygZcUeX6JI xSUQt84ard6kC2yatGfT0KVsCObnYukkwW7FUvUvhIpuzytb9W5OgOW+3GXbdz+l1+CE 3Q== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3n87xa4a1s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 24 Jan 2023 01:37:00 +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 30O1ITrb039678 for ; Tue, 24 Jan 2023 01:36:59 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2047.outbound.protection.outlook.com [104.47.66.47]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3n86gb4b63-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 24 Jan 2023 01:36:59 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oAQhmMrzHKv5pwoTTUpcYf1k+GHL6M2Z8dunjUuz3zNg1MDOfdAbPwBdHcGKky8z9eEmmxGy+AL5CjmoLw4XsLALgiFvVjyEXfHmD912Ewm3P0AGyeJL4v/Uz31tEEFRJPyHG77NecH8ukZojamZA6ccwAn2Vs89Vm7BNd9nHI46cisPdQOBzatzlOEshFvlwEbHPOGOnZXhrDqT1JuXYPYqgT3OsmX6lsk/Be9ohn2g8OIQ0KGlpKjQWS5eyTz903l1JYUbu5yvsY46cLA/5ykxO5Fbl/WBERMz+l8R1VQ3bmxqt5My/mjJuYK3VnMICqKj5B5LRGq8f92j9AtGLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=lIC8fdeyODQX4149WUoke6Xnl+AOfMDBbJODIBnqukw=; b=Pb5l1DPZ5vqnpRVg1tZIxnlGi9A0kOjmMBt+9HrqXZJqZNVLsq53MSdvj4qFwA5e5GO10743aeXEX0tt0/wKNSmDgy3k21DSqg0/2CquvalM7dlW6EXPriYiCa511al/QQoj2Dp5NxPrjwep49TwbPDoayGhB21xdkT/FWVOA7GQXOKwS5L6jbwT5rFLMODlOf3XDGde52ERKoI9+7gqfERB5BxEr7/5+UMuxi8q8/yOAYTEq2yuGntafj7s9FMd6rZnaEXAEMOdEW2Pc6CapM7vaLFvrjZZASZwVGArFd5Ptv8/tO5mpJnhm5RFbGtE7juS8nUeSrt2VSLlPWkb2A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=lIC8fdeyODQX4149WUoke6Xnl+AOfMDBbJODIBnqukw=; b=CVCtMWNVqeBWfhYKcGmf9brCKSsE9YX/KNNhClNtZ9eXlziT6a2iN4fXve1nXdT7Q88rdRCsKAKmqtXlrMRZBO/xmiR2nXSpuojIvGOpJ/LsUz4MFmE251CMXqqyQXoP5NHUI+SlZVo8QaF3HT7W5cWr8cf6abOC8lHex3bhHTE= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by SN7PR10MB7074.namprd10.prod.outlook.com (2603:10b6:806:34c::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.8; Tue, 24 Jan 2023 01:36:58 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::eaff:9f55:4641:db38]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::eaff:9f55:4641:db38%4]) with mapi id 15.20.6043.016; Tue, 24 Jan 2023 01:36:57 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v8 22/27] xfs: Add the parent pointer support to the superblock version 5. Date: Mon, 23 Jan 2023 18:36:15 -0700 Message-Id: <20230124013620.1089319-23-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230124013620.1089319-1-allison.henderson@oracle.com> References: <20230124013620.1089319-1-allison.henderson@oracle.com> X-ClientProxiedBy: SJ0PR05CA0142.namprd05.prod.outlook.com (2603:10b6:a03:33d::27) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY5PR10MB4306:EE_|SN7PR10MB7074:EE_ X-MS-Office365-Filtering-Correlation-Id: d60b409d-0451-4549-eba2-08dafdab7b56 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: c9Jb/TDve4iQcyQbnPZkd/19EHk//yWA3b+6gRItn40OYtTFgZ7pJ69GhqWzuyH3s8u/YXnYA56Wkoh2F9I5pKq74XLIVrqcFWCrMtnIg8CtAII2CyBZz4tekISA7rr4YLQHvBqJY8LMtZb0TPWAAjFxim24VSrDCyxPZXNoYmlWy8m2O1OCwOgRaN9Vhk4E1isV5E3/iRL6HKP4BQSKhMWYwTWQQKQ6sTKyfECqG8mslmwfO7nATkGz0cNtAWJcAVSaV9hw8brsfq7iH44uDAh25ctY2utHVwUeU7wL4rsut56JPi+6qwH/1R8usAwHRaJA/cMwSkf4TbC04t4CiEqkSPXt62kFeEE7twZxKkhtKLGXxsf18uWpToDP2zMvH+XJYSXX1dGYZSIXV6Ch8+b07vjpwcsk3VKN288/k+V6q68E6i8RyhwMqhF9gnEQxyVXKsXxCZpv8TreER/VryvSCgczK+PW0kgP8jCRXxvYktpatgrlRX4EfJ9NSmutaXjzvv3nD9G2km26uyxkjQOXBKystawnK8rw4lVX3AY2XJqGqMtL31Udb0MbGBGu2CZRpxuZw8oaemahA+ygG0mJWnp8pJbZkOQjzCmTvoFjtlvHWs32pD5vR+9ZXZ00rRxE7M88fEqTUnE1uqUtNQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(396003)(376002)(136003)(346002)(366004)(39860400002)(451199015)(66556008)(66476007)(83380400001)(6916009)(8676002)(66946007)(41300700001)(86362001)(36756003)(1076003)(316002)(2616005)(2906002)(38100700002)(5660300002)(8936002)(6512007)(6486002)(26005)(9686003)(186003)(478600001)(6506007)(6666004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: mS4lIhJ4rH5LnpPzLtoVcMxinL1Bu07cEFvKvHZlTWq3xjYQc+1vG2pEzBjrIq0CKIJcDUQuvnxBsBRz+Lk+kZyevNbcBZf1dwjP0DC2zjMPLT64mJkwI2TB74N3OTlO4toJyoZQ/3YYZFP1UF7l0UiiC3aVuwVpGTCiG8veymE0nT/IAuVCH6NNhUsveSX6Fhsppx6SpaT+WMJ7UxsCLkdAi48dtTPTkiETPMElnGR4eHZf8QKy9wPmKvJuDiuI5Z0sbBeRU1qeys3XPDTPGMprRqtO19L9y1rpc6s3LlOq8PXNDVk0Idq2YpWwaTqsefZ2gaPnKnXi7QewejCHmC1Bj2XDhtwuX4nf3N3quNH3m8dBdhYeVct0sF/9jQoXg20+woG6Sdz6jDageug3KcX0cz3jSvfde40GFwgeGgyBCizkbmsIj9nzJU28cxIoKY2JJIxyliMCpGjwstjnTsVGjGro5JNQoR9bNps/KTcaL0TWyUTMUHM6LY5bywoHaIKS9nVE6S3/qdj1tsfd0+93TOxYSRLnh0Ir4x+pbY0yUt7Ws4pzrqCvy5h4xat54JChFnICjTtI96B2/7OHijPUknpA6JWPxb14iyheIECt4aeWvO56jYmnTf18H4PQI1OpJBZ7jLZxdEcVt2/nTCotb+h1wLQe7N7BCaA3IfAkQlhtC3vwgCcNKEHkWomp97Z5M7ohsLLbxsx42rbO8WbbELfjvst6dBOV/VpkclWYmp3m+CvQYk1XtUwc2Q6qUBVkveqXOL80aNphDTIAiHGKXs/B2SlwxrsDxtuFtd5uXLGSCgQUAI/C1HgdNrZeATeYbqmrYG9D9JpQXp72N5gk+7H/sqefHddTtYNKKK802cEjNlKnDXs6Ntsf3osi853xGyXWrLrYcw0iZKH+8xUiVqj53oYV3okWJZOSOub24DPg8fo3UxQPLxAzpYlPlLa9vCjpimjw3Lud5zuENBPn3pJ0ryhYGDlqxQOFAs6knd1HhnPMXTqMh42dAS5IK7vOeOoiXtNTmM2Yze3nO3szHhlFV9OyrvcXgf9660umC3qtpLKGwcOXkCkdI88lP73Ww0n6keRzirkNwuollSvsu9vuQIjuQVH9odosM0B10u64EVfhoVh28D7YE9JQeGKvRpN/z3Qn62RqUNr+mpbvud/jrAVce7t+poOEQkk2MjALAIYrAAaSXu3xle5dkT1JB3TMeXPRIwRwrdK+dFbv/LS+fWNSQGGjHpdYanyzxjG9Xn414RGkGOUU1vl34y1Jv3UEBhlmFz1XK7dEfhSHiqt597p7HGX9HCUHD6Ad6CAzE2TMGmIsOM/74DbYXAwU0SJs9U+rwYkp+3jrm6hnRXJvg54swHuptvXeEMtumcL+VoeMTlKzvgKPvJkZGtyYYXzF4bfjAr4PBnbSRsJEZbVuU/U7JBlD06NlOADaaW0eqZsDdSloJwiV14iWXFCEGinFrcgVtxTFyKePbag/Y55HN9lXbXKh3ZJ3kUQBGBjLXxwargvc+GU89HYN/VX9efEy3uJhivA/uAmfiP1jlHxorzNkCw5RhH6NFK/uaMHp1xbNWVGoFEnvOiyo+1mBahkMPYPbzDKnHanNtg== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: ledAemPxpQwpkiKvyHm3eWsHb0vf3hl5NHTsYO1a3N/H8wmFR1DBdgdbC7D1/uJ17L6V6bOkKW7Jbf5K/u1myVvmd/i0x5IJ922gWksY1gRHTbint650Z5MYBooQNBemseWPAXbN5QrxtFcMzniHtS4D+lvOHEt9l6NiPgvMnZuVVDIFxrghUOKjiLy6zheK9mTaHuXsq6e2QOBreAksu1ZsRKx4ev+CsrjOCTG2FuQqzWTcqgtmB2kxLWl3v594ekRjVVQ276/zz20QTq17Poi+xaCF8bSI1IVTWsN+lPU2Tlc4AnRAlY3hLUZ7oATCbz/mv0VFZ1CRUdSfhOGGiLrU0pQs9iVRDOvgrDEMRqwKl6SEAPzAKR3Vg+/X09hJZm3hRCFLUYnT5m9S7CDTPVNWRRh7+h5UuZoOvbAbFzdvOY/nL1yxhYRiYYiI1JAUYltzJABZRoKbD8CYpYDxno6MD+JeIZgac4NzZXah0azaMSRKpINd/pArS5Lg529RKU7MEi44qaJlQNGVGgsUUSdG6ZemaJ0fOIWJzYczW5p0eVZze/XKr74Uf5vOZCluHu+QvS8Cf6ZokcMV5ajKducLMjVN3zf69LFvWV9hSUjj2pz6FHqGBz5rZlqntYSuEOD3FdMke7NuI2tRgPtpUJ5Axku9eRjPXY7npXigcLsSzWgiMCqk7uPmvDtgftgMASPNnOZ4rUu126zUBT6YUgzbvW7m/JFMt5Q7CHTC3c7X2tbfRJXRizr+7zoUkfM/ZAb/62lBoZLbeDYbi92yag== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: d60b409d-0451-4549-eba2-08dafdab7b56 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jan 2023 01:36:57.8593 (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: R3TfN3oS+CA560VGFzd5YpP//MsGtaoBiTnL4zWrj1snv60Xs5SlKtH6NoOtQmZdfgS7Vvcnq9bD6/AtYNmxPBemhcqFFStGKdeX+wjkrrE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR10MB7074 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-23_12,2023-01-23_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 mlxscore=0 spamscore=0 bulkscore=0 mlxlogscore=999 malwarescore=0 adultscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301240010 X-Proofpoint-GUID: dN-VeWIVR2BbsL3VMiZU9e-Y2ZpVVBHK X-Proofpoint-ORIG-GUID: dN-VeWIVR2BbsL3VMiZU9e-Y2ZpVVBHK Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Allison Henderson Signed-off-by: Mark Tinguely Signed-off-by: Dave Chinner Signed-off-by: Allison Henderson Reviewed-by: Darrick J. Wong --- fs/xfs/libxfs/xfs_format.h | 4 +++- fs/xfs/libxfs/xfs_fs.h | 1 + fs/xfs/libxfs/xfs_sb.c | 4 ++++ fs/xfs/xfs_super.c | 4 ++++ 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/fs/xfs/libxfs/xfs_format.h b/fs/xfs/libxfs/xfs_format.h index 371dc07233e0..f413819b2a8a 100644 --- a/fs/xfs/libxfs/xfs_format.h +++ b/fs/xfs/libxfs/xfs_format.h @@ -373,13 +373,15 @@ xfs_sb_has_ro_compat_feature( #define XFS_SB_FEAT_INCOMPAT_BIGTIME (1 << 3) /* large timestamps */ #define XFS_SB_FEAT_INCOMPAT_NEEDSREPAIR (1 << 4) /* needs xfs_repair */ #define XFS_SB_FEAT_INCOMPAT_NREXT64 (1 << 5) /* large extent counters */ +#define XFS_SB_FEAT_INCOMPAT_PARENT (1 << 6) /* parent pointers */ #define XFS_SB_FEAT_INCOMPAT_ALL \ (XFS_SB_FEAT_INCOMPAT_FTYPE| \ XFS_SB_FEAT_INCOMPAT_SPINODES| \ XFS_SB_FEAT_INCOMPAT_META_UUID| \ XFS_SB_FEAT_INCOMPAT_BIGTIME| \ XFS_SB_FEAT_INCOMPAT_NEEDSREPAIR| \ - XFS_SB_FEAT_INCOMPAT_NREXT64) + XFS_SB_FEAT_INCOMPAT_NREXT64| \ + XFS_SB_FEAT_INCOMPAT_PARENT) #define XFS_SB_FEAT_INCOMPAT_UNKNOWN ~XFS_SB_FEAT_INCOMPAT_ALL static inline bool diff --git a/fs/xfs/libxfs/xfs_fs.h b/fs/xfs/libxfs/xfs_fs.h index 1cfd5bc6520a..b0b4d7a3aa15 100644 --- a/fs/xfs/libxfs/xfs_fs.h +++ b/fs/xfs/libxfs/xfs_fs.h @@ -237,6 +237,7 @@ typedef struct xfs_fsop_resblks { #define XFS_FSOP_GEOM_FLAGS_BIGTIME (1 << 21) /* 64-bit nsec timestamps */ #define XFS_FSOP_GEOM_FLAGS_INOBTCNT (1 << 22) /* inobt btree counter */ #define XFS_FSOP_GEOM_FLAGS_NREXT64 (1 << 23) /* large extent counters */ +#define XFS_FSOP_GEOM_FLAGS_PARENT (1 << 24) /* parent pointers */ /* * Minimum and maximum sizes need for growth checks. diff --git a/fs/xfs/libxfs/xfs_sb.c b/fs/xfs/libxfs/xfs_sb.c index 1eeecf2eb2a7..a59bf09495b1 100644 --- a/fs/xfs/libxfs/xfs_sb.c +++ b/fs/xfs/libxfs/xfs_sb.c @@ -173,6 +173,8 @@ xfs_sb_version_to_features( features |= XFS_FEAT_NEEDSREPAIR; if (sbp->sb_features_incompat & XFS_SB_FEAT_INCOMPAT_NREXT64) features |= XFS_FEAT_NREXT64; + if (sbp->sb_features_incompat & XFS_SB_FEAT_INCOMPAT_PARENT) + features |= XFS_FEAT_PARENT; return features; } @@ -1189,6 +1191,8 @@ xfs_fs_geometry( geo->flags |= XFS_FSOP_GEOM_FLAGS_BIGTIME; if (xfs_has_inobtcounts(mp)) geo->flags |= XFS_FSOP_GEOM_FLAGS_INOBTCNT; + if (xfs_has_parent(mp)) + geo->flags |= XFS_FSOP_GEOM_FLAGS_PARENT; if (xfs_has_sector(mp)) { geo->flags |= XFS_FSOP_GEOM_FLAGS_SECTOR; geo->logsectsize = sbp->sb_logsectsize; diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c index 0c4b73e9b29d..8f1e9b9ed35d 100644 --- a/fs/xfs/xfs_super.c +++ b/fs/xfs/xfs_super.c @@ -1663,6 +1663,10 @@ xfs_fs_fill_super( xfs_warn(mp, "EXPERIMENTAL Large extent counts feature in use. Use at your own risk!"); + if (xfs_has_parent(mp)) + xfs_alert(mp, + "EXPERIMENTAL parent pointer feature enabled. Use at your own risk!"); + error = xfs_mountfs(mp); if (error) goto out_filestream_unmount; From patchwork Tue Jan 24 01:36:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 13113279 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 14245C54E94 for ; Tue, 24 Jan 2023 01:37:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231511AbjAXBhG (ORCPT ); Mon, 23 Jan 2023 20:37:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56870 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232516AbjAXBhE (ORCPT ); Mon, 23 Jan 2023 20:37:04 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 41CB01A483 for ; Mon, 23 Jan 2023 17:37:03 -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 30O04h8f020122 for ; Tue, 24 Jan 2023 01:37: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=vsMvGLx8okHtK0olwwc7WZqMVdIoOvrBE31gaFSs1aE=; b=Ua1v1hUVaXOyPf7OPBfb0y9O1FjJpmM4KN+Tptxmz6u5FQzhP+4YmuiOR/OkX1EH5teA Y6wtVi2VutBqHIRTeD8hxXXxtOT9nIyRir/PMq/vw14M1c8HxIYL/KCLHVTAI5H5rhTG gwxWbC52XcKWjvLtHYliEGbwtydwCrRec2lsPSv4LGcqnz066gQm2bMwsbLvPc87wMVt I2/m6oD4/H8t8zm1mOjVuznjqa7JD4/WvPiEcXNDRiDOkOmgpqvvDfNj/958Znq4ezPF b7MkT/vTrAkoX3Nc2yikCeMZTABlSJAwVpKDz/1mZLD1hPKs+zyCG5KCUslP0ByZDBoQ Qg== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3n86ybcbj9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 24 Jan 2023 01:37:02 +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 30NNTBcG039914 for ; Tue, 24 Jan 2023 01:37:01 GMT Received: from nam02-sn1-obe.outbound.protection.outlook.com (mail-sn1nam02lp2048.outbound.protection.outlook.com [104.47.57.48]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3n86gb4b7k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 24 Jan 2023 01:37:01 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OCaIX5peg4oGE3/mXt8wrxE0rTdkJIthJKaIzDhsCbit7Qi/Oapf+PX7KpGSjmSgoIcarM1hHXjOi6twUfbGL3pjoN0IM8cspl2ceYToldiUvdv++IPBRQsIGXue/ynCYroLRja3+sx1sb/jHScatQjqd1Ew7fx/oVDOr+5iNDwEBKSLgZZ9gx9P8Ip0RDeoLcehCwcIpsxbOlWZDFzENrr8QWkN96WzO+luoG02DuaqvGjyxtztD7ixx0zNRORRIWtfEoWGw1wOAtczDgf69mWH19AJEIbjse3MAiLA9NXM+VyM5/1HqoCu+Djw6ks0qVzDpZ6bm/A6F/FlHvF3+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=vsMvGLx8okHtK0olwwc7WZqMVdIoOvrBE31gaFSs1aE=; b=LSXedEyZuMfb+VC2ElCgRuR5CtZr0+2INNwKHiB1KCp23S9ijiZEYnAg/yqSIskW9Vtw42EuSPbPJn9A88ufx4lxJjCJDwTC+rGa436b4tbOVUn23k6RBgvnkmM/xv+PYHJwPAmrH6F7jHLAXC89AqSqd2Po1NOgBPtq47B/R/V2bsIrLub6kjOzpnrYAvWbssHQyeMW35H7/vnYJSAWBhpeG9wDSsVI8i3W+VixuXOWC1ZFb7UV3AExS/rJdtwMpnH7w/FNxo8qRfZdhgOeJyT4quajIyebyptHsXdGqCnA15Ugot045QoKVPsEd4MJ1UoLlObTWdq/k5F2pU994A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=vsMvGLx8okHtK0olwwc7WZqMVdIoOvrBE31gaFSs1aE=; b=uHj2owC00FcLHGDRQIH0zmGhwgX42wwAX5dOoi7brUYZJiQu8NR7TVH44t6BbSPKqpfxCr8ZHTRldXT7jHvGbM/pvACz4H5WtJnV/Fexo9xZ/eliNR7/805AbqI/KxXvsnhAXV2fYCh1vejy1H2fhsBnmMJJS1M3amwp+JoGGEQ= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by SN7PR10MB7074.namprd10.prod.outlook.com (2603:10b6:806:34c::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.8; Tue, 24 Jan 2023 01:36:59 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::eaff:9f55:4641:db38]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::eaff:9f55:4641:db38%4]) with mapi id 15.20.6043.016; Tue, 24 Jan 2023 01:36:59 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v8 23/27] xfs: Add helper function xfs_attr_list_context_init Date: Mon, 23 Jan 2023 18:36:16 -0700 Message-Id: <20230124013620.1089319-24-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230124013620.1089319-1-allison.henderson@oracle.com> References: <20230124013620.1089319-1-allison.henderson@oracle.com> X-ClientProxiedBy: SJ0PR05CA0121.namprd05.prod.outlook.com (2603:10b6:a03:33d::6) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY5PR10MB4306:EE_|SN7PR10MB7074:EE_ X-MS-Office365-Filtering-Correlation-Id: 7c2dd9a8-76b0-4293-f7be-08dafdab7c5a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: pbUFdE4irPuuv8hjFCt3K3Yk41hz3tjaGG8/GYEnbLo0VMMqOvMLgIVSxV6lp8cndp3mS1/Cj7EqPyp9u3Y1se9YHzkJp/LkeYnQojtmSKUM3fC2uuYCJk/RK0Kckii9q2C/gkniOoAAyTh682ZzHrhehIDJ4S0abWWt9RcB4CLFBbCmDW8o5y4l8ZGzag9tfpMFFgQ9YAO3OdttyAig3iF3ccJ+clIP1t9Wrfp2w2zMCjwkvtnbKoilEPwxt1cJGo2xvwC20HiFl987NKp7L7Vz1i1WPmrcvGGSDgySEIPWGfKIxIedsfFRa7pubeRYLOw+WWcI+KdvJ54sq5f5KiIGk1Pdt/PS8De39LuhCp3Nlmpb/83xtFtJnWdXypMq1v+FhubnFOPeriyxmSxuE51rzPrhBeOpWyyTg+5fLQBUKKoMXIq9GxgTu3tCSKopDw2bQwsZruPsDHlt2bSdac7gYtGzLABoWoL6jMRLberndmxDOeVcmFHOkcrvEI4m9wrHmCUXdTXfX+lHQf0bJEVqes1CXNtKD64uFQA7ZhZpB+zb/cjukmcYIYOQR7+k3A8hlSSzZk096zFKk+1cWq6aYPe/XP39Vl+RyCFynjQuu0t/BSDFjLZz4FJrtr/CksSnvLx03gpmxOG0fl0W5A== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(396003)(376002)(136003)(346002)(366004)(39860400002)(451199015)(66556008)(66476007)(83380400001)(6916009)(8676002)(66946007)(41300700001)(86362001)(36756003)(1076003)(316002)(2616005)(2906002)(38100700002)(5660300002)(8936002)(6512007)(6486002)(26005)(9686003)(186003)(478600001)(6506007)(6666004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: soIVwTFzbtevgjRdSmPhcb+gVtGrlmlpesZGRJN8W5EoWKYs61Q7lbvMquZ6OwsHXeR443abQ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lWc+Kt+K9rqBfk/Q3Cr4riTnxg59NS5KuukeZVtZS82BnpOx2HTmfNExEpfwejW8HLpFyKGhVFwGJljI3hsRz1mry03bDWOkklGqKSkhEEwcks32m9ZIa4bdu1Ifjsc/kvYmDru6dRwNlOCRtNO4VyNDDdO/Uv4sroCiPx2QCNr37loSz8JtvveFUKLWB7n3xyLq9udiRnehGwn4QMJO++DchVgLn+izZUgLrTo/07W7feH4UMkxSFCa4qVhu6Q== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7c2dd9a8-76b0-4293-f7be-08dafdab7c5a X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jan 2023 01:36:59.5167 (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: Bc/jAB4uwv2hE2+toDJSppK0HivZkK5e/OuNUQKTgwc+OVwKsT+Np3kSX+7MQNZ8wzoz5lp9WQQcrs5UV/DF9tgvBYk5NoYIYsE8Nde92lM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR10MB7074 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-23_12,2023-01-23_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 mlxscore=0 spamscore=0 bulkscore=0 mlxlogscore=999 malwarescore=0 adultscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301240010 X-Proofpoint-GUID: -gx0LEQaGZMLNWcAc_dnFI2_Q_5HCyQO X-Proofpoint-ORIG-GUID: -gx0LEQaGZMLNWcAc_dnFI2_Q_5HCyQO Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Allison Henderson This patch adds a helper function xfs_attr_list_context_init used by xfs_attr_list. This function initializes the xfs_attr_list_context structure passed to xfs_attr_list_int. We will need this later to call xfs_attr_list_int_ilocked when the node is already locked. Signed-off-by: Allison Henderson Reviewed-by: Darrick J. Wong --- fs/xfs/xfs_file.c | 1 + fs/xfs/xfs_ioctl.c | 54 ++++++++++++++++++++++++++++++++-------------- fs/xfs/xfs_ioctl.h | 2 ++ 3 files changed, 41 insertions(+), 16 deletions(-) diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c index 595a5bcf46b9..9c09d32a6c9e 100644 --- a/fs/xfs/xfs_file.c +++ b/fs/xfs/xfs_file.c @@ -17,6 +17,7 @@ #include "xfs_bmap_util.h" #include "xfs_dir2.h" #include "xfs_dir2_priv.h" +#include "xfs_attr.h" #include "xfs_ioctl.h" #include "xfs_trace.h" #include "xfs_log.h" diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c index 736510bc241b..5cd5154d4d1e 100644 --- a/fs/xfs/xfs_ioctl.c +++ b/fs/xfs/xfs_ioctl.c @@ -369,6 +369,40 @@ xfs_attr_flags( return 0; } +/* + * Initializes an xfs_attr_list_context suitable for + * use by xfs_attr_list + */ +int +xfs_ioc_attr_list_context_init( + struct xfs_inode *dp, + char *buffer, + int bufsize, + int flags, + struct xfs_attr_list_context *context) +{ + struct xfs_attrlist *alist; + + /* + * Initialize the output buffer. + */ + context->dp = dp; + context->resynch = 1; + context->attr_filter = xfs_attr_filter(flags); + context->buffer = buffer; + context->bufsize = round_down(bufsize, sizeof(uint32_t)); + context->firstu = context->bufsize; + context->put_listent = xfs_ioc_attr_put_listent; + + alist = context->buffer; + alist->al_count = 0; + alist->al_more = 0; + alist->al_offset[0] = context->bufsize; + + return 0; +} + + int xfs_ioc_attr_list( struct xfs_inode *dp, @@ -378,7 +412,6 @@ xfs_ioc_attr_list( struct xfs_attrlist_cursor __user *ucursor) { struct xfs_attr_list_context context = { }; - struct xfs_attrlist *alist; void *buffer; int error; @@ -410,21 +443,10 @@ xfs_ioc_attr_list( if (!buffer) return -ENOMEM; - /* - * Initialize the output buffer. - */ - context.dp = dp; - context.resynch = 1; - context.attr_filter = xfs_attr_filter(flags); - context.buffer = buffer; - context.bufsize = round_down(bufsize, sizeof(uint32_t)); - context.firstu = context.bufsize; - context.put_listent = xfs_ioc_attr_put_listent; - - alist = context.buffer; - alist->al_count = 0; - alist->al_more = 0; - alist->al_offset[0] = context.bufsize; + error = xfs_ioc_attr_list_context_init(dp, buffer, bufsize, flags, + &context); + if (error) + return error; error = xfs_attr_list(&context); if (error) diff --git a/fs/xfs/xfs_ioctl.h b/fs/xfs/xfs_ioctl.h index d4abba2c13c1..ca60e1c427a3 100644 --- a/fs/xfs/xfs_ioctl.h +++ b/fs/xfs/xfs_ioctl.h @@ -35,6 +35,8 @@ int xfs_ioc_attrmulti_one(struct file *parfilp, struct inode *inode, int xfs_ioc_attr_list(struct xfs_inode *dp, void __user *ubuf, size_t bufsize, int flags, struct xfs_attrlist_cursor __user *ucursor); +int xfs_ioc_attr_list_context_init(struct xfs_inode *dp, char *buffer, + int bufsize, int flags, struct xfs_attr_list_context *context); extern struct dentry * xfs_handle_to_dentry( From patchwork Tue Jan 24 01:36:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 13113278 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 E7391C54EB4 for ; Tue, 24 Jan 2023 01:37:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232446AbjAXBhH (ORCPT ); Mon, 23 Jan 2023 20:37:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56876 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232339AbjAXBhF (ORCPT ); Mon, 23 Jan 2023 20:37:05 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D045F1A4BA for ; Mon, 23 Jan 2023 17:37:03 -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 30O04Uuw027011 for ; Tue, 24 Jan 2023 01:37: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=6r5E+jUVmqy2GQaGZCtwPHOxi4Rm8gm673bMX9XGoY0=; b=NCqKsrP/WEhkL5mfLW3MqkIIOv9Y3FCBM/9VACS2XcWpW8PUYb7H1Bm/3ejvSarWdVy9 xIuIrJjSxnKzFLM1f57stI0dD+xgjziBoiWB70J1NyMpgYOgfyqhsJY3Gp7gHdyvuAbS Zt+E7DZ4jlQWJ8TajyFKOOvjiQ4sVRPWqui24WaDF+O57dz0Io6UMDsvK2Ze8gDsUAAT gNOqT7G1enTuEqqsRgX9QnpCQ0a0/bYIm3GtkhBFVS6kTQ8zOxVt5wZt0b+DJbF9dTXY cxFFFDZRLBDYuwrdLQd/MtyXZaDFKKNPAXtrC2OvS4021FXRbeEbBizTOFWkq4QtcqjM Sw== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3n86n0vcgs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 24 Jan 2023 01:37:03 +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 30O0PAm5040137 for ; Tue, 24 Jan 2023 01:37:02 GMT Received: from nam02-sn1-obe.outbound.protection.outlook.com (mail-sn1nam02lp2047.outbound.protection.outlook.com [104.47.57.47]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3n86g4a8bx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 24 Jan 2023 01:37:02 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=V2uIkvQENN44tm3Myijyu98XFVbG5ikX7kwqiHdrRGg/X+l+Do3bap60oI3xClaeR0EPZdOUAcQYxhaS25yr4xXCCbxgKQrN+Oqyu5RIthOBN1eJ1bat4d97o58fA0kHQGCqv2lLLqCjGQ9ZT8I5AObpyA16/hrNF9eNKIdy8/6XfuSnHkA2AnePpxcioXw9Dj8LRl1KftgFmxZrcl8jHV5adjTdbjXaPTq8vSkxOwDobknE3LLRyVDkBcDVqklAlrMJcDLPJuQnn6JVyz1PwionsGYwFfL98eSL0N1A0hhAnfr4P54S1GWmS4ZMQUIk/KD+napWKXSOjhD5ecbKcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=6r5E+jUVmqy2GQaGZCtwPHOxi4Rm8gm673bMX9XGoY0=; b=SdKP0xcMpRw6yT/QIBjgm1OQMGtya9P1u4itMsL7whKhtzp8/sl73sW6IzzYmetUrpVaOZcWOZpkfqtcePs7K1zZhEfRP6SLXR70muDqOmAoc2lp7xA9VrZNXRoasqWrUv77UlFavN9kSoiJy1ct006sh8pOyHiyGnYbhNrZCImtNw3OPKKGbE2tIgy4cpS6w7Bj/LVlzh/0M/up74rIMHxxWSuSIboIhXBVhgnGYGlanItVx1GVQlqkZKvwbBSxjvHtDG/ORyGfW+D/Ds2lhPgCJmR7SUTxd24uGAquQaCcF4e/q5Ez8qChgrnH3ccgcvRdyzOdlKaIUWBkHV1NtQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=6r5E+jUVmqy2GQaGZCtwPHOxi4Rm8gm673bMX9XGoY0=; b=ie/q0LvRvSWKxICU3S0EUaF3SEJ+8Kn8MPN/bx5caZRwerm9xxLCWx41awjhn9bQTw1LKPSXoz4vwC1VVQLzvSEoc069CpKWFMnBdH43rjgUJliGCd4+5gEAIntiCqXy0L+KqVXMXxPOrmalxxVr8gStuXB0Ynp0S6tdrhAskRk= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by SN7PR10MB7074.namprd10.prod.outlook.com (2603:10b6:806:34c::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.8; Tue, 24 Jan 2023 01:37:01 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::eaff:9f55:4641:db38]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::eaff:9f55:4641:db38%4]) with mapi id 15.20.6043.016; Tue, 24 Jan 2023 01:37:01 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v8 24/27] xfs: Filter XFS_ATTR_PARENT for getfattr Date: Mon, 23 Jan 2023 18:36:17 -0700 Message-Id: <20230124013620.1089319-25-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230124013620.1089319-1-allison.henderson@oracle.com> References: <20230124013620.1089319-1-allison.henderson@oracle.com> X-ClientProxiedBy: SJ0PR13CA0072.namprd13.prod.outlook.com (2603:10b6:a03:2c4::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_|SN7PR10MB7074:EE_ X-MS-Office365-Filtering-Correlation-Id: 3817e4c4-5ee2-42fa-0c04-08dafdab7d5e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: an4LAt2CfjTlSPFGbOaJ1erunfF9K0pWGpJliRgWSzjM+ocszWKpib3WBmlRcjgm5gS20DvpWvGbo+TIbNVp9MWbOqAQ/21cl7JZdDDPHYJyMqUqQTUvxUIAYL6hwFj9gCXvW6xqsg0hpXZTMx6Y48kMqys/ofPFUqP+ZHgdFaqD+Z3/idm+9aOkJpN5G0jmInICrVMKwmJLjMyJHJTyeSO8JX/mDBszYlm+h13/uWytKU00Q1KCwdzJKlfhy/1PrVtvjhTP9tCDF4RkOQygF07ef4xC6zaxuS6hk3NMbGDJBN4HA0tFysGxJDAjVQWDtA116argADDVT8WfriiBR/v+paq6wWfw8N/RkDrywjj6uBa8nni+o9aqRTF9lnVY5kLd/in70K5+sDc+T2yC9dqnOYpKSbgloQpc1uglH2J4j/J/rL/NkM5+1Qpi7jHKCwB/dkxBFXHwYojRcYjYMPE7ScrbHxxDAGaUiCFdYz7T+dBxjj0yX2RJErTq3W51QLCShW2RHRhc6ZDAhyA59J+CD7zbYjlb9SBxJt3HrEDRNDqjZXtepEkqjF5K/DhR7KJDE/R7uQAXyrVaxNN5MT/CFfEKJ+Nqc7243vadWKoqtx5+KCrKs4jBC9ejfEeCj5O/gDYXFYwLtZUBp8B1Bw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(396003)(376002)(136003)(346002)(366004)(39860400002)(451199015)(66556008)(66476007)(6916009)(8676002)(66946007)(41300700001)(86362001)(36756003)(1076003)(316002)(2616005)(2906002)(38100700002)(5660300002)(4744005)(8936002)(6512007)(6486002)(26005)(9686003)(186003)(478600001)(6506007)(6666004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: DBH34WCslPmspHyF9IOGCqsZ+Di0BjkwtwVHlqhJ8Eo6AqnAv3/hBjC047MEUuYpiZc6+2MbiDyexto00jobufPlZO2zVgB3WuAsOTCqHjU1zy/YDv1JKB9cj5BTkKpZG+Zh1DEzjPz5i1kImagMyMNEwrY6NqtPJj+y0NBQPq6m6yZQljBVwc1gfV5CfHxkwSrUZkISiAlGjf51ZAQ0dp5pFDk09AbShKi4O8H0hHJuaX2HHG3s3U+Id+5WVnjAQRxo8p2nIRGox2DlrFPZ9maFTrFLzpvpp9zV1CoyZKrAysVp0H8qTBEfRvIU6Jea+ss4+cYN/XVPRX9y9d13oQEiW9Bok4mY8QFhQiFct1Gl7a41iCA6Nn7L13DX+ab5kA5Z54drDxqZwFZL9BhhytCmvp6Z+Y71b8HqJWc7WGo1ZHhFplX9h3Aoigvd+edZovdWZGNJ2OjwHV6Ckd56II59SZDZPE/OIzTzfihQytKpCU+nB4PpdF2R6RANyxs7hPtXUihZ18lWLX3hGRUlIxCLI2h4amtOTtNo458ahO/y7nT9KqlCnayMCkceqgT+RlHXIcl6tF7ox2VRjan00Agd/PZz7sEZ7DdVj51AP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0: drudJWvJ+NzWfpJ8LW/Zz1dwCWN3DxALjPC+oggmD3i1vS6zFGoLItuAM2koMmBnqHiN15qwS9J2w8QQM3K+GOezdkArlziHrdN0Kv7I06DrKbGJSY5gfJuxfG+ySd4S7UEU89Ew1lsUusij6tktoCEU4tCGnV7hDQWxDVoA2+cFyb5et4WFjkmZq3DGEvxnR5N2fmBjfvmrdhbyguBRfEiaI8EUF9oAc+JccMB4Xh3IKXWE52Znc4iqq9siW63VV4d8i6btHxozdwrGgixoMMHHMqKNCBsL+EbYe5fcKoHFgukadAjkwwKSrVqhUyHw1B6UMCpnLL6HVNbxnCKzX+oNFT0duAHrVwgo+VTFzGsffHEtrNh4tRUk00B7lN2JJ+LG2hgVR4OWm/VN5yYIROIhGwuRa1fODKyzFuZIwUUCvbvyp9MO5GHzCiZBBFCkOkxgzz0OorJVBidWMnNySthMiQz9M5+sdYZBfM6tGVIQ6iW3rQ3CFO+UD2ilJd25i3II+jeMlKsTOZUBoMRwIOEdr8OCDit01LPQ3OQ4ajn/wgZ7R5ZYU1Y0ZzyYOrmoMSwxV4q4Hc7WLJPq9+VgxgJ/J5JJCygwH6ICqaInOiO6C+yVj2DcmymA3euVbmrxNU4EfGyJ/FQe3+jLmSkaSKgCTAykdx2bgynGcBnWtlg22JctJanZcBofXSVClz49QNaZECy/Qy+fyXajLc3EM3r/COV/sPC6ZZQBhWNcpRBGyqpJW29dIYJuPeNQGyn2tz4v/weULj+XVRxqMVfcqA== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3817e4c4-5ee2-42fa-0c04-08dafdab7d5e X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jan 2023 01:37:01.2302 (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: OHjxE/pXmsDjd/GfkTd72rOu1R5MHjqWaYfsYpb5hjSfokK6qufusjJLZ6ilDGRDF4/HNEuWog82azCkTQxQYoKK9ejc3aEbPmedlAdxH24= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR10MB7074 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-23_12,2023-01-23_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 bulkscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 spamscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301240010 X-Proofpoint-GUID: hwJ-Ygqhc9_B3-T2ZATZTjkMElRUMJcc X-Proofpoint-ORIG-GUID: hwJ-Ygqhc9_B3-T2ZATZTjkMElRUMJcc Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Allison Henderson Parent pointers returned to the get_fattr tool cause errors since the tool cannot parse parent pointers. Fix this by filtering parent parent pointers from xfs_xattr_put_listent. Signed-off-by: Allison Henderson --- fs/xfs/xfs_xattr.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/xfs/xfs_xattr.c b/fs/xfs/xfs_xattr.c index 3644c5bcb3c0..3d54701716ab 100644 --- a/fs/xfs/xfs_xattr.c +++ b/fs/xfs/xfs_xattr.c @@ -234,6 +234,9 @@ xfs_xattr_put_listent( ASSERT(context->count >= 0); + if (flags & XFS_ATTR_PARENT) + return; + if (flags & XFS_ATTR_ROOT) { #ifdef CONFIG_XFS_POSIX_ACL if (namelen == SGI_ACL_FILE_SIZE && From patchwork Tue Jan 24 01:36:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 13113280 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 6C229C05027 for ; Tue, 24 Jan 2023 01:37:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232143AbjAXBhK (ORCPT ); Mon, 23 Jan 2023 20:37:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56932 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232339AbjAXBhJ (ORCPT ); Mon, 23 Jan 2023 20:37:09 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DBCB51B57C for ; Mon, 23 Jan 2023 17:37:06 -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 30O04j4g022188 for ; Tue, 24 Jan 2023 01:37:06 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=C1lm0sK2KeKSUuw7ZKnVsh38+y8qrhooA0z1zYiajTY=; b=ifRpH6bzCFF0GqmZ5dHWOoyDk+Ga/ws/UJr69AqVoR+MOSDb6372hascrQKTVohKG+ym /3DQybj0SXbT7qNeEngeE6CjlEw3zTyuU5iywtqAN6s9F/iy7URqL7ShFy3nZilO1RP7 BYhxRiz8Y/jR6LZ7V41PGdI+Qg3aiLscWdWJaQ7dE+Zsb1YVhGbCkhVziXFkha/JgJg7 FoUhL5vcNt9KMlIzYQL7wOR+xRENn/5kXL1d9pleEawxijbENu/fYDsqsYYYutOEzYFn +1UqzhgY4BrlHxoqUuqTEl8tNmiHC0qypiV+tMUTqGoMJqZH+qa2+awLY95Gpj3dbd2u tw== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3n88ktv8da-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 24 Jan 2023 01:37:06 +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 30O0xVZU001093 for ; Tue, 24 Jan 2023 01:37:05 GMT Received: from nam02-sn1-obe.outbound.protection.outlook.com (mail-sn1nam02lp2048.outbound.protection.outlook.com [104.47.57.48]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3n86gakvy5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 24 Jan 2023 01:37:04 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KAaQ5uVHg8lT845KQhquqOwO0MwRdRx3aUm/b+kBc9qLr2dVBgeZY966zl6IIRsoxo7IHS4d3wB4NArSnLjIe3IdUkwbdKYk5E4r6zdh9JsFP10gADZbxMmFtxFsvZlgq39zJrCsG2R+9Ghjk8iHGbsQ8VHrEo5Vf0icGxJhBl9v7P7ktmPFrASBSWx6SKiEp9/w3kEQwFFe0HSgmRg1jcKIeck+33WFb14N463SOeLrvW37eCye+IPh5FSrcfTZ1K4qV3e24fXCa9jV5VsmvK2OGy80IOxyMgbJ7MBFDNzOdNYvu7QdMG/KWzNh5/HfjIlC0ncFo+/M6w+5MEbzUA== 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=C1lm0sK2KeKSUuw7ZKnVsh38+y8qrhooA0z1zYiajTY=; b=eO5KTc19QLxFL5L5el9SpO6tLd2lRZ+hcX0aI+Up/LMLk5oS6CnCHgzjjUw5Cp/z53FvXoulswJZBOU07kBaYSf6W4O3iFz+MixHRO6IRwE7EFYyMNNK2alq5rR+p3VmYkbsrexeLP0+dtYQesEub1pKjknMiVfXrcqU0rAjJuniOin2s5/85O3lSKjDNNKl9GlozoBfRpO9vceZxcYQHS26GuugPanKv2QuHVW0Rf0Rj2spGy84admdcIgGo1IIMzNn2Z52qpEqLysii5c1VJ2N2rXBFiotMHIMrLBo82tNe+CBtrOR4Z0L4CAD3zBb1LsQHV7msi31xp+3wvMwrg== 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=C1lm0sK2KeKSUuw7ZKnVsh38+y8qrhooA0z1zYiajTY=; b=ZjfvKgJxTW7ziC45JCKCM/qcm/AyNHEprlTXbRdaBnjfZpuxQj/38M/NQ5eZZIF0z5wlVvbpk/Vfk2p6MY9vkh93HPcP7fIfWeSV8uaVrQ5WUiHolrKkSOr2yew6rlxkxUwXPIAOhvmfcXUGC6OnmfbjWVLsTfuOKnDK4bGOWpQ= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by SN7PR10MB7074.namprd10.prod.outlook.com (2603:10b6:806:34c::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.8; Tue, 24 Jan 2023 01:37:03 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::eaff:9f55:4641:db38]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::eaff:9f55:4641:db38%4]) with mapi id 15.20.6043.016; Tue, 24 Jan 2023 01:37:03 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v8 25/27] xfs: Add parent pointer ioctl Date: Mon, 23 Jan 2023 18:36:18 -0700 Message-Id: <20230124013620.1089319-26-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230124013620.1089319-1-allison.henderson@oracle.com> References: <20230124013620.1089319-1-allison.henderson@oracle.com> X-ClientProxiedBy: SJ0PR03CA0272.namprd03.prod.outlook.com (2603:10b6:a03:39e::7) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY5PR10MB4306:EE_|SN7PR10MB7074:EE_ X-MS-Office365-Filtering-Correlation-Id: 581ab375-cc55-47c5-a3f9-08dafdab7e5a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xe25W7w19k9kq9cn7ALAgTSvRsbfXc3yQFAbapIcCWuriA980eQf2o5or4B6PVILdvR0ymEgtUTG8RV+H3cfLsuA8OllHYl1bDDkeuLX7N3N6uboJD+aJio3OVOFejEtK5MqQSK4aMi2U/M8iL6MfP2y2KHqqftkRpmWcL35Gaf/2VItFIcPY5f2WsUt29AQb2wSKNzRiXYB9jkbJVYxjaxAZ1Nxm4E8l7rI1tsfaTrx+twX7QC08LSTFSFgVrkEC2nGWj/rEQ9RAjQ1eL2tQRZswjxe6X5p6TWInvL4dI0SQCK3g9iJrBxYIdDAa0drsdkGsjxofEbHxXk5xqMYxneDZViPmLkKJbsVcM4ccBmxPcw9J1OIHScC4EP27QSRskxGlw/5183S3oM/WYPr9oEP6UanHXKCSKWKKKLUoeHICfb8JKDf9LKioaYugQptC7Fpjl4XG87GFdz/Rz2TylSBTbH26ZmdYy5BKxaLtzz49lAWpEmA9xwHyM+9lcaCIcVVxDg+sY7tI8m/M20eNFhn0LHXfkL7v+LxI57oDJZFTygpz9eT3b5MSL4yznJee//7Z5YbOC1V9tDywx8KHMy11Vv0EiXXzvA5lIokwLUqQJ8zDbYFRsCcqWiKsntOGaDz8yLrIyNDpBMa4cf6XQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(396003)(376002)(136003)(346002)(366004)(39860400002)(451199015)(66556008)(66476007)(83380400001)(6916009)(8676002)(66946007)(41300700001)(86362001)(36756003)(1076003)(316002)(2616005)(2906002)(30864003)(38100700002)(5660300002)(8936002)(6512007)(6486002)(26005)(9686003)(186003)(478600001)(6506007)(6666004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: /GvKl9j/qcF1blaed0tSj/E1RVC04Sk74TfRK/1OS/1S4CgZDzwLiUPK7WQCIVMQhwt4Y3lvVif96EiObFJLIHWVQFpH2RqgrfjgSuu2wywIocHt6328DC6W3lLEspVYpMlO6+liU24dmeUMqq0ytLRyHR6SkRuwsdEoXJb67Pw5zreUuT1Zj5yGuvGdV6is+vffLWXHcXFUVqIXNmQEgrQsgauK28Jg/bcKWb9+SE0ZcHeTjGIbof4x0cP88Ex6zZTZApl68MpGyJAIXIlsTiW7mMQdCDlrqNTiNH73wTby/JaGVD4JcdatEqqqM5pzwN1AWx68+OFVjc5ilNBfRqoKcI0gAuNwVeBbigzknjm/2yY5hWbKjekEdt4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ygg6ttZyXaNZxJuXZFLuiU7bVCzn8hN6k9kGeYL8NrMYo2ZVExrEhBla0224fnGbzv9awJWdXidJq7tgIqP36f8EgPEQUvECZIfDF9GXRbkJDrgGJJmtzA9wxhaQydDKmQZ2ZMjHJHnkN/kgcrkvkiRDrpMDDmi3OhoEJeI3hmRwaPqt/4w== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: VfM9vWR5P0qFaO89YPmDFDRl2hx/gbWjEanbE78m0c2z7/wFWCt4jzgMIDvdjzfKbHG2k1aENg44q6Lr5cG9WqQPCWP+EmHCbHG8lSgrKYDpwGjwPsiUw9DufnctcvPdyol2jIooEMnBCkDwqibE6eoM4W8s06wrg1nhlJa+3mm2iGLnXxk90McjeSvHA+vgM7b1alhYGGLvy/LPyMG0QI8xT8RpEiNEmWH13aBQrFy7+3zYDc2qmFiChTw1hClAKB7fRapx+P5S9YnoeMrhln9RxiYxe7NwJ+Zf0D60sFt9eiAnWmbTd+d4j7joXAumxBBBO4913h54eh0JuAWCymRugEYLri6CV1KPqrpAybPXL+f6bDj+H6yqoiwEsUxdHPQjo6ZtrWL25Uk2Qy39gx7P05u10ddu1BRirS7ejmUqaURIVe78dQJ/CTkan6QY/u6LXcxIKILwefX88bQf3NlcpelQJGY7+IGS8D/nWay4FqJMlFvdT1jeelKK1VWhFW+yx6czFVL0Gzq+wj941AYLjAEHsh0BfII5JCCuq80ALLuX7SnPpj6UeAtehsGy3kzaiEUzK5UCjRCVHUhuCXQAZAvwdpYQcK2wMkCk+8AqbkdMcPxIAyuucjrB9QUDcisZojBNYugQLY97QPxmc8GuXrj0hpX2rzX9jkn5ouTrWI0MGGTLtsGA6ApMGB3yWutMQWOgGy3jfuNUVutljkKieBNjJ6fJwP/WmI64UyoljG+I3DH+7Sp5GD3/dMFXyJ6E9srCKpfp+SEfNfpYmQ== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 581ab375-cc55-47c5-a3f9-08dafdab7e5a X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jan 2023 01:37:02.9013 (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: l3SbWY2tLfzIBz4JHg9lekKygHvXAkSRmUoHf4q6VgSQaGWcK2ab+yrSC7EiMjpw3mmhkyslkpuGkglM2pIxOgo8qP/+xj4bKJkiDZRwaE4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR10MB7074 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-23_12,2023-01-23_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 phishscore=0 mlxlogscore=999 adultscore=0 mlxscore=0 suspectscore=0 spamscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301240010 X-Proofpoint-GUID: CwH30sEw9tEoow4M708Dt7VoxQp9a62r X-Proofpoint-ORIG-GUID: CwH30sEw9tEoow4M708Dt7VoxQp9a62r Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Allison Henderson This patch adds a new file ioctl to retrieve the parent pointer of a given inode Signed-off-by: Allison Henderson --- fs/xfs/Makefile | 1 + fs/xfs/libxfs/xfs_fs.h | 74 ++++++++++++++++++++++ fs/xfs/libxfs/xfs_parent.c | 10 +++ fs/xfs/libxfs/xfs_parent.h | 2 + fs/xfs/xfs_ioctl.c | 94 ++++++++++++++++++++++++++- fs/xfs/xfs_ondisk.h | 4 ++ fs/xfs/xfs_parent_utils.c | 126 +++++++++++++++++++++++++++++++++++++ fs/xfs/xfs_parent_utils.h | 11 ++++ 8 files changed, 321 insertions(+), 1 deletion(-) diff --git a/fs/xfs/Makefile b/fs/xfs/Makefile index e2b2cf50ffcf..42d0496fdad7 100644 --- a/fs/xfs/Makefile +++ b/fs/xfs/Makefile @@ -86,6 +86,7 @@ xfs-y += xfs_aops.o \ xfs_mount.o \ xfs_mru_cache.o \ xfs_pwork.o \ + xfs_parent_utils.o \ xfs_reflink.o \ xfs_stats.o \ xfs_super.o \ diff --git a/fs/xfs/libxfs/xfs_fs.h b/fs/xfs/libxfs/xfs_fs.h index b0b4d7a3aa15..9e59a1fdfb0c 100644 --- a/fs/xfs/libxfs/xfs_fs.h +++ b/fs/xfs/libxfs/xfs_fs.h @@ -752,6 +752,79 @@ struct xfs_scrub_metadata { XFS_SCRUB_OFLAG_NO_REPAIR_NEEDED) #define XFS_SCRUB_FLAGS_ALL (XFS_SCRUB_FLAGS_IN | XFS_SCRUB_FLAGS_OUT) +#define XFS_PPTR_MAXNAMELEN 256 + +/* return parents of the handle, not the open fd */ +#define XFS_PPTR_IFLAG_HANDLE (1U << 0) + +/* target was the root directory */ +#define XFS_PPTR_OFLAG_ROOT (1U << 1) + +/* Cursor is done iterating pptrs */ +#define XFS_PPTR_OFLAG_DONE (1U << 2) + + #define XFS_PPTR_FLAG_ALL (XFS_PPTR_IFLAG_HANDLE | XFS_PPTR_OFLAG_ROOT | \ + XFS_PPTR_OFLAG_DONE) + +/* Get an inode parent pointer through ioctl */ +struct xfs_parent_ptr { + __u64 xpp_ino; /* Inode */ + __u32 xpp_gen; /* Inode generation */ + __u32 xpp_diroffset; /* Directory offset */ + __u64 xpp_rsvd; /* Reserved */ + __u8 xpp_name[XFS_PPTR_MAXNAMELEN]; /* File name */ +}; + +/* Iterate through an inodes parent pointers */ +struct xfs_pptr_info { + /* File handle, if XFS_PPTR_IFLAG_HANDLE is set */ + struct xfs_handle pi_handle; + + /* + * Structure to track progress in iterating the parent pointers. + * Must be initialized to zeroes before the first ioctl call, and + * not touched by callers after that. + */ + struct xfs_attrlist_cursor pi_cursor; + + /* Operational flags: XFS_PPTR_*FLAG* */ + __u32 pi_flags; + + /* Must be set to zero */ + __u32 pi_reserved; + + /* # of entries in array */ + __u32 pi_ptrs_size; + + /* # of entries filled in (output) */ + __u32 pi_ptrs_used; + + /* Must be set to zero */ + __u64 pi_reserved2[6]; + + /* + * An array of struct xfs_parent_ptr follows the header + * information. Use xfs_ppinfo_to_pp() to access the + * parent pointer array entries. + */ + struct xfs_parent_ptr pi_parents[]; +}; + +static inline size_t +xfs_pptr_info_sizeof(int nr_ptrs) +{ + return sizeof(struct xfs_pptr_info) + + (nr_ptrs * sizeof(struct xfs_parent_ptr)); +} + +static inline struct xfs_parent_ptr* +xfs_ppinfo_to_pp( + struct xfs_pptr_info *info, + int idx) +{ + return &info->pi_parents[idx]; +} + /* * ioctl limits */ @@ -797,6 +870,7 @@ struct xfs_scrub_metadata { /* XFS_IOC_GETFSMAP ------ hoisted 59 */ #define XFS_IOC_SCRUB_METADATA _IOWR('X', 60, struct xfs_scrub_metadata) #define XFS_IOC_AG_GEOMETRY _IOWR('X', 61, struct xfs_ag_geometry) +#define XFS_IOC_GETPARENTS _IOWR('X', 62, struct xfs_parent_ptr) /* * ioctl commands that replace IRIX syssgi()'s diff --git a/fs/xfs/libxfs/xfs_parent.c b/fs/xfs/libxfs/xfs_parent.c index 954a52d6be00..fa3d645731a9 100644 --- a/fs/xfs/libxfs/xfs_parent.c +++ b/fs/xfs/libxfs/xfs_parent.c @@ -27,6 +27,16 @@ #include "xfs_parent.h" #include "xfs_trans_space.h" +/* Initializes a xfs_parent_ptr from an xfs_parent_name_rec */ +void +xfs_init_parent_ptr(struct xfs_parent_ptr *xpp, + const struct xfs_parent_name_rec *rec) +{ + xpp->xpp_ino = be64_to_cpu(rec->p_ino); + xpp->xpp_gen = be32_to_cpu(rec->p_gen); + xpp->xpp_diroffset = be32_to_cpu(rec->p_diroffset); +} + /* * Parent pointer attribute handling. * diff --git a/fs/xfs/libxfs/xfs_parent.h b/fs/xfs/libxfs/xfs_parent.h index 9021241ad65b..898842b4532d 100644 --- a/fs/xfs/libxfs/xfs_parent.h +++ b/fs/xfs/libxfs/xfs_parent.h @@ -24,6 +24,8 @@ void xfs_init_parent_name_rec(struct xfs_parent_name_rec *rec, uint32_t p_diroffset); void xfs_init_parent_name_irec(struct xfs_parent_name_irec *irec, struct xfs_parent_name_rec *rec); +void xfs_init_parent_ptr(struct xfs_parent_ptr *xpp, + const struct xfs_parent_name_rec *rec); int xfs_parent_init(xfs_mount_t *mp, struct xfs_parent_defer **parentp); int xfs_parent_defer_add(struct xfs_trans *tp, struct xfs_parent_defer *parent, struct xfs_inode *dp, struct xfs_name *parent_name, diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c index 5cd5154d4d1e..df5a45b97f8f 100644 --- a/fs/xfs/xfs_ioctl.c +++ b/fs/xfs/xfs_ioctl.c @@ -37,6 +37,7 @@ #include "xfs_health.h" #include "xfs_reflink.h" #include "xfs_ioctl.h" +#include "xfs_parent_utils.h" #include "xfs_xattr.h" #include @@ -1675,6 +1676,96 @@ xfs_ioc_scrub_metadata( return 0; } +/* + * IOCTL routine to get the parent pointers of an inode and return it to user + * space. Caller must pass a buffer space containing a struct xfs_pptr_info, + * followed by a region large enough to contain an array of struct + * xfs_parent_ptr of a size specified in pi_ptrs_size. If the inode contains + * more parent pointers than can fit in the buffer space, caller may re-call + * the function using the returned pi_cursor to resume iteration. The + * number of xfs_parent_ptr returned will be stored in pi_ptrs_used. + * + * Returns 0 on success or non-zero on failure + */ +STATIC int +xfs_ioc_get_parent_pointer( + struct file *filp, + void __user *arg) +{ + struct xfs_pptr_info *ppi = NULL; + int error = 0; + struct xfs_inode *ip = XFS_I(file_inode(filp)); + struct xfs_mount *mp = ip->i_mount; + + if (!capable(CAP_SYS_ADMIN)) + return -EPERM; + + /* Allocate an xfs_pptr_info to put the user data */ + ppi = kmalloc(sizeof(struct xfs_pptr_info), 0); + if (!ppi) + return -ENOMEM; + + /* Copy the data from the user */ + error = copy_from_user(ppi, arg, sizeof(struct xfs_pptr_info)); + if (error) { + error = -EFAULT; + goto out; + } + + /* Check size of buffer requested by user */ + if (xfs_pptr_info_sizeof(ppi->pi_ptrs_size) > XFS_XATTR_LIST_MAX) { + error = -ENOMEM; + goto out; + } + + if (ppi->pi_flags & ~XFS_PPTR_FLAG_ALL) { + error = -EINVAL; + goto out; + } + ppi->pi_flags &= ~(XFS_PPTR_OFLAG_ROOT | XFS_PPTR_OFLAG_DONE); + + /* + * Now that we know how big the trailing buffer is, expand + * our kernel xfs_pptr_info to be the same size + */ + ppi = krealloc(ppi, xfs_pptr_info_sizeof(ppi->pi_ptrs_size), 0); + if (!ppi) + return -ENOMEM; + + if (ppi->pi_flags & XFS_PPTR_IFLAG_HANDLE) { + error = xfs_iget(mp, NULL, ppi->pi_handle.ha_fid.fid_ino, + 0, 0, &ip); + if (error) + goto out; + + if (VFS_I(ip)->i_generation != ppi->pi_handle.ha_fid.fid_gen) { + error = -EINVAL; + goto out; + } + } + + if (ip->i_ino == mp->m_sb.sb_rootino) + ppi->pi_flags |= XFS_PPTR_OFLAG_ROOT; + + /* Get the parent pointers */ + error = xfs_attr_get_parent_pointer(ip, ppi); + + if (error) + goto out; + + /* Copy the parent pointers back to the user */ + error = copy_to_user(arg, ppi, + xfs_pptr_info_sizeof(ppi->pi_ptrs_size)); + if (error) { + error = -EFAULT; + goto out; + } + +out: + kmem_free(ppi); + return error; +} + int xfs_ioc_swapext( xfs_swapext_t *sxp) @@ -1964,7 +2055,8 @@ xfs_file_ioctl( case XFS_IOC_FSGETXATTRA: return xfs_ioc_fsgetxattra(ip, arg); - + case XFS_IOC_GETPARENTS: + return xfs_ioc_get_parent_pointer(filp, arg); case XFS_IOC_GETBMAP: case XFS_IOC_GETBMAPA: case XFS_IOC_GETBMAPX: diff --git a/fs/xfs/xfs_ondisk.h b/fs/xfs/xfs_ondisk.h index 9737b5a9f405..6a6bd05c2a68 100644 --- a/fs/xfs/xfs_ondisk.h +++ b/fs/xfs/xfs_ondisk.h @@ -150,6 +150,10 @@ xfs_check_ondisk_structs(void) XFS_CHECK_OFFSET(struct xfs_efi_log_format_32, efi_extents, 16); XFS_CHECK_OFFSET(struct xfs_efi_log_format_64, efi_extents, 16); + /* parent pointer ioctls */ + XFS_CHECK_STRUCT_SIZE(struct xfs_parent_ptr, 280); + XFS_CHECK_STRUCT_SIZE(struct xfs_pptr_info, 104); + /* * The v5 superblock format extended several v4 header structures with * additional data. While new fields are only accessible on v5 diff --git a/fs/xfs/xfs_parent_utils.c b/fs/xfs/xfs_parent_utils.c new file mode 100644 index 000000000000..771279731d42 --- /dev/null +++ b/fs/xfs/xfs_parent_utils.c @@ -0,0 +1,126 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2022 Oracle, Inc. + * All rights reserved. + */ +#include "xfs.h" +#include "xfs_fs.h" +#include "xfs_format.h" +#include "xfs_log_format.h" +#include "xfs_shared.h" +#include "xfs_trans_resv.h" +#include "xfs_mount.h" +#include "xfs_bmap_btree.h" +#include "xfs_inode.h" +#include "xfs_error.h" +#include "xfs_trace.h" +#include "xfs_trans.h" +#include "xfs_da_format.h" +#include "xfs_da_btree.h" +#include "xfs_attr.h" +#include "xfs_ioctl.h" +#include "xfs_parent.h" +#include "xfs_da_btree.h" +#include "xfs_parent_utils.h" + +/* + * Get the parent pointers for a given inode + * + * Returns 0 on success and non zero on error + */ +int +xfs_attr_get_parent_pointer( + struct xfs_inode *ip, + struct xfs_pptr_info *ppi) +{ + + struct xfs_attrlist *alist; + struct xfs_attrlist_ent *aent; + struct xfs_parent_ptr *xpp; + struct xfs_parent_name_rec *xpnr; + char *namebuf; + unsigned int namebuf_size; + int name_len, i, error = 0; + unsigned int lock_mode, flags = XFS_ATTR_PARENT; + struct xfs_attr_list_context context; + + /* Allocate a buffer to store the attribute names */ + namebuf_size = sizeof(struct xfs_attrlist) + + (ppi->pi_ptrs_size) * sizeof(struct xfs_attrlist_ent); + namebuf = kvzalloc(namebuf_size, GFP_KERNEL); + if (!namebuf) + return -ENOMEM; + + memset(&context, 0, sizeof(struct xfs_attr_list_context)); + error = xfs_ioc_attr_list_context_init(ip, namebuf, namebuf_size, 0, + &context); + if (error) + goto out_kfree; + + /* Copy the cursor provided by caller */ + memcpy(&context.cursor, &ppi->pi_cursor, + sizeof(struct xfs_attrlist_cursor)); + context.attr_filter = XFS_ATTR_PARENT; + + lock_mode = xfs_ilock_attr_map_shared(ip); + + error = xfs_attr_list_ilocked(&context); + if (error) + goto out_unlock; + + alist = (struct xfs_attrlist *)namebuf; + for (i = 0; i < alist->al_count; i++) { + struct xfs_da_args args = { + .geo = ip->i_mount->m_attr_geo, + .whichfork = XFS_ATTR_FORK, + .dp = ip, + .namelen = sizeof(struct xfs_parent_name_rec), + .attr_filter = flags, + }; + + xpp = xfs_ppinfo_to_pp(ppi, i); + memset(xpp, 0, sizeof(struct xfs_parent_ptr)); + aent = (struct xfs_attrlist_ent *) + &namebuf[alist->al_offset[i]]; + xpnr = (struct xfs_parent_name_rec *)(aent->a_name); + + if (aent->a_valuelen > XFS_PPTR_MAXNAMELEN) { + error = -EFSCORRUPTED; + goto out_unlock; + } + name_len = aent->a_valuelen; + + args.name = (char *)xpnr; + args.hashval = xfs_da_hashname(args.name, args.namelen), + args.value = (unsigned char *)(xpp->xpp_name); + args.valuelen = name_len; + + error = xfs_attr_get_ilocked(&args); + error = (error == -EEXIST ? 0 : error); + if (error) { + error = -EFSCORRUPTED; + goto out_unlock; + } + + xfs_init_parent_ptr(xpp, xpnr); + if (!xfs_verify_ino(args.dp->i_mount, xpp->xpp_ino)) { + error = -EFSCORRUPTED; + goto out_unlock; + } + } + ppi->pi_ptrs_used = alist->al_count; + if (!alist->al_more) + ppi->pi_flags |= XFS_PPTR_OFLAG_DONE; + + /* Update the caller with the current cursor position */ + memcpy(&ppi->pi_cursor, &context.cursor, + sizeof(struct xfs_attrlist_cursor)); + +out_unlock: + xfs_iunlock(ip, lock_mode); +out_kfree: + kvfree(namebuf); + + return error; +} + diff --git a/fs/xfs/xfs_parent_utils.h b/fs/xfs/xfs_parent_utils.h new file mode 100644 index 000000000000..ad60baee8b2a --- /dev/null +++ b/fs/xfs/xfs_parent_utils.h @@ -0,0 +1,11 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2022 Oracle, Inc. + * All rights reserved. + */ +#ifndef __XFS_PARENT_UTILS_H__ +#define __XFS_PARENT_UTILS_H__ + +int xfs_attr_get_parent_pointer(struct xfs_inode *ip, + struct xfs_pptr_info *ppi); +#endif /* __XFS_PARENT_UTILS_H__ */ From patchwork Tue Jan 24 01:36:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 13113281 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 DEBC4C05027 for ; Tue, 24 Jan 2023 01:37:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232516AbjAXBhP (ORCPT ); Mon, 23 Jan 2023 20:37:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56968 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232339AbjAXBhO (ORCPT ); Mon, 23 Jan 2023 20:37:14 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 60B921A941 for ; Mon, 23 Jan 2023 17:37:13 -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 30O04tAn020240 for ; Tue, 24 Jan 2023 01:37:13 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2022-7-12; bh=0HDc5oSRZUZiwCZrUG1G6lMOEEvHfQHLGVwhC+kxeKs=; b=zo42y7z36eXl40JdZeGr0jdxB/kPz4swBfoLgWC5vF7eJOJNuEIBqUBUh72UdpIAt4Ah aL0Wo+4gsdJgjvn1TEVG0oHlKD5ejwRtnoqZYMfjVd7BE/EHEfAxBuKivYNGn14R1TaK rX9vb4erpmoF/sixX1VfXj198DdEOquZCBeNsbD2FhIOcvYeJ3d9LlFFD43/4qJdfkT5 K9q9sK8oVVKPd6ELA/73e2P98aAgY4XU01VlrI7oxMiSir4FZDVJI5eXMVQa42OEUZY5 lP6jFNJ1P7XGCcZzP5U7//KGf02NZN0uxN+P7cnAUw7Q+VQJjEZrVaG7DWL+1SAOVkWb +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 3n86ybcbje-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 24 Jan 2023 01:37: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 30NNVFTc023319 for ; Tue, 24 Jan 2023 01:37:11 GMT Received: from nam02-sn1-obe.outbound.protection.outlook.com (mail-sn1nam02lp2041.outbound.protection.outlook.com [104.47.57.41]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3n86g4m6h5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 24 Jan 2023 01:37:11 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PW9tD814aOlaHELGQoGGmxKZpHqYKZ65pxtsUe3++CCU5PbUInOAToIGfkpPmj2vq5hyZ0vPLPY36LKItx0ngsWTFiDIIX0SONlZPxVbV7MAL1VS6Z8OBCb46KYgbLJWOOrgv9yBBcDe7R2LH837sQOhX6YAFB7zi4O97yEoWe5nYLe4SuEBVQDSGUK54nPwMeN6X42dE582Q5YsfBNIs0WXDnSqPsCeVLOOn1GnpjJWAuEkFiLqe0V8PONjAvmxIfbJixe6nSo6jj+P6QFIoGMtGRCX74Sox+NP9ol19Mf/Zc0ZdeDIEh3OxaBxpucYt7gfZFOBW0IlmmAy50PDLA== 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=MQwXNFxCyIM8UwHBnfOMXgX0jT9XSt00NV7L9ECJBGi0inODBzaWucTlUkWpO8kt4twDH7ICdkE8ikf4Al2Lit2dJjryODy86LH7Eh1MFqeBkEtYZV5BCVqbUEghueH3Aj1w+4m70x7dhpphrl/5reFY90z4bPIYOqTdnUVbWFY4h1y2HTb+yw+vk1Qj8JIpp1rp/h43+mgtN4AVc6ZViUT7zBSxqz0McSYtFe6NV+zSMgH7SkP+/KLZz7uJuHk3Wrrr4u9CVTHPpdUpM1MIt3Z9tvag+JaV9s5EaSXayaNbrIf459wEV/Nf6xus4DDqOXO+gs9wtdovzI9e7Q02cA== 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=r0ZdbdJJWUcUIjWRJD2L2/LXV5S1A80lAxnArKUGErBfUNdduM/wJAi/jewPg/JdQl2aqH5xkWJKmhsJhsAyY3YZInaKhtxApkR8FJOPneGQCMF62hybKTlcYiHfPOh+YZ4Ydb9hZPEgM6VU0c87IhIWbbsI9ec7zJS3hcm4nlc= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by SN7PR10MB7074.namprd10.prod.outlook.com (2603:10b6:806:34c::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.8; Tue, 24 Jan 2023 01:37:09 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::eaff:9f55:4641:db38]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::eaff:9f55:4641:db38%4]) with mapi id 15.20.6043.016; Tue, 24 Jan 2023 01:37:09 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v8 26/27] xfs: fix unit conversion error in xfs_log_calc_max_attrsetm_res Date: Mon, 23 Jan 2023 18:36:19 -0700 Message-Id: <20230124013620.1089319-27-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230124013620.1089319-1-allison.henderson@oracle.com> References: <20230124013620.1089319-1-allison.henderson@oracle.com> X-ClientProxiedBy: SJ0PR13CA0068.namprd13.prod.outlook.com (2603:10b6:a03:2c4::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_|SN7PR10MB7074:EE_ X-MS-Office365-Filtering-Correlation-Id: a0824eed-06fc-4d4f-61ef-08dafdab8252 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: RFatrxAu9UzNKR1QSDUtoN2VDTUobpQRvoMEAyV9za7WIn89yK5t+VGZDDTyAf4CxDw+Y2lZQWsjGW/Ylc+YBpNKL3l3gLXjgtRKqaEBA0UKs42RO2T7WAPjPzUX/JxLDzTX35Ll7xI+MmH22fCfzFwvLQ2fMnY6dORS/E/C7wfQoKTX/rdLqehGv2fYtI+cJKBeXpKSGEsB7UY3cNrTEPxBvlj8oPjhSnFeJQbmiSMBgceJB6n+A2+jJOvNhXn/Ydxd1jb2mSIi8+wLr8dkiG5U53JAE1Ta6a6T8mh3w+DA7GOWop2MljB/KnwIncAPmvb2ytLWA1VfvyYhQh5CoS7e0sbYH1hmJjypFYTdBM5D0rlbXZ+9bEi4mO3gNi4nKjUSsPMspZQGkNgEurS1y2rwSKzuY8PLEJ2KMbEtwAQeKdBhLbYgslqP7Q4jU1t87lke6ShB9oHQ4ikV+/wZhnTKecRYsrsJCFMyi/RedjStQD9LFn1BBFVc9FRKMorjU8TQ/voWQnnKd4G8xj40VixOcbRFM98Ypz2xljr0vMOWFtVvoVsVW0YLSBD+4Ydt4VnAlc9U0NAmz36EmQEJseSznNkOgbSOH6ogYx4tOgeqCbulrx5AndP3mq7mdWZBc1gIERS8Of9vN/4pVntrOw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(396003)(376002)(136003)(346002)(366004)(39860400002)(451199015)(66556008)(66476007)(83380400001)(6916009)(8676002)(66946007)(41300700001)(86362001)(36756003)(1076003)(316002)(2616005)(2906002)(38100700002)(5660300002)(8936002)(6512007)(6486002)(26005)(9686003)(186003)(478600001)(6506007)(6666004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: uAOhfnbzVNJQ1DyEBxlPoiM80/7WxkHOMPFTuX2/vmBd0+VwlBeHh3KtyiC+7Fxru4YanLMAVeKrJnOTtDVqLi2DWRj2mX8x3btOz2iVVf12n37IoEAJ/BORbUkEvA9o44gLWdjK7pXvg33RH9QAZzAbhqCc00E0Am7KbyyL1X15STskSCK5OjottT22vggJJhpJtqyzevHHXVoiiyW2vEgSxt3WUMjTIOo4tCqJMcIFNAjoMpkRpqVkKOxFEghNT0+kA507C7mL1yxnI6wV9OcGy3JmLTjFVdTxtZ9rzjd084BIekZZfHEEZ9VRgHaiPmWILluV+xNNt+XdcTa06sQ4cz+ZXH0o1OafPv8lJDClxQXYXmfVs8gmm1jbPCG2pq3qmbTqomCnDV474v6eKkDeYmHsG89AGS1SkqrT8TivcC+rS4pMKUA7tBCcd6QV14ybYQsMa7YEm0t1Jxye97x7Sh6/HA54BL1amwr5TiJAVOcaoS1jas+CaAGcmYMGqeHah07Cr8S81S4pAiC9uTY3RKVrkrZLp1YSpC2l+RmTMuWSV4S4P+Y4ySi1NtWI76LNnczENXVb0+rCIZBNiIUfPdb5tsbGj9BIn5zMvFh+8yvUoTRUdO0cNB5QKJoGqAM870c+P4aG4M+G/cViTYT1siPjLlGTF+w43A119jJsD+cggezzSjYA9I4NiwX7n8gPIcZQCEZ6gDW8EMG9WBmblkdWXBE5Ed2i2Vy27IyezJklBezYjZdFNgrg01DoQlW6P3aaPXA6vHgdlGILHACQi65AXByS5b6/O9GwyXmhrCOuaakZwp/35ceJ7JEoNorYEsOetODo68ShVEZKGmIfoieG9c4ybo+PAD2qPqTjJUcEpwLqOTFYxOzj/qRydb4i64ZKzhdlH8cZXy5/nLc69i+K3TvytygXXKvvKHWOkd8uVYO9+dj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FIIZDsUrCArSintNAhU//43q3QYvM/tbJCc8qFGtzLyGOi/4kaZrMj9qG8XkJ5QBM/7JXhpGNWfijdLv+l8SD7pcjb/F7bksebMZrEaYhLXH5UNJPZ2n8vOqF3FKwdc2dnlLKHkLeA9eniPIe4BSBxKJW7eG7AjrkZiVybl91ak90FwiqwZNcWM4+L7K12YnDVpxxkTifv1vPJp1UqvU8RtCt5SD0+aIfboK55r+8cRvkFJBXwG0AHOPpel4B7B+IJClk6dQAh3e96ApAoJr9AfxBUDo/PrD34fCFr/fzFU720IwhVA6xPty9E1exn7cu85g9llBpt9EjK3/4ylgObe0QcdXSV/9mEg0G8s1dHoz3ZXLQkLTH0ci7uBkRZtMAZZ1rLzOg0yLlaeBKEOlrKn+0ILs0xKyZOkjSckJQDTAjU1T6QUvAWttMOMuc6H8UNdgLUnO0ZmZsmw== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: a0824eed-06fc-4d4f-61ef-08dafdab8252 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jan 2023 01:37:09.5580 (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: 4cBzEVSgpSDrob/d2WEoOGszAyNTD9wI2Tn16jJLoKSHsbLC5iAPELKilpw5dTRGQ5iAMMP/LJr/P8PxBpkpmLNs9SrSJsJKRYvVDFOHbcE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR10MB7074 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-23_12,2023-01-23_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 spamscore=0 phishscore=0 suspectscore=0 malwarescore=0 adultscore=0 mlxlogscore=999 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301240010 X-Proofpoint-GUID: AFVQ5y0g8GodgTX-oPsqUsoJ5wZT9kPA X-Proofpoint-ORIG-GUID: AFVQ5y0g8GodgTX-oPsqUsoJ5wZT9kPA 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 Tue Jan 24 01:36:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 13113282 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 B1DEBC25B50 for ; Tue, 24 Jan 2023 01:37:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232588AbjAXBhQ (ORCPT ); Mon, 23 Jan 2023 20:37:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56982 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232339AbjAXBhQ (ORCPT ); Mon, 23 Jan 2023 20:37:16 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 21C0E11EBD for ; Mon, 23 Jan 2023 17:37:15 -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 30O04X72021356 for ; Tue, 24 Jan 2023 01:37:14 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=RBZ40kIwKYQ+Ip5L5oJwRcvSvah44fhNCFLBjBaY5cOMv9F/7fs1j/GnhZWPf/xKY4TM H37UETSoorEbEUD6JulDg1F/KMX7csPSxJA24juzwBGA9ryanaeCyyzgoZoSDImxXvX4 tzE/MQqbWIciHtu8cLXQMslUsxp1jwsswagWFVQm2FK3Px8RsktFxA8/NDVl+G671bqJ dL7bArIt3Vf7C5FBYprpSvbPeWSmEeUxVF/HQsx44cWrknsBg5QkZhbtuHYNY1OlYS5S kHq8tjBouWEC79xEbhijM/A+akxymTosvH5mviYxvRP/6K8WPui4DReabL/52D6TxVob WQ== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3n87xa4a21-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 24 Jan 2023 01:37:14 +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 30NNeBmF001149 for ; Tue, 24 Jan 2023 01:37:13 GMT Received: from nam02-sn1-obe.outbound.protection.outlook.com (mail-sn1nam02lp2047.outbound.protection.outlook.com [104.47.57.47]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3n86gakw2e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 24 Jan 2023 01:37:13 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=e1GChdJy/Xy+794aa1XTxTPhLswT0lqhkTxxRrbVJCM9xHrbNOo0ne45WWywi61s65VQpyF7R9YNrZWdtzoPfEqAafb/goCZrlCDblutBnvUusnt8Or2JicbHXBmaF8/7Q/E9u+BFQpXgu/vTpxGh/4HtyPaEVJJ4nLkHlP4KfK8fAU2MuEdSSoJmg1dDr/YLBAGNTbCQUQt+4KmLb8yck3Y8wdPiNyGQyswOAxJIXX0cKxN4wssPoMtp+Tk/AL0uc9rWQ/hqd+XSSzs8DQMR6+WylonQEPw68ca/AGYexwiiRzXMTHZ6hM5b5GxnW8YhMZ8szOHRUw53PrswR7jxQ== 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=Quy1eI9bT2A239dC1/hMpT0CNNa47X8YCK24kJITqOzwPm0QgQkVZQ6MLtPeWoez3GHW8p2k9zjLdcHqOgMinyF6evVUTac2hGLE1Y/62tbX0p5hzuLJEUqqnCvtbHClpqo2HLOk4z7d1FgeqDL566WMn8dToIJPwt1HVKkuM8bwKvdqVmO75093uxK5aFrApAwV8XH+QEqQVUYy1cM0Bi/cUxlw/KkhZCHR88JRM/09BRv5D/lWtt2x4n/BTZg8+5xpZg//HLiqejbpkNwN57Hj6w3dsD4wWVdAQ7F8u4Y7OqpOPX4iu2tH4J0t8m0UuLqnTo5Ckqc8qP1emheYlA== 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=TAbYhVFhQj1MPW2ISEr4FUFl/CTi6DenUZMMOtwI8Ia+TvR3TNTyn4CbQfWhU7dn8WjtcAzEwccrDf3l2NidrtuJbzc3sflxazVpMXRsvZ6K/YClekzu9L8IzKWTbmv2oGPNjqpzTjY9MBWTHQccS9wv2CabsCUUHyBJ+N6IH00= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by SN7PR10MB7074.namprd10.prod.outlook.com (2603:10b6:806:34c::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.8; Tue, 24 Jan 2023 01:37:11 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::eaff:9f55:4641:db38]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::eaff:9f55:4641:db38%4]) with mapi id 15.20.6043.016; Tue, 24 Jan 2023 01:37:11 +0000 From: allison.henderson@oracle.com To: linux-xfs@vger.kernel.org Subject: [PATCH v8 27/27] xfs: drop compatibility minimum log size computations for reflink Date: Mon, 23 Jan 2023 18:36:20 -0700 Message-Id: <20230124013620.1089319-28-allison.henderson@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230124013620.1089319-1-allison.henderson@oracle.com> References: <20230124013620.1089319-1-allison.henderson@oracle.com> X-ClientProxiedBy: SJ0PR13CA0161.namprd13.prod.outlook.com (2603:10b6:a03:2c7::16) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY5PR10MB4306:EE_|SN7PR10MB7074:EE_ X-MS-Office365-Filtering-Correlation-Id: 367a3eb9-cddf-484d-7a8b-08dafdab8377 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: rdgRM1BJSUJMK0KseRvfxww/dPi4c6STDX4TbqnN6qhonmAEY7GuuooceZLeJD+ttFq0iMuPvSMxsHPEQNV6ucGAc5w0/bW68yg9KAK/yMZuei7PsGWvM9tLZge6y1MyBZumzXtKEr+DmQuOg9vZNW5MZqJRHIHsR9NOo4/+g3lx4Ml/AEivaNqkyETnHwSmzvhmKtM7GoPnvEgjg5wxeyubDo93WiDP/et4ZP04UrmIC7dqNoUBx2HykfcjMtLQT7ssb6/QRrH6M0k7jeU/hT9iTI3aoM39nt7NFqRvwHYSDpijyFGRGqWaMvTQ5ZEjqkyMKhDYlyDiIyKq/ynCY+8ZiVUjjnptYHr5n4T5VfW+rRcGLdlZtVKxQDuBQYNd0N9oJhAsmUnS2V7PLEmxa8ji5ZHvr17uF6aA99mI63pvUhhqCBL1QVRppeM2QjMqUq2dpj7cYTibSHKDw4QH+P6zKFRCAjMCP9IPcO6jpI/ot4DpYj0njsoQKOe5HJ6wbmQbbvfCorTZ0jC7QgfcYa3+MohBvefv1dfw9xcrvRdxai1l4tr9FungUa70VlO87OPkLKRLHEwog8O03gViluOU8hFLOhKIp1QEWHCXDSlf32SWg41XSoVMbvkDzZpjctdZxjmoGXAc8xU9PanqIQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(396003)(376002)(136003)(346002)(366004)(39860400002)(451199015)(66556008)(66476007)(83380400001)(6916009)(8676002)(66946007)(41300700001)(86362001)(36756003)(1076003)(316002)(2616005)(2906002)(38100700002)(5660300002)(8936002)(6512007)(6486002)(26005)(9686003)(186003)(478600001)(6506007)(6666004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: qM8wskH0CPBjM1EPD6BLwG3NEu7Pzdvi+mQFO0GF3MNEJMJt+lJlpf6RqCOtEP5Irx6oFAbwCGQKi1KwfnwGuphFyp24HNmXiXAop8MbByyVDWJuR0owlTQvBr1mnPvHfy6bg3npNJ8mVQK8qVO6HTGaJLR62Y1TeNt/jbeYdpOEp363qQo2r9m5MwLKzmzi5to1xgcr6jHMTZPfLk9nnzk3RTvRThYTXTrj9ADpkA52EBfcMb+UHh8is3mJbr1glcbH3NJQyARRzR+D/PkhnJuxpZCWUEcHZ7dpF9QM2x7WuK06hOsq6ZcltIfqP8oGO6vo6Ez7ato1UZRuQV9zgdPXi3D26wxbW2CWiBbw9b0989oQAxp9PxlBD2m7LbfGG15Y38r8ieFKnEJhBNxSfZShHXF1SG44BjYE6/TP4sYlJyLMqvQvS+Vswe6m4+qjNN2D267/6fryIGoltwgkI9oXee8T6oWnsGpbP24tpYKfnnAA1OMVHn+2vYzslFhbZAUyQD14Gv+2MbaPpKHR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zwgqjFgw== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: QTjc6wSDqdtKUO8lAjcKvVUDylp1JK4e3TpXt/nCREvuNQaeoUUKwYkQGeA5pnn6oA9V8Nz7ifeZsVQbjZr1xzHRaZ/pFq8UOBPkqUxzRQROcFDqhCqIJ0kcd/aK4AHXZzq2sV2A82x52601j5QYuRhhfDVtQfNJjLeGb/hDWJ9kpeyPnzQuz/Rov4EAzYzizlobVIdgiIkF3eR4VODS2yHiwwN3HYcN/ZZfCMlMpoDeYoeDRTzzHuRGUQnFlnck8IDglvRJzOK0dSecc0Ro9nW6pMTFxB2elbCV3Ot3vElrrtb0pi4TKx10ejiWWTvuhMpUT9HyUM/GT54y4ZDBrxMLBxl4RHMLMawl6NqSIgn+pxgLDIsbHvGTcpd4ezQVe68PHTytZrqyV/ChQ16PyZtS5RWMZv2YWfKuv5ekP2fRegBOj0buqjqXee/7Wz6gn3QDfIGiRKN1eYMZDWvc5VPXnQ1GTEiHDMVScBa2IJXCk43kXKSMt+KceALVzotTzCcd5grUEVp/pRNGxYStjwpD645IpoeENi5q2dh5UZe9yaagdIe53T6/p/zafLuMEtvxDe4ibVBBfny2gEGl5m2NcD8ll9roRe7EU/5aPDzBgOVORufByfXYTOvvlkYVvaK+MT2dqkNxHavc8PS7LGhtaV0w+n1HzxXEKqYau8WbNPP1JCgVmTJ/J1lnfZTJtW377spFW3S+2Ud1XrbM4e5NXVI+vuPGcFZ29pW7P7tFUqLlewg94dhamhWFXHh8wXb68ojlEcg5voObrE4Yeg== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 367a3eb9-cddf-484d-7a8b-08dafdab8377 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jan 2023 01:37:11.4476 (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: OfZw3YnfnE5OsEWvwB/+zwQ8QJFKiGvCs27I06WkCzwfXlu4V0p/kyG2ciLaVlAEZ3FF9upbR5h+xcfl4bPXVAkyBdEJOGk3ZEvkFdU9KEs= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR10MB7074 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-23_12,2023-01-23_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 phishscore=0 mlxlogscore=999 adultscore=0 mlxscore=0 suspectscore=0 spamscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301240010 X-Proofpoint-GUID: kt2rI1ql76w79b7YyOKLdxUWU5snWwB1 X-Proofpoint-ORIG-GUID: kt2rI1ql76w79b7YyOKLdxUWU5snWwB1 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