diff mbox series

[14/64] libxfs: when creating a file in a directory, set the project id based on the parent

Message ID 172783101992.4036371.12940733887668033364.stgit@frogsfrogsfrogs (mailing list archive)
State Not Applicable, archived
Headers show
Series [01/64] xfs: avoid redundant AGFL buffer invalidation | expand

Commit Message

Darrick J. Wong Oct. 2, 2024, 1:11 a.m. UTC
From: Darrick J. Wong <djwong@kernel.org>

When we're creating a file as a child of an existing directory, use
xfs_get_initial_prid to have the child inherit the project id of the
directory if the directory has PROJINHERIT set, just like the kernel
does.  This fixes mkfs project id propagation with -d projinherit=X when
protofiles are in use.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
---
 libxfs/inode.c           |    3 +++
 libxfs/libxfs_api_defs.h |    1 +
 2 files changed, 4 insertions(+)

Comments

Christoph Hellwig Oct. 2, 2024, 5:49 a.m. UTC | #1
Looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>
diff mbox series

Patch

diff --git a/libxfs/inode.c b/libxfs/inode.c
index 132cf990d..d022b41b6 100644
--- a/libxfs/inode.c
+++ b/libxfs/inode.c
@@ -121,6 +121,9 @@  libxfs_icreate(
 			inode->i_mode |= S_ISGID;
 	}
 
+	if (pip)
+		ip->i_projid = libxfs_get_initial_prid(pip);
+
 	ip->i_disk_size = 0;
 	ip->i_df.if_nextents = 0;
 	ASSERT(ip->i_nblocks == 0);
diff --git a/libxfs/libxfs_api_defs.h b/libxfs/libxfs_api_defs.h
index df316727b..a507904f2 100644
--- a/libxfs/libxfs_api_defs.h
+++ b/libxfs/libxfs_api_defs.h
@@ -166,6 +166,7 @@ 
 #define xfs_free_extent_later		libxfs_free_extent_later
 #define xfs_free_perag			libxfs_free_perag
 #define xfs_fs_geometry			libxfs_fs_geometry
+#define xfs_get_initial_prid		libxfs_get_initial_prid
 #define xfs_highbit32			libxfs_highbit32
 #define xfs_highbit64			libxfs_highbit64
 #define xfs_ialloc_calc_rootino		libxfs_ialloc_calc_rootino