]> www.infradead.org Git - users/hch/xfsprogs.git/commitdiff
libxfs: rearrange libxfs_trans_ichgtime call when creating inodes
authorDarrick J. Wong <djwong@kernel.org>
Tue, 9 Jan 2024 17:39:35 +0000 (09:39 -0800)
committerDarrick J. Wong <djwong@kernel.org>
Wed, 10 Apr 2024 00:21:33 +0000 (17:21 -0700)
Rearrange the libxfs_trans_ichgtime call in libxfs_ialloc so that we
call it once with the flags we want.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
libxfs/inode.c

index 38531609cc58edd3ab25fdc1dc53bce81ce39a22..326c88a42aa0236d18e81feaab4579684cc4fb88 100644 (file)
@@ -91,6 +91,7 @@ libxfs_icreate(
        struct xfs_inode        *pip = args->pip;
        struct xfs_inode        *ip;
        unsigned int            flags;
+       int                     times = XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG;
        int                     error;
 
        error = libxfs_iget(tp->t_mountp, tp, ino, XFS_IGET_CREATE, &ip);
@@ -102,7 +103,6 @@ libxfs_icreate(
        set_nlink(VFS_I(ip), args->nlink);
        VFS_I(ip)->i_uid = args->uid;
        ip->i_projid = args->prid;
-       xfs_trans_ichgtime(tp, ip, XFS_ICHGTIME_CHG | XFS_ICHGTIME_MOD);
 
        if (pip && (VFS_I(pip)->i_mode & S_ISGID)) {
                if (!(args->flags & XFS_ICREATE_ARGS_FORCE_GID))
@@ -120,10 +120,12 @@ libxfs_icreate(
        if (xfs_has_v3inodes(ip->i_mount)) {
                VFS_I(ip)->i_version = 1;
                ip->i_diflags2 = ip->i_mount->m_ino_geo.new_diflags2;
-               ip->i_crtime = inode_get_mtime(VFS_I(ip)); /* struct copy */
                ip->i_cowextsize = 0;
+               times |= XFS_ICHGTIME_CREATE;
        }
 
+       xfs_trans_ichgtime(tp, ip, times);
+
        flags = XFS_ILOG_CORE;
        switch (args->mode & S_IFMT) {
        case S_IFIFO: