]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs_db/mkfs/xfs_repair: port to use XFS_ICREATE_UNLINKABLE
authorDarrick J. Wong <djwong@kernel.org>
Wed, 2 Oct 2024 01:25:00 +0000 (18:25 -0700)
committerAndrey Albershteyn <aalbersh@redhat.com>
Fri, 4 Oct 2024 11:13:51 +0000 (13:13 +0200)
INIT_XATTRS is overloaded here -- it's set during the creat process when
we think that we're immediately going to set some ACL xattrs to save
time.  However, it's also used by the parent pointers code to enable the
attr fork in preparation to receive ppptr xattrs.  This results in
xfs_has_parent() branches scattered around the codebase to turn on
INIT_XATTRS.

Linkable files are created far more commonly than unlinkable temporary
files or directory tree roots, so we should centralize this logic in
xfs_inode_init.  For the three callers that don't want parent pointers
(online repiar tempfiles, unlinkable tempfiles, rootdir creation) we
provide an UNLINKABLE flag to skip attr fork initialization.

Port these three utilities to use XFS_ICREATE_UNLINKABLE the same as we
did for the kernel.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
[aalbersh: drop reference to kernel commit]

db/iunlink.c
mkfs/proto.c
repair/phase6.c

index fcc824d9a0e56084908559485c6429cb9dda6854..2ca9096f159b3432c3e24458bd724ebba4fe3d05 100644 (file)
@@ -315,7 +315,7 @@ create_unlinked(
        struct xfs_icreate_args args = {
                .idmap          = libxfs_nop_idmap,
                .mode           = S_IFREG | 0600,
-               .flags          = XFS_ICREATE_TMPFILE,
+               .flags          = XFS_ICREATE_TMPFILE | XFS_ICREATE_UNLINKABLE,
        };
        struct xfs_inode        *ip;
        struct xfs_trans        *tp;
index 96cb9f8544bf853adf5228cc736992750fcf1c34..251e3a9ee019e98d00505500f9b827f0875bd45d 100644 (file)
@@ -432,8 +432,9 @@ creatproto(
        xfs_ino_t               ino;
        int                     error;
 
-       if (dp && xfs_has_parent(dp->i_mount))
-               args.flags |= XFS_ICREATE_INIT_XATTRS;
+       /* Root directories cannot be linked to a parent. */
+       if (!dp)
+               args.flags |= XFS_ICREATE_UNLINKABLE;
 
        /*
         * Call the space management code to pick the on-disk inode to be
index 52e42d4c0bc8893619f70fa92540cf704c33eedd..85f122ec79ae5f9e74a1a9ae919c44cb545f8787 100644 (file)
@@ -909,9 +909,6 @@ mk_orphanage(
        struct xfs_name         xname;
        struct xfs_parent_args  *ppargs = NULL;
 
-       if (xfs_has_parent(mp))
-               args.flags |= XFS_ICREATE_INIT_XATTRS;
-
        i = -libxfs_parent_start(mp, &ppargs);
        if (i)
                do_error(_("%d - couldn't allocate parent pointer for %s\n"),