From patchwork Sat Jun 11 09:41:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12878386 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 681C4CCA47A for ; Sat, 11 Jun 2022 09:42:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232673AbiFKJmS (ORCPT ); Sat, 11 Jun 2022 05:42:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49160 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232540AbiFKJmQ (ORCPT ); Sat, 11 Jun 2022 05:42:16 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B652AE6F for ; Sat, 11 Jun 2022 02:42:12 -0700 (PDT) Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 25B3vwxc029669 for ; Sat, 11 Jun 2022 09:42:12 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2021-07-09; bh=LLSFn/qhyYnhFTN0rnJR8gD2cjGnPL4Uj2opv8r2ZqE=; b=wcDW1TvXoIFM2v5scwncqs33MvWseuC+iJBpVx8NnM6bxoUjToOlCpAhzlj/KKPIsJh3 IJAUj41S+/rQGzZP/KU0452WGduBxfTOLurQBV11x1BieX+xEd96nXdA+lPaaG6OT96o pFbYhj/MCPgNXi/X33U05yiWBhXmFNgKcorkTiUxkAfN5WvQkrDKJdb7qmZ9PvlLKjkY OLbcb5AvtxE3ttxsdxW23S8WQ9wgQg48EF/n08lRT5McqrYTgrzN16KC+cNQ3n10HUnq yLTVgEJoDsoSMpSOf0lFqNdrYXVPrF0Tl36RaueJhHstn1Mg2nrYqWoTWE6BuQgwsQn3 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 3gmkkt89wa-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sat, 11 Jun 2022 09:42:11 +0000 Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.16.1.2/8.16.1.2) with SMTP id 25B9ZMQ6025527 for ; Sat, 11 Jun 2022 09:42:10 GMT Received: from nam02-dm3-obe.outbound.protection.outlook.com (mail-dm3nam02lp2046.outbound.protection.outlook.com [104.47.56.46]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com with ESMTP id 3gmhg6urjp-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sat, 11 Jun 2022 09:42:10 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nM/+6Qh1AhqR0YUF1bgtvNCCZW8Dt2OkvFBagyeQDnSv9pm5QWERpc6aUD/4tZkC8PgFqibHAUHsuNhNXLLWx3tnY8jeIm6L224TknNFNY7evmsQ8DtGJ3E0OWdnwtHlPNFKX9DSc1vUPaZ1aga3D+E5aM9tNhEo/QFa/BxNEF9rIXoKO1UrUPYtlBPA+Ke2sframouT/7ElvQj+XlLpoZeWqYQfr2KVWL1rMe6wUmKs3vzzCuvTIFKTttjC7MZRDt3pKoEMwyU9pZGrqXdP55VgITCv1KzHKrq1++rTaJNMfuBX+00IrdmBHsSTeX4Cs4/T20YbkaCiANlPxvPnaA== 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=LLSFn/qhyYnhFTN0rnJR8gD2cjGnPL4Uj2opv8r2ZqE=; b=eNt63BjQD7AdJTKhkiECAVtj8kkGsJ0BA9S8f0qLCZRWxVDK0TFABZApIsTQN8gYd38Y6IYuzwD/bI9QrMJDPjJV0xj5AEXrWe1CA/Rw/fNbv+UwWr9jzQl1O+7d0w8qc7FvRrjKeyvrR6nJ8ge/9IaTRcm7Vom1MtLs/P4/4xG7B1lmXiufDdEXno0u4Kdv+xMe4Ap2Ba7ZRBmx0NzcuAfW4J4nPThv2oZ5aFCXadIui2ttcsondRQTYDiEs+mPONYaRLrt/V2eTwvR6Fxx780PZDQqQPvBUtc/k2DmRsAHEaWfJMuXBA1VuJOXeW+dia7GxAraZWJeSrZPQZIxVw== 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=LLSFn/qhyYnhFTN0rnJR8gD2cjGnPL4Uj2opv8r2ZqE=; b=fcxNIj3Li0ylWwur99O4IWFzkzvsFhUiBRFNjOvGPmW3s2RZELl95wMalBdptOyeH+cDF8i8XVdziOtngsTLhGei8wtHkMwDEAirhEUfd50cOXN7yqY3eAZmOGnvVnH/ej12JwTRnXSyajXbupQvJrOW1k2gkT9qPXBqYO3yHsY= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by SJ0PR10MB4606.namprd10.prod.outlook.com (2603:10b6:a03:2da::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5332.13; Sat, 11 Jun 2022 09:42:06 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::30d4:9679:6a11:6f94]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::30d4:9679:6a11:6f94%7]) with mapi id 15.20.5332.013; Sat, 11 Jun 2022 09:42:06 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v1 01/17] xfs: Add larp state XFS_DAS_CREATE_FORK Date: Sat, 11 Jun 2022 02:41:44 -0700 Message-Id: <20220611094200.129502-2-allison.henderson@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220611094200.129502-1-allison.henderson@oracle.com> References: <20220611094200.129502-1-allison.henderson@oracle.com> X-ClientProxiedBy: BY5PR13CA0002.namprd13.prod.outlook.com (2603:10b6:a03:180::15) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b536670c-653d-49fc-8047-08da4b8ea5ab X-MS-TrafficTypeDiagnostic: SJ0PR10MB4606:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Z+vu0M2b4KdOs+Z98JvIjfCLHfhhoBLLPQd+4Hwad/JEFeH8lyGvsp2eF3XBj+FK3ZDZ5X2HPnpNNhRePmt6V6K6tYMOnP5400iwUMoRMmMzxFR87wS4t/HGE7IXYvnRf2LDAVoM2TBlfBJuDwP5TscTW9XPyKPXBZA2qXRPVMD4+aA88QGVKEiZKRmK9TFAO5rcQ8U473E8NySyo9B0yqVLv3Innq/1vi9awM9KBtBX5poMhzy/62M4lXVAnFHvcGZiYxfRv4ZIjRgVHSuM+6VEnqQLJAfZnY6xMsLSpxb53eTpDINjLZVSWtz/8bfdg+PtbNCiEGxmG52zotrKGi9lOUFMgAkfLBho+3W2PI4p3Qij/iRXcUEvPSKzw2joKy7Uq68I4ZiFvG0ZYbM+7DdGp+MuS9lxH+QAn7aUGvk0nHy2A0wV5rWLi4FAaKYnY2n4/b0XO/rGSMg4xzQBnqIElQke8gmX03E+uQK4SPoqonZU9pNaEnh31byUBuv2Bu3Hnfhr5E3X98alkRSp7yqkWURF/dZBVyclFPBoO8qv9IAQOx2RyvOs0DyBja0kIok47VCnD0zDSyYNSDSuHqdel3B4awcurhOFL608aJ57EcoOs8iIrNIHSlwrCK4f/8DPXPKh6rX1nqGYUWu/+K7FKHJ9LmvybPouC/D1uktsza0cQokQZMn/xBh/vuif0fv4/2RCmYLSIjmorhfKsw== 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:(13230016)(366004)(6486002)(44832011)(86362001)(2906002)(186003)(83380400001)(36756003)(66946007)(66556008)(66476007)(8676002)(5660300002)(508600001)(8936002)(6916009)(316002)(2616005)(6666004)(6506007)(52116002)(6512007)(26005)(1076003)(38350700002)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: x4/MSu8kQOyyyZ1DXyOIRlL1gnD3fFtdIHsPEkYZbm9I2/DVe5njMf0vxFdQAoDNnK0ujzH6oqgPF8q8HzrcpYTC0lIjiFsGpay//BxHvVX1bP22E8JXtfQBCtjQVbPAWNnvWE2plRsI8ecSC/kVAm7xrZWSd2aU30KISChJG5DhhJJVKj5uS5NEQXeSFORtBAU7DJfqhsmCAsSz7NmvF5GiVHPZc9HhM+KHikUQdLGqwY9FUXm5f/ilM4fh2aCmtOX4nXWvffcv4NCzXqBKayEJfN1hZIpbEYctR13o77lVzbe3pxjkcNAu9xhTOEOuJVMAYyxt6DDd7JffPrBIUQk3bfjVgmZQfuRcndYEInfK2Tx8/TEYSJtL+KRYZNAQhuQWTHWXguLEEHqpg5xqzw2GZfQBvd+7GWrapV/+/5lu47Q+X3ZweOKXRQ7Fp8SyjHUB1ioSfVQs8qdw0JZNU9LG4w7V21bN0d2BnCyyHcUXqjAVhx+chTwnaExacHth/UR2VV27nOHT9WIZfyaYC43QdNFncOKKsooDWuvFuAIp8Dho+QiDxJGAwgSWM/zCv67Jy+1T7vIQ12voOyNDQDctBnPDsge2pqFXcamTiODhpY42UeM/iq2KcrCkPXnqWDNn4gVR83bxWU6UckBvfWmnDi6CewHFwxg3iAcacY1EpyQuRgUgsonn6HhHUrKWQZkiBOWmlqdkYN0jSxXEUJ/WzLNTCBVIKQP0DcFtptYXMyom66FrrZ4FDdlmhF7iq6AP1B0+utLsaB2RaimJGNx7RYouLrF3fqdsm4aZ7fOpmtcYmcNVwaoQcLFQIJxIP5eRH6KlpbSGWRx5jldVHkhlnbI5QKDI6H3enGDYjyDhRjX2IInq2f6tHdb4W51YxNX3zoISXdcsXA+6j4DOVFJWM05yfXQC5I//zAXk+Vz2toGw6DKqqWy3ZfG3TJokcDHE7LIBXlnTelfiJpiuNUv7Ty3A5u36L+yAXqIEyyCydB778DaEU/hXOrSjytSYHkNWnGbiaZpj71VtULRkabr+ijjWPNWQxxwlqyxv5r4BjUmNe3io5VoceMvm/YhVAtEwEVYYGdMnQjQu8dwwi2d2VCi7JMvjJah1PczytVspXc17yCka6zKHMlSRL3qQtFPbTdmwYYlphbD7/SxTtOtaCjkRKUIXc/ivo+QBexrQbZipkTG1UA9fdot7vDZysPlpdnDONBAtUe4xcnHoS3G6v8pXiarZ3eOhCKPwOmtscS7Zag51wMtXPtwVkFrb+0S0QZ8eRDWWlnkGeZEKKSpMyrGm5kdGpKISPr3c4vTkyhGEPOigh5J5z8ocpTV7uXjFtRKDRR3TjD4n/UVEoHUayMd75qWG8uwG8XJZOCnG+MBrxhSA1pTfy2oIezsY7x6c453DeCfWaM9CBoqpMxa+Kz0t6dBAPd2QJDIii6c87XH06IuNWRi2AUNHb05njH60NV78dzWzFjwzTEQ8sUBGj6KG6D1bf5t+hOlfpH9MplilnXIzGl3NQDrVI1GTj06Q6f7UC9Y0cNJ3hq/ZESVjgwfMnU6VsL6TCRwTb7aj4EHBJlAaLMeBUTB7qftAhupxDwpBNN+oLQj56i6Lrukyoca6jWzNtm7m6dpkZjaw+DmW9zxyqF2KcPz1SmfSkXEbnXcWX1VtF7ojYTowKHYuaRswSIEoDzSFIIeJ+qYF34u/nkaN+UQzPcxWmi6AG3qxsc2xZbMRFlsaZdQSEpm1ujjGWqIAm/+5uu7Ggz0= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: b536670c-653d-49fc-8047-08da4b8ea5ab X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jun 2022 09:42:06.4358 (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: pEShAfIr7NeG5cAmADLCQZISKox/ZMNqtR0PRO26pCmPSyiJfIbfWqOXwm6alzLZOOqtwn59xWxTEM2Tz6Niee3IxfACy9J6RGFlTPQ8Hdw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB4606 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.517,18.0.874 definitions=2022-06-11_04:2022-06-09,2022-06-11 signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 spamscore=0 bulkscore=0 malwarescore=0 suspectscore=0 mlxscore=0 phishscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2204290000 definitions=main-2206110038 X-Proofpoint-GUID: p0_R4u9stwwKtuQwdZiMl4Ta9iQRSrfr X-Proofpoint-ORIG-GUID: p0_R4u9stwwKtuQwdZiMl4Ta9iQRSrfr Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org Recent parent pointer testing has exposed a bug in the underlying larp state machine. A replace operation may remove an old attr before adding the new one, but if it is the only attr in the fork, then the fork is removed. This later causes a null pointer in xfs_attr_try_sf_addname which expects the fork present. This patch adds an extra state to create the fork. Additionally the new state will be used by parent pointers which need to add attributes to newly created inodes that do not yet have a fork. Signed-off-by: Allison Henderson --- fs/xfs/libxfs/xfs_attr.c | 22 ++++++++++++++++++++-- fs/xfs/libxfs/xfs_attr.h | 2 +- fs/xfs/libxfs/xfs_bmap.c | 2 +- fs/xfs/libxfs/xfs_bmap.h | 1 + fs/xfs/xfs_attr_item.c | 4 +++- 5 files changed, 26 insertions(+), 5 deletions(-) diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c index 836ab1b8ed7b..a94850d9b8b1 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -719,15 +719,31 @@ xfs_attr_set_iter( struct xfs_attr_intent *attr) { struct xfs_da_args *args = attr->xattri_da_args; + int sf_size; int error = 0; /* State machine switch */ + next_state: switch (attr->xattri_dela_state) { case XFS_DAS_UNINIT: ASSERT(0); return -EFSCORRUPTED; + case XFS_DAS_CREATE_FORK: + sf_size = sizeof(struct xfs_attr_sf_hdr) + + xfs_attr_sf_entsize_byname(args->namelen, + args->valuelen); + error = xfs_bmap_set_attrforkoff(args->dp, sf_size, NULL); + if (error) + return error; + args->dp->i_afp = kmem_cache_zalloc(xfs_ifork_cache, 0); + args->dp->i_afp->if_format = XFS_DINODE_FMT_EXTENTS; + fallthrough; case XFS_DAS_SF_ADD: + if (!args->dp->i_afp) { + attr->xattri_dela_state = XFS_DAS_CREATE_FORK; + goto next_state; + } return xfs_attr_sf_addname(attr); case XFS_DAS_LEAF_ADD: return xfs_attr_leaf_addname(attr); @@ -920,8 +936,10 @@ xfs_attr_defer_add( error = xfs_attr_intent_init(args, XFS_ATTRI_OP_FLAGS_SET, &new); if (error) return error; - - new->xattri_dela_state = xfs_attr_init_add_state(args); + if (!args->dp->i_afp) + new->xattri_dela_state = XFS_DAS_CREATE_FORK; + else + new->xattri_dela_state = xfs_attr_init_add_state(args); xfs_defer_add(args->trans, XFS_DEFER_OPS_TYPE_ATTR, &new->xattri_list); trace_xfs_attr_defer_add(new->xattri_dela_state, args->dp); diff --git a/fs/xfs/libxfs/xfs_attr.h b/fs/xfs/libxfs/xfs_attr.h index e329da3e7afa..7600eac74db7 100644 --- a/fs/xfs/libxfs/xfs_attr.h +++ b/fs/xfs/libxfs/xfs_attr.h @@ -445,7 +445,7 @@ struct xfs_attr_list_context { */ enum xfs_delattr_state { XFS_DAS_UNINIT = 0, /* No state has been set yet */ - + XFS_DAS_CREATE_FORK, /* Create the attr fork */ /* * Initial sequence states. The replace setup code relies on the * ADD and REMOVE states for a specific format to be sequential so diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c index 6833110d1bd4..edafb6b1bfd6 100644 --- a/fs/xfs/libxfs/xfs_bmap.c +++ b/fs/xfs/libxfs/xfs_bmap.c @@ -977,7 +977,7 @@ xfs_bmap_add_attrfork_local( /* * Set an inode attr fork offset based on the format of the data fork. */ -static int +int xfs_bmap_set_attrforkoff( struct xfs_inode *ip, int size, diff --git a/fs/xfs/libxfs/xfs_bmap.h b/fs/xfs/libxfs/xfs_bmap.h index 16db95b11589..a35945d44b80 100644 --- a/fs/xfs/libxfs/xfs_bmap.h +++ b/fs/xfs/libxfs/xfs_bmap.h @@ -172,6 +172,7 @@ void xfs_trim_extent(struct xfs_bmbt_irec *irec, xfs_fileoff_t bno, xfs_filblks_t len); unsigned int xfs_bmap_compute_attr_offset(struct xfs_mount *mp); int xfs_bmap_add_attrfork(struct xfs_inode *ip, int size, int rsvd); +int xfs_bmap_set_attrforkoff(struct xfs_inode *ip, int size, int *version); void xfs_bmap_local_to_extents_empty(struct xfs_trans *tp, struct xfs_inode *ip, int whichfork); void xfs_bmap_compute_maxlevels(struct xfs_mount *mp, int whichfork); diff --git a/fs/xfs/xfs_attr_item.c b/fs/xfs/xfs_attr_item.c index 4a28c2d77070..f524dbbb42d3 100644 --- a/fs/xfs/xfs_attr_item.c +++ b/fs/xfs/xfs_attr_item.c @@ -625,7 +625,9 @@ xfs_attri_item_recover( args->value = nv->value.i_addr; args->valuelen = nv->value.i_len; args->total = xfs_attr_calc_size(args, &local); - if (xfs_inode_hasattr(args->dp)) + if (!args->dp->i_afp) + attr->xattri_dela_state = XFS_DAS_CREATE_FORK; + else if (xfs_inode_hasattr(args->dp)) attr->xattri_dela_state = xfs_attr_init_replace_state(args); else attr->xattri_dela_state = xfs_attr_init_add_state(args); From patchwork Sat Jun 11 09:41:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12878385 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 49B9BC43334 for ; Sat, 11 Jun 2022 09:42:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232638AbiFKJmS (ORCPT ); Sat, 11 Jun 2022 05:42:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49156 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232533AbiFKJmQ (ORCPT ); Sat, 11 Jun 2022 05:42:16 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BC64CBAA for ; Sat, 11 Jun 2022 02:42:12 -0700 (PDT) Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 25B1hoNS021293 for ; Sat, 11 Jun 2022 09:42:12 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2021-07-09; bh=i0XU+PWY+6kM/ytmVPz/a4wYWvNvfL4MNM7jU/83bhU=; b=e5JWPKNThYaWmdhDMDm+OPihTwFkmgH00YanD7+I9/Vo2HGj3CTj+mGcMcbkJm6leL65 rj3+FQ/Mq7nRH/56f5EHBpjupObJgzRT8udK352C2dtK7DQH2n+wVY97MJiMoO8DWP1I X7kFz1nbJtKh6YcxqJRlQKKRm3m7/l1KyApkXqZAexJYj4Sh2MZAQwdrNRh1mM0DJTeB TuEraqBpwZEedelfSMaTtVjxWMaw/7ZftTq5n3MOU7san8OERZSlD46bBIZHrsDqbful nxCf6REY3qUCJqRXwCclMoeXdyUd1oqB4rOziIkzninoB1VaDPeLtmsBWNhhI6m1+dth NQ== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3gmhn08c6w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sat, 11 Jun 2022 09:42:12 +0000 Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.16.1.2/8.16.1.2) with SMTP id 25B9ZMQ7025527 for ; Sat, 11 Jun 2022 09:42:10 GMT Received: from nam02-dm3-obe.outbound.protection.outlook.com (mail-dm3nam02lp2046.outbound.protection.outlook.com [104.47.56.46]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com with ESMTP id 3gmhg6urjp-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sat, 11 Jun 2022 09:42:10 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gBpVKDeIjvqHsyk4BnlHuC2vsmY+hHepau4aNpCKiqQ5FNLHhM3f5T3Q6oLqbyMo9ES3ScsFICEgYDwXUoN/KnITdm4BF1NGgBaSTfviiHh52eFEpJ1B9UNfM27Yjt3Px6H1VxPnxaEAM4UeP8lN2Sa9xjc9aeU2JqhSo7DUwmcumUfMK0tLMSQWqty+Flhy/jxuvWasqncowO/PdloG5AJoN+gqaImkKVN4+ZpRxLF315+F65XMYAw/sDPtqJxjp6/uN3EufCpO9Gyl0qR/w73uAfcWB5AaA/QqRlrNlDUjGSIvnYcFS7K1iDCXz3O8+R51g46+oRw+twaEXKHcvA== 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=i0XU+PWY+6kM/ytmVPz/a4wYWvNvfL4MNM7jU/83bhU=; b=dMhppo8G0WxDv5M9H+H0V6yMM8pAaOqunrLKfzqGHsa1EiRzFcjcskURiLB8ccgN+8ihOHSRIWgnvdK5mtLytTnr8lcdiJdbldBtyIi1NlQi4M/ZGPhcHcqiXL3ug6diz8lN2MbzN35sOxyxN2Mx2gFZ7TWsLnJxueJeqKfRHKESq5WXQgy1Iwl6IYPUP5lEL6GD0JAI++eiKHvOfs3wn4og2Q0jpUZluf8nE3oceWEEphh2qAEsqLDfBBSdx8OEGi2Pu8D37z1vzKs60Qni6Xfi5NLr2o8kCEH0/8ylGfZXJnISb5dS+cYQTLMck10UAb6WJtdgsQKVInd4Xktjdg== 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=i0XU+PWY+6kM/ytmVPz/a4wYWvNvfL4MNM7jU/83bhU=; b=DAKPttXa+qR1sHrgGaw/7aBYYPYL8TjhSoKR4DelYAd7HIkjeDB3A9eXfIkPLX1cdziwiOw39Z+QblcXLGGgEscQXhuW9wyiryA78ek6HbYNrxWbET+GoyNi01t5aLb46jjyBM5xnyCcB94qTsUJVgEi/t4xcI7+tX5Q5JQ7E1Q= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by SJ0PR10MB4606.namprd10.prod.outlook.com (2603:10b6:a03:2da::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5332.13; Sat, 11 Jun 2022 09:42:06 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::30d4:9679:6a11:6f94]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::30d4:9679:6a11:6f94%7]) with mapi id 15.20.5332.013; Sat, 11 Jun 2022 09:42:06 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v1 02/17] xfs: Hold inode locks in xfs_ialloc Date: Sat, 11 Jun 2022 02:41:45 -0700 Message-Id: <20220611094200.129502-3-allison.henderson@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220611094200.129502-1-allison.henderson@oracle.com> References: <20220611094200.129502-1-allison.henderson@oracle.com> X-ClientProxiedBy: BY5PR13CA0002.namprd13.prod.outlook.com (2603:10b6:a03:180::15) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 857d210e-7b23-433c-04b5-08da4b8ea5d4 X-MS-TrafficTypeDiagnostic: SJ0PR10MB4606:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: kxmKm0TvFqS7oeOOShyzy1mWIMdMQPZJ9u1NkaCllZ7/7EZ+Y2M3MyE1Q5Fg3xYtCsJotcDywnTO+CvhhClPeGUi9PQNwimdbkLPZpruhnVQrt8tZMVc1fIV33zfiOMrEwQX3d36bAdDMYze1XQfXpeMhvFt4hVaNKz/Hd6YZVp69uW9HgJT+LaE3W9XiaiuNiEHu4lLOH17nyVQ66kbIO990knOBjS/ZABmfEHaZLEoa8RF2XAmNQ1qc1TLTeU33FLK2j8Jru9LsCpkaTd309RzQ88a35rzcUDTo33EnWGIPyv6AWQSf7uW0o8Hsv3UKf9qjek30DPCHwep7TG5OJYWApvbU+GNTWvgjMD1wUyXjhUp6adwCRlp38NRfPTJjoR0XqFTWzDrPQQdHYITv1cpLHMk8MdwHKvf9ob+PUw2c9CRl3gTgwb8yJV7P8JGSj1tsOrm+4t/CxGsnLAn7CPVlrcC1DKTQ7X8WwCQ387sngmaQGXmPIhpKnHcCT6dWNp3IyEtUXzzGnBnY6zOgwLhIJ6iOD3Gp8pugpQAZHjPBecQxg7RKuWXcsgpXS3Q5IrcDdli3C0F50P714hoB3MDRzFyt0/j8APwzrgxuTFeZG5/hI4sM26B8+6jiex3VkguQfyJI6y1fpH1/jmjEN1wYtLGvVaciuL4kcbWNqdlmyo+gLqlpHKiVQP4OUkveL14GmNB4g7Er/tZfGOA7w== 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:(13230016)(366004)(6486002)(44832011)(86362001)(2906002)(186003)(83380400001)(36756003)(66946007)(66556008)(66476007)(8676002)(5660300002)(508600001)(8936002)(6916009)(316002)(2616005)(6666004)(6506007)(52116002)(6512007)(26005)(1076003)(38350700002)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: o/D3l4DSe2eiqxRAloGkrCz3LQk1T5tsgOL5jHYfzAdKM8b/ZmTwa0cAUw8WaTJc9jriaNvhcUUqqvPR9g9cnaGGSxrxg0EapOKUGe2AeNEjCYhkPcX0I60WW97Tl4dOW8lPVTpMpdAuFTnaHw5KSLqvlmaZWF3U5Z/3C0VdstBE4n24RC9CeF62NhcrJptSMzSst6cTnQJHFwbMROv5MSuidokyo1280Qgn5z4fazECmNy4RhOeDM/n5M5Ee/H9SE5UggvxPjIif3fNhEBJqX9j6mmirckOnozqc4V9P/Ar+GFscvaoTFh9MKqpV+ncrWOjqlb/bj2LHgwtgsLCdhjJmf+uzkYAFYTB+BzIGOnaccLdeLqZtwV8mDq1daaR8aBo2n/Dfm7ol0UaZSZLcCBYHNwVRotuxJqS9ewgyTFZ7T+dCLHMEHRB0YUBFt0IXdNnHj4xOLUdeMvfJ/RRVzdhPI4QlaXquLFDQ7YWOHm43bFDT0PgpV/KWs09/ItVq4t5wGRhcPD6OWN9OzS6Xp3vsh8aCsC1hZMfcNWm0FOetkcIz7fL+4+QtYLj4RLF74El8MRRgGRjkdyizYyAlJKPiNLVMM6GMwrBn9ftyuviaB5rOxGK/RV+vpq0NOSCPa/BstlneUM1G5AhHWDPt3ixB/rVk522S93lDZaw/9oLJHvxhms8182AinnuV3ugXfhIDTF/DJxfHIfLGgjX/eLFp9JAOlxwnyRZDzmVxV3RJlGE1ChZMh2CuEqb4wPe/Du+c3I96DKsjr65JEg6BtEqaz66FpJxMBYbEC1aJh9OgXDFkp+xkSZu/cuDgAIExweV0lu3P5hJaWVznbhsnX30WGLEoFXl6+5BF9nhkRyG41mUVnHHRlhXYeYjlmA5wCgOMYrf7Jzzh9aZZ5a+tYjroQsazCTynzFJaGlN0cvdVzfd1XWcA6x76ygGoPYAgaZQkamjc5lclJrsc5TsecoBDDp4jv8sn4symjoR+AxvfMmhKSjc0ZJ70szQRtkbmTSrkGyXGZZPMHEdUMrC741pjkgF+rxcco0oUGtNU6FZ/AGbCMsH3jS8lF1hTfLWuUsW/eJrT+vRK8v1Bwbol5pCvIxTPGhONZgxxV0e6qimgeyNMYNeaEFOOlHUA5mMQC9YmhSGzQ1C5zyrog1AkNW8uPSvuLjB+VIi3k6aAfhiKqapNmitLvKKjYZzu2ylVQKZGbpxhyrbE+ffVMW+Bml7uwETJErRgsWuc/bmptV7hyh9dN2HO50Zai4cX6Job0A2AeeqPmwuUydKV600QTrSZ2gp8uqlLA/g48TkamEaM4IKHj2OLnAuLJiqIU7KrBXxOYMBFWvS1jWsTMSOXHlss3T7HsaslmYBGWFLFn1KzEKltKYQeMeDUe1olo2LVavTXa/1vL9KiOiZxUlw+1AM1xLgp2ZMflWFthB7ommNGRsHSST845nLffAXuRofx3Kmt2Sht8jdxH7BXeg/OrAYx0gmuF4YW/EG/XXOuxUvyKSL8qQm3Fn2DJC5egiuQlaWZdBdDMDUwdEkzmBRWtDft2K7Ugq+sz/QsKnn4PbJw+VfEB4FYh1v92l8ifkL0/3+j9NW9h2cYrRd1v36HzUvshBh5QIyNUP5MuOfnYG1/ObrKIcMVOxG9MIghOsSLl0lJ3+3LkqOcaXhM/7ZXbfDzhLpweaA3hGrypj9BKFlCeuDUiaKA12cqn6lMamBQgyuDcUMJF20qdEtktMySc451zoouycs6Ca5QjbAqu4= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 857d210e-7b23-433c-04b5-08da4b8ea5d4 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jun 2022 09:42:06.7171 (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: vIr2/9z3puwbmB5kJw6TQUlEbrMgcxbkLt8Sh2NE7BZVVgG4wFdJdAvcl08Z1MLUrah8JJ7SJOiKi5q2zOD/s5fukHFmEBYUI7nI8T3T6b4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB4606 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.517,18.0.874 definitions=2022-06-11_04:2022-06-09,2022-06-11 signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 spamscore=0 bulkscore=0 malwarescore=0 suspectscore=0 mlxscore=0 phishscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2204290000 definitions=main-2206110038 X-Proofpoint-GUID: 1VCb7BaYh3hd8Op-p9hBm_IODbZM51Ny X-Proofpoint-ORIG-GUID: 1VCb7BaYh3hd8Op-p9hBm_IODbZM51Ny Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org 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 --- fs/xfs/xfs_inode.c | 6 +++++- fs/xfs/xfs_qm.c | 4 +++- fs/xfs/xfs_symlink.c | 3 +++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index 52d6f2c7d58b..23b93403a330 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -787,6 +787,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( @@ -913,7 +915,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 */ @@ -1090,6 +1092,7 @@ xfs_create( xfs_qm_dqrele(pdqp); *ipp = ip; + xfs_iunlock(ip, XFS_ILOCK_EXCL); return 0; out_trans_cancel: @@ -1186,6 +1189,7 @@ xfs_create_tmpfile( xfs_qm_dqrele(pdqp); *ipp = ip; + xfs_iunlock(ip, XFS_ILOCK_EXCL); return 0; out_trans_cancel: diff --git a/fs/xfs/xfs_qm.c b/fs/xfs/xfs_qm.c index abf08bbf34a9..fa8321f74c13 100644 --- a/fs/xfs/xfs_qm.c +++ b/fs/xfs/xfs_qm.c @@ -817,8 +817,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 4145ba872547..18f71fc90dd0 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 Sat Jun 11 09:41:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12878388 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 74C65C43334 for ; Sat, 11 Jun 2022 09:42:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229735AbiFKJmU (ORCPT ); Sat, 11 Jun 2022 05:42:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49192 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232333AbiFKJmR (ORCPT ); Sat, 11 Jun 2022 05:42:17 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3B70ADF61 for ; Sat, 11 Jun 2022 02:42:13 -0700 (PDT) Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 25B3Bj2M022581 for ; Sat, 11 Jun 2022 09:42: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-2021-07-09; bh=iCIavo70sMafFKiT1pCjGAsMcTbl1AaiMh24xvs23HI=; b=cSxNHfKY7RwLpSg5TGNPaM2hxREMG/s9U0razthfJj4yGAWwMU3oLpwI//mYRff9bByA lJsJ0XoJ5Ayj/YjU3RHNqul8p5AzbWVGVZSrtc1+bGetIt3pSXxzOXwM6ynA0pW+upyb tgyDSLYnbmehSkMbySnFbVOHNialD5EUXp257zO/3MgljQ36JTQq77MrKf9hqorqA9QY 0dTrBxf1tanmn+YjVkShpjpGqLWeGWmKSwqsz1108UU2l9cwOyLZcTCgrf3fyrahzqGE x0un0S1j9IYt2FJ9ZTJPpaozsnHAEfYQishT0AESU9ezMZxEqalewqNzdKVFz+7SEi0C ig== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3gmjx98am0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sat, 11 Jun 2022 09:42:12 +0000 Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.16.1.2/8.16.1.2) with SMTP id 25B9ZMQ8025527 for ; Sat, 11 Jun 2022 09:42:11 GMT Received: from nam02-dm3-obe.outbound.protection.outlook.com (mail-dm3nam02lp2046.outbound.protection.outlook.com [104.47.56.46]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com with ESMTP id 3gmhg6urjp-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sat, 11 Jun 2022 09:42:11 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EYLM40L0j+jO/bYmaSmBtGRyUt+8g+ir/AzaESOE+PcAMhK1yrJVulNi7Yhh9oYCMjNzPIbviVmfLzFY4yFxGBLRgcO5fKU20WkpQooAD5GilSRMYZyFwDa49Q7btVBimkrXiOAvoXtcoMMKeEmRFxlVK0yUgMpBJbaZzm3hA3ZDnjdR6mqEVBtBLpBM6EVuQ4u7h+bfzhSP4XjccclM3ngAwP3IQ3/3539iAqYp73XwjDbQJOcAlfUrj9hRxRmKEJ4PreTawm6WCNrKArO8/eGOhCsJjEfnje9Nm5YzSH4RKCPSo65Y838QjAzflbde7tU8rhohJxXWkgeH0rxQrA== 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=iCIavo70sMafFKiT1pCjGAsMcTbl1AaiMh24xvs23HI=; b=gwEmt6B7VEf/jy+UbfBW9vX/tJh5KKuq/O/Kje2mqaocYfTnwkmgHke6a89D46xp3wPPLwMUNbWGM5z/R2W+gerVb310g9h5/8fMUBmbz1ZrNC12AsfuFNeFvmXqGu4o5UupVlknQWC+FtNJDftPWqFZRUz+oeRxDcge1aTwCwiPB2Ks5+MNjIuW/TF7m5JQ96laPaah1EgIquHYK07uLCn7Asx6FutvPtVlKeETh0xGNKZ7Yb1uGalR+9ngdxHu2LJvLhAhOmnguicRCe1fXsdzkqswiemVCG/BLsDbHT2ytp8TCjgi2I2L6mEK4xhxwu2DbxEa49DMt1H0GDYh4g== 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=iCIavo70sMafFKiT1pCjGAsMcTbl1AaiMh24xvs23HI=; b=n8WNRuLc9NExrCtlVWvSgOHB94FVZYpi+KYtpAQ+H4Yp7HS5U3rdf8WQS9XZ3nQ7dP7fz3IdiDUb7O0YgPiMp99AnD5wXvO/xw9D/6s8Fc1eszx2cwFXeyr+21vEB8zh4PKUyDywjGH9j37v1sAuU/Jj5OIiBGi0I8UskoFh9W0= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by SJ0PR10MB4606.namprd10.prod.outlook.com (2603:10b6:a03:2da::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5332.13; Sat, 11 Jun 2022 09:42:07 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::30d4:9679:6a11:6f94]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::30d4:9679:6a11:6f94%7]) with mapi id 15.20.5332.013; Sat, 11 Jun 2022 09:42:07 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v1 03/17] xfs: get directory offset when adding directory name Date: Sat, 11 Jun 2022 02:41:46 -0700 Message-Id: <20220611094200.129502-4-allison.henderson@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220611094200.129502-1-allison.henderson@oracle.com> References: <20220611094200.129502-1-allison.henderson@oracle.com> X-ClientProxiedBy: BY5PR13CA0002.namprd13.prod.outlook.com (2603:10b6:a03:180::15) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: da624411-3617-4931-ed14-08da4b8ea5fe X-MS-TrafficTypeDiagnostic: SJ0PR10MB4606:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: m0+FM7wMJsQ88kviZ+mWqxWRN+sUlQcfkCBBfVjzjDToAvSQ/mSE4vwY0vEw8UxHd1Xr/ICIl+GEhEzjzdk7CoKTmAdbl0V8AokjY0K/+yoWjj28HltuUFIFK+eWV3zNHQrqbOEcOcV+RAzdtkq/wFJEAAHeC00AweJz/jyzOnDG+vTIhEp1uqPrzYSzp2rwqLXPYd8WT1wYdA4lAxyqxxbgK2psmWt8MvSp4gBLVrBKSGvJ17LW/Z/BYHGxYTteMBRN/55ywsYCHnYCKuuM4C3Wg252Tb3tP3K0tnZ/MDPNPuvAct0MW0mpbgq9Xibf1Q7Wpj39fxGKFcTA/h/XYtr2gmO+c9chaIVlNnluusYhoFifc1t9ZGnjxdZ8wLYLQq5rDNcEF1qCx4xYQL7EsN31VHPX7DXpqSswbjRrgwrMdOS705q8TSmMKkAixp5Aj3xBH+XLyZ40NsAdv8C5ZUDnAS0U0pDE0+Tsy5E9Z63N8rEC+zgwYgAm19o3GaxnYvwfTVAu5VlHz7fLuFcffzJz3pwUe7AclRoXeYWE77clcQeI/5lsZixHO9QmEt028OnM8VhMTgMp16uuAwdMIv9CgRvwF/BaszyJi2peERZRFmYrJJujmKrrVySSqs5Ycb5lJBCS6cukxqc+eSdrYSCJkEzZROSdudrbfC8Ox7o+FXNhB+MkR2qSnKsFJESOkNVgB0w11MHcTd3lwd7PVA== 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:(13230016)(366004)(6486002)(44832011)(86362001)(2906002)(186003)(83380400001)(36756003)(66946007)(66556008)(66476007)(8676002)(5660300002)(508600001)(8936002)(6916009)(316002)(2616005)(6666004)(6506007)(52116002)(6512007)(26005)(1076003)(38350700002)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 3Kn+R7R7efHJASMFzWnCMHBCTX7oMXdsSDeSSqnt91pK5mU7m9EpZOg03kdmri5iXdijY0JJWR6V/BT5MTPDdZBZ+zcHAdRdbYhWOVWIUAe+3DvDlzaq0GQFyTFgsk4FPu/4JjLFENe2iVfqzpiMxfkmSqGVNjGzVjq3dF4UbBtUULC7iUkbaWYn4GNw78+VinA4000zc9dx2eLazmcb2ZhUMlsvWiOzCrJt6nZHHRZg2/yaQMK5Y1QI/tVQugEV0W4/MpPQ+hxSlL1qsjKBu1nDD8RjwSgZt8ZH3voLfvHTFDUxLcNKk2QRlqYNThHJaQ4f4/RYQQIGItuhFabAmJjE0NHgZ6dKAVSQp9btAEbiesTzsRgUPWI5bhppMwPpEv35bgugW1BGLX6a5IPmwkisefz0EfIQkBU8qYEKi0kZVfWnaYa/obNqq2/IR95twH/vpneGE4nhd/xuMs3maD63rzukoM51E25P0BzsuC4IxrtO3YwGSWBRZ0hMzn/cVmwTdPTi4soaAFH4Er4qv8gyAe9LkMY+4VjgIq+TqdcNerADCCb7Yjr5bsLxypwt9mi+nsihgKgv53CTsxDSMIKodjJ6dBRwP2s05yIrya7/mQx3mvZuCr5QE9WI+y+6iylY7xLKiKV8n1BvXbddywJ6l9Ud+nnnvnRSy6jOSDKOPKwZVFgRH5kxt8SwXW7DAo9YhPMpH16hL5uRiF+lDbeQFfh3Z8qLu4toysf2gIyy3nxlt/6oA2kxa32JcRLtx4Q1E46dMiXAtFVlGuggyAuOsLU7oxA6KOoDMyy5CEpDYVr6J921gvWz0dLVReSiV0ip+FkwtTrMV8lN/VN7MONcEYPnUoIT4DZLLv/cdueIldumSJnQkep+FRhQKqE0QlFRroPM4TXuN81RJKsiU9GhmDo1/El2auhoR1rQayzcysBDpYnkZW8d6aN5X95pGC3oFRZl0JFEztMewRsRwfBtooobSXwath0JGoR9m+XDQcdZ4FXgDH0IJ+swxfnTRGnDuekF9BDrepkbfvas5VByyeXN1zgFINeXEO0mmJSzA8F+Xsr7qXrIPjSvFRsn7RtJPyBr0Sut2240JEuCBfhwwLKltgbxiLSh7Q+nS9CQ+t7B8V/O4T9VdAwrjaR/k7eRwSiIP0ySmlmkVNFntnVRgkOrsupbCsFsf8dHM19mY3tvC1PddS5tWw5vvkYEjZZSJj3r1M+FJqAiZ3nyQS3Zn36arS5Ta4IYl18UwpSnL5Ub5u31ueLOqOGPlsURaQ7Qp5KhFciQeMKPvLcY5pCL+7279abB5VaBfU3+Y3x5YuKeeh1yfP1nARGzVHpJ+7LNun/+SSTiEpyz+l3ZIqbdePb4pBwcVN6zhqOjNpthxbhMb7KLIjzmAQBYAHVn1M09VtyZKs9jPO1TCZ64GOBAPuDPfcSk4X27B8Flvk+ZHePay7MG+LODAW2tZct60RW0BYvn5296UaAr9UOYG8ehyLV8ZSxgfN2JPOfhVX690Mt8JzYYlAlU5k6zKUinbcfF96sI9HZjCrPVi8IPk/Iqy3AtUh9/h+Ly1nofNCQRHtULYeSHeW/RzItJcy0yDnRDyvtmMqZKivFFVnNZYWO7JpNChQGMwVkUS3RYYRQyAQGmQZKvOs6XQGq67Tw/Jnev/wLmkJACcYyyqshik0vega+TRnHCWNP6I8LkWd7MYDqvJGvLHR3j4wJFQAeh1lFlcNF+DQYPqW8RVgbnKWwoFoOB9OAas3tcK2ciFcM= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: da624411-3617-4931-ed14-08da4b8ea5fe X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jun 2022 09:42:06.9827 (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: vEnHuZX94ZmQNJ2dXcxh17IjQfM0N+7Uc/id2JnCao8hvaVcwm7tgTduBIDMN1R82dsSNDoz6W+G75q5k210RppGWEREUPnTY3b+nN/0OD4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB4606 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.517,18.0.874 definitions=2022-06-11_04:2022-06-09,2022-06-11 signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 spamscore=0 bulkscore=0 malwarescore=0 suspectscore=0 mlxscore=0 phishscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2204290000 definitions=main-2206110038 X-Proofpoint-ORIG-GUID: 5XJ1VX2WEMLol0luxWnrZzuddYLWiaPA X-Proofpoint-GUID: 5XJ1VX2WEMLol0luxWnrZzuddYLWiaPA Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org 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. [dchinner: forward ported and cleaned up] [dchinner: no s-o-b from Mark] [bfoster: rebased, use args->geo in dir code] [achender: rebased, chaged __uint32_t to xfs_dir2_dataptr_t] Signed-off-by: Dave Chinner Signed-off-by: Allison Henderson Reviewed-by: Darrick J. Wong --- 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 d33b7686a0b3..e07eeecbe8a9 100644 --- a/fs/xfs/libxfs/xfs_da_btree.h +++ b/fs/xfs/libxfs/xfs_da_btree.h @@ -79,6 +79,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 3cd51fa3837b..f7f7fa79593f 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 b6df3c34b26a..4d1c2570b833 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 df0869bba275..85869f604960 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 d9b66306a9a7..bd0c2f963545 100644 --- a/fs/xfs/libxfs/xfs_dir2_leaf.c +++ b/fs/xfs/libxfs/xfs_dir2_leaf.c @@ -865,6 +865,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 5a97a87eaa20..c6c06e8ab54b 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 23b93403a330..05be02f6f62b 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -1052,7 +1052,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; @@ -1275,7 +1275,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); @@ -3294,7 +3294,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 18f71fc90dd0..c8b252fa98ff 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 Sat Jun 11 09:41:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12878392 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 475E3CCA47A for ; Sat, 11 Jun 2022 09:42:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229541AbiFKJmX (ORCPT ); Sat, 11 Jun 2022 05:42:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49158 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232588AbiFKJmR (ORCPT ); Sat, 11 Jun 2022 05:42:17 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 882C865ED for ; Sat, 11 Jun 2022 02:42:13 -0700 (PDT) Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 25B3vwxd029669 for ; Sat, 11 Jun 2022 09:42: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-2021-07-09; bh=U7SPMCwKHSsRGhNwGUyDPIr4gLNJ2Fg+yiB2e0BZL1k=; b=P2NUJlIe5C6Pqz7OR8ikWuKpNzpW8NyPFCyFZBMyWFRPrPMKtAlFt5Rhi8e1x75YdtPa 0tLwC5b7D33O9dVt6o8xoc28zCbL2IbQXVzkcGDthVu04T19YCwnN284P2YsylW37Uuo BLnJznYMTixfItoaYZaWlJYQqjyQuBNGM2i4WQ3Zk3byrpRtOJmcNCurkv/lIu5bKelq JSJpOXZU2nz3NQyJjOHdhRnF3nF3KvVlR8tClVuaXx0t/vcZEkA3zBcz/XOM1SngDR7y lEK/cZsH5VroYyVAELinoueyk98BdAmUxHhUy1+b8v0EYlY2VALLxW8mIJd2KQw+spSI jg== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3gmkkt89wb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sat, 11 Jun 2022 09:42:13 +0000 Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.16.1.2/8.16.1.2) with SMTP id 25B9ZMQ9025527 for ; Sat, 11 Jun 2022 09:42:11 GMT Received: from nam02-dm3-obe.outbound.protection.outlook.com (mail-dm3nam02lp2046.outbound.protection.outlook.com [104.47.56.46]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com with ESMTP id 3gmhg6urjp-5 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sat, 11 Jun 2022 09:42:11 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lPxvZa5uRUG4Yi9UcTXR5NbgDSGaH4/o3XEyg2rT1xyU9Jjm5VBe6+46GfzPqFnQiAu9ODLMhqo/DNlCyzdjEQ7L9S49fajjG3SeanEw21Z/76lCin65bKxyEDExcf/lhnYD/6FiysuIrsNkrDjCD+sp5bncM87Hel0q3GJ6ni9n46mMyAF+ewvyPywXXl5OSaqRqfAC5aOAyQWyDw43nwaHAP2DA2Khyl7fOM6AJW08yYfq+wFVpDxoZew+MkfhPBWOj0e51OJKHY3slFoOobNzCYIerrttKk7/R73uWBampo321BQISiHr8dTZPWPvKpEgLG8N8v/7kJxxR+U3Fw== 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=U7SPMCwKHSsRGhNwGUyDPIr4gLNJ2Fg+yiB2e0BZL1k=; b=dBAJ8ymgPVYmqVMvUvcMzQVpjl6ePGwB+JKYWGfdI+8LBIbz4cWbFByupxK08WcV1/GDOOIKlSn6zK0H5YdH2H6L+9KXumdyt7+Og4lKieWeTnpiBGFmICmtm5CLHO2g1EkcYU/JIWuo+VQs76ajK9NhbBJmIfGYCQNDWWj1GUBdAkjbQXLEyVhe5Wag3SiEHL+y8i2kLS7kHXt7eImJef4Xl7c7/SPuXsBH2xGz8Udi8SzawRENvnJpVFCIcf2RZ9bMbKPhiDOdyL3Va4jQf+INBrqUQjNphz/RP6ENpLz66A+SW91/uXVdZkMWO8mbcg5VTAi7lGe1Eyd8wZ5kUA== 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=U7SPMCwKHSsRGhNwGUyDPIr4gLNJ2Fg+yiB2e0BZL1k=; b=djUqp3VD8oec3GoiGOTcTE/JkGr3WUCF2IcOAmrQfDVPaSZJk73e5jyc6Bqb9LvI4fXV3iJqdNaJspO5v0rIqxDBWnkUcnUeC/EMC7F6JoJmsviXGa8IDE1Zi/YJovh43jmP64yTkwB9JPpjzbutSYqHcxz5MVo7GD/ALiN+UMY= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by SJ0PR10MB4606.namprd10.prod.outlook.com (2603:10b6:a03:2da::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5332.13; Sat, 11 Jun 2022 09:42:07 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::30d4:9679:6a11:6f94]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::30d4:9679:6a11:6f94%7]) with mapi id 15.20.5332.013; Sat, 11 Jun 2022 09:42:07 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v1 04/17] xfs: get directory offset when removing directory name Date: Sat, 11 Jun 2022 02:41:47 -0700 Message-Id: <20220611094200.129502-5-allison.henderson@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220611094200.129502-1-allison.henderson@oracle.com> References: <20220611094200.129502-1-allison.henderson@oracle.com> X-ClientProxiedBy: BY5PR13CA0002.namprd13.prod.outlook.com (2603:10b6:a03:180::15) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b74aa884-cdb1-4ddd-13b6-08da4b8ea625 X-MS-TrafficTypeDiagnostic: SJ0PR10MB4606:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bBelfC7YBee0jtcL+zF//Lqadt3iNjIGVh3lQBvX+ZFcaJ1mKbv6+Cq2StgnIwA8XJN+/CqCzTd/8NsBWQZVgA4xqvew4wjazAIU05Q4CDneMNcwEVnCorUs80QiqBr/z5vbVtFXo2iBiHK+HwtwWAr4843VPJKXHPKbMAVTX+LpYueus+Yc1O9yweV3UfCKkb6mhN2UM0MM4bzIupsUDMtjmCDqJaXGvJMcnYqqJ9p7dNwyB1KpbyCyvIOajENdNna5wcZe7DnIcB/MZXtkiy3PMwXx4cheHpagohlBBI5ijQRCQt8IYF4RS6Dk5QkSDqQbHuE2WV5NfrGaDGPBy386QViSzOzoJESjWO8vRbkX2Kf+amMRB3avd+IxSzGlydyKoVk6fdHO0zo/eX+kNt1I/K8en+VZELjJTqmGy99fbnmIE1c0EYw6Cr0vyiI8oeyRJcp+Q9ggbo+X6XyLycP1dwFTpWyi9LudScTAEjnPM1VAk4i9hPk+shoDZlFXM77ciAuALXMd0sVnftBxl/eJKAUHlrEPrK/DrEt1UJ1mS8Or0Vxkuel8Rf1SIXQU1BP8HGwXpFqV49PKEgcXWwHQeQI/AfUoSdMPxgxlaDPMyBIS8iSXVN/5H2/S/n4H111rEzKQHoCD5MYoZFI8YJ8I4LvU655AmChIUSHc+WUZCcvVViXdKVnqeE2PG7lMt2VAQLZ4tLtQ6kKnsXTjBQ== 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:(13230016)(366004)(6486002)(44832011)(86362001)(2906002)(186003)(83380400001)(36756003)(66946007)(66556008)(66476007)(8676002)(5660300002)(508600001)(8936002)(6916009)(316002)(2616005)(6666004)(6506007)(52116002)(6512007)(26005)(1076003)(38350700002)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: tUCQK7ovqwYEwgeRmLHLrAiirIt8Ucv3L5lcxpTYFMej+ERHj7j/8r0/hQEHbV838i5HcQvW6hsw3rr7A6wmwZHSQZmYGGPJOVhmErAPn6hf5VmnnXiZ+c1RRLH2ZjOX8GOrD/mF8D1/YW1cyRu3Iuc2nKApF40WFRMTMCqkxSrsbTjEzVlD3NB/2mSqSIkI116D9dAlO6EC2nK0SbBuQymDOKS344iAYCag3PhM2EjxZ2AiKJf8rC77DbBkC03YuAlL0OogF0FeG3qr5Kp2YVpk1JmhFOtQwPUsQU3093w6HTQ/GLSsuM9wI7hOBJl6w7uKSriVuwzL0g4rdJcPJ6pugCl1Fg6NcU1nmlbMCR/ShqUKq359yKji1mr7X5t1yyvkdfyetGlWsNBVza4ZJWj2akt7bbfGvEV6TUqrHqI6n73SB4GSSOOXknAQfre+CpqpzMoqoJswWyn+rvwAj6qZujLPT+76YFRaPQXzaBYh6VRZAPoxGp/cMykaQsiU3p3CRYPUfC606PdFjdJL/zkt7GWCLcYfUfB2o0syJPTW1MlWseDhUztgVyjGRUMr5wMpmn3SSD2iXojvId85GlzU0iKWRnJX3KCHykG6RuM9Rvk4gTfcjiljllnw0ORqK8/M+GKPDTZsSYrCKfA9ymIFZ1lLh6pQ7AxiCd74cy7VkNaze5EJ61QhqI4QYMVS6iF1fkipamSZI+tIkUMS1kiFXmzLoh4TjdRNthTTOHq4/L3SDgiynLE/5jx1aG+pycM0nG6wlX13nwnWhfmPgcgiWNUCf5p2TIKxNAPv6EhekKKBxgg7xOkdoo1Ar+wzVa3e+Efo5PE6XXpF6imMGnezu6fLoJo7DiDW8kU6YhM32DYmhWeANlSfAILeoCre6ZNMTk1M7HxodSSBLEe+wDW+njSRw9+iMi8U+GhCbV+ssI8hpbgFR5eHDIpQEUv2UR9cPj2jcEyx0RQPpNtor8qRl/u00ZVskmVdeBqZ0ao5GwMTtLzu1ixpHIKzwmklr31s2o/fH5D+vCX9haE4huaPfGeZvrF63Ld6IMXpeqU6pkF44wGQFE05a7Osk28c4YG5wzbG/syugaYsvHIkX+L9+I4zNbdNfP/90N7Xf3hXJVqPJXpj7DeZ1MrqHxaVvAZczbjbkazjh77LzEgTfEI1HhsnMLbdQ9N+yxcJRl0gowbtrixO2qbWXvckqJx4fdBzvGbBj28yA7yQ3xgyTHXu0+PUWhm/AmRzwYML+zByBGyGdpqMbrvzTSe9+pfyL6b2Ey5bvFMCGjp6Ryo37qbYDcKKQBMDbeG0pKLSP6b+ffg4ffyvjnnDQPJUSpFbFKloAZU6ZmYTlgJ7IFFUTBYPGmrppnFEAkirOeIrAYZFMgzolGshzdmLnoXfJEx2LC3/qPWBj7O/VAaI4oyOJtPX5CPWcCr4kGJSFDYdNg56PvD3yGhz1NOBL1jSyRvy9i6SPG3elBEXhC04loVflND08ZeaBSduVvurxIz/1mk1qboxfQ8hxMvV4G1Sx/JLlIfmzFa6O1pWk0HdBHqhN1FqmqKql77pwcGKS4jKFubvl94rLAN++1x8BGNU6IvANf07TzwxgXYAAuAD5wmwbKl9vM77jeYh7WYE3+K0u7dkQ9ODq1MPG0+g2D/28dw3lI5GUOIKuRnYJalTd0vizQ2AqPin6gBYtKexiA+gHTLrQTIuwvmOhYt4NBCOQ/sb6sdfRRKJddkqBmRPz45UtHlyi9B+uXmuRRJzwOQjpko= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: b74aa884-cdb1-4ddd-13b6-08da4b8ea625 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jun 2022 09:42:07.2326 (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: /y4J59HHR5nwPTOzr/8i9hBxK5wDnux+41nvxmHC+qsL1Jbxwla629UCA+Mpzr1Ievd/4ELYjuQ2G1id1cDNx/FMuQ46HTYZyYiHLKSwnfY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB4606 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.517,18.0.874 definitions=2022-06-11_04:2022-06-09,2022-06-11 signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 spamscore=0 bulkscore=0 malwarescore=0 suspectscore=0 mlxscore=0 phishscore=0 mlxlogscore=976 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2204290000 definitions=main-2206110038 X-Proofpoint-GUID: bKbctz9plu8ETBnxQWWX0l0N78i5Jmiy X-Proofpoint-ORIG-GUID: bKbctz9plu8ETBnxQWWX0l0N78i5Jmiy Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org 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. [dchinner: forward ported and cleaned up] [achender: rebased, changed __unint32_t to xfs_dir2_dataptr_t, Changed typedefs to raw struct types] Signed-off-by: Mark Tinguely Signed-off-by: Dave Chinner Signed-off-by: Allison Henderson Reviewed-by: Darrick J. Wong Reviewed-by: Darrick J. Wong --- 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 f7f7fa79593f..c3fa1bd1c370 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 4d1c2570b833..c581d3b19bc6 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 85869f604960..4579e9be5d1a 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 bd0c2f963545..c13763c16095 100644 --- a/fs/xfs/libxfs/xfs_dir2_leaf.c +++ b/fs/xfs/libxfs/xfs_dir2_leaf.c @@ -1381,9 +1381,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 c6c06e8ab54b..51d42faabb18 100644 --- a/fs/xfs/libxfs/xfs_dir2_sf.c +++ b/fs/xfs/libxfs/xfs_dir2_sf.c @@ -971,6 +971,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 05be02f6f62b..0c0c82e5dc59 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -2836,7 +2836,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; @@ -3391,7 +3391,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 Sat Jun 11 09:41:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12878389 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 48FB8CCA47F for ; Sat, 11 Jun 2022 09:42:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229748AbiFKJmV (ORCPT ); Sat, 11 Jun 2022 05:42:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49160 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232546AbiFKJmR (ORCPT ); Sat, 11 Jun 2022 05:42:17 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA2A011812 for ; Sat, 11 Jun 2022 02:42:13 -0700 (PDT) Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 25B1i6sQ021605 for ; Sat, 11 Jun 2022 09:42: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-2021-07-09; bh=fLaM6kbKWeJC/dicDhwftMRumfVTbGhy0eyW/l0ONOI=; b=GVWE+GJ6zTWuivlBysI/pm6wPO4Ma/ox4Thq8X5I4Rxq/d3baQpzdlYWlxsZCgChdrlW 0pKqqxFuBym1wgNuKC+aJrKRunrg79Oqy6qOUozAY1F0x1TCuEI6UYr+sq4Dg0AJRPLh 4VySUwfOIflmGVFHAJvXqPSPod3HiiVjeGX7pdpYZmYe6oSydQnpqKB/wVwdfscUwV7Q WbYrij+631iIVwjCu+OGhRmw1uN64iFQ6rVixFAR9rUqkmiBGeee5FGt3BmMnL4VE6Ae +IIZy4gT45lfgJdZhLJf0jZWPiypYxQfZZ0Jl+VyqhWFK6sW+8RCiJstAvnXaPA16gB2 Ow== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3gmhn08c6x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sat, 11 Jun 2022 09:42:13 +0000 Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.16.1.2/8.16.1.2) with SMTP id 25B9ZMQA025527 for ; Sat, 11 Jun 2022 09:42:12 GMT Received: from nam02-dm3-obe.outbound.protection.outlook.com (mail-dm3nam02lp2046.outbound.protection.outlook.com [104.47.56.46]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com with ESMTP id 3gmhg6urjp-6 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sat, 11 Jun 2022 09:42:12 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jzfjUUfiUd2KqQ5trhEzagwb3dWdwCQhJwfhJg6sWnhLtcDOPxHiilpYB80s6spqk5EJOElxZ/iHT8Yrbl5BMdQI8Xl2519cdoKMFKoJxvnJAPrHonnZFM8xecaDDqC75LQMJ1eKN9Vxk22SWX8otWF1s5bZsZNK+iz38pA0MCuit3yqgUHe0cU8hRnvl0FeZ0vkvHTt97LeQMGhzbgy9wqn+kQQkOL+r1rLTHy2XOHvtlRQinBFR8BfI0ckmXo0F4Pmhh7jqoknL3Nq5uvVRABhk5gaZQ5CEiUD0kS7ljQ646/ZlfNgQ7RQKHNbOcO3eB/kiB36uoKmx/oWRJdk5w== 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=fLaM6kbKWeJC/dicDhwftMRumfVTbGhy0eyW/l0ONOI=; b=i/+sl3U2h/o1jymtgbZurJcHzxQrxUKt9Z2ylY53xxIO+xymDV+bmNNFe9apgGjUaY3knQPvq31ACqomukrH9/IQkwpfBejPHYMNdfYQpSbmdF/EVz/LO1sd6S0V43fB1WPB8PI9G3LBnRjqC182IYEaBO0F6oEkbWkDY9ef6k+629pLr8RsswZcq008GFhN8MysYQZ6iC+zlxcPAh9bzhmV5Y1JtPnmvSvbZVzoD2yFqZlOXXQd6StfKZc2PsiYCoEDtzEOb7KAoX+r5T0uQ7DRu/CB9s8v6IwZNolroUvf++cDl6gZ5yV/LyhpBGGgsYI996x/vjVPP+LjUKM2pg== 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=fLaM6kbKWeJC/dicDhwftMRumfVTbGhy0eyW/l0ONOI=; b=QeyKtMevPdt3lAeiAKtCfJQ/laKsPfALZcueJNtjB6N6Z/jS90i54PhdUAQQ3SLtmZnfgQibMo1wYmVvgv3tbQdVQlKPb73UdS7fKt6cW9itdVwUwDNKoa2P9Y0ijVYwZN0PC4lBU5Y1RRmaon3ceG7vlRDSrXi2Fv/bz6PkQ7w= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by SJ0PR10MB4606.namprd10.prod.outlook.com (2603:10b6:a03:2da::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5332.13; Sat, 11 Jun 2022 09:42:07 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::30d4:9679:6a11:6f94]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::30d4:9679:6a11:6f94%7]) with mapi id 15.20.5332.013; Sat, 11 Jun 2022 09:42:07 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v1 05/17] xfs: get directory offset when replacing a directory name Date: Sat, 11 Jun 2022 02:41:48 -0700 Message-Id: <20220611094200.129502-6-allison.henderson@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220611094200.129502-1-allison.henderson@oracle.com> References: <20220611094200.129502-1-allison.henderson@oracle.com> X-ClientProxiedBy: BY5PR13CA0002.namprd13.prod.outlook.com (2603:10b6:a03:180::15) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d1babcb1-1fff-4527-f95e-08da4b8ea64f X-MS-TrafficTypeDiagnostic: SJ0PR10MB4606:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: YRIHyNlVdWItExFeqDThU6AkPXZT40i87pnosQbFTuJC12W3eoVD1ShlrNn7Cvlool9H7rc3sLphbAjkeP18NBQS4bgD7OFHThQoMLO1dDd7JoLzl6MyCRKjTacQHMVA4ynG+7JwplEa1K4sz0M/uwRnCCebLGbPQ9I9HYj+vS0qmQdn2PyEtZAhEPvq3ukKwLoVr8FTQTC2G8zJAsQdCZsVtwRs2JQqVCpu/3LrRrYQocwB87wOWmFZdTZrylLJZD1BB8PD9jh2cEM6y1XN2/BExpJpV9HKMEecO95mHx0LjEtAuz+ViFJroeFDp5WlelvWfGbJ0jRVIyeq1mtA7zFmj5wUG6UrduUFYY5g6h/0IyD/Ivc8RjT2R54shEMzVEGLTdyksFTnGmbVFDQyywD/rA9dxbYB49uex8r84GXa1YPNJgzl6R2HVzC09bNXDyG4yHV6ScUskip/azL7OAszUhOorwyJK2WzAtkx1moaVolfBa2WBLV6f1581DrjaCyrtZhZDKwRde/uA+IrACCNe0/8mxINxwD2BzjtVtXpDIu9h7aRffSpmAipWzGGLu9l9/21ccQvlU5KPsNa3qPmLzGxAdk06v1ShHN0gAUjlJgILR69oGcA/0JNz+U6FMazQVk9CTmUSk4k/SwixVPtR0Th6mZWf/TtcDXX3pR9rqiFoAUTbMYxB2ZxDb8gAZD8D8JtQbcKAB/P0WxIBQ== 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:(13230016)(366004)(6486002)(44832011)(86362001)(2906002)(186003)(83380400001)(36756003)(66946007)(66556008)(66476007)(8676002)(5660300002)(508600001)(8936002)(6916009)(316002)(2616005)(6666004)(6506007)(52116002)(6512007)(26005)(1076003)(38350700002)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: qxW9njZdVrlSaaRzj4WFEATyiEMpHP3sjbMh660TzSO1ZrXixt9fUucFtuJE+7lpQd9L3ikCbg2Yp0ma1UyuYwAyGgA6WWK7SMIDfgLGoTyu5qUEjxE5BSqGED0vQ25ZbcET41fDQAppy4Lbr7Hyusjyg2fO3lsq+YEdzYOsKVlwhrGc8cPIViSV/xGCKIneaBLsFJUPhPRkT8CIAA/EVOa4HiWDVOdFpLtlgnMo12YqaHcgEM0+CCUuajl91Ua4QS3+nwYjwjT/xFYGa6o3rFNnMBZK5v9SUxtyk5xaa3vFIjJYTPX6g8AFCZRy49HmYQl0e3BwohSOqBzFLt2wKhqfP9UK3tuPWZIKK+ojaZNA7XvKXCJ2m04dmoFvC/SPe8cy/QwKPaxeRiII5jzW47wPjuAU8nobf8zDgzimFF4j0j31vJcNk8WRXkj3jkjwzBODtlDrpaLr6i/aunMjZqNke00jdQJrHsYrC+3h+1d6zpwwhsW2MsmfnQRpp/s+qAw9UwE4aGysuWu0kjZJy9b/DGyK4ATmC/1z5bgQkqI6WgVn1pBL0wlnhTaVM03W6XdGytdP++LcuSrdYdCg+JXPbIx4FzCKZYRBXk+F+D6Y+MKsLxquiUWyOmeknGOHMe9PltDU5DGpvcEtJngBpItf4E9bZWtHem/+cGPOjpIWW6gU1MnvGi/IncqzdMvZUDNfPB+n4poAwxWbtGQXVQHHRpU+ooOHkg1MzW/KEt9Ye2oGeVela2IVrS3ezAlHYoJ8N1Aj6i8URNuO3K3uL8QbLcSQtCiz3EIHsqvcQ4/qKJo1wY7eaod10wNeA8N3MoQhHIlgmX71ntS6/exfA4TFE56gCD7P5PyCFqe90YlE/I00wWkRufWuGGtIG+h9pAm9QWj5YcR/8sDQlnh8x48UK4lIzTSECrGjs/a7IJCQmLfQ6FTlw+UOIRDRDUBpOLxDMGWOkH1nexzdxqsWTt18qAB4fa/uGCiP3BW78E3v4el/pluRBBqbWD91guiYzKAdrjM54SbS7cYGqgFa7KsX3I4/aAtbxUCpG991//HnfB2iHPVFo7x4i6npdnQshOAiqs7OgeLMSAf4zwtIfOFJQXf3iBldV+ou2W9SJ93XU44NNJPTPL2rNf4gOOhPUGjgwVwWesq0MlISKQapEaxf77OHIsRKAPkzdIizVthKaMjW+f3ERNWvRSnijq/ECjETQIz6OSyQrgQ420uQaE19pewVrPeJlF+kg5WgQNwLqUt6tWWubUjlAZ05iW5rCWmNFEo09ENEo4bQLdEjlrNoJ74R+u2p2gCBqi0E5vzT3BwDqG9QECep69mMt9MqehKMw3pWOuPCNlxmqOkdu9wjq2U54/Zlp6VmYqSRrYmQlZFJsi0VGXRVDHHdUWodFG6KnXNymjbLfryb2DMY08ViJoxkdrSNXnPi+mEPicL9ra3x+g5brOgsBD1hmLhJv/HY7qMNSa91AcZDFz2div5hnPi4FtwbbYs3rfh0DPTAAJGFS17a9kb/Wt7NeewSE+57DIUorHBUR1W6rQz68xLe84IjadqsG0F8pbFDZ7gnc+tttH9L9tUnlWncMVO2OJsXB+CiuEr4GWUVPOn/FURk7NAsmlCGxmS8wxhp7th89v322BNNNWKzeyYru7WMjL/1JkuyY4XgDRTeDzI3+JJEjgUwvqFxUk0mYgkZqHL+eglcwSwOi20t5B4ezipvowmjguriT+DwwdNFSyuzqcN2/NUG0QFmdD1hR4tStq8= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: d1babcb1-1fff-4527-f95e-08da4b8ea64f X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jun 2022 09:42:07.5295 (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: mgT2dDCRLCNM9bxLcfZrLJ7XN8y18s8MCNIJXjYAgxp9uC3CwlB2LU3A+Ivng7iBJz+Vs31PtArP/Kr9ngmKIMfHPWPt6qTRymaeBKL0624= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB4606 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.517,18.0.874 definitions=2022-06-11_04:2022-06-09,2022-06-11 signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 spamscore=0 bulkscore=0 malwarescore=0 suspectscore=0 mlxscore=0 phishscore=0 mlxlogscore=881 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2204290000 definitions=main-2206110038 X-Proofpoint-GUID: 6vQX8N5NWM2l2SfHq32hnYqhUfcJfnm7 X-Proofpoint-ORIG-GUID: 6vQX8N5NWM2l2SfHq32hnYqhUfcJfnm7 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org 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. [dchinner: forward ported and cleaned up] [achender: rebased, changed __unint32_t to xfs_dir2_dataptr_t, Changed typedefs to raw struct types] Signed-off-by: Mark Tinguely Signed-off-by: Dave Chinner Signed-off-by: Allison Henderson Reviewed-by: Darrick J. Wong 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 c3fa1bd1c370..6af2f5a8e627 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 c581d3b19bc6..fd943c0c00a0 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 4579e9be5d1a..ee8905d16223 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 c13763c16095..958b9fea64bd 100644 --- a/fs/xfs/libxfs/xfs_dir2_leaf.c +++ b/fs/xfs/libxfs/xfs_dir2_leaf.c @@ -1518,6 +1518,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 51d42faabb18..1de51eded26b 100644 --- a/fs/xfs/libxfs/xfs_dir2_sf.c +++ b/fs/xfs/libxfs/xfs_dir2_sf.c @@ -1109,6 +1109,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 0c0c82e5dc59..b2dfd84e1f62 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -2817,7 +2817,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) return error; } @@ -2952,12 +2952,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; @@ -2971,7 +2971,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; @@ -2995,7 +2995,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; @@ -3315,7 +3315,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; @@ -3349,7 +3349,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; @@ -3388,7 +3388,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 Sat Jun 11 09:41:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12878390 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 15BADC433EF for ; Sat, 11 Jun 2022 09:42:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231728AbiFKJmW (ORCPT ); Sat, 11 Jun 2022 05:42:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49156 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232548AbiFKJmR (ORCPT ); Sat, 11 Jun 2022 05:42:17 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 375DF11C26 for ; Sat, 11 Jun 2022 02:42:14 -0700 (PDT) Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 25B1hwNn021516 for ; Sat, 11 Jun 2022 09:42: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-2021-07-09; bh=7bmUqUQhKFUy06InPoMGiQt0qMa2J/bjFNjbgcp8fcA=; b=MZx/MjxKKSZKbRx5aCNrL6C2hnJHSpigxw+slISgcnKHUjGLbrX3FcrNrinojTQuDliM epk21w3iMSJGXkycp2Lpl879ovZNqhcJl+vpa2GZF/wfQB1B4CbsxHAKN90U8/oljNNQ GLCW63oHBKYjBuPros1XTbc/rBgdmIK/NvRJlz4cG/dwGz7vrWv4EC9PKussnBAnEzte Ms0RgVjIzTVJ60+v6iXkG8/21gkLALLBacCchWhPvRYF2WSMlw63V9ZtYE+zUPsWbSvi e/sKVDfHAVPTu6y4HlOePhon6MzBhjIxFcB7l/Uc+1Bhj9DXcIyXCJus9373aLDmvI42 hQ== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3gmhn08c6y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sat, 11 Jun 2022 09:42:13 +0000 Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.16.1.2/8.16.1.2) with SMTP id 25B9ZMQB025527 for ; Sat, 11 Jun 2022 09:42:12 GMT Received: from nam02-dm3-obe.outbound.protection.outlook.com (mail-dm3nam02lp2046.outbound.protection.outlook.com [104.47.56.46]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com with ESMTP id 3gmhg6urjp-7 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sat, 11 Jun 2022 09:42:12 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KPd2vA76hlRCUEIb1GlLhM5FDEPk3OFZ/iGBatdt6vPoJjny6thAH/Zd1ZdH8KyYB1ST8mbNT2vvE4AK5YOKqN709GTlnKHkXKQXwRl4Q6Wxm2BMp2tMR1jnSq0z0W+qtjE/Yxl6au6QIcmoMtwij/xf8vND3lMBmnfx9Qj5Qn2vaNbRgbPwHaT/ZGCenzwAK4dyLd2ZA13ATFpGPHic0AHNx7vrTDNXjqylAEDw3EX5I3scSgLwlhaMO03Snsch3XkBzuKLUUIehMnSlZFwFcf7lx8XiRnxUzaXgRaWUXoKLfgf/Y0A347TBzTAZTOuTmvHn0quya8w174P/4kPlQ== 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=7bmUqUQhKFUy06InPoMGiQt0qMa2J/bjFNjbgcp8fcA=; b=VnmCmTWsabuii50lcrQ+GOndib3nqVHSSREyfxx4G6YEWw5HGNn0RmdwsuSy//7U+pOi/ij3gM3gatMqYxSsl21x3gQa64wpnSaEgQj0pzryX1hY1fQZzuJU8G9/OO/VQqd1uUWN4i/Fc7o6Ja5GSrOKMMcVoD5tqlhVoMHawpkIdUWmdKQei08PDS+3JgNpHs91arzwJHODZlGi1C8VA21uuz6ig6N1rta55fI0vBHOwWWr9436lB9QUnNIVdk82E+7iE4wjg6iQdYbi/V9201E/2u+4HKNq8biXHuES8aLbxBrV4lDLsBl7p20lIcKARu8fihCMK9+Fp0KhJEdSQ== 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=7bmUqUQhKFUy06InPoMGiQt0qMa2J/bjFNjbgcp8fcA=; b=MUuRMPCVauk3SkknAyORODrrzzM8vwRjlmS+873trMytJpNnRnmRbR4DfSxTiZZ9MFUh5vXLEnQhJUZn3MzG4n894ltXfdtDRO4wX4BKwCsh/VMFh8LRepgmu3r+BkET8rMgcj/Zyy7Dv+y2Vi9VoBlaSH82v69Rw5UlXYNStUg= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by SJ0PR10MB4606.namprd10.prod.outlook.com (2603:10b6:a03:2da::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5332.13; Sat, 11 Jun 2022 09:42:07 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::30d4:9679:6a11:6f94]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::30d4:9679:6a11:6f94%7]) with mapi id 15.20.5332.013; Sat, 11 Jun 2022 09:42:07 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v1 06/17] xfs: add parent pointer support to attribute code Date: Sat, 11 Jun 2022 02:41:49 -0700 Message-Id: <20220611094200.129502-7-allison.henderson@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220611094200.129502-1-allison.henderson@oracle.com> References: <20220611094200.129502-1-allison.henderson@oracle.com> X-ClientProxiedBy: BY5PR13CA0002.namprd13.prod.outlook.com (2603:10b6:a03:180::15) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 60faf14c-74ff-4f41-b38a-08da4b8ea67a X-MS-TrafficTypeDiagnostic: SJ0PR10MB4606:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: TcxTj7TQmIM71IvBRPcePjDZDe9RZTsICJyNNw8IFMvyq+GPRFuogS2gNVRAZN9Ui2VeRkKgc2Ym63rCPTOTYKAdrrtUZJ4NbUO81ouqP94Oc7H9vc/POH51E04hWuEz/sjFZL5yWp7skZ4s3nU7mPwbEph/obf8DspHSO1Jsj5yrBnP0OM7oVYiLQ3f3CVhCFkQZPIxcnGnR1OD2ApGcSaMvoR0okNpNnd6I1fn8pbmZH1L9BW3ZemKoBHHtTrijkuKirCDRZqnypIVlhGCC5DnPsWdXdCX3XZURPz0XCn9i1nTGWgs6GY5Di59oWkeKviRGfY+r0RXgaIYQQxTtjdeoVMPClD3ViGKhJasNRrAbp6zKga2GGL3CGTqaqCfxfQtzA+vJw+BlczZcJZ0tIdsub0oAMXjUdjx0lldfL2WQbPAmPJwJyLoa+spwjqjmAB/skhIBaG6MnUTcWNqrKq7OsvK6/dy1ptMh7xmtCMiHlkLHYhntQ/jrqeRvOZI7jvktmPYiiBfp4OPGHmnaRflCVlnz/W+sDNc/gZaQ0GlrUKI5VRFmIqzD9zooHiO3JThQzl1Wjqm9J3X81W+5QMaIN+jXa/DjW4vlyIoS3grSUaWgiwJjU6biVkHDGvJ6X6oyruRAnp9oshhfH+Fx5c4WPnbGKfh5+OhBUTOTfNVA+9OQFrDi+vuAhOlShdbkTiYc7ZgK97VP3O0Px//2g== 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:(13230016)(366004)(6486002)(44832011)(86362001)(2906002)(186003)(83380400001)(36756003)(66946007)(66556008)(66476007)(8676002)(5660300002)(508600001)(8936002)(6916009)(316002)(2616005)(6666004)(6506007)(52116002)(6512007)(26005)(1076003)(38350700002)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: qX1l+dhbr04XGJP5QJq+f3Ebcik6rq/WotsE4C7+PTJBOZPld8izfDX6PBELz2cTdjJwoTg0eWWp5y53uL5YIxEMt/DGxdBFLFxKfTobQvNrmmctsjb5ACHt5QpTWb/iiqQu+iYhxHM+sWMTIkEYXpm1AtwA8+qlPQ4K/uyclm8j+dZxwKMY56NJ/PJmzniOrCDIpkuJwXhmMFwFREKyLWxZZ9U1Oq9nQMMc0Cop0XDWVQb8c05fsMjbrluOku65Z9H/AoC9foPdxDitR8xCyYfkMGxPQ3otSpBkRplq15Ee/5io+9N1x9Gl+3JQHzdmY4639bx0dnA+Sd9kzwVLivPkZoOozJiAxmcjFN1gQKSql2Krgu12kRUBjfUgvg/Sh3uc8nqtLLiknNggr04wQGnMBZ8dTOGVvpH9l6O0itz4yjPVQUESxJfBhBZWlihlWGjev5bBUIZjbwAHxOZEC90DCBKkfUe1MyneP3blH0fBNWil6+trEXElNCM+zCgaScoEm9N3+/V6/HCiNIGcSPB6PXgL5S7kVfYYVndP5w+uwmQqaRnAsdll4uoLtBWZox3CT7ESlqF1FW5aO3f1FCrCBdMjAeypw237yUJmSWamovh9UPmsdp4eTEpecmwp8dVFc5RTwmIR19Vxx6FfACt0VueTwClmKXFevYE3gE68tIAiJxYhLf1L5KdVNHWJKzRnOD5jfirhHOxsNmW1J3VRMWurbDrmz9/4yUgdtWmtMbcup9Da9l2yAfnvrDasJHl91ddO1DAQydOOEt/aGv4tF00UwIMVANkPJwHNlWlifWSDXwc9gVxzzSz4SPmwya4qfaj5EbuWq4W+/oQtALs7RKyDpott+GT+xqaKeTIhTPaVkOdtso/N722Oy93D7BJ2pXkYIcIb6e2a6Cl6ZqzleeONGck2Y3DoNJEqymvfTyYPIVnXU2T0AxJVoIzbinUskn61CfwCLH6cpwkrKduLff2bQJqcCnPDHlKFVPiXljoDxkC0m7ktidtIlWqzIHJdL1WAD8Yw8Wx3AdJ/Xnb/OjOUpoHOaxDsACtnCCBmtp29jMZ1ChghrTcYOwKd+OqZCcSvBr2wdT6btYcNb2F7fzbUXZHZ5/gRrwR7pMhi+hR3KwiubQ9L/i6pnxEGGMhKGU9B56i8ollVEwD1s9RWYqZ3jTMFzWQUSaLoVvFjWFgAy9HGGD4LHFIBctYEJ7z3+ZkCVkRRkD3o7gmfW1BLOR9aOx8MXk8Zi0Hr0oEpk0/TULEAzk+1KxKCvc6lAgUuGgqNiG7J+7gYe1iXtth9WNEs5AtulkFHALpF7Xtan5HWpErrvhberBVvcY4fiAInlX9az/T7ygREFM9h3MRjAH9F+qtLl7qByzdkGyroRLCRoTnuqUSE21x/uQhMmmvB4RejjPBjg2zIFcYqYrhoWjPVZvO6HNxZbZKtw/pDwYgfX1Gn9MlvIh5qtI50tLJKshtfP+B1HvxwqCokyCgFlJL/lpNqqFVaVV1oY/7KitAD/gvXTc/Rt3ixWhRu4cbJoibKOZcx39qc/UhvYBrji+2qTHfrf69/XNNQYOLnFdK0Lf++fsDXKYeqp4UAVA9iKQIc6hqmR9iV8KsiaontIQo0qDRQvKuQZ9nAnsESLbRyWwCmVHwdGYPZWRLylfoSLKXB2okjNTKt/TE/n0p7YK+UyXAnqfrxMo4HU9rRt74TSbldShr8gcb3jw9vArpdXaFB3ZBO9/pVpA9R/yQe+XHsRBWjuts88sA2u9c= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 60faf14c-74ff-4f41-b38a-08da4b8ea67a X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jun 2022 09:42:07.8106 (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: UXAU6gPmIoLNpFhpR6hYVoJhL0empQzWzWhMB0JHas+OH+exDqEqnlfuMQpI+dNxPngSU7FhgG9jl0Ep1LjI40kyx0TUqgFBNBDXcZ+rl6o= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB4606 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.517,18.0.874 definitions=2022-06-11_04:2022-06-09,2022-06-11 signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 spamscore=0 bulkscore=0 malwarescore=0 suspectscore=0 mlxscore=0 phishscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2204290000 definitions=main-2206110038 X-Proofpoint-GUID: bcexKx5FSePEv2qMKVKjO0UF63rXijD0 X-Proofpoint-ORIG-GUID: bcexKx5FSePEv2qMKVKjO0UF63rXijD0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org Add the new parent attribute type. XFS_ATTR_PARENT is used only for parent pointer entries; it uses reserved blocks like XFS_ATTR_ROOT. [dchinner: forward ported and cleaned up] [achender: rebased] Signed-off-by: Mark Tinguely Signed-off-by: Dave Chinner Signed-off-by: Allison Henderson --- fs/xfs/libxfs/xfs_attr.c | 4 +++- fs/xfs/libxfs/xfs_da_format.h | 5 ++++- fs/xfs/libxfs/xfs_log_format.h | 1 + 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c index a94850d9b8b1..ee5dfebcf163 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -996,11 +996,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..2d771e6429f2 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 secure 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 b351b9dc6561..eea53874fde8 100644 --- a/fs/xfs/libxfs/xfs_log_format.h +++ b/fs/xfs/libxfs/xfs_log_format.h @@ -917,6 +917,7 @@ struct xfs_icreate_log { */ #define XFS_ATTRI_FILTER_MASK (XFS_ATTR_ROOT | \ XFS_ATTR_SECURE | \ + XFS_ATTR_PARENT | \ XFS_ATTR_INCOMPLETE) /* From patchwork Sat Jun 11 09:41:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12878396 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 6971DC43334 for ; Sat, 11 Jun 2022 09:42:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229871AbiFKJm0 (ORCPT ); Sat, 11 Jun 2022 05:42:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49192 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232611AbiFKJmR (ORCPT ); Sat, 11 Jun 2022 05:42:17 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3E436FD25 for ; Sat, 11 Jun 2022 02:42:15 -0700 (PDT) Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 25B1uTH9025474 for ; Sat, 11 Jun 2022 09:42: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-2021-07-09; bh=pSeCaSqfRZVqqmeIpTq9APffMY8QowTFI0cbOfoab84=; b=O3SKXk6P998azEMUJpqGguMTI4zgHDR7+GFkjNEBr9NvSzB9VBo8FpeCuym4eJ2L/mAN rEk96PooYRRmbpHgKlUVyDAIL+U61lSu02HXpfn1QCqCPoedjXGo2diV+ql0OVsB4A47 UwhTAjhFPk1YhpE77azzWo9srayaUIRKdLALVIGe5blCQaS1Huyo19C7wznyrkUPN/0O 6bDkjXWewqDCuSWw8Gx1tvI2qhLyWa6DnpXbWhPy1OVFrCoEa6cQN9OVU+wKbitiwlhx z2SvkmNlIbJ2xksajEw/MFhRnfwr+K108ETlnTErIHyMTyJBAqRWzxJtRHjAh6b9kXDL yg== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3gmhu2gbyp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sat, 11 Jun 2022 09:42:14 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.16.1.2/8.16.1.2) with SMTP id 25B9allG001303 for ; Sat, 11 Jun 2022 09:42:13 GMT Received: from nam02-dm3-obe.outbound.protection.outlook.com (mail-dm3nam02lp2045.outbound.protection.outlook.com [104.47.56.45]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com with ESMTP id 3gmhg0m9ta-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sat, 11 Jun 2022 09:42:13 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lAhdDdYPcjsaDgy0cl9H3PkoSDjQ/0ex/fo+sP1nKvUDeIP5AxdO5YLV4LvCCP/PtMel5Ktt8ulcVJ1W6UL98fDSq89Z51FFda0PFDcfe7phOvchKYUnkiEUoqY72OkKuMCpnbP2Gnt48HBAApx0S+BesLsoB8H7OUZSgTDEvLRWwan/SNYnOmzcGq7VaRshEQfPOH+BZIv5AckM9OqKrfpYN8CiSY9lxF/3EQSSfEFIH7caSXHvti83GYJyaevsjpsp8YYsVk//a4xlLiZHB854KNyMlhLFKXrSosrAukl3kmODKEIu9nW4gZwuVTAYUuCnacBhEGecVOMsJx4sSQ== 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=pSeCaSqfRZVqqmeIpTq9APffMY8QowTFI0cbOfoab84=; b=GqVHSyQHXfiW7QB3Vr83WCo38IQoIn8KWTWoOSPAYDgr2M+FOfw10cRFYLZTZ6R/5mdqz+3HessBS52bP4uBGxPFEAJ3foaIJWDnfGV3wHem24skX9gwFXaKRZ+xYC509ay+BoBZ+5QF5BkThZ77Fx/ArcdBCxYcargcYXwu2L4k0wDBM/LohLJJiA46S2lGLEhCOCGfve/aw8S/onu20W4jAA3KR4HASRzQthyu0z9h5Ir3VoQtHNP5+B+jfeZPlE5fag6FOlC9ZoYlqTetvQHA7RqdNhXQdIvtDT3850Gx+5592CkHkRyY4miv/XcJIINENXTxdMnRS/l6p8htMw== 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=pSeCaSqfRZVqqmeIpTq9APffMY8QowTFI0cbOfoab84=; b=F+Ock1k2MOyvLMuw3oOTUic4DxIa6TidbljlSJfZbTH7KCTU5DLR8Lxht8ZQom1Me9G1Dda4BC2Ml0PsYLil7HxODVlku5CCoBmAGCPznpkfcuf9qUQ5AOUJxOENIx0HDqD9YfR3Pzg/BQ35FNp3MT+JkBKksUgvg5N1DOK2ZFw= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by SJ0PR10MB4606.namprd10.prod.outlook.com (2603:10b6:a03:2da::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5332.13; Sat, 11 Jun 2022 09:42:08 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::30d4:9679:6a11:6f94]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::30d4:9679:6a11:6f94%7]) with mapi id 15.20.5332.013; Sat, 11 Jun 2022 09:42:08 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v1 07/17] xfs: define parent pointer xattr format Date: Sat, 11 Jun 2022 02:41:50 -0700 Message-Id: <20220611094200.129502-8-allison.henderson@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220611094200.129502-1-allison.henderson@oracle.com> References: <20220611094200.129502-1-allison.henderson@oracle.com> X-ClientProxiedBy: BY5PR13CA0002.namprd13.prod.outlook.com (2603:10b6:a03:180::15) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1a70e475-3e37-4e37-cd7c-08da4b8ea6a5 X-MS-TrafficTypeDiagnostic: SJ0PR10MB4606:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5kwcGi5gm1SGKyZquuFLeoJIXdqTgL6o/HX9rbO9682LxLoMiAXemPGHCvFpMonEUQIG+wEDJLpOzhc4syXHc/Vh/IwWhvqFWTfwkiDhClWCz9X5RDWN4nrTE8gsfel/9R1wOmu7SsT/hd901fPUqnC2eLhDN1a2Ih3U2z5jPk0h6EYlKFqT4EeaGwOUf/0X6XBJKrUKOQ5/2wSBxql/l3f9NHpnofu2CGkfUZYA5nwOJJWBh7xuqR/7tj0wX/NQepRCixfyghS+KL5pxsqNt3MgBQcOkAmX4jJj8f/szME1qrGTeIyqnYKuqxsNDVDmc+NLQIUeZdGb7/M7LVage4qk246t5pFGf5pHeb1rioFWZBScUK0u6zUFW5CMy9ps25omvg7OdEdIxYBGy2uK7meIxNMiMaft5bRJz9v6bHiURBOAFvdaOzgZr1xQ/+yCQI9G5aIpBgbMC/a6HEhNwNnftHQypcHPQrKoutps6MLc61S60338RoTlLpYYHojUSOh3WTq9mzbrO1udXWL0f++174teqzL4Hhz2hVqR45qrbHhCzBOtNWyOsBQC3KlThPcaLAQPlUorInVV5J36gBcl68nglP8IWqqPppM7dxYJR0OR+Da8unqG8xIN8aqvTNVyMed0KVEMBQgXeUn9+0ynHcpulUnT4gNQcsXhQxkNhLjQmloPaBlHywkudvCaMWQqHRl7UHSRscmstUEZBA== 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:(13230016)(366004)(6486002)(44832011)(86362001)(2906002)(186003)(83380400001)(36756003)(66946007)(66556008)(66476007)(8676002)(5660300002)(508600001)(8936002)(6916009)(316002)(2616005)(6666004)(6506007)(52116002)(6512007)(26005)(1076003)(38350700002)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: txH/0E4mIH2YlykxRXcCFWR6GE0vWKlRuq6qzHArKo6b1D7wc/Ext8f9v+sq7gaDFkhqqZa8V7y1dlWCIrv/OAJcLZdyDm8KuBG5+siXxqZG/4KzEc+SyOlEvTX8OQHfOpf2i0DXVKJ0VCMtn0Wx6d93doOFoC2WGlLh99lXVIOohjJSHQL6Ll5eGFYgS947ePMn52Io9G60DAcOfUpgWyunTq4U5hqsEIU0JsBndIVBBaZDiXmBBBm4eOdHQ0SaHryz5XavaTQjVUhVrUCZ3sfYRJxhsFlkN4OtDg3LB6BNOUldqMoIigbV+dCBGkCmpgWq2wtWTwf3WzMzdn3Brfq5z+rNgqk0RzBCYxg8FCP5n51jKKruCcJx2VWw+jA2ub+LXZvXPDVrjKyXdPOR1BbTQknma+Y47h2hDSM1wzwl04060yJasnfT65ZsdZpp6y2/u1LG/I0galfo0VVoCer1KV7hpsvATjX74AU5Zh1Kp3rpm5KV1Nmw/r4JkW/y/a/iOhUXEe4heQ5xY4aWVSt06AVSB07pOOEaCMv+8I2xFrbmTcFtyawYuAJ94ZW26WVAHoWtN5M1v94L3jMbZ4WE6p+slIzlAXsGisqKN38YYBMidjH1jLAYaTTrt6//2tdPfg27xMB3jK8lAhEioEo7fAFeSx0jMX8hfPUTC5R+d2CA93WjmWuwMerREgW9AXzTUAEg8NmSKW3tiuadYXCveG+m6F+Qj2J+TOAegu3M+BLSAtWXvCL0Blb1FtY37j2KqCieZOLNLtAntx8twJN2wl780/bJoKPmsR9Ym6hbQqOBzg1OFbtQ0d4V3CDKeMEa0cpM02rUdekIkx+frtr6zKKeWgfiJYRyskjPa1tCNqlbeCmpCBNMsNFcRWAkAyukLC6RcVJSfh8WoISbc1vRu+KmzBUSU16KBRZ2dpTUKbuNBrv2XHPcxsAQmGWuiUe7TfUzMmbjZAbg4s1H7yZPjUjheSjhpWGLWhjRTr7h2r9vwmKGHte9m09ChymXpC8tbq4fdzHZlweckr038eV1x9VYrn+C62tqDxno/eOt0gqM2ieamCY/y13dBnSRbTispgTBUvqAfS7swWEjjAUiSlSRfNWnYqYn8B8DtyvZWFOk6aTC1h5YdSAmY429f1voRbe1462aWTWXiN8aN/VQ8rkD1MhxQqX23eG6nxQoI/7WU8/HE/PhgY9U2lGl5dLEsVYrarJS2z/l0QcnKLPE0JwINBdc/YIK6ISWG4YBMt4YUEfclKpWcym4pmD9obH9pOFubCtpW7sX+Ear6bVm/DVb6slhHMY4+iRJjE09OgVQgl+XwK6ngCO6LtIBpgS/SJJQT9qxDNJvlcf7CSvXwzyIBsL7wMLsXt/khfgj80KwsMcupmKOYwujjcVmEB0RXPjBU4GNr8zdX44zoW9nva0hMDwTkj3W7FuN/QrvgoffCNFii9NzpdAmJJHm6YMIiXgtXqk4OR31/IhJgWdGNIv75gxv9dCUk2OnnKGUiAQeLj4vKNxadxsKBys63IkaMK2MMA46YBZQHSO626YVtA0Se7PHZ8u34FvPx+sF0iIwfGzdzu/Y98jrx3Z7wL9n14uwaQmInZmNsEZJUc9E/VqBoH/8YhfyKwi6zLRzS9WoUq4VDkE6N6CHc2HGB75lEyuUAQ4M9O1CKNGOY4/zftLUT/uKpXdB5KJPsOFs6YJMtKTE40VFRZuVQCaYTGX3gLssx3K9tgNrlkAWRtcXjdYgGtYqaTCDCsCeyyg= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1a70e475-3e37-4e37-cd7c-08da4b8ea6a5 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jun 2022 09:42:08.0762 (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: P3xWXTibxOjRvmhJXWTveXQl53xOYqOE6a3RP+kJe+Twq6yHOWBqRLTQLOgWbi1TH8gI2tzmRqcBBE+E1ekOpEyKzjho6UwEODeMYb4qW0g= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB4606 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.517,18.0.874 definitions=2022-06-11_04:2022-06-09,2022-06-11 signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 bulkscore=0 spamscore=0 phishscore=0 malwarescore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2204290000 definitions=main-2206110038 X-Proofpoint-GUID: 3-zKHRA3IpG_nb3mMylDdEIN6Ch_edX1 X-Proofpoint-ORIG-GUID: 3-zKHRA3IpG_nb3mMylDdEIN6Ch_edX1 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org 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. [achender: rebased, changed __unint32_t to xfs_dir2_dataptr_t, changed p_ino to xfs_ino_t and p_namelen to uint8_t, moved to xfs_da_format for xfs_dir2_dataptr_t] Signed-off-by: Dave Chinner Signed-off-by: Allison Henderson Reviewed-by: Darrick J. Wong 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 2d771e6429f2..6ac8c8dd4aab 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 Sat Jun 11 09:41:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12878393 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 49A6DC433EF for ; Sat, 11 Jun 2022 09:42:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229543AbiFKJmY (ORCPT ); Sat, 11 Jun 2022 05:42:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49218 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232591AbiFKJmR (ORCPT ); Sat, 11 Jun 2022 05:42:17 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 92B815F54 for ; Sat, 11 Jun 2022 02:42:14 -0700 (PDT) Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 25B3vVbv029561 for ; Sat, 11 Jun 2022 09:42: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-2021-07-09; bh=ghFV/JCHsbsOc/x/yCnMQP+cdQocYzjVtpi6RPk00+o=; b=LEyGNo6AlUwdgsllr4pRiuOPsiPGs5R4pKzUzhPyFR1XHIYMT9UL30N4jIb5PDNULq01 BB38mL1VUzsphs4OwfzFqSf6LftkQ5IPoDs/ZKZzcstbExrmIct9i1E0GZPfU1HwrHyE uCdM8tg2AWOLvnd+dCy+YMro3H8ojcAwQHCv9j39QeUj+YnF5u+s5qJ5Zehj3W14ql0T G9zbgNxjqsZIF+EQavSZd5n4xkG2usgHHOKwvGYKwUeoIEmgaATDDLzmTh1GhYNRhKXv sp8z73QWav14aWkmzgi+BEujVR4iUybRtvK1ubB2++by45tOFXf2d1Ue9W2txgzskq+3 5Q== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3gmkkt89wd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sat, 11 Jun 2022 09:42:14 +0000 Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.16.1.2/8.16.1.2) with SMTP id 25B9ZMQC025527 for ; Sat, 11 Jun 2022 09:42:12 GMT Received: from nam02-dm3-obe.outbound.protection.outlook.com (mail-dm3nam02lp2046.outbound.protection.outlook.com [104.47.56.46]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com with ESMTP id 3gmhg6urjp-8 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sat, 11 Jun 2022 09:42:12 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LZMpJaPZAUoyRM+LD+PgE6G6lX60l2dPDTn2tHkZQSK97g0FYZ5z2hDKN9vxja3G/6RPmuvctVCvrUYwURaBRftNzY375DEVc7L5wkhExEYcj3DZXROpfru4/Hl8SeREo7297GH7f5f8jpVYCrb+bRewBcYKW8T18mULUvj1UvhckE8y5oPDuq6m7LPIySUNZW9kdFSL189RFn8Z7WKRfgUDP2N55ahNTHl8RNyvL/bjeOSHrQ0WACLmKb65jd+sVZv1HgqpmxUZiwBmEPXIDZ8JURZIzv3+lCHeUW50m+XjKTZMfD3Gv2kiMFnh4Ipnallhg1TxhCmI3InnZrctAw== 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=ghFV/JCHsbsOc/x/yCnMQP+cdQocYzjVtpi6RPk00+o=; b=avY6YnR6U7wRIHyiYSfCyFNubhHVJqdPulOj4ITkdyhmXCPrTAmweydiI2dOLXdyfUd6ze1ZIJelcqPAWdTHwC7tcmqNLTELJam4xrsSsxmHL6QEOvLncZwfSKg4qWgcGO2Jv2SWVEBF4Jto7j1Ez6MEXaa3amDb5XtyCeG4buV9neoYOU8NE0D+QiTPVduiQ1u7e4/7BeuB0FROPOcBTm/4fsd59nBNByIr036Im6fFbS2uezwyWx1Y7xN9VE2scwC8T/FEPMAngfDURs003qNFnPTCCLTyrKUgw4guQ06+D5nF8xvKrF2e1yP7M+h00rELKYXXHwsLbZEkRIWleg== 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=ghFV/JCHsbsOc/x/yCnMQP+cdQocYzjVtpi6RPk00+o=; b=ZcPeS8R4K7St9phjqUGBsw2qqSnx+Smmkq0AX8vIIC/S7Mfxi8Q0Ny6/97aC3w7yn3tztGr5MzetFb4BrNSk7kf//9TZqVU1p4wMunEHPlXn4C2H+ZiLqPC74d6DUhWux4iV1KPE7BJRFtXvAl/RElVDBCtChaxSZr/dAkGQWrA= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by SJ0PR10MB4606.namprd10.prod.outlook.com (2603:10b6:a03:2da::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5332.13; Sat, 11 Jun 2022 09:42:08 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::30d4:9679:6a11:6f94]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::30d4:9679:6a11:6f94%7]) with mapi id 15.20.5332.013; Sat, 11 Jun 2022 09:42:08 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v1 08/17] xfs: Add xfs_verify_pptr Date: Sat, 11 Jun 2022 02:41:51 -0700 Message-Id: <20220611094200.129502-9-allison.henderson@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220611094200.129502-1-allison.henderson@oracle.com> References: <20220611094200.129502-1-allison.henderson@oracle.com> X-ClientProxiedBy: BY5PR13CA0002.namprd13.prod.outlook.com (2603:10b6:a03:180::15) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3bc4ed8c-f7b4-4dc4-efad-08da4b8ea6cb X-MS-TrafficTypeDiagnostic: SJ0PR10MB4606:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: wtNykPGqu9m2f9f7RAHKVcueTusGwd0mdgmSSbUqkNRnu3r/ua6XDpz4mJV+tnP3VN/OShDIGH7AUVnjafriLLowB1q7PuJnkf1ieS7mEAtAqTGZtbTM2Lh1waaPBO6AghDs22ujhtRyHQbRj5d68+L49zKzh+W6e3qEGaBvDFrx4NkI3d5txH0pXVc6seal/R0BnYXz60n4mWhinECGwqPV1EHVRUD6gs+qWmFhhlw3rOjPfC4+LWy2soH0dL0qXNQhFpoLPdrT+e4kDLK9IFVzl/Cs20JAdYg3r7182VRSRiJyqVUGJYBzU8gFi2XrU+sxrOgIR+7MyacTDrJAd6sWuzma/+GIKqSBCectZ7vjLQSjH/jX8EYJ4aR2NOM75OO7f9UQ4zTxjfbhK/HbOelfxlXbgeohMtoOHp626/z5f0WFYLFMsy433qkxqv+BAT+3njA2Q4eCnrqoZLc0hiir5NY2uRIG2cUJBoiDgFwmk16qguQeoMoBMUmb//55PA1Syo6fW9I1aRMmqFH9AFxhdk/ISPEFARzphadDb6l3TIOQ5OH5fdRa/oO6+FynDzJaT26gOSiu4L27KxVWxtk6gndD1tczVisg3Va56kjagGrFFrkDUT1z61hqmX66Cv9aM2PBI7ckMO7DtYc5H3FuOB7v64u2xMlUbFqjd/z3f6xFo5VIiKpSHi5rzZ3M9JJjafTllNMgS0Wa2k846g== 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:(13230016)(366004)(6486002)(44832011)(86362001)(2906002)(186003)(83380400001)(36756003)(66946007)(66556008)(66476007)(8676002)(5660300002)(508600001)(8936002)(6916009)(316002)(2616005)(6666004)(6506007)(52116002)(6512007)(26005)(1076003)(38350700002)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: QjF4/lhu5eIi2Cxm8DSrW+KcFcC2ZrXwDy86wcLoypEhhDoM08a499BoTyQhVSj8ocOLlB40g0rursqKCD9ZnjddUXFIkklD7glrRWlozOcnoBDdEI0NbXxqttvIt0bwmuFIcLojxw0QuZ2LrLZYJm5EiY6e1sF4cRG2U3/nVBTTRn4K4mOC9BrK+BkX+uH+SQ3zeCOHtT6NYFLm2rmqElWQPQnt4v2rGHmx/dlFxhsqOrwfw+x3L+Viq8wUlwToT3v0M4SMj4a9NKFl2tgRhgaV+jdOjaTx5mdNwWWeblzamZ2hXSSFZtMhramDv3a1WsKziiDg8qhfks4IIluv6w7zEhvtRW0Ide9AIXQtiHKFaIDVjJgrImCV62zN7CeNqgSW/XSqle8lSy9+21R0FdTlXduaWSxpPjBD+IgLGyFL/3AM459bN6exnTV8K2s1T5ewGlM1q6LO6lgwRDSV3o1SqTP74e7s1o9F5NbBm5RLBzK7bHM5Q0+bUccwBOUL5SbrwwimtpQ1pPzAKtzygxwFIjK6kjugNTiMkfiUvwmIo5cSt/VeSS+PLbIE6ppeRCjI5K4MEf5FY55kNeZuuntz2oLWy7WD1rUkwC6NT1QaFbcvbyZIkk099sD9wCMGSbVxkguTv/Bp1sorqU3ZrexEJd54Hu3i+8Ov35geYIcjYs0BwjBSstfU45ripITJxXJG9UnDYmh0ImufGZgJQjWffr1LvJwMKwAMIBigPi3nHaHYQugpUKoaPabDvGrZcIpW//kQp0BT9v1o5mbxtdrW/7DOw1IZy9lfbx2gdshu3ZSV1U+NZ0Ff2Rp+Zk3/HWVjdVrLxRX6qSJyRHy6ReJMaT5QuwKzEE2OnJcEkj4fNbGc3EpWIoa0saCPCIgAhbE4jBvhvYX6B8qMno/8DEacaxCvXICMPa6Wqb6pNdorjfPQo9QXzwpvQY3gdtJl2OztyHXRdWPVWTwrGqiOKAtF+T2pZ8MvRMd+exFusqKClDrVrByfB0pk6YCHq7Nnv8JOZwl3tYiTRQ1C+SGT60erf4F9ZMZZPZoVkm/9nghYSCRwOnxduBk6e5Oe0vmEKHOjiw+nOemhCUUmVB4tHXx/vkOp2xhbgYiFduYULZP6T7UaH7T3WuZk0t4qSdKYg1CbHdxmugx5w9ZF5SKK6PicZUXx4wtJ8u6RhwK7Tj+dd/4Jf36Zjy6vPUuZk5uLY4QIWUn459GXs3r+5QiYVm7/dwXascfcX8SDOePtkp783kcQ1/yXbzYI38MZXBOs0hjnOGcwzzlvmj+JYVYgvlIueiMzV8d9jfV3WM+34ilUfRi7ud9mYgSJoTx51wch0hZAoXuuyh20AJuk+z/nwGHBU51JkTkdNpBm3k+DJkmlMVfdHgndfDs+wOdQuYvukuH1iNzXOzPWMba6HCMfrFroY15/7bh4Pox8rthC0Icpk9pij/Avy1CWGfLjV/JHKV/vtJkCbEQupYTKy4WmFFt3FaKgqPr6373O3lWTPeU+29/E4hxrEnMsA/J+cpW3j7kiYGw4qCN4KiNwrWIHCkn3TjLKoYBAqyoPuo95YW0o6ua3xOTbBX6vYb8CQrPn12y/CJgbVK4UDK+ytjdhmLzcH8clrXBcqAIsTqaUQvE8v4vlw0EStjxWgmQevqnf0VUrfVXKaBKKfhVxArrbQ9dyWJ2QSkxXiaecOXSS6JT+I49L7oGoPGZ9aOCn9GbV5F5BJ9TOwrB8tTRSZ5vsvR9h8ADRxIjXA9IU4dwKO/U= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3bc4ed8c-f7b4-4dc4-efad-08da4b8ea6cb X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jun 2022 09:42:08.3418 (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: sNare3Tru/8524ui/7FHP+/ochSIyM0gxlya3whXbQBwrzn1fIr/5F3hSs0u49AuM1QmRXzkCGzzIT1wbfpULU9SHarp06DLeuuQPphlNdo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB4606 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.517,18.0.874 definitions=2022-06-11_04:2022-06-09,2022-06-11 signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 spamscore=0 bulkscore=0 malwarescore=0 suspectscore=0 mlxscore=0 phishscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2204290000 definitions=main-2206110038 X-Proofpoint-GUID: 7dchpTA1HewHllvu5Gy9DzH016zaT02Z X-Proofpoint-ORIG-GUID: 7dchpTA1HewHllvu5Gy9DzH016zaT02Z Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org 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 | 43 +++++++++++++++++++++++++++++++++++++--- fs/xfs/libxfs/xfs_attr.h | 3 ++- fs/xfs/scrub/attr.c | 2 +- fs/xfs/xfs_attr_item.c | 6 ++++-- fs/xfs/xfs_attr_list.c | 17 +++++++++++----- 5 files changed, 59 insertions(+), 12 deletions(-) diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c index ee5dfebcf163..30c8d9e9c2f1 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -1606,9 +1606,29 @@ 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, struct xfs_parent_name_rec *rec) +{ + xfs_ino_t p_ino = (xfs_ino_t)be64_to_cpu(rec->p_ino); + xfs_dir2_dataptr_t p_diroffset = + (xfs_dir2_dataptr_t)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) { @@ -1623,6 +1643,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 7600eac74db7..a87bc503976b 100644 --- a/fs/xfs/libxfs/xfs_attr.h +++ b/fs/xfs/libxfs/xfs_attr.h @@ -562,7 +562,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/scrub/attr.c b/fs/xfs/scrub/attr.c index b6f0c9f3f124..d3e75c077fab 100644 --- a/fs/xfs/scrub/attr.c +++ b/fs/xfs/scrub/attr.c @@ -128,7 +128,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 f524dbbb42d3..60fee5814655 100644 --- a/fs/xfs/xfs_attr_item.c +++ b/fs/xfs/xfs_attr_item.c @@ -587,7 +587,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); @@ -742,7 +743,8 @@ xlog_recover_attri_commit_pass2( return -EFSCORRUPTED; } - 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_ERROR_REPORT(__func__, XFS_ERRLEVEL_LOW, mp); return -EFSCORRUPTED; } diff --git a/fs/xfs/xfs_attr_list.c b/fs/xfs/xfs_attr_list.c index 90a14e85e76d..3bac0647a927 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; ASSERT(dp->i_afp != NULL); sf = (struct xfs_attr_shortform *)dp->i_afp->if_u1.if_data; ASSERT(sf != NULL); @@ -83,8 +87,9 @@ xfs_attr_shortform_list( (dp->i_afp->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, @@ -175,8 +180,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; } @@ -466,7 +472,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 Sat Jun 11 09:41:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12878394 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 4AF0AC43334 for ; Sat, 11 Jun 2022 09:42:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229822AbiFKJmZ (ORCPT ); Sat, 11 Jun 2022 05:42:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49298 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232608AbiFKJmR (ORCPT ); Sat, 11 Jun 2022 05:42:17 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D35B560DE for ; Sat, 11 Jun 2022 02:42:14 -0700 (PDT) Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 25B1hwNo021516 for ; Sat, 11 Jun 2022 09:42: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-2021-07-09; bh=rJetYnhE34E5V1I38EQLNvmIRRtMx6Tp08CJ5Rl3wI0=; b=p79+rGwzNln6Lysao45j0BhbcFMSe2zi0s+gI8Q8B4kC/AKpCp+VfNkR8rpYjIjd/01V BLej3W4jIw3Wa+RTbSG5aswTpKJsC9NAbeMD21rJImDCvdaGYt3dRs2OPUdp8lPWoySN jeXdFNQO5MwU8nLGOzyxhEIPUrCq1+WhTnkziYO5UGeNDpav7Hx3QjKx005+sK0fwHaM SiR7/9byLo3afmNqWtujzFYrbCJp26HuZ3JixTSo65eIN5eyaE2k33SAIjco+NfISZ8E 9rQuHjPEWZ42PFIrMqyXe2K7hK0dW3QJK9C6OJR7dHsiCqsAQgo7IKj0qI5mPe46V/vk mw== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3gmhn08c71-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sat, 11 Jun 2022 09:42:14 +0000 Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.16.1.2/8.16.1.2) with SMTP id 25B9ZMQD025527 for ; Sat, 11 Jun 2022 09:42:13 GMT Received: from nam02-dm3-obe.outbound.protection.outlook.com (mail-dm3nam02lp2046.outbound.protection.outlook.com [104.47.56.46]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com with ESMTP id 3gmhg6urjp-9 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sat, 11 Jun 2022 09:42:13 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lWmO5Jk0yjLUrS5017hcIZ30T9ZCvFNqWhEekARY2rplebb2Wv2NUf91yPuS83+Ka7zprwb4HnyKSodhqSW7rnS1HvwmNv6ZgCWK/D+rILq9wmDA92Kw7WoBOY0OlNC3r1RUAulY34QF0bo8bqTriGcRj7StRedCfdPrPlpH8XoQU/EGOIhZECtdNZTWo6NupyKm6TY09vXyhwrHHtV0Gs25NX+uhCdpsLqAGp27KuCxzZEfq7JsJXvIel4a05JNHD0cMSWm4sS3Ao4AmIZ6FgUKmlyF1dj+qcvIf4ZzB3MmpAHpUFuRDGOx1rG8slua4XTJTM3bbY3HFHFcJauK/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=rJetYnhE34E5V1I38EQLNvmIRRtMx6Tp08CJ5Rl3wI0=; b=kO433S2vHapwEKWnOc4f1pC4iYewbuZWoaUw9y26+XHl0Slt4jja2+GvVe/ROn5H6lPfdUFNPmra34jzCWkZ4iDJXlA3pfx/0OuELRLTuGbYMFKswdiO4JbpYNwDGZZIVADqpgrt+ef1vuNEQzu7MdL/ffaVOqyWCzgNfyY4B7CT17MUuVkpNB2Xb6cdJx2l62AgOkCaXyzkasQ5ohSuzaYzeznZ6xITVGS0hp/NXzfP9tNCnjiGkGkHTxL8aoJT3v6/fkY0l2qxpZu/GZK76WrFrQvM9npwu+IX8rmL9I1qafdanLy5gtyeE9GClUk+4DeRlulMYGy5df8JsqWM3w== 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=rJetYnhE34E5V1I38EQLNvmIRRtMx6Tp08CJ5Rl3wI0=; b=fxuP7xjxGhHDeOYXjpMCIokskf5MnVTV/SO34GXfK2HXngVMWZxidXBCeBp2si9hPHDTb4mrjPxdIrxQg5LNnXfT2MJDBjZxQ6Fy8EHiflMVf6QMUqFpE8B3QfvCplIieDUSAguujKsuaBd1NmoEsqaceQn6yCPkINaExpVcaVk= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by SJ0PR10MB4606.namprd10.prod.outlook.com (2603:10b6:a03:2da::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5332.13; Sat, 11 Jun 2022 09:42:08 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::30d4:9679:6a11:6f94]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::30d4:9679:6a11:6f94%7]) with mapi id 15.20.5332.013; Sat, 11 Jun 2022 09:42:08 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v1 09/17] xfs: extent transaction reservations for parent attributes Date: Sat, 11 Jun 2022 02:41:52 -0700 Message-Id: <20220611094200.129502-10-allison.henderson@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220611094200.129502-1-allison.henderson@oracle.com> References: <20220611094200.129502-1-allison.henderson@oracle.com> X-ClientProxiedBy: BY5PR13CA0002.namprd13.prod.outlook.com (2603:10b6:a03:180::15) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 06ef282d-2cca-4aa4-77a4-08da4b8ea6f4 X-MS-TrafficTypeDiagnostic: SJ0PR10MB4606:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: saw78AQF5D2CwbBrVetqG6DiGmMPuE2CEMSJjRu7l3jLEuCdozINT98Um1+VVtey9wUgnWU39nP/1mvBfBwVvuCv2+Qv6SMJxlEIRFcVEfvUkTHTaLO/QOlGCNBmCeU+RNH6zcSvW+GM0I9xR5TfDEzC74SLnGb+GjarBU7PtNuC0KW8lSyLYkLO+jPbnfmYYYzSWhOZMHthuUb5fNCvL0b1WtYqkyq6oEQOGLwsG9/c8ORrDNwwq6PEJ/Sq7u7jbNqBc4lnuVj5p/MOMwFhg4fhze7Yucp9rEv9g2WrBEs90q4PS2doxM3IltZKdAMm8hT4drzP/37qlCEnbvhNr340xJM/tzf+hWK/m/i2cT++S8P5/4dVYuSQhVaQ/g4AOcwbuNlotN5ntU3ItFzSYKszvnj7p3jNB36KOwi27JgVyrTikrzQ2snCv7CetpKKOYvaV38nV88yaF9sxOwmSMnL3pe7EcAjp1rSfj8SR+4RCguZjxAPAGcQlUkmQ3G3S2JTzcq4N8XKpb5IpdedgEutWkVDvzVZO30vmnVWI2L1AYkGNMEJBKxMeIIr6mgLbQ7iIyh7azlvEomOQDi0/JLbAzADuYFcL+7H0yR/E5Xx7OfD8E6J/cG5WoV9c9xnlP2e41swpDX47IMZMP/swxBZlgoiEebEtmA8F8Z2W+Lfax2p9RQ6Pi0Vh9VydjoY8kp8WCpXvZFfgsOd1MLPLQ== 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:(13230016)(366004)(6486002)(44832011)(86362001)(2906002)(186003)(83380400001)(36756003)(66946007)(66556008)(66476007)(8676002)(5660300002)(508600001)(8936002)(6916009)(316002)(2616005)(6666004)(6506007)(52116002)(6512007)(26005)(1076003)(38350700002)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: dfND/qI/fxlNz5ugabNLN8TIcy+57kbXanwKKcpti1n6Cr1/tsL1qJnVnK1u+z9BIYjSNhwnS8Qww60vx/889hLTbstp8spMScxmnnyrWIZke3KNllZwlMnk0iiJvDuBhPD59g7OsvKP0B8XL7xUDztYFnSzVufTWndDQX6Wc+d/NfVEC/tUrscud+5v226K+Ooi9z3bEt1uRO7LD2EHAE+uikbkXkT+6zAvy40X4kjJI5H4dCwvUuxfehih6hso5FJpb+66oAb0gAdd1xJyasQpZ8EOUDcT0pLq6hqzdz/9uaSfe+BWoqkiCsMEptqX6QK+KivnNsSNTyvonZRMUTj4ANXP6GAG8ThEWzyFHPkVC5Bp15aBz21sI2M7pIHZKkl/t4NZQRdy8sRzXyplmhqH+mLg0+sY6b5WOXaJIV35lQ7NFkJUHqiEUMpc7/SF7YTMdW/dgt+hg71Uyt5k5SV7TO946FzpxskxtWGktTlgm907S63EyMPQ9KRHgTFu/YfNqUK9tcfHLWWHH3vJxgmKpxVFeiv+XxVy45GhhfFPYVu8dV0CyKh4NqamhERfCWdSGjIsiQ7D1NBtJAw5t3NQIOAhtAB/YiQVGRlxPMTABHz80B3tb7+0X2ANCMvAKRfaaV70nAXCehPgdS87yC+L9/opuBxwzC75COlS/gI3UdKTSrytiuY9cWXx78v1Tmt+esjWtGCIuLg+DQ1MVVsatFDsiJiJPF/5ekhURM8MOOmJDzlfvd4pyvxF/nMyBVgSUqe+IyXKQaMeSzEYK2R7LrX7EMk2kYKX8CdOjME6PHeq+C66211bKdM+PQV9QsPIEV2dTsyJTp2d6hi9k/iRqUVrJN91Ib/Hcm+M8gQLBWjUG6PWOc+qUuY7OSGOoRxY+tbXWNVdnZfWUyqD0XByl8gvuKHifm2qk/UHlRepBWyUi9V71+6oMIomQanxOOafs17q6Aj2ICf5fRhf6FzsJuKbj/W1teth5RFGNoVA5g7P9Eeca8XG9Jm89H8W6IOQIRw+ZJ0EpyJ6MoT5cS/AZ6+lKmhrzZTlx5so0fJMGGTO/S27UIZREzSE9rcpul9GqoUDMKvuZorhr2YgjmmtMsTxfsghPLtpc7XGKdfH4+IIRDKYfI2Ca6MmGfM4Sn//fC1n8rasLWnB9cM5DRL7BFg/zVZWrPJ+KRC7BDCOIPheo88RfZXn2N1iFxLT/X3Jx0QcoSEO2tuehbBRsa9CPC3xo5VIvbgNSd0CevPY5wSmIQybCLR/Eu5nBa0t/vPgjOfGMH0W0ddguQSgo5/jPnsanhTQ+iBJkk71Cm56nXRly/oDSN8T0dPEMf+aKwQ0k017+fs25kiaEUiSHPL5aZvsmvYMrGfyfo3jEUOkB7WMeW3dJi4j1Dt396UNSDYk+pk75CBiqXIMeHzXWia2Idx94MPPU7Lynq4D/G/Q1yhaX9ppgKHUYYRa4HP9wG0udITg3LM1SoWXBg/enE76On3bOR8P3wJylgozVAvOGHwqXPtRcWFr5AXwayJ1NRMnKN6l9kHSmvYwniliF6Kot9G2YRVpw8Mu60dECRv0DHgwriXyowGZRRr6Wq6T6HwvUbKeetQ6DL2bVFOyujQD3Q9OiFt+CxIZUTdiVXAeLA4w2zQIkKV2BJrdf046MGzphyfz9BFmevH4BWOGPMmoI4Mz0RNjyNqL3TKjb7RgmuOjMZkGxOTKxlQCzo2k7N3jHRfl8r+v6KtMr2kj5TuFqtgaGD4xZfPSa7EmUpA= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 06ef282d-2cca-4aa4-77a4-08da4b8ea6f4 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jun 2022 09:42:08.5918 (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: Dx9A1bQxJ3ty3L0pvxti5zlSm4csRSCDeZW9OTp19SA74anK64ykWlRr4uloJ5HlMeydcvZFdYPbhPwVP75XsqgJlT8iBxYeF7RqyfOS5f8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB4606 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.517,18.0.874 definitions=2022-06-11_04:2022-06-09,2022-06-11 signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 spamscore=0 bulkscore=0 malwarescore=0 suspectscore=0 mlxscore=0 phishscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2204290000 definitions=main-2206110038 X-Proofpoint-GUID: ZxEIjrYC6o7U2wRFgA6d5_gaORTrnhI4 X-Proofpoint-ORIG-GUID: ZxEIjrYC6o7U2wRFgA6d5_gaORTrnhI4 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org 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. [achender: rebased, added xfs_sb_version_hasparent stub] Signed-off-by: Dave Chinner Signed-off-by: Allison Henderson --- fs/xfs/libxfs/xfs_format.h | 5 ++ fs/xfs/libxfs/xfs_trans_resv.c | 103 +++++++++++++++++++++++++++------ fs/xfs/libxfs/xfs_trans_resv.h | 1 + 3 files changed, 90 insertions(+), 19 deletions(-) diff --git a/fs/xfs/libxfs/xfs_format.h b/fs/xfs/libxfs/xfs_format.h index afdfc8108c5f..96976497306c 100644 --- a/fs/xfs/libxfs/xfs_format.h +++ b/fs/xfs/libxfs/xfs_format.h @@ -390,6 +390,11 @@ xfs_sb_has_incompat_feature( return (sbp->sb_features_incompat & feature) != 0; } +static inline bool xfs_sb_version_hasparent(struct xfs_sb *sbp) +{ + return false; /* We'll enable this at the end of the set */ +} + #define XFS_SB_FEAT_INCOMPAT_LOG_XATTRS (1 << 0) /* Delayed Attributes */ #define XFS_SB_FEAT_INCOMPAT_LOG_ALL \ (XFS_SB_FEAT_INCOMPAT_LOG_XATTRS) diff --git a/fs/xfs/libxfs/xfs_trans_resv.c b/fs/xfs/libxfs/xfs_trans_resv.c index e9913c2c5a24..fbe46fd3b722 100644 --- a/fs/xfs/libxfs/xfs_trans_resv.c +++ b/fs/xfs/libxfs/xfs_trans_resv.c @@ -909,24 +909,30 @@ 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 assumes 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. + * + * Note for rename: rename will vastly overestimate requirements. This will be + * addressed later when modifications are made to ensure parent attribute + * modifications can be done atomically with the rename operation. + */ +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; @@ -948,15 +954,72 @@ xfs_trans_resv_calc( resp->tr_create.tr_logcount = XFS_CREATE_LOG_COUNT; 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; + resp->tr_mkdir.tr_logflags |= XFS_TRANS_PERM_LOG_RES; + + xfs_calc_parent_ptr_reservations(mp); +} + +void xfs_calc_parent_ptr_reservations(struct xfs_mount *mp) +{ + struct xfs_trans_resv *resp = M_RES(mp); + + /* Calculate extra space needed for parent pointer attributes */ + if (!xfs_sb_version_hasparent(&mp->m_sb)) + return; + + /* rename can add/remove/modify 4 parent attributes */ + resp->tr_rename.tr_logres += 4 * max(resp->tr_attrsetm.tr_logres, + resp->tr_attrrm.tr_logres); + resp->tr_rename.tr_logcount += 4 * max(resp->tr_attrsetm.tr_logcount, + resp->tr_attrrm.tr_logcount); + + /* create will add 1 parent attribute */ + resp->tr_create.tr_logres += resp->tr_attrsetm.tr_logres; + resp->tr_create.tr_logcount += resp->tr_attrsetm.tr_logcount; + + /* mkdir will add 1 parent attribute */ + resp->tr_mkdir.tr_logres += resp->tr_attrsetm.tr_logres; + resp->tr_mkdir.tr_logcount += resp->tr_attrsetm.tr_logcount; + + /* link will add 1 parent attribute */ + resp->tr_link.tr_logres += resp->tr_attrsetm.tr_logres; + resp->tr_link.tr_logcount += resp->tr_attrsetm.tr_logcount; + + /* symlink will add 1 parent attribute */ + resp->tr_symlink.tr_logres += resp->tr_attrsetm.tr_logres; + resp->tr_symlink.tr_logcount += resp->tr_attrsetm.tr_logcount; + + /* remove will remove 1 parent attribute */ + resp->tr_remove.tr_logres += resp->tr_attrrm.tr_logres; + resp->tr_remove.tr_logcount += resp->tr_attrrm.tr_logcount; +} + +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 +1049,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. diff --git a/fs/xfs/libxfs/xfs_trans_resv.h b/fs/xfs/libxfs/xfs_trans_resv.h index 0554b9d775d2..cab8084a84d6 100644 --- a/fs/xfs/libxfs/xfs_trans_resv.h +++ b/fs/xfs/libxfs/xfs_trans_resv.h @@ -101,5 +101,6 @@ uint xfs_allocfree_block_count(struct xfs_mount *mp, uint num_ops); unsigned int xfs_calc_itruncate_reservation_minlogsize(struct xfs_mount *mp); unsigned int xfs_calc_write_reservation_minlogsize(struct xfs_mount *mp); unsigned int xfs_calc_qm_dqalloc_reservation_minlogsize(struct xfs_mount *mp); +void xfs_calc_parent_ptr_reservations(struct xfs_mount *mp); #endif /* __XFS_TRANS_RESV_H__ */ From patchwork Sat Jun 11 09:41:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12878402 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 34518C433EF for ; Sat, 11 Jun 2022 09:42:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230394AbiFKJmd (ORCPT ); Sat, 11 Jun 2022 05:42:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49300 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232660AbiFKJmS (ORCPT ); Sat, 11 Jun 2022 05:42:18 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 98A7EC50 for ; Sat, 11 Jun 2022 02:42:15 -0700 (PDT) Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 25B3C0D0023173 for ; Sat, 11 Jun 2022 09:42:15 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2021-07-09; bh=EkLDzWt6YOPCgdNwBARtT49CQv5M92i0s6Lr1s1oCvo=; b=Fqz47goBvx864S2HExYxLxSZBbl7kggENPMotilDplM02EXVMCasYaFk/eU/3ZXHBvUq aHHBzNZ6uLt7FPn6QzqUt38984VZzf2F69XgoFROzBJpfgtuXWUU8qVV0zUX5zDeiH10 ZQbzK4KT3N0H+y6GKsm5oQvw7EeuwmcWzbP2qh/HtZpqj0xqANf3ut6n/Q3pkbwoNREm ziJImKYHJX44pShuiyum9bHXbR4gVKNjjALb8BtlbamChz0A2bl/cFS4G5hsZ7uftCnw P7dKH5XQq5rolB3H9oQbZReALgHYetUgidVh9RpfdciytHLNNVhGl5mvabuVTA4ahdtZ ag== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3gmjx98am4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sat, 11 Jun 2022 09:42:14 +0000 Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.16.1.2/8.16.1.2) with SMTP id 25B9ZMQE025527 for ; Sat, 11 Jun 2022 09:42:13 GMT Received: from nam02-dm3-obe.outbound.protection.outlook.com (mail-dm3nam02lp2046.outbound.protection.outlook.com [104.47.56.46]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com with ESMTP id 3gmhg6urjp-10 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sat, 11 Jun 2022 09:42:13 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NGFhIijgzcp/jv2vjFrJ6uYuyss46abibczlfK0MvAbun2MecMGwJfxjrTcSocpwkl1UzDC5SYPWoEZh0Y71LUS42Vx4msSQBRLdRglylM+OpeM0JVxFD0EKHGGLs543qm08cnwEmr8L9TwSrYK4Axa2alI/OxD0/XxZp6T7kX72zD9XptFP9hKQjL3I6fs0XzthdTY51+h+/jYkmdcH9ehP2Rnhr/rXINXPIZFkGpT9k1I2FAaqNJ18gx8svnGLuXDKnjik/OUcDSH5sHQWrHnHWFvP4ihH6Fi8dYi03RMDXFVZSutFve70xlPLLlMDkYb/nKGKcnfVv6LhiduqDQ== 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=EkLDzWt6YOPCgdNwBARtT49CQv5M92i0s6Lr1s1oCvo=; b=H6EMtmYbSgWblcI1OBatzXtnaavBX4EVGncPuFRSmsuWcA8t+wfQgxduTyHVnFbSIzDXvCrxuUBFFs8PFU5Auc79Pban88GWNAwlYjyXfjkycx/ToHt3LytOl7vuwqXO7Yb78NMM4fMvHLemS1h7r3b7QAP0tZOr3dcq74xx7mEDPd0hcIc6iTkJK6qG+sPrPEWEzjnpm9/+4MRq0JD709XhfO39d34VW/Eqk5W8sKomUax458YAvxzkf6yN+inTqVAdJPLi1JKxOcwYzFUKbZImU5hShlA6Q6UI2D08IrQ2XRp68u2a4+fvce4rN2aq5oJF+E8gcP4UlSl8yY6Q3A== 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=EkLDzWt6YOPCgdNwBARtT49CQv5M92i0s6Lr1s1oCvo=; b=PVW7cIBiea0B3Ulunu+vHoA8r3gPewVfnFf13Dw5wYpCFr63kKuMiTjNh8FZ+lk7KnDXfbAGawqZmNIXQc8XmVDjQ+8JOj9z35fdnpn1lm+HH+MJEi4zY6iHmwwX7O/fHswt69RYGLn3lwDvUZkLy81LxAiDKcIDh/RcOUYv2Qc= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by SJ0PR10MB4606.namprd10.prod.outlook.com (2603:10b6:a03:2da::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5332.13; Sat, 11 Jun 2022 09:42:09 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::30d4:9679:6a11:6f94]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::30d4:9679:6a11:6f94%7]) with mapi id 15.20.5332.013; Sat, 11 Jun 2022 09:42:09 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v1 10/17] xfs: parent pointer attribute creation Date: Sat, 11 Jun 2022 02:41:53 -0700 Message-Id: <20220611094200.129502-11-allison.henderson@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220611094200.129502-1-allison.henderson@oracle.com> References: <20220611094200.129502-1-allison.henderson@oracle.com> X-ClientProxiedBy: BY5PR13CA0002.namprd13.prod.outlook.com (2603:10b6:a03:180::15) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: eebc37dc-4c3b-43a5-fc07-08da4b8ea71c X-MS-TrafficTypeDiagnostic: SJ0PR10MB4606:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ZoouofFo4CC2tlLXbOA/8jYzCtRpRVusykJ391zLUIOp+lM6bPFECokoXGLKlgjCkKP85G3Pk2IFbdCEXul3U72CSMyD6lBywk7nW25azDMerQdI+Btd+MHDSH4Q41OpCAHAXXvs62dxUf9+tjtLtPyNuQHhaN7omI0NvkP89lU3+9H9RL3OmBPz70fe+V8BrQJFZxx6KY8/ujrzugWmauO0uAcGgUO/bphvP4+/QAIaAp7klW9glSC6xhgS0Sz58+VRYYFwuWEGwh1bdOaw0LQBSckFaT43kLFPsYMr/Ocm4GhYrEGRdv6He38rWif2fz4o6C8z+ABjX7YEhnNGEamnz9Z5LoQ0gyG8CnwBn/ryC6AoiB7I+hU+S5IxaBgtKrrzoLXlF9WvaJFnzmTN2iiRjiCfjPqsVvs5DJk5PUN0gOGFGfhu5Smpl73lfxD8mKaEiQ1Srfom7zpZR9xy8UGxor30uva/AZYp/XllTdKB7NW7bGVCOe21oeuhczAuemCKjHhXv0euzxMUOe1OKC3Ebi/J+u+EBf8tuhqPxeLkNITkNOJDRuZKQDxsyqkf7o2ABsEtzVWWl4e34N1+Av8edeEtwJEb+4MyQ3mzTVK2u5jNSY2AgCmBzZa7ikQ58XLuQXnoAlj++Dd3bbIOb69qxB67ftbgv1L4w7Cn+Yf4t5wn7JQ17558QlUKINsfwQYl2Cy/RQyH1j8AnGMYtCX0G5RAe2eBSyZyhUlpRNw= 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:(13230016)(366004)(6486002)(30864003)(44832011)(86362001)(2906002)(186003)(83380400001)(36756003)(66946007)(66556008)(66476007)(8676002)(5660300002)(508600001)(8936002)(6916009)(316002)(2616005)(6666004)(6506007)(52116002)(6512007)(26005)(1076003)(38350700002)(38100700002)(2004002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: L48M4ZTI3dODqVeIqe+OM/fhtDqBD8QTI072jcS3aCsBcY+2Cu2wTASXXZZ3FpwvuJvhdAz4AWdSc7Zahs3sk8zSILawEWOxqlPVNses2v8oqnN9waSUDASWrfuXse/IIQG7a1yviHzu428JZKQ2ssmtD6AshkFv9CiS3JAfEmHcelG/pMi5m9Dd5orpLwM/vTBGlR7eobBo/FVI7RRL80fcxoU47Zm9THfPFBuOUKe/ahkDdeZoHA9F220B/3mplP9A0EYMMKNNvStv2tgwqdWRAlQqLWaDxuU84L8yvPiCuDCG8qfJewOXRc/nH7nxGBqtY3lOO4BtmdNBnxVEwclswnawWF/XckdXIVwqYijbkzz2i+XhgCZh/z7sve88JJRsp/o8VoLPlHzDhdkqO670H5ThsIvhJ9nd7NyckdalgMYnNmUHfAA9XnyR5uSXWg/tLixpwxILQd7fYCuBs6cmfc5iZgrYAcxnI05YhNC4L1mzOuNLxEpVXU8zeYgvTq+3jRgYWyfS0yOIEHqsUr1ayVc9SS8SXTTLgL8GkFpzAPfp91u98rZ0gcPbQIMDl00EH+gOC4tTsJZh1d8Ir3tk/6v3GUvmg+bQYuB4e+YGhk5II63Cp/+Fs2oaVOHofbs9WTUcELUDzTy/0xFwvDv56LdiDIqY0V0lcNQ0joURKJxg4US/EkUd2l7Yr6flDIzhLZ3s/RXvmJe/yRJKOAfD2DgKa3OzX5Li+m7FnfTLhnLA0h3JNqDpg2NPTKnSMvqkBTfC5pKn5zaQJMihF3CUT6ZA9QH5Um/aAc/VVpA18fIRbzs947CVulI3jQtyYhoe/sOsasEumZTVH5tKcfqHDsvvNeVo9uQhHWdaW03d10s1VEntUDIF4tzu45swMzV3uHuEZms49wqxDORE+8s3JdnRHDjtsjAnBRYCZ+nANKNo9JEwJQKyydXWddGb/GVZUOPVwQdkEMdkKS1UKPgAOV/do1SsfqCWEqeqwoi8Bmhc4wu8vQpVyvcPnIJFUZssPtPvhNR9RGbCvFTPyxwmCMOVRHoHZYfdx1BuKLTIJmY9KTBbxgnf/H9FIVvp69fvczpbF+ZmQdcbO1BIXjL0MyjWMwohHTytdc1ZmX5ig6cGXjjEvCp+ULvYVbEmwkEFJI0z0w8PR3vnQZU6ltyNLLtaJ9CDykAJXRd+7FeyVUzv4XEWbaT4dcoOvYqEOhoS9XJjZ3mNr1t5yB1C5df18GQNpuRA/Qlbp9fmHbEu2yyXKzluHXakBjxiMXSHhWtkjM6kcYAy3AekKOGZ/9fwiFokOQvJd1WIc7wNCZSsf544z6iatylTFqTDPPumn6rSO8c4IzPdSIi0Fx+KiObSr3+bwq6fAQtEMa8gDTgR9EKjUlFIdZOuLrPka4UMfdFmA9HjvmYKpAUyEsphZhR39nowWlkqOcOyaZqWBbn37Va7ZQOGr4frcv7gGLKwNiS+s3CFeOKRHjIih93C3rC82h6b+puHvtl31j9nl2mm/F8xLEr3O6DriGifgxxVSjTRjcPT2CWtFMRcsg5j+gwtY2n5qn2NRII/UovPGVp1yzukRsMx9ZSSj+2iebzapMid+A4PCbb5eqaBByP5Ww5Q4BVi2Si2y/WD3nWjkzW3O095OhYr2aXnkywMNcM7fg6zpJLe54DhVQ8zdcK3cWvV4puM6U0Sqd9gRdq9LnuCvvuSsXC9vwVIyTM2FjjVI0YNHxhsgIYHXJdyx1tLGRexdnPPdODsbiJD7rR8Ae8= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: eebc37dc-4c3b-43a5-fc07-08da4b8ea71c X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jun 2022 09:42:08.8730 (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: afO/yKe+jpaRI9bYdQsVqqqE8G9G1I8NDYzHWmJcAsv9BylrhlR8lQjR1f7LjXFvFwz1vkv2l8rjia492fZG8sgK+8HA60k+EE1jzp97hX0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB4606 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.517,18.0.874 definitions=2022-06-11_04:2022-06-09,2022-06-11 signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 spamscore=0 bulkscore=0 malwarescore=0 suspectscore=0 mlxscore=0 phishscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2204290000 definitions=main-2206110038 X-Proofpoint-ORIG-GUID: XOHGv3GVSSRyKIgMauKdjP2cxnObWc08 X-Proofpoint-GUID: XOHGv3GVSSRyKIgMauKdjP2cxnObWc08 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org Add parent pointer attribute during xfs_create, and subroutines to initialize attributes [bfoster: rebase, use VFS inode generation] [achender: rebased, changed __unint32_t to xfs_dir2_dataptr_t, fixed some null pointer bugs, merged error handling patch, added subroutines to handle attribute initialization, remove unnecessary ENOSPC handling in xfs_attr_set_first_parent] Signed-off-by: Dave Chinner Signed-off-by: Allison Henderson --- fs/xfs/Makefile | 1 + fs/xfs/libxfs/xfs_attr.c | 2 +- fs/xfs/libxfs/xfs_attr.h | 1 + fs/xfs/libxfs/xfs_parent.c | 77 +++++++++++++++++++++++++++++++++ fs/xfs/libxfs/xfs_parent.h | 31 ++++++++++++++ fs/xfs/xfs_inode.c | 88 +++++++++++++++++++++++++++----------- fs/xfs/xfs_xattr.c | 2 +- fs/xfs/xfs_xattr.h | 1 + 8 files changed, 177 insertions(+), 26 deletions(-) diff --git a/fs/xfs/Makefile b/fs/xfs/Makefile index b056cfc6398e..fc717dc3470c 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 30c8d9e9c2f1..f814a9177237 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -926,7 +926,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 a87bc503976b..576062e37d11 100644 --- a/fs/xfs/libxfs/xfs_attr.h +++ b/fs/xfs/libxfs/xfs_attr.h @@ -559,6 +559,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); diff --git a/fs/xfs/libxfs/xfs_parent.c b/fs/xfs/libxfs/xfs_parent.c new file mode 100644 index 000000000000..cb546652bde9 --- /dev/null +++ b/fs/xfs/libxfs/xfs_parent.c @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2015 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it would be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write the Free Software Foundation + */ +#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" + +/* + * 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); +} diff --git a/fs/xfs/libxfs/xfs_parent.h b/fs/xfs/libxfs/xfs_parent.h new file mode 100644 index 000000000000..10dc576ce693 --- /dev/null +++ b/fs/xfs/libxfs/xfs_parent.h @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2018 Oracle, Inc. + * All Rights Reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it would be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write the Free Software Foundation Inc. + */ +#ifndef __XFS_PARENT_H__ +#define __XFS_PARENT_H__ + +#include "xfs_da_format.h" +#include "xfs_format.h" + +/* + * 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); +#endif /* __XFS_PARENT_H__ */ diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index b2dfd84e1f62..6b1e4cb11b5c 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -36,6 +36,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; @@ -962,27 +964,40 @@ xfs_bumplink( int xfs_create( - struct user_namespace *mnt_userns, - xfs_inode_t *dp, - struct xfs_name *name, - umode_t mode, - dev_t rdev, - bool init_xattrs, - xfs_inode_t **ipp) -{ - int is_dir = S_ISDIR(mode); - struct xfs_mount *mp = dp->i_mount; - struct xfs_inode *ip = NULL; - struct xfs_trans *tp = NULL; - int error; - bool unlock_dp_on_error = false; - prid_t prid; - struct xfs_dquot *udqp = NULL; - struct xfs_dquot *gdqp = NULL; - struct xfs_dquot *pdqp = NULL; - struct xfs_trans_res *tres; - uint resblks; - xfs_ino_t ino; + struct user_namespace *mnt_userns, + xfs_inode_t *dp, + struct xfs_name *name, + umode_t mode, + dev_t rdev, + bool init_xattrs, + xfs_inode_t **ipp) +{ + int is_dir = S_ISDIR(mode); + struct xfs_mount *mp = dp->i_mount; + struct xfs_inode *ip = NULL; + struct xfs_trans *tp = NULL; + int error; + bool unlock_dp_on_error = false; + prid_t prid; + struct xfs_dquot *udqp = NULL; + struct xfs_dquot *gdqp = NULL; + struct xfs_dquot *pdqp = NULL; + struct xfs_trans_res *tres; + uint resblks; + xfs_ino_t ino; + xfs_dir2_dataptr_t diroffset; + struct xfs_parent_name_rec rec; + struct xfs_da_args args = { + .dp = dp, + .geo = mp->m_attr_geo, + .whichfork = XFS_ATTR_FORK, + .attr_filter = XFS_ATTR_PARENT, + .op_flags = XFS_DA_OP_OKNOENT, + .name = (const uint8_t *)&rec, + .namelen = sizeof(rec), + .value = (void *)name->name, + .valuelen = name->len, + }; trace_xfs_create(dp, name); @@ -1009,6 +1024,12 @@ xfs_create( tres = &M_RES(mp)->tr_create; } + if (xfs_has_larp(mp)) { + error = xfs_attr_grab_log_assist(mp); + 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 @@ -1024,7 +1045,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; @@ -1048,11 +1069,12 @@ 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); + xfs_trans_ijoin(tp, dp, 0); unlock_dp_on_error = false; 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; @@ -1068,6 +1090,20 @@ xfs_create( xfs_bumplink(tp, dp); } + /* + * If we have parent pointers, we need to add the attribute containing + * the parent information now. + */ + if (xfs_sb_version_hasparent(&mp->m_sb)) { + xfs_init_parent_name_rec(&rec, dp, diroffset); + args.dp = ip; + args.trans = tp; + args.hashval = xfs_da_hashname(args.name, args.namelen); + error = xfs_attr_defer_add(&args); + if (error) + goto out_trans_cancel; + } + /* * If this is a synchronous mount, make sure that the * create transaction goes to disk before returning to @@ -1093,6 +1129,7 @@ xfs_create( *ipp = ip; xfs_iunlock(ip, XFS_ILOCK_EXCL); + xfs_iunlock(dp, XFS_ILOCK_EXCL | XFS_ILOCK_PARENT); return 0; out_trans_cancel: @@ -1107,6 +1144,9 @@ xfs_create( xfs_finish_inode_setup(ip); xfs_irele(ip); } + drop_incompat: + if (xfs_has_larp(mp)) + xlog_drop_incompat_feat(mp->m_log); 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 35e13e125ec6..6012a6ba512c 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 +inline 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 Sat Jun 11 09:41:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12878400 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 45B3FCCA47A for ; Sat, 11 Jun 2022 09:42:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229847AbiFKJmc (ORCPT ); Sat, 11 Jun 2022 05:42:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49298 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232533AbiFKJmS (ORCPT ); Sat, 11 Jun 2022 05:42:18 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BA6B6C6F for ; Sat, 11 Jun 2022 02:42:15 -0700 (PDT) Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 25B2rQSU017081 for ; Sat, 11 Jun 2022 09:42: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-2021-07-09; bh=ShLwHKhjJrgKbso2ld4Us/JABrJzn8ghZTLe/u2o5O0=; b=sgsb5P29msSwBiFWY0zlP7yxXMXkIAwBxRiDka6lAqdpW6Hm2iYOkUCLjj6s+JXK+3+5 YW6pX1ZP+PeIlYgn4e3q5tSqNTWiKJ7c37dJ/vuR1xkqPTnhNs1XeiTgWdgQ5lst/5Sn HVA7Kk35vCm02GcOJuNl76io5WNv3mG8jaiWiHF7/kInNSMT3JpEAAzWSoh6BirfQQ36 8QXkShWa2MwnXnjMX1qlCUezUkFbKnS8WSSCmfuo3vbeUAZvoxqDSj5HvVAVc/QEjroV Yhxw8gp6P1MFAbOmAXAjBFkzLEcX4OvWJBoKKOAwhF5GV4/2mnzeQebRq1Y4W+ij4TpR qQ== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3gmjns0asp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sat, 11 Jun 2022 09:42:14 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.16.1.2/8.16.1.2) with SMTP id 25B9allH001303 for ; Sat, 11 Jun 2022 09:42:13 GMT Received: from nam02-dm3-obe.outbound.protection.outlook.com (mail-dm3nam02lp2045.outbound.protection.outlook.com [104.47.56.45]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com with ESMTP id 3gmhg0m9ta-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sat, 11 Jun 2022 09:42:13 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=V1L4qO7hZpNPq06Zm2H11cCRwCzSRunSjbyYzol89vvv+vCyERGQ5k53E+IJFESuVOV193QY/N3x++ubkQudG06jEPTC+tZU5p9VHEhXsCznz2KlmQubozUL5mY+jF5UyFsOIDcG9NkEpxyiYNkxQcufXIWbtqok3ccGdPX8PWujJbiN78q039vxsiltFwsJs2HWcbvcb5Tdded1e/tzdJDV7Tl2a6t+9ZQDHWGRUFXNZUFp6UvxIuPUOD2IfVx+ziOJ78uwFPI/83qxrWVfOu1elKVdWAoVI48n8R7Dotf1lmlUgBjcMakryZe355WCvQzXFfIRrCsJj/br3qyd2Q== 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=ShLwHKhjJrgKbso2ld4Us/JABrJzn8ghZTLe/u2o5O0=; b=H0opoOVnsnhBUgagbygoLaNHWMYvZOtoUHP/zGm/Lq21nvBC8/C6Njc+aqXcmBmZW6mQsp2vKtRsIeZ+ia3lXmBdGuh2sqYbEocaBNajOgwLaoALYUG4QBAAMvlfehE4FGYSMaqfEYBjXcZmwvVu/AtGggxzmM2PJMMVJcHkhWltO/yN/Rn3lqeOwo7y5A29uRabWrALWh/HjFU4PIs8oH5rkSz/XSJTmCqYVz/7Qrid+HcW2ldWRLppeRIC8KpaEfZN7SCVD7/2WEWDmgdPc2HKCYpUqlj7ToETIi8VnJ2ZJC4MSF45Uywwn/fpsiSdjqpSMuWvJTLDK3mw5gmoRA== 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=ShLwHKhjJrgKbso2ld4Us/JABrJzn8ghZTLe/u2o5O0=; b=D4Gdd37BhE4jLiMB9JSkeq1sYWBryD/dX6vgZUGv7XWcxmnPbsu6A4Er9vzFpu8zBSpmxE7GlGLbIExakPhXtqKrvv3u/fp2N52a7xpcjj3Yz9xoLBXJ0mooYtxSRSIdAPgYCeTSUbAhNZDfDdN0MQtOk/9O9DNjIcyLeyQ16eo= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by SJ0PR10MB4606.namprd10.prod.outlook.com (2603:10b6:a03:2da::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5332.13; Sat, 11 Jun 2022 09:42:09 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::30d4:9679:6a11:6f94]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::30d4:9679:6a11:6f94%7]) with mapi id 15.20.5332.013; Sat, 11 Jun 2022 09:42:09 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v1 11/17] xfs: add parent attributes to link Date: Sat, 11 Jun 2022 02:41:54 -0700 Message-Id: <20220611094200.129502-12-allison.henderson@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220611094200.129502-1-allison.henderson@oracle.com> References: <20220611094200.129502-1-allison.henderson@oracle.com> X-ClientProxiedBy: BY5PR13CA0002.namprd13.prod.outlook.com (2603:10b6:a03:180::15) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 962cee53-95c8-48ab-e454-08da4b8ea747 X-MS-TrafficTypeDiagnostic: SJ0PR10MB4606:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ksLiCRYDbaatWIJ2fto3vBzZmHj1d/W2witgBOK6aJnDCig6OMqufNavoy5L0stwKtgUfTS6wBnuCi7p5EmdZh8vvgiIF/SMvbj1ltNbwXam4OkK3g28c083iwd/rvPRcUe7Q6QD1dnNCVY4paRqnOghTzi4eQ3Ml0pvKyCB6g/CQy9UuwC39Q+gO7SC4k95yMCsIWlIij0rtFyIP7L4ArL6qWmOSMUiIRw3Z0Rb3wp1vmI59HCAaIezv0qpPXYpYS05LAhJELTxyiWZx4VxXrmsYhhkgN7YyDuWDyEg4ytE7JVkrBYMayShexYtN8x4b+evEkDmqlF1tBnk4SCF4lymeEvNYuGqANxtvklZj5d3Qn/9bfOI8sBqVoVESoeHdCcPmL4bhIVUjfn2KR/Be9lCw9N4UCuXdCKjZWchBvLvRd8HY5zs/Z1KIgIjyoj6spQrQ4WIh5lshDrrDB07Wfd1R1P0rNcm48gLbB30V0zr/FrMN+8mI7eaJiO5IBR/U/r4EaJpgcY4aHtFLIhGMXjg0F6AmoQTofn3+32BGi98OCqd+sSgibsneUJ2pixfDIZwfyht7XKYSZt2cZyHTYf/+eSfTRCN4BjZ2oER0rH93w8BQcCkB2VIroG7TUBMQtyaDuEXeHXY48jdh96VYqnSHsKtVFmnCd/oLKnFwujz6Qgciyj/sBky00WT0Sy9nTrisyNGb+F1yd0+Ndo+4Q== 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:(13230016)(366004)(6486002)(44832011)(86362001)(2906002)(186003)(83380400001)(36756003)(66946007)(66556008)(66476007)(8676002)(5660300002)(508600001)(8936002)(6916009)(316002)(2616005)(6666004)(6506007)(52116002)(6512007)(26005)(1076003)(38350700002)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: cKkr1c0SROewfqPLtcRl6XdD2omlhircxK2fSYf3UAYv0YYKr34uZBxMcCBfzS4z+aDWOMr/y3YHziRJH8A7ODaxpAQDO5Gqe/364086UmvqF8VsO6nDjy9BfEURltLXYajKylFIDgslbVL+F80kR6nUwfCjeAgthyqg9KQjnCOy+AErZfHPjj/nAhA8m20o13yIkgW6L7yhfpE6m5FhRcgNAiYg1thUiJy1u0HUsimqetbJnP3lrcZjzHanYPHXd7oBzohIDEFPt6kX3R8Ss0YqV3wFMJ4IJVqC9e6wtwp/pGqbvnLFUUR/49QLxqejIqlwWyLmjmbWOYEV9C2Qp6YYD/D9kYG3mMAIzC5Nemnk96WjUyyzoWMr9F2Z00nolWILO2ty+0nJLgIvrk/fhn9li7kiHf3LbJvxupQk+r3jrXZ+EDS9eZNBi8Js1VitDVTJoQqO6+y+EMhIAsT8EPvE72CrTnwb0a8u0y6l1KzujSGr3wum6w08s7Gn9tnaoJ7eNpp47D8XPwooizJx+PGvI+8KLwWso45iDR8j0TRYhTz1Bq5+NcjeTB5dQJ1stQQdiLq0H6tB9KCidNqyEKaOmor5ut6BEKrZfVFo2q9PVunES0oZGoLyK7pRu9SOxlp2zYFL7PvjwP/2k/zbvXfisQpCEo9V7AP5gbvD9B1lTZhCqa2yGIN8x5zEibfF7k8NKBZiZCTBQH5UgJUqWGHHzZqC0mwRL6tiF06AqoLJKl9TKr1sQDz8BRikRmvglBEWaDeFLgmtxkDmA0NjeIR8YofzfHG+XVs5sgueguhCgGFXPWUROi/bvjR2MK14/iLYlDa/zzpCDJOy4basg+p6bl1XKSlwjEf9G1wqWydCRWSh1HRt/38obyhQ6J7aCl77xCuynuOqEsM+0mWZBcFTg5vVcgTGJaHoW6LwrQuOUMElGLn44B/OO0XNWcWc8BS7oQBtkNj+JhZVCaNfBVnfoCnW7J1OoHmaelVls0kTOLTgeW39+K/oTlIgCWwxtO/4DcXu68aw3F6MvQ6SLYuEcSiBH58bQtO5rM0RBr3Sj/4OgxuyhjjAjMYzRDzG47O+bORR0nPj8nPf/9amu0DvzPVh/+yjF8MGWHFGg1iJMCCxGBZ80Uzcq5dxekecbSb23bmlhdRYvVtu/NalF/ve76KY/okQaAjqckXkAVNcPfkZ8G7UJqWIb0MyIcoX2wFhNtkmpd6Utg6czTaVuXkMSKo9VU2J6t00wkcDmx8z3xnShvIvXuoalVo+wiXVpz5f2+74WK1w8a6oHENfaXPKE0PdbUxmIkNH4SpKSvkZjravqtWDay9046Y98m7YNKJLM4/1/ZPph2s/7jMHeeRcJbjVFhZeKPwrrt82H0cqqZywiq3WwZYi76PT51iI+DKPvHFnOkkqnv912El+mBWG8nCm37l2ptrVbACoH8KiOlvtgr6DE0nbXz4Z/iP+e+gwOsP3JIacq2wnnukuBTh5F+uZhnlqCR7cl0JxUwHhomSo4FwGam9tUqHFsq4dqU5TA+/X9wRTsm0chs3WBmCY1xXLGaYVRkgXFcUHsQDiW5gcYGdSP3XBhpMDtHsk1/6fDB8W88ddM49v6eTMH3r/r9m5kjltjtzlreyOlghgjzYdQUmGT/ubMVD3mAbMjm56WI9fuFh07utBm4aKIAbAbpoowMv5fbS3VRNSOBB6qPNYrothWWJEDW5u7W1lgYjvlFopUVK4pIxL9UkvHlWTP13TvbeMqHFTjjzaRZw= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 962cee53-95c8-48ab-e454-08da4b8ea747 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jun 2022 09:42:09.1542 (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: V2PPHCxG5F3sbfELYxMYQtPgmwZRPhN2gLhisV9Qi3QypkMzb7f9LVT+U8E/EPgqDItvp5oPFdca1oCQQUv7p6lpwIyHIvR3IvhOLEM89vI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB4606 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.517,18.0.874 definitions=2022-06-11_04:2022-06-09,2022-06-11 signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 bulkscore=0 spamscore=0 phishscore=0 malwarescore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2204290000 definitions=main-2206110038 X-Proofpoint-GUID: d4S9aN6cxYBixoOPDwNdzqmFYYtJAply X-Proofpoint-ORIG-GUID: d4S9aN6cxYBixoOPDwNdzqmFYYtJAply Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org This patch modifies xfs_link to add a parent pointer to the inode. [bfoster: rebase, use VFS inode fields, fix xfs_bmap_finish() usage] [achender: rebased, changed __unint32_t to xfs_dir2_dataptr_t, fixed null pointer bugs] Signed-off-by: Dave Chinner Signed-off-by: Allison Henderson --- fs/xfs/xfs_inode.c | 78 ++++++++++++++++++++++++++++++++++++---------- fs/xfs/xfs_trans.c | 7 +++-- fs/xfs/xfs_trans.h | 2 +- 3 files changed, 67 insertions(+), 20 deletions(-) diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index 6b1e4cb11b5c..41c58df8e568 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -1254,14 +1254,28 @@ xfs_create_tmpfile( int xfs_link( - xfs_inode_t *tdp, - xfs_inode_t *sip, - struct xfs_name *target_name) -{ - xfs_mount_t *mp = tdp->i_mount; - xfs_trans_t *tp; - int error, nospace_error = 0; - int resblks; + xfs_inode_t *tdp, + xfs_inode_t *sip, + struct xfs_name *target_name) +{ + xfs_mount_t *mp = tdp->i_mount; + xfs_trans_t *tp; + int error, nospace_error = 0; + int resblks; + struct xfs_parent_name_rec rec; + xfs_dir2_dataptr_t diroffset; + + struct xfs_da_args args = { + .dp = sip, + .geo = mp->m_attr_geo, + .whichfork = XFS_ATTR_FORK, + .attr_filter = XFS_ATTR_PARENT, + .op_flags = XFS_DA_OP_OKNOENT, + .name = (const uint8_t *)&rec, + .namelen = sizeof(rec), + .value = (void *)target_name->name, + .valuelen = target_name->len, + }; trace_xfs_link(tdp, target_name); @@ -1278,11 +1292,17 @@ xfs_link( if (error) goto std_return; + if (xfs_has_larp(mp)) { + error = xfs_attr_grab_log_assist(mp); + 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); + &tp, &nospace_error, 0); if (error) - goto std_return; + goto drop_incompat; /* * If we are using project inheritance, we only allow hard link @@ -1315,14 +1335,30 @@ xfs_link( } error = xfs_dir_createname(tp, tdp, target_name, sip->i_ino, - resblks, NULL); + resblks, &diroffset); if (error) - goto error_return; + goto out_defer_cancel; xfs_trans_ichgtime(tp, tdp, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG); xfs_trans_log_inode(tp, tdp, XFS_ILOG_CORE); 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 (xfs_sb_version_hasparent(&mp->m_sb)) { + args.trans = tp; + xfs_init_parent_name_rec(&rec, tdp, diroffset); + args.hashval = xfs_da_hashname(args.name, + args.namelen); + error = xfs_attr_defer_add(&args); + if (error) + goto out_defer_cancel; + } + /* * If this is a synchronous mount, make sure that the * link transaction goes to disk before returning to @@ -1331,11 +1367,21 @@ 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: +out_defer_cancel: + xfs_defer_cancel(tp); +error_return: xfs_trans_cancel(tp); - std_return: + xfs_iunlock(tdp, XFS_ILOCK_EXCL); + xfs_iunlock(sip, XFS_ILOCK_EXCL); +drop_incompat: + if (xfs_has_larp(mp)) + xlog_drop_incompat_feat(mp->m_log); +std_return: if (error == -ENOSPC && nospace_error) error = nospace_error; return error; @@ -2819,7 +2865,7 @@ xfs_remove( */ resblks = XFS_REMOVE_SPACE_RES(mp); error = xfs_trans_alloc_dir(dp, &M_RES(mp)->tr_remove, ip, &resblks, - &tp, &dontcare); + &tp, &dontcare, XFS_ILOCK_EXCL); if (error) { ASSERT(error != -ENOSPC); goto std_return; diff --git a/fs/xfs/xfs_trans.c b/fs/xfs/xfs_trans.c index 82cf0189c0db..544097004b06 100644 --- a/fs/xfs/xfs_trans.c +++ b/fs/xfs/xfs_trans.c @@ -1273,7 +1273,8 @@ xfs_trans_alloc_dir( struct xfs_inode *ip, unsigned int *dblocks, struct xfs_trans **tpp, - int *nospace_error) + int *nospace_error, + int join_flags) { struct xfs_trans *tp; struct xfs_mount *mp = ip->i_mount; @@ -1295,8 +1296,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, join_flags); + xfs_trans_ijoin(tp, ip, join_flags); error = xfs_qm_dqattach_locked(dp, false); if (error) { diff --git a/fs/xfs/xfs_trans.h b/fs/xfs/xfs_trans.h index 9561f193e7e1..4ac175f7ee69 100644 --- a/fs/xfs/xfs_trans.h +++ b/fs/xfs/xfs_trans.h @@ -266,7 +266,7 @@ int xfs_trans_alloc_ichange(struct xfs_inode *ip, struct xfs_dquot *udqp, struct xfs_trans **tpp); int xfs_trans_alloc_dir(struct xfs_inode *dp, struct xfs_trans_res *resv, struct xfs_inode *ip, unsigned int *dblocks, - struct xfs_trans **tpp, int *nospace_error); + struct xfs_trans **tpp, int *nospace_error, int join_flags); static inline void xfs_trans_set_context( From patchwork Sat Jun 11 09:41:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12878398 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 AB3A1C433EF for ; Sat, 11 Jun 2022 09:42:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230004AbiFKJma (ORCPT ); Sat, 11 Jun 2022 05:42:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49158 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232656AbiFKJmS (ORCPT ); Sat, 11 Jun 2022 05:42:18 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9185CBF1 for ; Sat, 11 Jun 2022 02:42:15 -0700 (PDT) Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 25B3w5xg029706 for ; Sat, 11 Jun 2022 09:42:15 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2021-07-09; bh=fM4Relasplvefc/wwawkejBLr24x23nPqOvaIjKXkqo=; b=yoVjkvR14qm9jeM1dRjPoYav+9/IFq1S0tlH88ehOnGALFw211avznNtRwqnWIEA3fhd L+iPQH1WTRVSK8LBjnCeNChflMGGEeAEnJO90y1tWYCtCU27zzne0kB2cUChsHLUkvGs KmrQ/MwZ/5EcfLziQbBwy8I0Axyuau6+3NyoH6IbfDPztIvlOJuN1+QfBc9KYU6UylB9 fpriySp03cCFoUOFGPHNbn04tdVVGSRS0ozv4ZaXFsF02nF3TG8Ta7EkoLrZgMZROXuZ m//WdEpK/dJAFRd5JeeJAdfqAeCcQA8zR4rIaWvcKOk3WQEuU4/ukNPAhjeJl97yfZyv FQ== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3gmkkt89wf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sat, 11 Jun 2022 09:42:15 +0000 Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.16.1.2/8.16.1.2) with SMTP id 25B9ZMQF025527 for ; Sat, 11 Jun 2022 09:42:13 GMT Received: from nam02-dm3-obe.outbound.protection.outlook.com (mail-dm3nam02lp2046.outbound.protection.outlook.com [104.47.56.46]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com with ESMTP id 3gmhg6urjp-11 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sat, 11 Jun 2022 09:42:13 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Qyd8kDvq8CO98k5EfrBYy6LU4LmRP0CqABIgQaaYtm5lB/fZlE+wdicYzkls0pRtrV/6tyXbQ8r/h16FG/pT2Oe1Fd5HL1AdCxDwt6NdAOh5boLV8POfqgztFoN3DuLBGPzqOjvpgRTxzJRxsh6LWmxjPr23K5Cw99nOr2xKv+vhQfeVBZ0lS2Nu3hbyr7C9ARXbY88QrVRyFkkneK1TaCKpe5lpbUwxkCMZhzsLZLQE3B/Qqr1EPa+wD+pLVMz6Aklf2dyZW2EZ15ZMyeOTzIQFn6hF0gzYlTP6+H4zG5J8s4YBAK+mKr3wH/5eOkZnhppGSCm5AbAAqsHCy0YjIQ== 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=fM4Relasplvefc/wwawkejBLr24x23nPqOvaIjKXkqo=; b=SC9iZFmvG1czYU/o7FNlfdky0KsoztZltg5EtEp8P0qI63d55mdPBBcKQY3DW30kRZrqHEBMt3hqc7SFFToJ/v5SdLP2z9DbPf/KZWs40MpXkshkQ6M6RtuwMXROH43JKdqUh0M8+N9cShzKjoJ6RIsEar/FQ4Nu7VVECgMx2+r5OhJUZp+54P5S3x5m/8CpkagFuRASgqqnXvhxFKnaNgpk4NFrYbyJipKYsbOkILQTC0SHepfm3KAi4IPkAEUSr5owbFYA5tKSE/hVBRutWK7kste2cvxQ/isjsYu3/6Pxc9baKaQhAuRP36uKtIvFmBYcGlKACRLTJIEbwvomSg== 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=fM4Relasplvefc/wwawkejBLr24x23nPqOvaIjKXkqo=; b=CdYfhI1uc9xzt+nq7XEdI2Q+lI1wHgJM1oideh8YKN+h1+8iY8zzx1PVyBznwExtNT20SBhPRFEB6pwQM3Cvoh/4D4xnANKIBeg7vlJLZl41rIl2gtTjNPW1TFCAcBBnTMvGU0oecNhnPfF2dt1brMgv7fBHzezquB7G6XymwMo= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by SJ0PR10MB4606.namprd10.prod.outlook.com (2603:10b6:a03:2da::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5332.13; Sat, 11 Jun 2022 09:42:09 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::30d4:9679:6a11:6f94]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::30d4:9679:6a11:6f94%7]) with mapi id 15.20.5332.013; Sat, 11 Jun 2022 09:42:09 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v1 12/17] xfs: remove parent pointers in unlink Date: Sat, 11 Jun 2022 02:41:55 -0700 Message-Id: <20220611094200.129502-13-allison.henderson@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220611094200.129502-1-allison.henderson@oracle.com> References: <20220611094200.129502-1-allison.henderson@oracle.com> X-ClientProxiedBy: BY5PR13CA0002.namprd13.prod.outlook.com (2603:10b6:a03:180::15) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: faca4b69-08cc-40e3-6a77-08da4b8ea770 X-MS-TrafficTypeDiagnostic: SJ0PR10MB4606:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2aUAu3ZJdAnNriGVETjZ24yjFB7e6vR22bYoiv7SDrHcWhYPsyXLGZ59sssGj8M6byOTxIZ6VE2hkI1i056UXclST9HbqfMn0ZKjWokW6OPhNVK++ncrVqIYw0Cy4KcT9Op9gOZRycu//ZDqS50fg49GZBCKRTnJh4MXmnTdkA2/E1SqbMqlF5RUiqahXVN4vEUC+EV0RO4yP3nIxruLVqdmmD39nX1b43jrtvtuSP/NKVFTNYn7XY8M4zz5VlPRz2UfTpSg79TI2oeApoELYJiZN+kSDtcxADDkIx+26qllo1iLB+8HNeNtgP6kniZQJFqhsDb11fsMMhv0s8TLibCW4+Qa/fk3dKrs5I0By3c7oLZM1XCCJ+thaVz2VE1tLw0Pk/oPkwixIJjRN1xoxbPydr4m+mohog6sVKnc2Ao2iuE1iQGRkvjO2GNa+9bwNn+XV7TzSu3GcKWQ7/9cJkpJJUP4SGow5NhVhOHsaXPDSkgWfBXTxO9ZWtvgl9xRWbkxi+4iu+17GrIKphVUI3ac/Ngz5FdwcrKFRpqIBj8dqY1qX57X+OcBpls8o5NPbVpJaguYrWuw+BWL0oYdBjgYwBTnaGQBhItL0vO1xXWhgz/LeC2uIWLPsSlIiEkPJMY9DGfCYEQvxOAZEmsz4YSCdyITgYcq2bYgO/2t2E3J+ENan4D1jJyRAbC8rtEunhCrda/ENIJCJRfrR5XerQ== 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:(13230016)(366004)(6486002)(44832011)(86362001)(2906002)(186003)(83380400001)(36756003)(66946007)(66556008)(66476007)(8676002)(5660300002)(508600001)(8936002)(6916009)(316002)(2616005)(6666004)(6506007)(52116002)(6512007)(26005)(1076003)(38350700002)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 54n9ny19cQSu9TWEiyHhc0hCUn+sE/TtmqZFE8rqBclRpOe2BKpF2uM9zC8ySRu1fgfqHyHkBZ5jq/IBYCodjhJhedW5xai/NoUn3dUgHvXiZBcenbyKeY/AZ0+ef1R+NzbZ0zZt/hI081NDXoBpd8VmhJ/TvzjwrkjTc57Sj6lRo4/B5E9Ds3IYADiqGgV/l3Io3MNFAa2fD6sK8YoX7KXxoxtWIOxPSgcPUuzcM65YkaOmeiLIlAHD3OvweBAIN24rgmbKpMuRoRRGhAkTkE56YsYYZFHaEFWDoX3gN5G8QOQIouO3z/FE5RlPrv9QbYswBB9wYjlQflt7gmxs+LsMGsKUrjNRx7ybBCaOye9FTrJ8MrA9iP2LOgmWghOohAILblSYvWvAumKXgFe7nE00yGD8cEd8v6Kc1Mc7Wuk19jwNpG1q7IKtrkcAPvqfe+0isK1OzCn84WRq5/ENsigFjeF3CFDRgXrGJcNvZ8hRYX89XnWxyPvmVr7j2t8Q998v06qN24nBMDpnBDegLgcV+YK33NNfwLDVmQjEfkaXH4Y9UygQvY6Ri0ipnH6sAclMc+GIxW6lFNyKQByBxbgSQfddRYrBGtcFuGRQ/vdQIGVksx2CBf8bjDwAaicWM714bn6Cl9aqnaWk4Kh+ZGk8lcg2nVeFeFmbs/53X3/yllNsdSICPGwWruqWZ1o/mFD/eZgapG0HEZB+Adf0yPQAXVx163reKiVLCZzU5FcPKI9AiYWLTodLAKy/tnntVGrvkreMHfrJwIZb23EgMAYcJtegIM01Ej1AyANP0Oaat7hzTG+LgAJ/zlyNDrNDhZlCuarzlWfTRTzOUapG38lAeP57j+MA8O3BV85aJO6ARPZuY6GZzpf7lpjo8cOrQQMmJrjpK45r09+//lfV4fFLEj8hygU3sx9fidajGovWwM3/4NSOJJXz1Ne0lM+9g+JO4FwJ/yBWN3w9eHpeftyipATc4rBy6/IG0Z6/bWtQp6VirXYIvDA/0p7Pmn4IncuEOZ5iKKh/YsuZIuyEUBfP3gwJ6vdk/aETJvEka4WeGkysrIQM+qUYKsvPJfFQdXIvy72b4SnN2O3VS3UQaByuYGUcJsUdUxH/y/obRuwwTqR8QmH2k9TIZ2kNTPicxT3HzDUsQ++TV5DIsvr9toiVvZ+9nSN+YFADwayno8QdAPAMgigKmKtq+TJykwvZmGO2ZjCbHkcIDvvqUDC2v1FUGND0bghTT0Kj5cXfRIu2lf41a+5Fg2xE5ZKNZECUlJlgnG3azbPkFtcHlffR2dDAE5Yv0kkI+ihuDyrImueUfDu/EArWM65ESGKNk0ZiKBTc0oMmMa6qO1gy3KJ88gfJ8tukOG9T0ay5xAhHHN43h362y2arr1u0UeHZ3lH+hxp/z4k6wC/fU4/IOv1qULDtxigdYYGUhrH833JCZwZ/xQJKOM77sDeNq8FebBhCCIH/eROQD9GKKFEAvybS+fFA/CQuIjJWEFKLULVn2jRlzj3wTw6OW6WQlkLX7OmudiUd3np4OsqHF3ZGVL1qbyw94sZWWAS4gaEgfQJvDZheAG3KMyGMhI/zUGQ6Bqhfw92hTTwCZIND649zyvAUfoZlIV/BzgWjAk0u50vh3Iedr4giiAluNtD6s4lDYpj4JgChQO/dkfwcktZgkrlQq5E4F0zzEtR2vL+7QKdedxxVotxn+v1iG8A8V+uID0okP9i9MRK6OH52FTdesVTooDZyYIFCvF8EcoAyPpjlodA= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: faca4b69-08cc-40e3-6a77-08da4b8ea770 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jun 2022 09:42:09.4354 (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: yFvwjp1VTPAnyyXMihjnNistV8X80fTZGjjujFnBxjQSNQxCkAxiS1dRbYa8wr1Vc89g0UZ5Yek4Fq1Db2VtABOIKAqNcMvxbjYs9t92DIE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB4606 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.517,18.0.874 definitions=2022-06-11_04:2022-06-09,2022-06-11 signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 spamscore=0 bulkscore=0 malwarescore=0 suspectscore=0 mlxscore=0 phishscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2204290000 definitions=main-2206110038 X-Proofpoint-GUID: ga43GUBN7Az0Pus6otH5Qs-rIvu-FODU X-Proofpoint-ORIG-GUID: ga43GUBN7Az0Pus6otH5Qs-rIvu-FODU Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org This patch removes the parent pointer attribute during unlink [bfoster: rebase, use VFS inode generation] [achender: rebased, changed __unint32_t to xfs_dir2_dataptr_t implemented xfs_attr_remove_parent] Signed-off-by: Dave Chinner Signed-off-by: Allison Henderson --- fs/xfs/libxfs/xfs_attr.c | 2 +- fs/xfs/libxfs/xfs_attr.h | 1 + fs/xfs/xfs_inode.c | 63 +++++++++++++++++++++++++++++++--------- 3 files changed, 51 insertions(+), 15 deletions(-) diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c index f814a9177237..b86188b63897 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -966,7 +966,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 576062e37d11..386dfc8d6053 100644 --- a/fs/xfs/libxfs/xfs_attr.h +++ b/fs/xfs/libxfs/xfs_attr.h @@ -560,6 +560,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/xfs_inode.c b/fs/xfs/xfs_inode.c index 41c58df8e568..160f57df6d58 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -2828,16 +2828,27 @@ xfs_iunpin_wait( */ int xfs_remove( - xfs_inode_t *dp, - struct xfs_name *name, - xfs_inode_t *ip) -{ - xfs_mount_t *mp = dp->i_mount; - xfs_trans_t *tp = NULL; - int is_dir = S_ISDIR(VFS_I(ip)->i_mode); - int dontcare; - int error = 0; - uint resblks; + xfs_inode_t *dp, + struct xfs_name *name, + xfs_inode_t *ip) +{ + xfs_mount_t *mp = dp->i_mount; + xfs_trans_t *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_name_rec rec; + struct xfs_da_args args = { + .dp = ip, + .geo = mp->m_attr_geo, + .whichfork = XFS_ATTR_FORK, + .attr_filter = XFS_ATTR_PARENT, + .op_flags = XFS_DA_OP_OKNOENT, + .name = (const uint8_t *)&rec, + .namelen = sizeof(rec), + }; trace_xfs_remove(dp, name); @@ -2852,6 +2863,12 @@ xfs_remove( if (error) goto std_return; + if (xfs_has_larp(mp)) { + error = xfs_attr_grab_log_assist(mp); + 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 @@ -2865,10 +2882,10 @@ xfs_remove( */ resblks = XFS_REMOVE_SPACE_RES(mp); error = xfs_trans_alloc_dir(dp, &M_RES(mp)->tr_remove, ip, &resblks, - &tp, &dontcare, XFS_ILOCK_EXCL); + &tp, &dontcare, 0); if (error) { ASSERT(error != -ENOSPC); - goto std_return; + goto drop_incompat; } /* @@ -2922,12 +2939,22 @@ 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 (xfs_sb_version_hasparent(&mp->m_sb)) { + xfs_init_parent_name_rec(&rec, dp, dir_offset); + args.hashval = xfs_da_hashname(args.name, args.namelen); + args.trans = tp; + + error = xfs_attr_defer_remove(&args); + if (error) + goto out_trans_cancel; + } + /* * If this is a synchronous mount, make sure that the * remove transaction goes to disk before returning to @@ -2938,15 +2965,23 @@ 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); + drop_incompat: + if (xfs_has_larp(mp)) + xlog_drop_incompat_feat(mp->m_log); std_return: return error; } From patchwork Sat Jun 11 09:41:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12878395 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 13C3CCCA47D for ; Sat, 11 Jun 2022 09:42:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229838AbiFKJm0 (ORCPT ); Sat, 11 Jun 2022 05:42:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49160 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232613AbiFKJmR (ORCPT ); Sat, 11 Jun 2022 05:42:17 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4CA25389A for ; Sat, 11 Jun 2022 02:42:15 -0700 (PDT) Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 25B3Bj2O022581 for ; Sat, 11 Jun 2022 09:42:15 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2021-07-09; bh=ByYBarEdVxmG0EbkMSLWajehJlkS9QSMuSlucA8pqEc=; b=wF1dIl2Ff/WbgFgxCqTHOKiAN0jfUYY7B23KG0g/R5vgHCBokl4xjN/a782+YknYr3jb KyT89acH+VdxkYjsHqIqno8oNn9R1Is4HaC1FDxaeFVCE1bbg7fHDn65vJgjl78xTUPG sl0cNKJLY4ld/e8KGoIGJYCl0k3vVgsh9egarl5nG9fgf8n5VpqEflCGE0VhJtcelQLx PkjevFiM2zJ1L7T5XfoZUCzR/0/QAtCMyPgXaCQsaD5ubaMsCanye7Vqb5RLWunt0tzZ JlsSPELQGPP1btYFQtpxr/3qO7awRJ6ruPNrxI8uWw9Gazq4axLImzAnmzAjoBi1Q8n6 xQ== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3gmjx98am5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sat, 11 Jun 2022 09:42:14 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.16.1.2/8.16.1.2) with SMTP id 25B9allI001303 for ; Sat, 11 Jun 2022 09:42:13 GMT Received: from nam02-dm3-obe.outbound.protection.outlook.com (mail-dm3nam02lp2045.outbound.protection.outlook.com [104.47.56.45]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com with ESMTP id 3gmhg0m9ta-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sat, 11 Jun 2022 09:42:13 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IGV96FjkRvicJzRQQTrR4VDcvXMJzuHKfExkbW1JnlM7Sq86UlJaYGUlZgIDi4pX+ZUuSOf2rr8xIIHnW1VKyK5xTalvu9ch8M6QgFYYUeMzoITapxESrv1IKcuhEbfkio54pLBvV2TdsEJ4ma3zEPk+ps+ZgIVmuJlpZg6HVze2YwuNQCmWxo4wYOd3mAuUswbtGBrxJUGOekjuLUM8vhRzvZ25mzaKSnchu6Y5EQjv+5CPEm5tgsELumGx6fvpGEWU2IipbacO20D5q7KEaPpxK8QvhbI0Ig7j7TMfxAdY14oSmikMr2tBlHWvfbiY359tlAO1i56tRDsmnXD5dA== 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=ByYBarEdVxmG0EbkMSLWajehJlkS9QSMuSlucA8pqEc=; b=hAhJSfrPxHEKZr4JQglzBxRuolK/iA1tytEUVVNxwfbafkQ8e14+qcwOjd9YyhTYKT/Ldrjrdsm6GST7Ci9Bx00HmHAOlMytKedcp3h6wEWwQzu9XINCDbjSQimjoWE3KaGYpuM5mX3BFbU8i1+rtCykR9v3eAY4XW8dPniVMyE6x5CBfPRwJYu3vXTeoYkJIv+Hu6LyXvkydNpp1FvmPo7+Qm/9puctG4d5TWW4jHd+SXu52JyDaQDdTAE1vEX/tBoGLHA5eHWlQMwI8Hki+6ZfK0DaI/9nd47ABYWvuEb+nwCP5nHuXnNq6qmYXZCPDYDnlut0PYilwtM8U4whiQ== 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=ByYBarEdVxmG0EbkMSLWajehJlkS9QSMuSlucA8pqEc=; b=jx1GDFDF8DBZA3Otsqh9wi4etbyMim/LKNckDOZxY4ZeB9AJeMA1DPggPzPHwqf8ZKXgX/spXzA24hYrTJcLueLufLASiWewEluHSar+SyssKlSIC398V4TANAzm53OcsxI2D1QYD+HjVCHNrPO3X52LE+hZ1sDz8lA02ALrk2s= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by SJ0PR10MB4606.namprd10.prod.outlook.com (2603:10b6:a03:2da::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5332.13; Sat, 11 Jun 2022 09:42:09 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::30d4:9679:6a11:6f94]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::30d4:9679:6a11:6f94%7]) with mapi id 15.20.5332.013; Sat, 11 Jun 2022 09:42:09 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v1 13/17] xfs: Add parent pointers to rename Date: Sat, 11 Jun 2022 02:41:56 -0700 Message-Id: <20220611094200.129502-14-allison.henderson@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220611094200.129502-1-allison.henderson@oracle.com> References: <20220611094200.129502-1-allison.henderson@oracle.com> X-ClientProxiedBy: BY5PR13CA0002.namprd13.prod.outlook.com (2603:10b6:a03:180::15) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 48e0ffb1-8535-4b96-7b51-08da4b8ea7a2 X-MS-TrafficTypeDiagnostic: SJ0PR10MB4606:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: BGjWGIjvKVEaWeVcVAsYZ4oODQq0638qngbY4p0nE6T3l0LcyfVHlA0Iv/5jCLArcWH706AnwVABF/fYGQ9X0kCJPAPlm000YvieOi87WrXAxrJO/pWJkZpTmfSEAbHgZ3gcyK+5TZHs3VlivHnvErjbJSGR9IET904U7mIQrpDh+XHu5tDAx9RbUIbJ7sN8dtHfIOtMtp9B3KDTs/lAnin83LgOdSbPWEdzmmsdp77+NvmFydeI4QHk9IRiktPCaYBKp987vizeJdWtvp6erEfWo3vCVVqUuZ9A90bnVfWk6dp1HEZ1N1wogI1S1VWUrNaPYPd/+QKwh5Mjwi0vygQoxFy692VCfBqUWT9qZ7JxvmWKM+JEpcV1QGxTNtqP6X8tiM4sD8HsGp1t79E7D+Z+91584yTA3qqFFptet234d5logG18tX0y8z07cUjzldVKYnYWiLwXRNgAVFQOVEH7ZkYCX/lzxSzz4gzcO+Pvz4p+qXD+i4S1acdugsHWOR/jD6SClu0sV4KXfceMpPkHAuaWCy/mvLnVi3vx2EvNRBkN3aYfYEm/YHS7zWu9ldeYXDRhc7nnDCXatsK+p0MRVwGcq3jeLu+1NnAlPRu7J76DdMqYFZHjYH+Jq2xOK2m1mKUmdPp75k55kXfPK/SzZhOb5gq+i3NIhyDl8rmJvt+8QvSxhMsuVrEKgAoBGTL/p64WAH89U65oVAyTdg== 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:(13230016)(366004)(6486002)(44832011)(86362001)(2906002)(186003)(83380400001)(36756003)(66946007)(66556008)(66476007)(8676002)(5660300002)(508600001)(8936002)(6916009)(316002)(2616005)(6666004)(6506007)(52116002)(6512007)(26005)(1076003)(38350700002)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: VBM9l48WRDuA7QXmd/TNUFykVZMZ3xd62erQIgQ+XmlVGzffqGygqUf0JXSD76za7IZ2NRopAKh+BKnMgKn8i0uML3cITsdb/51MQWkBMj3r+n1q5e5ZWzMt6ExKW7UEEvbp+Ec1RuoN6Hd+84M+DfAgt2Jrut+G3JKSU8+owak/XOjswT+AGTy31g0NJI1C+Z7iPnUstVueFacyDStigPIbfDKI5mhsWlsqcNnzNHxa+Gw33Cl+8TS/zI5ZfO7O7wpaPkFBlBLkfWDNAbo8uPtOYRqWP4HmRAcIb82ywuaFfm5cGBM9Gtm/yYO+hM/FWNKfiFnetYTqHNmQipoOUiT/aAFiyWIECs7P6zkhJbyBXgHTiPaAcworSPRPjgTmjy2aodAVI2tt+uRZw6h8yA0VSn0KbjkjzXW4QcmMIkJrKZX2DUwEVu1gHoviMw8laz5y9JpV+9Tzov+eXxQJgZuLzbSuqo9JR8ypBL2Jd5nV7GHwCpmYIbRDEe30qKYaNGJZWRuUrSIz2KOsYWldxguFfJDdsumEjI0QJZ/mHeDcWQEhFKailIMdv0GrD+kl1Q2YWD/kul7ZeW4svbW4/VKsG70LHOfKAqGO91ggLMpXsVywS8xhzLMfoIZ0z3wOi+9RXaklNeZW/AmM8fzhPqCePIL7gWqKki/kGcnkddxa2/vTy+f9Ig1iawSHCD7IuZ/Xf4tvxkqGLJEDp9myIz+aF7Lww86DHr82Jor0S7MQntMyGzt6NGik7sUqzD8ozsapdjH1Kjm2KBZ9W3gJEHfgr5D5spKLKjI/w4QnSZTkqRJeyNfYDBFbsKJYlGvfU/GOEv1G8Q4npjyNDdj9J8fX2pbSRPX897HM28SoPSVz91Al1oI7yOjvhfxWPm0NnSo+EWECDGPL0Mkfn803aS7WYA9zuX3Zj0gDFdHRwEN6FR0lmMdSFJX0bHgUgp2EJgo+nKhMNXLUTU2xlpEAwVW8V6OUeJcM/tiuRFH5F6ywGLFAoEDZNfq+CR85Z8Khdr09my+lljooAoXzk1fD1dJQszUX+pE5M6vyP0bAKQmPCaqyYlLH26cSS3TZIpPc4ELeFUBbo4FOuqraBEb1lsiMBvv9aKe1PrUt0ICRekhzFN5lixRRebRttyKYt6ftEFy6BifX/XjH7Wt5+gd6c8JMhvv3fFpt0tElL0cAPcl0mCSSSZ438oKb3dhdJkbk+B+Xe8p2F/m7ld1752cxoC6IhSHMhARMdYaeAJYcyzVFdLHZi6++/jTC0cV+wRaP8H0HXlQRgrFD9mIoly02i902ZvHIyZgs16xL76o6oUZWzVF8K37f0CPEH9OE7EtUVy5YLO38Z6Z+OBnA8HkLalpWvV6QBas1PbyKWhmVYz8nlEnDMRkDLGou5gQUQ/hfZ0c4eynrcx9QQjEt4Co5yRycf+wXiS5Ss+yYGVU66BCzR2PwhYDBxZq9/R/xT5KV6oUy2mVK0FC3d07uBediHcgDltEwKo8QAC+/LjZ9RSFZSXYUiTmhdt+Vxz9aoDuPTMZtuxXGZv2/d00uNM58XwpntIohrGSikl0Y9rsTKOEZAUbBq2woSW23CHuSJ2Tf2sOJQ8fWvTjsVPxBsLetzYyNLNsnwpa5UmaoZrmoOcA0+vCDezR3QKIWKP0tz3U/eGs8iBmWogdIMv429zy9LkHGqtx5ioOaMND/eL4Rl/lFG/yHFubE2pYiiR26FmDixKBHgiPP6vbJHwU9wdO7k+vkKqSZE8p3GKBNWULlmdY= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 48e0ffb1-8535-4b96-7b51-08da4b8ea7a2 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jun 2022 09:42:09.7646 (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: H895PlT7jZwh+1+/eYk1hsTRTPskMLxSoei368+sU7zH6EZ9Llp6A6/teCqzHA91Fk8FW6EDWY8XadY7AE08g3IzyYclmwyt0IrBnJrOMmQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB4606 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.517,18.0.874 definitions=2022-06-11_04:2022-06-09,2022-06-11 signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 bulkscore=0 spamscore=0 phishscore=0 malwarescore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2204290000 definitions=main-2206110038 X-Proofpoint-ORIG-GUID: 6UuweMrwD7lJucGejOre5mwAnOURFWeF X-Proofpoint-GUID: 6UuweMrwD7lJucGejOre5mwAnOURFWeF Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org 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/xfs_inode.c | 137 +++++++++++++++++++++++++++++++++------------ 1 file changed, 101 insertions(+), 36 deletions(-) diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index 160f57df6d58..4566613c6a71 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -3153,7 +3153,7 @@ xfs_cross_rename( } xfs_trans_ichgtime(tp, dp1, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG); xfs_trans_log_inode(tp, dp1, XFS_ILOG_CORE); - return xfs_finish_rename(tp); + return 0; out_trans_abort: xfs_trans_cancel(tp); @@ -3200,26 +3200,52 @@ 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; + struct xfs_parent_name_rec new_rec; + struct xfs_parent_name_rec old_rec; + xfs_dir2_dataptr_t new_diroffset; + xfs_dir2_dataptr_t old_diroffset; + struct xfs_da_args new_args = { + .dp = src_ip, + .geo = mp->m_attr_geo, + .whichfork = XFS_ATTR_FORK, + .attr_filter = XFS_ATTR_PARENT, + .op_flags = XFS_DA_OP_OKNOENT, + .name = (const uint8_t *)&new_rec, + .namelen = sizeof(new_rec), + .value = (void *)target_name->name, + .valuelen = target_name->len, + }; + struct xfs_da_args old_args = { + .dp = src_ip, + .geo = mp->m_attr_geo, + .whichfork = XFS_ATTR_FORK, + .attr_filter = XFS_ATTR_PARENT, + .op_flags = XFS_DA_OP_OKNOENT, + .name = (const uint8_t *)&old_rec, + .namelen = sizeof(old_rec), + .value = NULL, + .valuelen = 0, + }; trace_xfs_rename(src_dp, target_dp, src_name, target_name); @@ -3242,6 +3268,11 @@ xfs_rename( xfs_sort_for_rename(src_dp, target_dp, src_ip, target_ip, wip, inodes, &num_inodes); + if (xfs_has_larp(mp)) { + error = xfs_attr_grab_log_assist(mp); + if (error) + goto out_release_wip; + } retry: nospace_error = 0; @@ -3254,7 +3285,7 @@ xfs_rename( &tp); } if (error) - goto out_release_wip; + goto drop_incompat; /* * Attach the dquots to the inodes @@ -3276,14 +3307,14 @@ xfs_rename( * we can rely on either trans_commit or trans_cancel to unlock * them. */ - 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 @@ -3293,15 +3324,16 @@ xfs_rename( if (unlikely((target_dp->i_diflags & XFS_DIFLAG_PROJINHERIT) && target_dp->i_projid != src_ip->i_projid)) { error = -EXDEV; - goto out_trans_cancel; + goto out_unlock; } /* 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_pptr; + } /* * Try to reserve quota to handle an expansion of the target directory. * We'll allow the rename to continue in reservationless mode if we hit @@ -3415,7 +3447,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; @@ -3436,7 +3468,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; @@ -3470,7 +3502,7 @@ xfs_rename( * directory. */ error = xfs_dir_replace(tp, src_ip, &xfs_name_dotdot, - target_dp->i_ino, spaceres, NULL); + target_dp->i_ino, spaceres, &new_diroffset); ASSERT(error != -EEXIST); if (error) goto out_trans_cancel; @@ -3509,26 +3541,59 @@ 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; +out_pptr: + if (xfs_sb_version_hasparent(&mp->m_sb)) { + new_args.trans = tp; + xfs_init_parent_name_rec(&new_rec, target_dp, new_diroffset); + new_args.hashval = xfs_da_hashname(new_args.name, + new_args.namelen); + error = xfs_attr_defer_add(&new_args); + if (error) + goto out_trans_cancel; + + old_args.trans = tp; + xfs_init_parent_name_rec(&old_rec, src_dp, old_diroffset); + old_args.hashval = xfs_da_hashname(old_args.name, + old_args.namelen); + error = xfs_attr_defer_remove(&old_args); + 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) xfs_trans_log_inode(tp, target_dp, XFS_ILOG_CORE); error = xfs_finish_rename(tp); + +out_unlock: if (wip) xfs_irele(wip); + if (wip) + xfs_iunlock(wip, XFS_ILOCK_EXCL); + if (target_ip) + xfs_iunlock(target_ip, XFS_ILOCK_EXCL); + xfs_iunlock(src_ip, XFS_ILOCK_EXCL); + if (new_parent) + xfs_iunlock(target_dp, XFS_ILOCK_EXCL); + xfs_iunlock(src_dp, XFS_ILOCK_EXCL); + return error; out_trans_cancel: xfs_trans_cancel(tp); +drop_incompat: + if (xfs_has_larp(mp)) + xlog_drop_incompat_feat(mp->m_log); out_release_wip: if (wip) xfs_irele(wip); From patchwork Sat Jun 11 09:41:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12878397 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 13B4EC433EF for ; Sat, 11 Jun 2022 09:42:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230122AbiFKJm1 (ORCPT ); Sat, 11 Jun 2022 05:42:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49218 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232642AbiFKJmS (ORCPT ); Sat, 11 Jun 2022 05:42:18 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E9500C74 for ; Sat, 11 Jun 2022 02:42:15 -0700 (PDT) Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 25B3vwxg029669 for ; Sat, 11 Jun 2022 09:42:15 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2021-07-09; bh=Sn5M+MvkTeadwVyvqcuIwkA3iRGI9fhiST0ncStYfNs=; b=FwLCzCwATniyco+r2fDro3o5gYsn2IUUDzn7azkI9vxD8IbjRZ8VPnknW0mp3g9Wa16g rcCEVioG+Y+Lr2T5IzLfANep3+d/evXjUwHkARxZyb2K9qOfXafCw+TdbHIWjbHFc7ri lNlR0RhljeQp/VL3Rwwxf+VinN3u1fwvnWcWyp9yE08zhRDE4fwU2wmTudywIru7dACA xO3KmiFkNlUi1/RDJzXfar/rF8srX8o3TyRaQKk9rBsXaklsmh9AzDur3GwHMK08/y9W krNhXLTaIYcEoATBI9hSiQLgGKOQjsm2TmdI5HzxVSrOImx1mWDC85HPXNMYKEb1qKzN dw== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3gmkkt89wg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sat, 11 Jun 2022 09:42:15 +0000 Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.16.1.2/8.16.1.2) with SMTP id 25B9ZMQG025527 for ; Sat, 11 Jun 2022 09:42:14 GMT Received: from nam02-dm3-obe.outbound.protection.outlook.com (mail-dm3nam02lp2046.outbound.protection.outlook.com [104.47.56.46]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com with ESMTP id 3gmhg6urjp-12 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sat, 11 Jun 2022 09:42:14 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WyuIzTGwUTfnL9NNuvpBwPAGMtyk72nmo3QLCnUZnvnnBcBWq9QazhyzS86b63hrSyGdQNMVCl3M9URyrw7eTXIfxaQDltNeSQ1DmEtypHrIKVANd+cFvUS04/OdhGn/uyR/Fbav083uGv4mYlhoPvyXw9aLEqfxTDaxZE2Tt9opG1pGUJUDcD6oT5904rMcYTtLlQo+gf01iZHFGL7Jji6bHoea2O7ZGmKm5VTUNqk8jOOwVGW+d6U7e7uKsZVh4L59lv+ztNW+ohtyYuqtNVaBhX5l3XSVtxKqA/+j/Q7/Kilejq5AHI55SfrUCIu9TxT2nkEtvYrdQxLfgfhydA== 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=Sn5M+MvkTeadwVyvqcuIwkA3iRGI9fhiST0ncStYfNs=; b=ACbzH+jWT7oDYMQ5W91rH9+ef6PrdO3nQIQWkRNTPML6cL9uXCSa6MTpqN4+e4jtLYNMc+uzc7u4mQeKGsi28JOplWguSVmUsQBXpLASKOhr99WbgCzI2KZkiAZeQuDCrYDPbrK395lvIs3fiAWoYkV6eVRZ4Wf9QGA9DhBHTHikZXMJNmqQA0fIVglUsY1mQlik0bqBEGuC8iEabxRabVg+uh6gQxUykw4ExGBQRuMgjEuRaxChUpXuBRy3s9RJyTfE0UbXHhlATDN/ibzIobzuZ8bFkpjLn0VxUU2Fy6Dm+qfj/Ozx3YwLoAnmyNYuS4Uv9EfMo9kB7B8g/CY30A== 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=Sn5M+MvkTeadwVyvqcuIwkA3iRGI9fhiST0ncStYfNs=; b=IIY/im+uTXY4LtMd7qyomZTaLl4I+eoZ6gyiQ2VNeoFnIVqQxHrRu36zst/+hyzzor49awevlC6RaJm8jc5LdRj1JRUOlBlgG5MMkLaUmeUpICyalbD1AKZGphipGah+XI5us11AVgec0AK07po568rkWaZhM0biI/a+VFUjKDY= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by SJ0PR10MB4606.namprd10.prod.outlook.com (2603:10b6:a03:2da::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5332.13; Sat, 11 Jun 2022 09:42:10 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::30d4:9679:6a11:6f94]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::30d4:9679:6a11:6f94%7]) with mapi id 15.20.5332.013; Sat, 11 Jun 2022 09:42:10 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v1 14/17] xfs: Add the parent pointer support to the superblock version 5. Date: Sat, 11 Jun 2022 02:41:57 -0700 Message-Id: <20220611094200.129502-15-allison.henderson@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220611094200.129502-1-allison.henderson@oracle.com> References: <20220611094200.129502-1-allison.henderson@oracle.com> X-ClientProxiedBy: BY5PR13CA0002.namprd13.prod.outlook.com (2603:10b6:a03:180::15) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6bf498bb-379c-479e-f109-08da4b8ea7cf X-MS-TrafficTypeDiagnostic: SJ0PR10MB4606:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: eerWx0331aIAdDi8qo3Z1FAasoTMtete2SqtWy6M9Rnypi4Vno7GS/OW/Na7QboO3oAqOj3EjXjuwL3mMV8CuRg6O918j/hAENS5PrU3AlvHcEW3xwy0R9YS+ErotQUSiMnPhwuGTpM3swunV2aFOjD3UwgAxJlLeFpEb8wJVjErp3L4XjX3d4NbxXc9rk4uhAfs4+jZrSjsxQV4eVzTKPIXLYCdhVjs6NUf0OJwq0OwCeZAptwJ2HKx6QWbYYLF4v1d7s9gjoboPdPaGhbgf8GYZZvim+jUUu+UqTXOKkRFIJFKCCNmYJXYUPRe5RkClw5ghpqSRgpBgcjUm6716shYpWbyvyK0Wkx0UVnbyr5ab4imuEf+y7KHZ27Kbrt3OjBBzLirzmElBkiuU7yCcAOLGtMP1Bw/b4CsF8ATKea846NeM1/tsYo03GtBqAidl3y4BhcHX7palFCz4Hv0UaI9nR/rzY0vW75MYGmjsdXU6d3t/gtw2Xw1m5gf+1RGF34rXJbfw4cHgRgoL4n4QE0j5woPoNIPOG7Gcn8DKF6uiw48tplzEh4X6IbiJh1nuxloyuZ4zv/Mlr3FnYiMr6RDpPO0bNtILvAAKtRWOk160F47g9EG500GY32NYRZ9g69XGW3TY8Tfg6Isr7DufdFpHq3XGUW+qhDJnMaylnexskvh76CveXdn1b1DykgDyMMFQ8tqKBhJBUsIJhcdIw== 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:(13230016)(366004)(6486002)(44832011)(86362001)(2906002)(186003)(83380400001)(36756003)(66946007)(66556008)(66476007)(8676002)(5660300002)(508600001)(8936002)(6916009)(316002)(2616005)(6666004)(6506007)(52116002)(6512007)(26005)(1076003)(38350700002)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: dkpnjk7OAq9FV43JmYRKkW56Knq9QLa09/ZKYH4eH0h1JsiP16A1XwYiOsUWY+BaZIF+YnsQPSQwcc7ZVQQWNWRgNbnczxGVNaZEEZ+6b5aYAFwt+ACsmIhTNFIH5IExXxvNorScGVgp1NVW8kL7aNFm7vJEByC0/+y8ZSejaqOVhPs8C9CwuRSJYEHDJCDX/6APatjZlPp6V0AnruZ0INTucvPBHyTbCSU1AIbL+TcOxtYlmTHBKQBB7T+2S9/QZUEKdeCMA4Tyz+JF8kOMRLvaq4E3Guckw8gsqa1PJ1fK9wiAPUfavwWamnXk9A3EY9HolGZzmONYzS3ElGHCfiqjrkyg2mfzoHENgVp46LC0jrSX0kyS5T3mIkaKOYyHRszJR0mahZxK/uK4+/7mhl+cnhU1Ku0r0Go/tifdf6ecW5fAHHdfNDsqSF6RL7eRCZr1NUYI+BFmlBpoiRxsbF87ejjOe8P+wXYJkNgGuBHw1LHTNJo5SKMdNB35h8wIWRc1uPiupvG7y8a9KsXThOBl8YWVYtaIj/PEDIFooQsPKOIrPuPqJoI126MM9OFBkIwOTGAci8D8O0FGP6HYcnYUayVO012XEmMjglVv3uQ+POSVDbh48HmVN4Khjh47IXMSBYPZ5jX/eHVcm80xW7BXaCs71KXvONLp4y7ZuoHdSnKHMssapjIksc55l2BM/brgnN4Fs0SVQdOK7b+G577qm0O+M7cM8pqyUthNK0V6Wkb4sqTMLJKlY0fDOOEwAuZhJox77bsSj9bfFMd0tmuJq5vuTYzbB07L3akVtWzud7tRzykwIGYW00rQ5Xid6adVA58hdJa8SvHFPSXb3//V+cYv+RUPyTiP5IgONbA1nZrw0zceTtbPoYvR3rb7FzMXKbjebkXZi06YM2a9uCl/qNIdBzm8OQdbz0TurZihKpI4Vw8XudimsjpD3iz9nI0aum4ij9jMvNkamGAS53VbS78pfIdgY16i0ENd74c0U5ym1XaupEKALcZyQpTQpm1Wufzfi4y1uzXfWXaM87aofR/+NZWKK1QsUeRhyCHdmaB7Nuz/cApExvMeQ2GRLGRLHhYj+w0P/F5xYBqYjLHJqr9tJuH6c0ztK/hB9QOwQl0tyRFrYNAHi+4KtGkDe0s4SXSQ32RiqW5J6pRuvusNAOEaj/9eilR/RrgzoSaMw13alVG1pG3Cik/wEA5A0A+/LdDlLYpm+PhUS6m197OC7WMbHEAOwnfIpBV+P52HVHWZozWHrgUaekTICTOfsISBgVb0ReLbnkSBJBSz9bv9emMXnwGlEp7R/zqSuzCt90hSenWyKA0fzQRObECfP7WCJoIa7rmOga41FKow8NnRP96pZSaUTy6Muam775VU3WkELLsdFY+9jBSgJ8kbTX39Of+533A7U2XoQB5osNhid2vr2b9MU3OPcgsVutAVcGSrG4i5qjq+Rin1GgaGXspSlNNJT0aq4oaUlS+jD++RHl5Gy0xHFt3JSYv7NlphGIyojoA0yT3F6q1ZnmYLqQcfRyRlxpyfE4gw51I0lYSB73ZlmR7Zn18YJ7DWNyc8GFPUmvi1DycgMIQ46kFLQ3Bkc4F62vlPBCRWiHFHApZHqiyWsH1v0SOtpNt3cnuDanOuDwFJKuZ8/Z3SmSHsVDV79BXl1XfsdOWvQlDZbtSzudW3eyzKQR9zgZ+7MrHEJUloka1HWYWuOlKfasEVPIaakTtBHnJBFPGsYiMJ2VaL0nswMhebqhiiuVrsMRg= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6bf498bb-379c-479e-f109-08da4b8ea7cf X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jun 2022 09:42:10.0614 (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: KV9AV+gXBzV+qwL/AKE5kwI6XZzB5kYGqRSYqRK73SNaio+mjbknywP4X/P5Pcbf6pG5Bj4yjUejTJYerCISO5mbycWH+WHi6EZR62LHxqo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB4606 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.517,18.0.874 definitions=2022-06-11_04:2022-06-09,2022-06-11 signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 spamscore=0 bulkscore=0 malwarescore=0 suspectscore=0 mlxscore=0 phishscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2204290000 definitions=main-2206110038 X-Proofpoint-GUID: azjaO-km6C1tDZ6opSyqhWZKukgcGZla X-Proofpoint-ORIG-GUID: azjaO-km6C1tDZ6opSyqhWZKukgcGZla Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org [dchinner: forward ported and cleaned up] [achender: rebased and added parent pointer attribute to compatible attributes mask] 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 | 14 +++++++++----- fs/xfs/libxfs/xfs_fs.h | 1 + fs/xfs/libxfs/xfs_sb.c | 2 ++ fs/xfs/xfs_super.c | 4 ++++ 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/fs/xfs/libxfs/xfs_format.h b/fs/xfs/libxfs/xfs_format.h index 96976497306c..e85d6b643622 100644 --- a/fs/xfs/libxfs/xfs_format.h +++ b/fs/xfs/libxfs/xfs_format.h @@ -83,6 +83,7 @@ struct xfs_ifork; #define XFS_SB_VERSION2_OKBITS \ (XFS_SB_VERSION2_LAZYSBCOUNTBIT | \ XFS_SB_VERSION2_ATTR2BIT | \ + XFS_SB_VERSION2_PARENTBIT | \ XFS_SB_VERSION2_PROJID32BIT | \ XFS_SB_VERSION2_FTYPE) @@ -353,11 +354,13 @@ xfs_sb_has_compat_feature( #define XFS_SB_FEAT_RO_COMPAT_RMAPBT (1 << 1) /* reverse map btree */ #define XFS_SB_FEAT_RO_COMPAT_REFLINK (1 << 2) /* reflinked files */ #define XFS_SB_FEAT_RO_COMPAT_INOBTCNT (1 << 3) /* inobt block counts */ +#define XFS_SB_FEAT_RO_COMPAT_PARENT (1 << 4) /* parent inode ptr */ #define XFS_SB_FEAT_RO_COMPAT_ALL \ - (XFS_SB_FEAT_RO_COMPAT_FINOBT | \ - XFS_SB_FEAT_RO_COMPAT_RMAPBT | \ - XFS_SB_FEAT_RO_COMPAT_REFLINK| \ - XFS_SB_FEAT_RO_COMPAT_INOBTCNT) + (XFS_SB_FEAT_RO_COMPAT_FINOBT | \ + XFS_SB_FEAT_RO_COMPAT_RMAPBT | \ + XFS_SB_FEAT_RO_COMPAT_REFLINK | \ + XFS_SB_FEAT_RO_COMPAT_INOBTCNT| \ + XFS_SB_FEAT_RO_COMPAT_PARENT) #define XFS_SB_FEAT_RO_COMPAT_UNKNOWN ~XFS_SB_FEAT_RO_COMPAT_ALL static inline bool xfs_sb_has_ro_compat_feature( @@ -392,7 +395,8 @@ xfs_sb_has_incompat_feature( static inline bool xfs_sb_version_hasparent(struct xfs_sb *sbp) { - return false; /* We'll enable this at the end of the set */ + return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5 && + (sbp->sb_features_ro_compat & XFS_SB_FEAT_RO_COMPAT_PARENT)); } #define XFS_SB_FEAT_INCOMPAT_LOG_XATTRS (1 << 0) /* Delayed Attributes */ 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 a20cade590e9..d90b05456dba 100644 --- a/fs/xfs/libxfs/xfs_sb.c +++ b/fs/xfs/libxfs/xfs_sb.c @@ -1187,6 +1187,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_sb_version_hasparent(sbp)) + 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 a6e7b4176faf..cbb492fea4a5 100644 --- a/fs/xfs/xfs_super.c +++ b/fs/xfs/xfs_super.c @@ -1655,6 +1655,10 @@ xfs_fs_fill_super( xfs_warn(mp, "EXPERIMENTAL Large extent counts feature in use. Use at your own risk!"); + if (xfs_sb_version_hasparent(&mp->m_sb)) + 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 Sat Jun 11 09:41:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12878391 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 D50FAC43334 for ; Sat, 11 Jun 2022 09:42:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229708AbiFKJmW (ORCPT ); Sat, 11 Jun 2022 05:42:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49300 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232607AbiFKJmR (ORCPT ); Sat, 11 Jun 2022 05:42:17 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 460BB1147A for ; Sat, 11 Jun 2022 02:42:15 -0700 (PDT) Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 25B1hoNT021293 for ; Sat, 11 Jun 2022 09:42:15 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2021-07-09; bh=EjtZpq1EAMMepYAQThwYQIl5awvyr4bz3cUlT/x2sp4=; b=ZYRm2JDbKYF/Wq++UBz6kL/uwOrkhFUqOnNeXck+wgaXuWQIKsnRoOkd6N+I/tSPIbea ctJZlC2duaepzsI31K/jWmVuF5FvsjFNFtObtkUsn7MV/FgVXPJmm9W3VoSSrrUP/mEu a7T9fTB5ZVlebtHnqj2B4Uv8Z8Yq3IRoZ6rWOXtaWdF4SJNYEwUY9EEqFSKYrixXZu1Y vrIDqAXLfXoGni5OiKbErfk5X0OE16ehoMSlOoTQe4EkQ324cwHAwvviLjtIj8uuOCRi SxyGEnQvu3cq7LS4UwiulJtQ11tiPWZJZ6yJesSGhtW0Ho8rL5SoUG4A/et/FndXQJzn WQ== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3gmhn08c73-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sat, 11 Jun 2022 09:42:14 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.16.1.2/8.16.1.2) with SMTP id 25B9allJ001303 for ; Sat, 11 Jun 2022 09:42:14 GMT Received: from nam02-dm3-obe.outbound.protection.outlook.com (mail-dm3nam02lp2045.outbound.protection.outlook.com [104.47.56.45]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com with ESMTP id 3gmhg0m9ta-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sat, 11 Jun 2022 09:42:14 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LzSCCdXKkV4CuVrw+Zm3/YuowOsBnDxBYgLhJ8DCiq3UBQYyw9e3Wi9vT9WwsTqUqpsEc+rjlT2iI+MaJDFD6PxbzwKqrVcNOhvbJE7Bzw+xwEf7NCpUfFQi7QpDXbGIQFtEaciSxposLR6kGZ4zu8rZiZRgOQh3VVQ4a0YohHtxjLC6eEnOvWPEjsPEfAYziT0yT/mrn6ldnD+Pc9NiNy2vkjt8sf29tBNBCzk2ld0bwMAtepwIUzyGojcOYfgXFA0Y1OFBeNo9Gi2rFfScgIpYBed90SYUfClTrK2K30irbJgLUwQAh7RougjE8ZT9GHn9oXy7OZQ4N+vdHf0hRg== 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=EjtZpq1EAMMepYAQThwYQIl5awvyr4bz3cUlT/x2sp4=; b=LSFobjNOjBbf+vV2VNCoyBXAaSe2685VJxuBMyihR4HF2fiOUw2KFZQHG8xROS7nWqlb+2c2AlFhOBGLsf7BVdf9gb3OgpqE0n4VTiruiDMK2K/ixZA6tQd3cVrV3kFrh+9B6i7gbEw80Z355b4YG8wfQ5HlnBvETzGFWzD1o/w8NFtGEepbovTqqy583+Rzl6IQ2oE2Y01ChUwTTIJdyspfm3oqi5MAqrixgWGn2et1uHP+b9im/PlmS+9olvnFJOZ9+XZNcbMhvw2JT0n0SD7C+LR1Po2o/+xDcGmbc4qU61A5FM2gXBWIMatAwOwCumZJziXXV4gXBpFKDBjw+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=EjtZpq1EAMMepYAQThwYQIl5awvyr4bz3cUlT/x2sp4=; b=Pi4OiCU85sArFFHznACfmeYg0FLSO59KUztZ9jPWeuoi72OksksGnEfPxj5ZKuieaU8H7rrtXKjwm4QX1jkvNF50yFhwbf3XN3HrEVOWK1bO75Utu6QSfhKC76884eswdeGIJLWy6TJf1siIuS182qgHbF3sKfNSJ/PeCXl4nD8= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by SJ0PR10MB4606.namprd10.prod.outlook.com (2603:10b6:a03:2da::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5332.13; Sat, 11 Jun 2022 09:42:10 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::30d4:9679:6a11:6f94]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::30d4:9679:6a11:6f94%7]) with mapi id 15.20.5332.013; Sat, 11 Jun 2022 09:42:10 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v1 15/17] xfs: Add helper function xfs_attr_list_context_init Date: Sat, 11 Jun 2022 02:41:58 -0700 Message-Id: <20220611094200.129502-16-allison.henderson@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220611094200.129502-1-allison.henderson@oracle.com> References: <20220611094200.129502-1-allison.henderson@oracle.com> X-ClientProxiedBy: BY5PR13CA0002.namprd13.prod.outlook.com (2603:10b6:a03:180::15) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f067db57-6497-495b-9de4-08da4b8ea7ff X-MS-TrafficTypeDiagnostic: SJ0PR10MB4606:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 00vuUOtp6PxNal4WP4PXiD28D7LVWjTptIeApeIC+xwpkLn4kH2sJDDStLRVH+RZ0LSSi5u+NS9JUdv/86hJhAZ8LYIv5SMzZishjGk383Yoaq39S2pEltZFOb5zsnb41LD/2BK3WuMhA4whq1MmmuBTHC4t/VWkAlp6Dcntczzc6JImD+dXXlEq2vwkYdmsQbmfMiG2LgoWe1lHhk7Fn5XOhy0/I9Gk31Q2i+ns6w2Koy48+ho38ZWPmmOu5PO6BEBJOZu42pHxxkyKCXdau+WOMyX8hQGYXDzCoP360oTdrKIv4ZzrQMMS1hOI5sguGgELo+cNAtXYh56CQvwhmOpHu7BeqDw16rqWKA92Hr7qniGKpQDLdwYncFJB0F6AWKgz08J8g6ee2EdrdLt0yfRA1IHa2vzgRW73/p1x6Xmo2fRdEgeEVP6OBBLQkBIPnD00eZFnikfhQfu76ybOtah9H4Gnp4G1xOMYGqSoxoDsI7Uk4ilpKlDkH5qoEiSvsnODeHJYnS0kFSQY0k1whlvK8XzMAXNDaUCORJ3c1VHiKNAC3QVLPtaV/LGlCzdQCuaHr0JyBd7vpkUNc6VdL8k4VVjCfNaRd9Mux5e79ZOyGdar1bd+5/Sue3GOsxdU4Q5ZGHJTXStIJtaDSkcJuDCNU/twtyXJg2mnvZE7fWbcJbWcbY3JHFWrFHY4dFKZncKATjss9uy+b4R0jT9JUQ== 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:(13230016)(366004)(6486002)(44832011)(86362001)(2906002)(186003)(83380400001)(36756003)(66946007)(66556008)(66476007)(8676002)(5660300002)(508600001)(8936002)(6916009)(316002)(2616005)(6666004)(6506007)(52116002)(6512007)(26005)(1076003)(38350700002)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: fQ58Pj5lQxMJgDp89yTxDhqKyiT4cE1kM4sWZZ76V6gzi60++TEA8zAY0jMPM0Ya9UwJ6D9/l5q1yVtRssFY+3rZNgJewpE4SURHLoZbDcBNy05itmRWw53DiMQoB/EC+FbnJFKbplxONCdc4zT5/v0pok8O6xL7aWDzdcM4iYwawA0TrCYuCOYOnsbc7Sbrvq435d1wfwSN36IQTkUwSFrC2EDVgSEVOwU1kMd9aE3pTU+/6lAlZkouC1mWtbuuVwnWo5fPIk9w8jff8o39/b+PYolMOfoqJgtArh2ci0+WyrzUk1jqygG9bdEbi5hZZEABONs3b0j4nEUOT5exzXOC7z1RPThvgrUy+H8C+mxFCxRlBShzlTJ+YzPLUviKsUNfJbjz1AC1UmEjqpSJuzePnli3CH8FG7iIHFj9PFFcjHAE26nd7mHJU46JAVH9TtvnMroS/5mWruxEYZY9c/19wcqdtmfjt60768fsHBh3sfo9fCYav1IEyWS21NTfo0j5djFxqsg4cAhbMTkVcAhluaZwpPhv6HJ7takDPdqv/WYmZN8GauoybEz9fOXxaFN9k8IDfeR7ONn9GjG/L+AYwjqpqAg8zw4ylc/gG6ecrZKKQO35ILaMJBneDDhl9W42r67rEKgBnsC90N8d1I7uBdR4Et5dxObgZOqfBtR2qn7htVw/d70LHFDd5wcw9GW8/5MCf/1II18BxCHBacD+CUulluNTCsfN1ohUqDlSxXN4Srkl4GOfKSUMrSy6PR3icbEzZXny+pAP3TKACF3kdIabU7SIgWZAETInT7QNf/cB2uZ4CVd8f4fMc/hzGIFbv1JxdJp0RWdNOhY6VsrF2oK/AHva5X+oAWpazPubA4ipMDOmBDYnfq1LVwazbj/chiHE0EM+QeI3cQgx6Po2a3TRSR9MisxwPGuiAbA/VkO4CLdstakzPQkuIkA9OkSRXl8PYZGb3PwixwOI9El/hP4nRdQf09CKGph/BMso9zfiTHl7ZG4ZZDkMRbLxaB4X9/Ur8jCJKw3vmbCIrNhYUNmqMLjLYKysiW/GW2jW0V2LN2xoxEqA4n4LT2w1HtGflIw1nMFp/tdrHSGe0lastkxkS9rfALqD7QqQpxqzD0XPjDpLpr9lhmitFLxvrc8mcTkkFFLRgU2m9zUHS3kXe6OdWVeTsZcDNQPGe4djy462m4Klj2bqWnwcoCP+h4sOL4rt8vJci+MOXjuOWGUvBCp7dkxy/LBKbZG/uXpsIAJc40YOZPV4Gcg7pg6yJif2ezRhh1gfDjqidRBkH8pt5fL/gUiRFH5hw7NClb0aMFW3uXTJzIgn+om8nThgdkvcB7NW1vgx+hxFTY1+buKyP6zHoCvQOyvxYxnknAGheH/em0JCPRM2oIs3rJIx5XsWQpNMRrTdWjuOBkaxHAkcnN8Nfh0Oga7opdKIuKkXrk9nbQF2Ar05iAu4zkVvft28MCTfMJDzHVJ2lbn8tPVktkbCVTSSgEYATx6+MH8bcK3camtYdA6w7MfTjHqoBDDZhJCUb15Tbvtf5mI8WDawrze/9oopZ8l2pLZ0hZnD4BJygADx+/UJFot1LXbBvMKqrJh9Ahx05aeGcq4krIPFHkbRTLYly7zjXTc0d1rf5kxXJc1kD5IyAIlZ7r6oGqx8FjiMT6moon+7jl6OeKp9GhNf/Yub2/PaEn39ROs1JZQAvezeCjLElntpIrKh79U3HY0yWLUSBh12Yv27qUYwc3pcG/8xoDLM353DPMA= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: f067db57-6497-495b-9de4-08da4b8ea7ff X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jun 2022 09:42:10.3270 (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: LWThaRh2LTS2qymVgZImSiDYeSLiYjdBAtqxmIg2xRohtrImooiC75LzvTCSS8szTC3t4aLasXGjfOJdJix1IJXZxGvCbbi+ga34vhhXAaA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB4606 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.517,18.0.874 definitions=2022-06-11_04:2022-06-09,2022-06-11 signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 bulkscore=0 spamscore=0 phishscore=0 malwarescore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2204290000 definitions=main-2206110038 X-Proofpoint-GUID: V6BCdqC8fyID6JQRxk6rnzjvYIYW0uJJ X-Proofpoint-ORIG-GUID: V6BCdqC8fyID6JQRxk6rnzjvYIYW0uJJ Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org 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 e2f2a3a94634..884827f024fd 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 5a364a7d58fd..e1612e99e0c5 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 Sat Jun 11 09:41:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12878401 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 4A7CAC43334 for ; Sat, 11 Jun 2022 09:42:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231160AbiFKJme (ORCPT ); Sat, 11 Jun 2022 05:42:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49160 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232661AbiFKJmS (ORCPT ); Sat, 11 Jun 2022 05:42:18 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 228A3CCA for ; Sat, 11 Jun 2022 02:42:16 -0700 (PDT) Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 25B3C5AP024318 for ; Sat, 11 Jun 2022 09:42:15 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2021-07-09; bh=0P0zldecsG3JMjgYhwoUPvPxsQ8fei/A0B7D3LRpOUo=; b=YE5miFdzWBOfazkJRC+YVGgCq8wu8y3nsB/YYYMe/dNA55iGNKAImZMIvY6vt5vUZ3Hs UIZamPtlmuPaIDNEi+SuO4sLlZTQon5V2wxQ3sfDliQl4QPkiv279Jd5Oq1vSeJyqOdK YJxQ9enoJKWgG4C4HD5O5gKuMg6TenQoxVPVl2IrdFxfCu7Geu/SAuhNoozlZIR7Ov4u q6h7ToHZUZ6El4dYvIaHKUQeeh8CkwWmBwwaNDGRUjoIoL5xmOgTKGH4XCKecVaKI0ZV ne42h9EzWm+044Cr6/r1y5mNYX6BNpJqB7vEyJJ/ZjWFZqY99eOg7klqwMzY9mw9v5/h Yw== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3gmjx98am6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sat, 11 Jun 2022 09:42:15 +0000 Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.16.1.2/8.16.1.2) with SMTP id 25B9ZMQH025527 for ; Sat, 11 Jun 2022 09:42:14 GMT Received: from nam02-dm3-obe.outbound.protection.outlook.com (mail-dm3nam02lp2046.outbound.protection.outlook.com [104.47.56.46]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com with ESMTP id 3gmhg6urjp-13 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sat, 11 Jun 2022 09:42:14 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=keahEWEj24uke4evzqzZyauIiuVjhAfAf5J2kZvk15z6MszObKVMmtShtvcVf+kq5Fjky1R6ybd82IJEh0kNusSy7YESCAKSjQxGoaoE4RvJQRHAAXtvMXeGJRUzOD2p6+uBeD0L6z8s5+K29p4IhqhoVf2LkowTWVJkL7TuEhCxyIQb4SetP1YcnoGtkPSnybTFss+XHqGFKlxrdC5D6hmiHA38eJOAx+HN6I9WRM/+JdHGTQAbPVSscUKU7LsA1AYquy8gwxtW+nwwWRaVd2DepY9ejuSjoGaNjRddwLJgkfAr5YEMP5NjbOjN2Uhz3D//VyG2fMJl8irfxKxS6w== 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=0P0zldecsG3JMjgYhwoUPvPxsQ8fei/A0B7D3LRpOUo=; b=kvHrcSucO6CwtYNu5rlBEI7Bc7hwANrr/RPjPlef+PgyaRA1F2AuPOcrg9fWohv/92yk6xa1WKuuKwUWSNaw2wR8ahOPUpTC/foQgxgao2KdyC2SvKGvPXND1vJ/sRsjTfDbwGhIzKn8Wn1s4VWGP/BEYgYGCgIhS1niCIIFEHLcN+Eh4X3W7nxpqerZKa39gvxQFwm3pVhM9XiXdCqwWUbWdVs+snUsoIzuDkgl5xegCVRg0IdilLb7opZFbqfv4uqLkg9oUkozlJXvuqscTciOtvMiMVVMwjRhPfkQTxVAgpfOu3H1FNdGkzrW/04tEXhmCVqQLxkw3TxxB3F2Jg== 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=0P0zldecsG3JMjgYhwoUPvPxsQ8fei/A0B7D3LRpOUo=; b=xWOM4ls90zBoqXZRqwIWrrMDMVOI7CXMMVX59C5XEFyK8FcejQNcZEgWge8zHfblYla0VmcZpbi/UqRPvLV0Ul+A62CFEkaEjh7w/nW2nnFKpSroRJOjNAuvvCf/ln8IYyvJb27fpVQAU8fCCHtonNf3U/QD4v4xUvTjVyodm6g= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by SJ0PR10MB4606.namprd10.prod.outlook.com (2603:10b6:a03:2da::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5332.13; Sat, 11 Jun 2022 09:42:10 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::30d4:9679:6a11:6f94]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::30d4:9679:6a11:6f94%7]) with mapi id 15.20.5332.013; Sat, 11 Jun 2022 09:42:10 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v1 16/17] xfs: Increase XFS_DEFER_OPS_NR_INODES to 4 Date: Sat, 11 Jun 2022 02:41:59 -0700 Message-Id: <20220611094200.129502-17-allison.henderson@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220611094200.129502-1-allison.henderson@oracle.com> References: <20220611094200.129502-1-allison.henderson@oracle.com> X-ClientProxiedBy: BY5PR13CA0002.namprd13.prod.outlook.com (2603:10b6:a03:180::15) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f1fa70d9-2ffd-43e8-c1d4-08da4b8ea825 X-MS-TrafficTypeDiagnostic: SJ0PR10MB4606:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 7CR8CSlUnGcwwr0jTpEdmz8TfyonxJuWraSeVzdUrBpV056hSchMQjfGdbXvBUyumw2+faQLWtWFjhvt/FUGIGCFquOdVoBNwLGllTNcC6qLzo0SUtRImOpVf0lfCfEW7fO0LWg6NtCAXdi+gAkxIkz41n1tTZHRZ2WC7brWuxJVxDGOyvzEOtAGUKU+MFwZt+kJVtILRZRVlRvhNQqrw7aQoaG1i2gKd3xZ9L09vikMaLywU7n/OG4j+95gUV0bLEv3cnQTUCx3//kl1UkG9tqXC3wsC1UiTRmz4JxZ8dctU8M7GygbR1GUplLqV4GvamU5JAYYmPKJI93MunACRv0UsaHcJObE5uqSouQr8+25s1Z8RrAupHp7iAlI6HkhrqQB1fcAPKVdfTQQzM50P8I11ihOjdhO9LWhtBstPBOW/zQwD2U1+xs3TyUG621KrezEFO2BnYbXPW0519Est3mlkyBvlJRPoOMR7bl5CEQrwZjrvTTX5U0cV85WgMA3BWrZPG62Hgp8yiksjVrWuM1yprDHhIOi7euB+9UOksClctQgF5Hg04Lx108RYcIjtHNpix9e4KWMH26Ey3J3/tHzpecLvElG6qy+TJlehXiaafomTzOg282qYhcRgJPe+JUxF9Lo36PSca/WWiNgCPjqu2osnyNzpSQ7n7CaBWKF+/AKlWFf/M7dM8vsvBYbSeHbIbBv62+aX6HDnfQipQ== 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:(13230016)(366004)(6486002)(4744005)(44832011)(86362001)(2906002)(186003)(83380400001)(36756003)(66946007)(66556008)(66476007)(8676002)(5660300002)(508600001)(8936002)(6916009)(316002)(2616005)(6666004)(6506007)(52116002)(6512007)(26005)(1076003)(38350700002)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: BodboZEC/RtMHh9LlV9Tv4UYezT0xlg1YMdLEl3cdehQaAJ75q+jriGCUZcQKzLdlyQNENG5icKa64LVHVcF1g7phcFZYLUCSmVpONgZq7sk2EECI35q/0w1uIX1uzOSHIQ3uJUX1xTqtwGj8Jd5+D0UEFweraWz11Ym+1l66I+aA0VbB64lCtzNf0OUWvopuSLnsWtjzyp8+AqbdQvplW7E6QoXWnVvkPWkXr2VZpsozlGEyuT0oUID0VyU2ZIuNzNViCUSIccWk6UMs5GqGc3j4OAjV+TefP7BWf71wtenmezRHZNQzyR8j24ZbESuFJrnI3xjH/+hh2QWExVPVEUG0Y8oKdy5d2jcYbZ6AywrCztDODQBzAsqePoibQhdm2Rpt+qMLBem5dkHoMGYu1NsFwSJUYa6eb4JGFWDCvRYvb5srmfUwxx+5Q4r0P3vMVaYMKYQFcl++p0PH2WeiRjZ3z05021oyPp+Dst+fL6FEqJYpE7IcTge0BKNi/g7ccV/qr0cTeZeCgAKrIb2pcSUSyzGuqZtVw2Rsa9euK6s12B+znXUxdXy5HOmUoaeyn6z5RqChoR0c5T+WskiHkLiHhjmq/ZXrC98LnNnb9jjlPjKagRMTbLudUWowlc6qo0GYwBBmG+1ueIAgZmJp6L/UzKaAaJllPT+hG/+z6Tiw4Z5d8hwWHARXccKkcQ11CZ6fuG7dU16GIkdqnUb7+JxB4xpgCA8HswIs1jGCd692v/cQQHCnOrMh+L7VjStYAasQjjJT9RAxBr2Jpw58EvF0w6Pp1qA5kodRPVYxYO1wlk8/HObGNzkFFzMPU5VBTbLvFCMDWIB2tpk7KyhUqnTCfGptm6f6CS2gxZfcWGCyEB4mbQfHYZBI5/quq2A1ShpwPzb10YGqND+u+jiH0m1rrodJIFf5TPvlUvoWw+gEtHwgalS6UBuXMZUfQGPuZ86qioVmU2Eihl7xcUNMEq0ku6BGwvgSawY3YjpnWqM9A8tI7MLF6kIpFBjo9Lns/UoNeTLXMJMv5GeRnYWcAzrCoL03IMzKJVmJKjf8qcemF9emqqIbot7EYIgvuS0sv5UVKgqBvBBBKl6VEA3+3TVUy3geYGJZHHIQ7/DSlORT2ffJeQcuOgt5mJgu/1yuBIx8AhAsC7ap70RrLte3Z1GcQTkFQQRZrHHFxsL4p98kfVGd9arcuz0NeogPbUR/8BQcxt5BOCaoWnrePDtbutY0W3+TBouak7Y5Y3RI7DV1O+l8BU4+TK1JzcXFeK7mCVuay9c13pC8MjEs/saCRGyfq900scVA2BbywnM2lNAiccZM12zfVWai10XIz3DSmKOruL+rRiBZVnSqOWku73wFZhIR9OtWRXGmw5qxIFYafhpky1eNluEIH/YbUX8v4lVhVG31PZW8Uy9PMtfJXfTbvG6Qvcl9BGmeXU2KVQ4tKJ6Jy4g3N2naCOix/doc4A5091YiAoMchF9iAr13ibwa9/Nfq91w+6PF0oT62lSVjl3ic9nln/A/IjVRDE5uReeK4WO1Bf9TiGR+UQSH0mv0jxKbkGPkLjgoFLdvSpr8dVSRVxko7+50dQpIkqQs/vakYHlLfDR6zAP5I42h7K2nPwXiCLKfG8uurpMZz37ZPioW5QdbPztDoHdRY/WZANTlDJ71iuGx0mmji2UGbI3UDxo1+8SdzYC8BmOHXOpqv2PbKAPcixuB1OVP22+GahqLHuQhkzvFE5peruSL2MMTnnTRwPSvpQzKPyn3Dw= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: f1fa70d9-2ffd-43e8-c1d4-08da4b8ea825 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jun 2022 09:42:10.5926 (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: CRfGy2xgRLU1U+i0XCtjuOqnEaQF5WguQBEYCjmP0Q8tpmGMMdBdzgOQFHZyIKqtQDo07EzkVCu1AAhPEAV1Otu0ukr/0zZaUVI7NxKbaf4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB4606 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.517,18.0.874 definitions=2022-06-11_04:2022-06-09,2022-06-11 signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 spamscore=0 bulkscore=0 malwarescore=0 suspectscore=0 mlxscore=0 phishscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2204290000 definitions=main-2206110038 X-Proofpoint-ORIG-GUID: _keuuUmzY1oIyUYksZN1p8glEU86zp8Z X-Proofpoint-GUID: _keuuUmzY1oIyUYksZN1p8glEU86zp8Z Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org Renames that generate parent pointer updates will need to 2 extra defer operations. One for the rmap update and another for the parent pointer update Signed-off-by: Allison Henderson --- fs/xfs/libxfs/xfs_defer.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/xfs/libxfs/xfs_defer.h b/fs/xfs/libxfs/xfs_defer.h index 114a3a4930a3..0c2a6e537016 100644 --- a/fs/xfs/libxfs/xfs_defer.h +++ b/fs/xfs/libxfs/xfs_defer.h @@ -70,7 +70,7 @@ 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 */ +#define XFS_DEFER_OPS_NR_INODES 4 /* join up to four inodes */ #define XFS_DEFER_OPS_NR_BUFS 2 /* join up to two buffers */ /* Resources that must be held across a transaction roll. */ From patchwork Sat Jun 11 09:42:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12878399 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 CC3FCC43334 for ; Sat, 11 Jun 2022 09:42:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230367AbiFKJmb (ORCPT ); Sat, 11 Jun 2022 05:42:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49156 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232640AbiFKJmS (ORCPT ); Sat, 11 Jun 2022 05:42:18 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F1DBAB7B for ; Sat, 11 Jun 2022 02:42:14 -0700 (PDT) Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 25B1hwNp021516 for ; Sat, 11 Jun 2022 09:42: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-2021-07-09; bh=71FNKC6gJofw7JsGgD8hs/h5FiBURuRad75YEhhgECY=; b=X8w2GGPCGPfmzaDUnvIDmHcpp83mVUFvYKcCyv4MSynuu0xwlo2xaBYm2tUAAsVV8u1L Cx0OfoSnJUdaKHcCmYeu36MqW8pqGOjMxduR+PUDiE2bED20rUkF0h1C/Zhs9TY73Mbs vARVdFEXT+XJN3oftQnEMh62i+zy1jgrPwSv/WJbbSvXlydLdJDEhwXedhtHqloLiyJn 1itobxpBgbrtwYNnSbaDozCskhSFcnBdP9rMthSioS9gchSBXuvo6Rt1lrKL7kEWV/RA JYZy13JxiDkq455d6r44mwHAtVTpYBCxsu+Q0BGz9PQvuQpunsX08DdfiEbXUTmWLVPG 5w== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3gmhn08c72-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sat, 11 Jun 2022 09:42:14 +0000 Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.16.1.2/8.16.1.2) with SMTP id 25B9auec021864 for ; Sat, 11 Jun 2022 09:42:13 GMT Received: from nam04-bn8-obe.outbound.protection.outlook.com (mail-bn8nam04lp2046.outbound.protection.outlook.com [104.47.74.46]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com with ESMTP id 3gmhg04unh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sat, 11 Jun 2022 09:42:13 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bym6ncHQRqpvaRefvo6b0nHz1mVxpdOqsrpRqCMBGJZifUHJMZYfjshissJn3oYozOnNu3CVnh3qZD4mGDfLY8lE9dvnKHU7XG4LNTaSq4owmcnz3M7LF/reOZ4wyUIsLn1JwjLxDAxLqKQZyEbu8kQez6WdX+VONe8OEx4nzV0Mh1q0s7Oh2tnMvd0n8TqrZnlqlXwXZdm1wIJPsce2r8ugPjCktPPm5Qo4mGf2h/JJn6q9CVB3pdEHdBFS3maQWnX8VdbdmwW+h0Ta8VhlCU/iXckwKaX5gC2nsImrtwuq4jnkuI/+m+V1BnnCniinsZBF0i5NJBoA3JYmVamhcA== 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=71FNKC6gJofw7JsGgD8hs/h5FiBURuRad75YEhhgECY=; b=DoXkFme+1Xnz5z0ua/nHcFyRdZ0GW1J3sIzkGgARHZiLIS0tmrzQtRZKrodhAlWAlm+MyqLMfNjv8vjJSpjXEzvjZ//O0dY5uzQ3FqF/DpVMKfTf3pByEUdy0D2J1rO0SQYDdWQ3CvXd8sycaL+6nWOCMK+HJOTjcKIg5TveGbaCZB05134T/PIUyDEz0LbcqsXTgMwAc9qAcz9fN2LEFHnCN9aofrEXYFKeHCfLtKrWAq2nSOTFhhC3z+Rsd4XRMWO1QGozI2CSo85PSrNa7ax/BDbb1d9aF79ePKVSblougIzOzjMEJZyjepeEZ9QIshcu3hnEiRyhb5JQ+PlQew== 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=71FNKC6gJofw7JsGgD8hs/h5FiBURuRad75YEhhgECY=; b=xcjJiSgRtg12zHUBHljC7sw5zLqQR1D78V/OpwP62WosTgS+67zMVrtIzpiscdB7XgaXe2GR0vZfBb26b5UwDw5QR7CyaxSHwliBkM5vAitbDZi14LwR0AhxhkylAlxTsommAHaFsTqVcMXERcWPYv2LtMlGGhEYFPk6mRwPgIo= Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by BY5PR10MB3971.namprd10.prod.outlook.com (2603:10b6:a03:1f6::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5332.12; Sat, 11 Jun 2022 09:42:11 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::30d4:9679:6a11:6f94]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::30d4:9679:6a11:6f94%7]) with mapi id 15.20.5332.013; Sat, 11 Jun 2022 09:42:11 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v1 17/17] xfs: Add parent pointer ioctl Date: Sat, 11 Jun 2022 02:42:00 -0700 Message-Id: <20220611094200.129502-18-allison.henderson@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220611094200.129502-1-allison.henderson@oracle.com> References: <20220611094200.129502-1-allison.henderson@oracle.com> X-ClientProxiedBy: BY5PR13CA0002.namprd13.prod.outlook.com (2603:10b6:a03:180::15) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: bc459984-1a13-4e8e-47e3-08da4b8ea84e X-MS-TrafficTypeDiagnostic: BY5PR10MB3971:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8xRWkNNOx8rtxZabamSWl1LbM4naVyXidazErSbO4W74GDPOBRvWmxiyQFs9ddbc0qcjNXs7iKUrsJ9owvZQhhWygWaMa0/jFN6ZxhT/tTs4tGp5wvEeRwjIK5bFlNeXJ5xHqvaPhv0qFDADdJFoBgqrKSufi5kFsfWgXM1jyDZEJHzgsuNPOYRTzjYVNl9va9RKNNuoM2AxrFffIrN+uoqhwnPuK2c6jGgGSTcdqTsFta6n1H+VIJ0CQwL2kFB3DhBzZ1jMbHvQUFMdoFO0abZoDgwIKwJ3cXeYmhPFvyMGhLAq59v4iPRpThTy98kMtzWZjpdTV0fiLyLwloecnXXsqGeEhOZhctWGqnYRqYvq54KfTs1E7r82ffZlJpMLFroUxn7X3qPJ/HIkBhwGNC88nZE4Yoa/gjf+KStY2GShYn4nKwbvdPHz+RemefGoSonwL4sd43s7C6dgZXA43Kf9nY12jTyLLx4wntQLvjP/GDLMeaIa3NRc8JGOt1s2GNtcV+nmIV6cI5JjZpNM3MCtAJckpoT++U+MZHOb23kKPgZ+zdzx/miK8y7wL0RAA7NyRZZtgDDdJNXJRclq8Q/dsErohTwlPWXUYnCGUppVoRxKEkNjLEuin7quLgROZ7+pXplKFhQw8+QOllb197LcJOlOaIwtrhV+n3Ik4zXuQ/cKJB9Y5oBgiUE/UmPiEtQXcYp8YkVQ2GfnaHr161bkJH5wVhdGQ3iuO31vlHY= 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:(13230016)(366004)(1076003)(2616005)(83380400001)(8676002)(52116002)(86362001)(186003)(316002)(6916009)(66556008)(66946007)(66476007)(44832011)(26005)(30864003)(6666004)(6506007)(6512007)(8936002)(508600001)(5660300002)(6486002)(38350700002)(36756003)(2906002)(38100700002)(2004002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: HQWD6K4EehyUF7rdJZ1LBC5qEA6NoCMfR7j1z0ZtI8ZUcOibBz5Sz2EDbzvTxYqKRHEqoPICF3GLb025N0fTEcjDXpt9b44tWST7zk9CnyWsosxV+x3IAxKEOVfce/BjZF3oZ6VOc9xRdh98P9aTcp2EHfIMYEXAn5O0GOe1uipgduaQEKPhXhk3SFkiGUzEOcZfMpm5+qGXKMkLIl/+Ecmghs3EakAaYyk02ttypOlU9CGexX0E8yGtwBW4XmEhA3G19HtA1LhsfNr5dCuzL7RCUlXkTazf+hc80SBDXoAGZyGBMFeV/ItsxHLboorVFFHR1XXZSTrkQtWg4mmi7akD+/C+AwO2r5MfZG8eCir5Bxy4dzBQB2XS7j5rZsrR5epAB3THc8thVXTREro4YBF6B1ZhxhOcuk8IE3sVwHsWzw069gVQyhYEuRRa8BBEYKWcK2A5fjjOpaHPj7dU4rzlpBy+vy2VlOjMkCdRDj9J8qet4NOnNSyDiTwchGPqJ54Wn/0XEr5xEUZb/9uM5fhYIqZ6HrtrnE1bmxlYAqJ7AZjw9fBDxyT1SP8guOKNM4Lg/giF9Ib4VyNnr49K1mdSuVgVf4AaeDeyQR6o9PrqnJPwHabHJW51sfKPCJoxunCqDvPE4AScsc5L7zhWiykExz1+j49Nw8oET+N//5uvEEyDQWxhpHf9kHPqK5BRnI7AjLkQFpHBOsBpatJGUw71WoT59TUkgxwDmQcoCB+g03amF8aMY/yVSSrNI9PswRKGuJkmXjoSwc3tlr3+MVORO1l70IChPuI1lMZj1YoCzivdDTDuKNxVwCw43WskvNfdwXCfiPvcZqXR9h/G9kmRIazkf+6rWEMh+5hgxZhVtZOGlr1xpt0aj7S2IO97dSM5QMqncgq3Wl1zmFI1WoNqlYKvQDNA1CbtmPJk7mQUWU9UFQkLXd/JUTz9eGhveKW0Xn5+ZBxkAxEUJViUIx1o85pDQpumXZTKOj4xgx2egcI0WRlPgzq/Bgp9A94dEnwISk/lMlM8aDYjwnrcBEh3PZpr7560pKnn4kCwT5Hfq0nJZOCnKCw+9d/AuG7tK9PN6/5cZfG5Ni3XfDJp4KpxDi0r05kOd1tgpyPTIL66PkAjMnICpt/fUJrEelBtvXHxTi5GIuK3y50golBu2Ls1soATFH6l3akMHoPRoms6b4o6KtJFFofPqCnHiDk9l2gZBgKDi86YThjxyf3z+hwtwekBo4vC8DMF7dLU4Vq6Qtj6IpkwcbhJyuxMgoYDB+dkyIqWuN15NCUjXf5geumEpIY34uvh4IVuT3IbiipfUb24Q60uSdQxY27ryeKbjI17muq8wq1/EgLiryz0UgfLcf9etK4Tig0tevAWClYLaN0UUl4Dmbxvqbdwi8aPtMJPCP435zcsuf/vq0d0HD5MHAo1HT9R27v9NqkRG/RsEofqR5xYdT4cNVJ8y95BAIjiqBbsjgcwYm6QUe2yJLPfhmQGvHriU0ctYaC/Sx7XWELvj+ywDPrR6w6trmdvOza4aCnBrIC1ti4HNdW6695ND7E6vgjx+NLC/wdpzzMaY6ug7S4fA04XXu4QoDViSqaFo1z7DIS1JPxD2Ucqe2M6qfK8lAJiO+GAzmjKxLr/VWgMZta1G3yPZ5a9gYjl3JucwcvSjEZMci1+UYCdFEhp0G/aYF037DIFao28PtzmhRBm8PjqrWSKTyQv2U449/M+8J/1xgMsz9rro67Z7o4sN1Um3fRTlYrkhAPyPQM= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: bc459984-1a13-4e8e-47e3-08da4b8ea84e X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jun 2022 09:42:10.8581 (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: hwV4hVc6dCdksZrO4x8gZC9C6duhQwBEvET3/tUXVpuC0OJhA1E6JGXZnePhZY5VeGf8tUna0jQfQ0NEkdFoeHBfWXDUu1lxISMO4SmmGw0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR10MB3971 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.517,18.0.874 definitions=2022-06-11_04:2022-06-09,2022-06-11 signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 suspectscore=0 spamscore=0 mlxlogscore=999 phishscore=0 adultscore=0 bulkscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2204290000 definitions=main-2206110038 X-Proofpoint-GUID: EyvZB3S4Ohjsalga5QTUFuGyJ76AUsS3 X-Proofpoint-ORIG-GUID: EyvZB3S4Ohjsalga5QTUFuGyJ76AUsS3 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org 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 | 46 +++++++++++++ fs/xfs/libxfs/xfs_parent.c | 10 +++ fs/xfs/libxfs/xfs_parent.h | 2 + fs/xfs/xfs_ioctl.c | 90 ++++++++++++++++++++++++- fs/xfs/xfs_ondisk.h | 4 ++ fs/xfs/xfs_parent_utils.c | 133 +++++++++++++++++++++++++++++++++++++ fs/xfs/xfs_parent_utils.h | 22 ++++++ 8 files changed, 306 insertions(+), 2 deletions(-) diff --git a/fs/xfs/Makefile b/fs/xfs/Makefile index fc717dc3470c..da86f6231f2e 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..e6c8873cd234 100644 --- a/fs/xfs/libxfs/xfs_fs.h +++ b/fs/xfs/libxfs/xfs_fs.h @@ -574,6 +574,7 @@ typedef struct xfs_fsop_handlereq { #define XFS_IOC_ATTR_SECURE 0x0008 /* use attrs in security namespace */ #define XFS_IOC_ATTR_CREATE 0x0010 /* fail if attr already exists */ #define XFS_IOC_ATTR_REPLACE 0x0020 /* fail if attr does not exist */ +#define XFS_IOC_ATTR_PARENT 0x0040 /* use attrs in parent namespace */ typedef struct xfs_attrlist_cursor { __u32 opaque[4]; @@ -752,6 +753,50 @@ 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) + +/* 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 */ + __u32 xpp_namelen; /* File name length */ + __u32 xpp_pad; + __u8 xpp_name[XFS_PPTR_MAXNAMELEN]; /* File name */ +}; + +/* Iterate through an inodes parent pointers */ +struct xfs_pptr_info { + struct xfs_handle pi_handle; + struct xfs_attrlist_cursor pi_cursor; + __u32 pi_flags; + __u32 pi_reserved; + __u32 pi_ptrs_size; + __u32 pi_ptrs_used; + __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. + */ +}; + +#define XFS_PPTR_INFO_SIZEOF(nr_ptrs) sizeof (struct xfs_pptr_info) + \ + nr_ptrs * sizeof(struct xfs_parent_ptr) + +#define XFS_PPINFO_TO_PP(info, idx) \ + (&(((struct xfs_parent_ptr *)((char *)(info) + sizeof(*(info))))[(idx)])) + /* * ioctl limits */ @@ -797,6 +842,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_GETPPOINTER _IOR ('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 cb546652bde9..a5b99f30bc63 100644 --- a/fs/xfs/libxfs/xfs_parent.c +++ b/fs/xfs/libxfs/xfs_parent.c @@ -33,6 +33,16 @@ #include "xfs_attr_sf.h" #include "xfs_bmap.h" +/* Initializes a xfs_parent_ptr from an xfs_parent_name_rec */ +void +xfs_init_parent_ptr(struct xfs_parent_ptr *xpp, + 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 10dc576ce693..fa50ada0d6a9 100644 --- a/fs/xfs/libxfs/xfs_parent.h +++ b/fs/xfs/libxfs/xfs_parent.h @@ -28,4 +28,6 @@ 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, + struct xfs_parent_name_rec *rec); #endif /* __XFS_PARENT_H__ */ diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c index e1612e99e0c5..4cd1de3e9d0b 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 @@ -355,6 +356,8 @@ xfs_attr_filter( return XFS_ATTR_ROOT; if (ioc_flags & XFS_IOC_ATTR_SECURE) return XFS_ATTR_SECURE; + if (ioc_flags & XFS_IOC_ATTR_PARENT) + return XFS_ATTR_PARENT; return 0; } @@ -422,7 +425,8 @@ xfs_ioc_attr_list( /* * Reject flags, only allow namespaces. */ - if (flags & ~(XFS_IOC_ATTR_ROOT | XFS_IOC_ATTR_SECURE)) + if (flags & ~(XFS_IOC_ATTR_ROOT | XFS_IOC_ATTR_SECURE | + XFS_IOC_ATTR_PARENT)) return -EINVAL; if (flags == (XFS_IOC_ATTR_ROOT | XFS_IOC_ATTR_SECURE)) return -EINVAL; @@ -1672,6 +1676,87 @@ 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 = kmem_alloc(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) + 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; + } + + /* + * 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), + GFP_NOFS | __GFP_NOFAIL); + if (!ppi) + return -ENOMEM; + + if (ppi->pi_flags != 0 && ppi->pi_flags != XFS_PPTR_IFLAG_HANDLE) { + error = -EINVAL; + goto out; + } + + 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 (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) + goto out; + +out: + kmem_free(ppi); + return error; +} + int xfs_ioc_swapext( xfs_swapext_t *sxp) @@ -1961,7 +2046,8 @@ xfs_file_ioctl( case XFS_IOC_FSGETXATTRA: return xfs_ioc_fsgetxattra(ip, arg); - + case XFS_IOC_GETPPOINTER: + 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 758702b9495f..765eb514a917 100644 --- a/fs/xfs/xfs_ondisk.h +++ b/fs/xfs/xfs_ondisk.h @@ -135,6 +135,10 @@ xfs_check_ondisk_structs(void) XFS_CHECK_STRUCT_SIZE(struct xfs_attri_log_format, 40); XFS_CHECK_STRUCT_SIZE(struct xfs_attrd_log_format, 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..9880718395c6 --- /dev/null +++ b/fs/xfs/xfs_parent_utils.c @@ -0,0 +1,133 @@ +/* + * Copyright (c) 2015 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it would be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write the Free Software Foundation + */ +#include "xfs.h" +#include "xfs_fs.h" +#include "xfs_format.h" +#include "xfs_log_format.h" +#include "xfs_shared.h" +#include "xfs_trans_resv.h" +#include "xfs_mount.h" +#include "xfs_bmap_btree.h" +#include "xfs_inode.h" +#include "xfs_error.h" +#include "xfs_trace.h" +#include "xfs_trans.h" +#include "xfs_da_format.h" +#include "xfs_da_btree.h" +#include "xfs_attr.h" +#include "xfs_ioctl.h" +#include "xfs_parent.h" +#include "xfs_da_btree.h" + +/* + * Get the parent pointers for a given inode + * + * Returns 0 on success and non zero on error + */ +int +xfs_attr_get_parent_pointer(struct xfs_inode *ip, + struct xfs_pptr_info *ppi) + +{ + + struct xfs_attrlist *alist; + struct xfs_attrlist_ent *aent; + struct xfs_parent_ptr *xpp; + struct xfs_parent_name_rec *xpnr; + char *namebuf; + unsigned int namebuf_size; + int name_len; + int error = 0; + unsigned int ioc_flags = XFS_IOC_ATTR_PARENT; + unsigned int flags = XFS_ATTR_PARENT; + int i; + struct xfs_attr_list_context context; + struct xfs_da_args args; + + /* 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, + ioc_flags, &context); + + /* Copy the cursor provided by caller */ + memcpy(&context.cursor, &ppi->pi_cursor, + sizeof(struct xfs_attrlist_cursor)); + + if (error) + goto out_kfree; + + xfs_ilock(ip, XFS_ILOCK_EXCL); + + error = xfs_attr_list_ilocked(&context); + if (error) + goto out_kfree; + + alist = (struct xfs_attrlist *)namebuf; + for (i = 0; i < alist->al_count; i++) { + 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 = -ERANGE; + goto out_kfree; + } + name_len = aent->a_valuelen; + + memset(&args, 0, sizeof(args)); + args.geo = ip->i_mount->m_attr_geo; + args.whichfork = XFS_ATTR_FORK; + args.dp = ip; + args.name = (char *)xpnr; + args.namelen = sizeof(struct xfs_parent_name_rec); + args.attr_filter = flags; + args.hashval = xfs_da_hashname(args.name, args.namelen); + args.value = (unsigned char *)(xpp->xpp_name); + args.valuelen = name_len; + args.op_flags = XFS_DA_OP_OKNOENT; + + error = xfs_attr_get_ilocked(&args); + error = (error == -EEXIST ? 0 : error); + if (error) + goto out_kfree; + + xpp->xpp_namelen = name_len; + xfs_init_parent_ptr(xpp, xpnr); + } + 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_kfree: + xfs_iunlock(ip, XFS_ILOCK_EXCL); + kmem_free(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..0e952b2ebd4a --- /dev/null +++ b/fs/xfs/xfs_parent_utils.h @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2017 Oracle, Inc. + * All Rights Reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it would be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write the Free Software Foundation Inc. + */ +#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__ */