diff mbox series

[18/26] libxfs: propagate bigtime inode flag when allocating

Message ID 160375536384.881414.3371469706002982157.stgit@magnolia
State Superseded
Headers show
Series xfsprogs: widen timestamps to deal with y2038 | expand

Commit Message

Darrick J. Wong Oct. 26, 2020, 11:36 p.m. UTC
From: Darrick J. Wong <darrick.wong@oracle.com>

Ensure that we propagate the bigtime inode flag correctly when creating
new inodes.  There critical part here is to use the new_diflags2 field
in the incore geometry just like we do in the kernel.

We also modify xfs_flags2diflags2 to have the same behavior as the
kernel.  This isn't strictly needed here, but we aim to avoid letting
userspace diverge from the kernel function when we can.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 libxfs/util.c |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

Comments

Christoph Hellwig Oct. 29, 2020, 9:48 a.m. UTC | #1
On Mon, Oct 26, 2020 at 04:36:03PM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
> 
> Ensure that we propagate the bigtime inode flag correctly when creating
> new inodes.  There critical part here is to use the new_diflags2 field
> in the incore geometry just like we do in the kernel.
> 
> We also modify xfs_flags2diflags2 to have the same behavior as the
> kernel.  This isn't strictly needed here, but we aim to avoid letting
> userspace diverge from the kernel function when we can.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>

Looks good,

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

Patch

diff --git a/libxfs/util.c b/libxfs/util.c
index c78074a01dab..252cf91e851b 100644
--- a/libxfs/util.c
+++ b/libxfs/util.c
@@ -197,7 +197,8 @@  xfs_flags2diflags2(
 	unsigned int		xflags)
 {
 	uint64_t		di_flags2 =
-		(ip->i_d.di_flags2 & XFS_DIFLAG2_REFLINK);
+		(ip->i_d.di_flags2 & (XFS_DIFLAG2_REFLINK |
+				      XFS_DIFLAG2_BIGTIME));
 
 	if (xflags & FS_XFLAG_DAX)
 		di_flags2 |= XFS_DIFLAG2_DAX;
@@ -307,8 +308,8 @@  libxfs_ialloc(
 		ASSERT(ip->i_d.di_ino == ino);
 		ASSERT(uuid_equal(&ip->i_d.di_uuid, &mp->m_sb.sb_meta_uuid));
 		VFS_I(ip)->i_version = 1;
-		ip->i_d.di_flags2 = pip ? 0 : xfs_flags2diflags2(ip,
-				fsx->fsx_xflags);
+		ip->i_d.di_flags2 = pip ? ip->i_mount->m_ino_geo.new_diflags2 :
+				xfs_flags2diflags2(ip, fsx->fsx_xflags);
 		ip->i_d.di_crtime.tv_sec = (int32_t)VFS_I(ip)->i_mtime.tv_sec;
 		ip->i_d.di_crtime.tv_nsec = (int32_t)VFS_I(ip)->i_mtime.tv_nsec;
 		ip->i_d.di_cowextsize = pip ? 0 : fsx->fsx_cowextsize;