]> www.infradead.org Git - users/hch/xfsprogs.git/commitdiff
libxfs: pass flags2 from parent to child when creating files
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)
When mkfs creates a new file as a child of an existing directory, we
should propagate the flags2 field from parent to child like the kernel
does.  This ensures that mkfs propagates cowextsize hints properly when
protofiles are in use.

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

index 148c232fb6e47362f3d8495ee14674a4aa550aba..1f240de48deb9aa43b723580c7f6711d1465145c 100644 (file)
@@ -59,6 +59,20 @@ xfs_inode_propagate_flags(
        ip->i_diflags |= di_flags;
 }
 
+/* Propagate di_flags2 from a parent inode to a child inode. */
+static void
+xfs_inode_inherit_flags2(
+       struct xfs_inode        *ip,
+       const struct xfs_inode  *pip)
+{
+       if (pip->i_diflags2 & XFS_DIFLAG2_COWEXTSIZE) {
+               ip->i_diflags2 |= XFS_DIFLAG2_COWEXTSIZE;
+               ip->i_cowextsize = pip->i_cowextsize;
+       }
+       if (pip->i_diflags2 & XFS_DIFLAG2_DAX)
+               ip->i_diflags2 |= XFS_DIFLAG2_DAX;
+}
+
 /*
  * Increment the link count on an inode & log the change.
  */
@@ -141,6 +155,8 @@ libxfs_icreate(
        case S_IFDIR:
                if (pip && (pip->i_diflags & XFS_DIFLAG_ANY))
                        xfs_inode_propagate_flags(ip, pip);
+               if (pip && (pip->i_diflags2 & XFS_DIFLAG2_ANY))
+                       xfs_inode_inherit_flags2(ip, pip);
                /* FALLTHROUGH */
        case S_IFLNK:
                ip->i_df.if_format = XFS_DINODE_FMT_EXTENTS;