From mboxrd@z Thu Jan 1 00:00:00 1970 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 AD19EC6FD19 for ; Thu, 16 Mar 2023 19:26:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229555AbjCPT0o (ORCPT ); Thu, 16 Mar 2023 15:26:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53668 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229516AbjCPT0n (ORCPT ); Thu, 16 Mar 2023 15:26:43 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CC703C8888 for ; Thu, 16 Mar 2023 12:26:42 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 65EDA620DC for ; Thu, 16 Mar 2023 19:26:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C614CC433D2; Thu, 16 Mar 2023 19:26:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1678994801; bh=1KEN42LiXPBKOY3IuYH/aqO+L+wW1zQtez9mGWda0vw=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=dJmPw1IpwMYWvpb8QKLdkXwB3FH4O3k8Q6aoKqGLvq1p2kCOPdtNy8XDgA0VWviMP Rl4ZUFtthak1dYvUHWjWMsuKtZrTZ6aOmfi/Rkmva1rPiX4GtuShiGegTzaG+2JpiT sNr7NfsobP9C1qOJamN5JDL/gGwUipXqrhEs5VdPQ3apB1IZwStHIieLgq4L8Ayai1 oC+1G8vLBvI5YFrvYX3K86jwpoqUzvLPtW/DRY9ICFlVZBS83IvmCF3B4MNNNNUmgw QdTuuz651cLBTWQB4CIjZGbo86xNlwWXggPnK/J8VQgvH0y/nixIEBNV6aJyQ0pAxz CBmI8T2NysN6A== Date: Thu, 16 Mar 2023 12:26:41 -0700 Subject: [PATCH 3/9] libxfs: create new files with attr forks if necessary From: "Darrick J. Wong" To: djwong@kernel.org Cc: allison.henderson@oracle.com, linux-xfs@vger.kernel.org Message-ID: <167899415416.16278.13396714496427226116.stgit@frogsfrogsfrogs> In-Reply-To: <167899415375.16278.9528475200288521209.stgit@frogsfrogsfrogs> References: <167899415375.16278.9528475200288521209.stgit@frogsfrogsfrogs> User-Agent: StGit/0.19 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong Create new files with attr forks if they're going to have parent pointers. In the next patch we'll fix mkfs to use the same parent creation functions as the kernel, so we're going to need this. Signed-off-by: Darrick J. Wong --- libxfs/init.c | 4 ++++ libxfs/util.c | 14 ++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/libxfs/init.c b/libxfs/init.c index 59cd547d6..101b77602 100644 --- a/libxfs/init.c +++ b/libxfs/init.c @@ -746,14 +746,18 @@ void libxfs_compute_all_maxlevels( struct xfs_mount *mp) { + struct xfs_ino_geometry *igeo = M_IGEO(mp); + xfs_alloc_compute_maxlevels(mp); xfs_bmap_compute_maxlevels(mp, XFS_DATA_FORK); xfs_bmap_compute_maxlevels(mp, XFS_ATTR_FORK); + igeo->attr_fork_offset = xfs_bmap_compute_attr_offset(mp); xfs_ialloc_setup_geometry(mp); xfs_rmapbt_compute_maxlevels(mp); xfs_refcountbt_compute_maxlevels(mp); xfs_agbtree_compute_maxlevels(mp); + } /* diff --git a/libxfs/util.c b/libxfs/util.c index 6525f63de..bea5f1c71 100644 --- a/libxfs/util.c +++ b/libxfs/util.c @@ -322,6 +322,20 @@ libxfs_init_new_inode( ASSERT(0); } + /* + * If we need to create attributes immediately after allocating the + * inode, initialise an empty attribute fork right now. We use the + * default fork offset for attributes here as we don't know exactly what + * size or how many attributes we might be adding. We can do this + * safely here because we know the data fork is completely empty and + * this saves us from needing to run a separate transaction to set the + * fork offset in the immediate future. + */ + if (xfs_has_parent(tp->t_mountp) && xfs_has_attr(tp->t_mountp)) { + ip->i_forkoff = xfs_default_attroffset(ip) >> 3; + xfs_ifork_init_attr(ip, XFS_DINODE_FMT_EXTENTS, 0); + } + /* * Log the new values stuffed into the inode. */