linux-xfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* xfs inode structure cleanups v2
@ 2020-06-20  7:10 Christoph Hellwig
  2020-06-20  7:10 ` [PATCH 01/15] xfs: don't clear the "dinode core" in xfs_inode_alloc Christoph Hellwig
                   ` (15 more replies)
  0 siblings, 16 replies; 52+ messages in thread
From: Christoph Hellwig @ 2020-06-20  7:10 UTC (permalink / raw)
  To: linux-xfs

Hi all,

This series cleans up how we define struct xfs_inode.  Most importantly
it removes the pointles xfs_icdinode sub-structure.

Changes since v1:
 - rebased to 5.8-rc
 - use xfs_extlen_t fo i_cowextsize
 - cleanup xfs_fill_fsxattr

^ permalink raw reply	[flat|nested] 52+ messages in thread

* [PATCH 01/15] xfs: don't clear the "dinode core" in xfs_inode_alloc
  2020-06-20  7:10 xfs inode structure cleanups v2 Christoph Hellwig
@ 2020-06-20  7:10 ` Christoph Hellwig
  2020-06-22  7:11   ` Chandan Babu R
  2020-06-30 17:58   ` Darrick J. Wong
  2020-06-20  7:10 ` [PATCH 02/15] xfs: move the di_projid field to struct xfs_inode Christoph Hellwig
                   ` (14 subsequent siblings)
  15 siblings, 2 replies; 52+ messages in thread
From: Christoph Hellwig @ 2020-06-20  7:10 UTC (permalink / raw)
  To: linux-xfs

The xfs_icdinode structure just contains a random mix of inode field,
which are all read from the on-disk inode and mostly not looked at
before reading the inode or initializing a new inode cluster.  The
only exceptions are the forkoff and blocks field, which are used
in sanity checks for freshly allocated inodes.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/xfs/xfs_icache.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/xfs/xfs_icache.c b/fs/xfs/xfs_icache.c
index 0a5ac6f9a58349..660e7abd4e8b76 100644
--- a/fs/xfs/xfs_icache.c
+++ b/fs/xfs/xfs_icache.c
@@ -66,7 +66,8 @@ xfs_inode_alloc(
 	memset(&ip->i_df, 0, sizeof(ip->i_df));
 	ip->i_flags = 0;
 	ip->i_delayed_blks = 0;
-	memset(&ip->i_d, 0, sizeof(ip->i_d));
+	ip->i_d.di_nblocks = 0;
+	ip->i_d.di_forkoff = 0;
 	ip->i_sick = 0;
 	ip->i_checked = 0;
 	INIT_WORK(&ip->i_ioend_work, xfs_end_io);
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH 02/15] xfs: move the di_projid field to struct xfs_inode
  2020-06-20  7:10 xfs inode structure cleanups v2 Christoph Hellwig
  2020-06-20  7:10 ` [PATCH 01/15] xfs: don't clear the "dinode core" in xfs_inode_alloc Christoph Hellwig
@ 2020-06-20  7:10 ` Christoph Hellwig
  2020-06-22  7:55   ` Chandan Babu R
  2020-06-30 17:44   ` Darrick J. Wong
  2020-06-20  7:10 ` [PATCH 03/15] xfs: move the di_size " Christoph Hellwig
                   ` (13 subsequent siblings)
  15 siblings, 2 replies; 52+ messages in thread
From: Christoph Hellwig @ 2020-06-20  7:10 UTC (permalink / raw)
  To: linux-xfs

In preparation of removing the historic icinode struct, move the projid
field into the containing xfs_inode structure.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/xfs/libxfs/xfs_inode_buf.c | 8 ++++----
 fs/xfs/libxfs/xfs_inode_buf.h | 1 -
 fs/xfs/xfs_bmap_util.c        | 2 +-
 fs/xfs/xfs_dquot.c            | 2 +-
 fs/xfs/xfs_icache.c           | 4 ++--
 fs/xfs/xfs_inode.c            | 6 +++---
 fs/xfs/xfs_inode.h            | 3 ++-
 fs/xfs/xfs_inode_item.c       | 4 ++--
 fs/xfs/xfs_ioctl.c            | 8 ++++----
 fs/xfs/xfs_iops.c             | 2 +-
 fs/xfs/xfs_itable.c           | 2 +-
 fs/xfs/xfs_qm.c               | 8 ++++----
 fs/xfs/xfs_qm_bhv.c           | 2 +-
 13 files changed, 26 insertions(+), 26 deletions(-)

diff --git a/fs/xfs/libxfs/xfs_inode_buf.c b/fs/xfs/libxfs/xfs_inode_buf.c
index 6f84ea85fdd837..b064cb8072c84a 100644
--- a/fs/xfs/libxfs/xfs_inode_buf.c
+++ b/fs/xfs/libxfs/xfs_inode_buf.c
@@ -218,10 +218,10 @@ xfs_inode_from_disk(
 	 */
 	if (unlikely(from->di_version == 1)) {
 		set_nlink(inode, be16_to_cpu(from->di_onlink));
-		to->di_projid = 0;
+		ip->i_projid = 0;
 	} else {
 		set_nlink(inode, be32_to_cpu(from->di_nlink));
-		to->di_projid = (prid_t)be16_to_cpu(from->di_projid_hi) << 16 |
+		ip->i_projid = (prid_t)be16_to_cpu(from->di_projid_hi) << 16 |
 					be16_to_cpu(from->di_projid_lo);
 	}
 
@@ -290,8 +290,8 @@ xfs_inode_to_disk(
 	to->di_format = xfs_ifork_format(&ip->i_df);
 	to->di_uid = cpu_to_be32(i_uid_read(inode));
 	to->di_gid = cpu_to_be32(i_gid_read(inode));
-	to->di_projid_lo = cpu_to_be16(from->di_projid & 0xffff);
-	to->di_projid_hi = cpu_to_be16(from->di_projid >> 16);
+	to->di_projid_lo = cpu_to_be16(ip->i_projid & 0xffff);
+	to->di_projid_hi = cpu_to_be16(ip->i_projid >> 16);
 
 	memset(to->di_pad, 0, sizeof(to->di_pad));
 	to->di_atime.t_sec = cpu_to_be32(inode->i_atime.tv_sec);
diff --git a/fs/xfs/libxfs/xfs_inode_buf.h b/fs/xfs/libxfs/xfs_inode_buf.h
index 865ac493c72a24..b826d81b356956 100644
--- a/fs/xfs/libxfs/xfs_inode_buf.h
+++ b/fs/xfs/libxfs/xfs_inode_buf.h
@@ -17,7 +17,6 @@ struct xfs_dinode;
  */
 struct xfs_icdinode {
 	uint16_t	di_flushiter;	/* incremented on flush */
-	uint32_t	di_projid;	/* owner's project id */
 	xfs_fsize_t	di_size;	/* number of bytes in file */
 	xfs_rfsblock_t	di_nblocks;	/* # of direct & btree blocks used */
 	xfs_extlen_t	di_extsize;	/* basic/minimum extent size for file */
diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c
index f37f5cc4b19ffe..e42553884c23cf 100644
--- a/fs/xfs/xfs_bmap_util.c
+++ b/fs/xfs/xfs_bmap_util.c
@@ -1217,7 +1217,7 @@ xfs_swap_extents_check_format(
 	if (XFS_IS_QUOTA_ON(ip->i_mount) &&
 	    (!uid_eq(VFS_I(ip)->i_uid, VFS_I(tip)->i_uid) ||
 	     !gid_eq(VFS_I(ip)->i_gid, VFS_I(tip)->i_gid) ||
-	     ip->i_d.di_projid != tip->i_d.di_projid))
+	     ip->i_projid != tip->i_projid))
 		return -EINVAL;
 
 	/* Should never get a local format */
diff --git a/fs/xfs/xfs_dquot.c b/fs/xfs/xfs_dquot.c
index d5b7f03e93c8db..912b978a6a72d5 100644
--- a/fs/xfs/xfs_dquot.c
+++ b/fs/xfs/xfs_dquot.c
@@ -868,7 +868,7 @@ xfs_qm_id_for_quotatype(
 	case XFS_DQ_GROUP:
 		return i_gid_read(VFS_I(ip));
 	case XFS_DQ_PROJ:
-		return ip->i_d.di_projid;
+		return ip->i_projid;
 	}
 	ASSERT(0);
 	return 0;
diff --git a/fs/xfs/xfs_icache.c b/fs/xfs/xfs_icache.c
index 660e7abd4e8b76..a3bbd6e4bb6fc8 100644
--- a/fs/xfs/xfs_icache.c
+++ b/fs/xfs/xfs_icache.c
@@ -1439,7 +1439,7 @@ xfs_inode_match_id(
 		return false;
 
 	if ((eofb->eof_flags & XFS_EOF_FLAGS_PRID) &&
-	    ip->i_d.di_projid != eofb->eof_prid)
+	    ip->i_projid != eofb->eof_prid)
 		return false;
 
 	return true;
@@ -1463,7 +1463,7 @@ xfs_inode_match_id_union(
 		return true;
 
 	if ((eofb->eof_flags & XFS_EOF_FLAGS_PRID) &&
-	    ip->i_d.di_projid == eofb->eof_prid)
+	    ip->i_projid == eofb->eof_prid)
 		return true;
 
 	return false;
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index 88a9e496480216..40e4d3ed29a798 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -806,7 +806,7 @@ xfs_ialloc(
 	set_nlink(inode, nlink);
 	inode->i_uid = current_fsuid();
 	inode->i_rdev = rdev;
-	ip->i_d.di_projid = prid;
+	ip->i_projid = prid;
 
 	if (pip && XFS_INHERIT_GID(pip)) {
 		inode->i_gid = VFS_I(pip)->i_gid;
@@ -1398,7 +1398,7 @@ xfs_link(
 	 * the tree quota mechanism could be circumvented.
 	 */
 	if (unlikely((tdp->i_d.di_flags & XFS_DIFLAG_PROJINHERIT) &&
-		     tdp->i_d.di_projid != sip->i_d.di_projid)) {
+		     tdp->i_projid != sip->i_projid)) {
 		error = -EXDEV;
 		goto error_return;
 	}
@@ -3264,7 +3264,7 @@ xfs_rename(
 	 * tree quota mechanism would be circumvented.
 	 */
 	if (unlikely((target_dp->i_d.di_flags & XFS_DIFLAG_PROJINHERIT) &&
-		     target_dp->i_d.di_projid != src_ip->i_d.di_projid)) {
+		     target_dp->i_projid != src_ip->i_projid)) {
 		error = -EXDEV;
 		goto out_trans_cancel;
 	}
diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h
index dadcf19458960d..51ea9d53407863 100644
--- a/fs/xfs/xfs_inode.h
+++ b/fs/xfs/xfs_inode.h
@@ -54,6 +54,7 @@ typedef struct xfs_inode {
 	/* Miscellaneous state. */
 	unsigned long		i_flags;	/* see defined flags below */
 	uint64_t		i_delayed_blks;	/* count of delay alloc blks */
+	uint32_t		i_projid;	/* owner's project id */
 
 	struct xfs_icdinode	i_d;		/* most of ondisk inode */
 
@@ -175,7 +176,7 @@ static inline prid_t
 xfs_get_initial_prid(struct xfs_inode *dp)
 {
 	if (dp->i_d.di_flags & XFS_DIFLAG_PROJINHERIT)
-		return dp->i_d.di_projid;
+		return dp->i_projid;
 
 	return XFS_PROJID_DEFAULT;
 }
diff --git a/fs/xfs/xfs_inode_item.c b/fs/xfs/xfs_inode_item.c
index ba47bf65b772be..e546b4b58ce2e0 100644
--- a/fs/xfs/xfs_inode_item.c
+++ b/fs/xfs/xfs_inode_item.c
@@ -308,8 +308,8 @@ xfs_inode_to_log_dinode(
 	to->di_format = xfs_ifork_format(&ip->i_df);
 	to->di_uid = i_uid_read(inode);
 	to->di_gid = i_gid_read(inode);
-	to->di_projid_lo = from->di_projid & 0xffff;
-	to->di_projid_hi = from->di_projid >> 16;
+	to->di_projid_lo = ip->i_projid & 0xffff;
+	to->di_projid_hi = ip->i_projid >> 16;
 
 	memset(to->di_pad, 0, sizeof(to->di_pad));
 	memset(to->di_pad3, 0, sizeof(to->di_pad3));
diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
index a40f88cf3ab786..d93f4fc40fd99e 100644
--- a/fs/xfs/xfs_ioctl.c
+++ b/fs/xfs/xfs_ioctl.c
@@ -1110,7 +1110,7 @@ xfs_fill_fsxattr(
 	fa->fsx_extsize = ip->i_d.di_extsize << ip->i_mount->m_sb.sb_blocklog;
 	fa->fsx_cowextsize = ip->i_d.di_cowextsize <<
 			ip->i_mount->m_sb.sb_blocklog;
-	fa->fsx_projid = ip->i_d.di_projid;
+	fa->fsx_projid = ip->i_projid;
 	if (ifp && (ifp->if_flags & XFS_IFEXTENTS))
 		fa->fsx_nextents = xfs_iext_count(ifp);
 	else
@@ -1518,7 +1518,7 @@ xfs_ioctl_setattr(
 	}
 
 	if (XFS_IS_QUOTA_RUNNING(mp) && XFS_IS_PQUOTA_ON(mp) &&
-	    ip->i_d.di_projid != fa->fsx_projid) {
+	    ip->i_projid != fa->fsx_projid) {
 		code = xfs_qm_vop_chown_reserve(tp, ip, NULL, NULL, pdqp,
 				capable(CAP_FOWNER) ?  XFS_QMOPT_FORCE_RES : 0);
 		if (code)	/* out of quota */
@@ -1555,12 +1555,12 @@ xfs_ioctl_setattr(
 		VFS_I(ip)->i_mode &= ~(S_ISUID|S_ISGID);
 
 	/* Change the ownerships and register project quota modifications */
-	if (ip->i_d.di_projid != fa->fsx_projid) {
+	if (ip->i_projid != fa->fsx_projid) {
 		if (XFS_IS_QUOTA_RUNNING(mp) && XFS_IS_PQUOTA_ON(mp)) {
 			olddquot = xfs_qm_vop_chown(tp, ip,
 						&ip->i_pdquot, pdqp);
 		}
-		ip->i_d.di_projid = fa->fsx_projid;
+		ip->i_projid = fa->fsx_projid;
 	}
 
 	/*
diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
index d66528fa365707..5440f555c9cc2c 100644
--- a/fs/xfs/xfs_iops.c
+++ b/fs/xfs/xfs_iops.c
@@ -696,7 +696,7 @@ xfs_setattr_nonsize(
 		 */
 		ASSERT(udqp == NULL);
 		ASSERT(gdqp == NULL);
-		error = xfs_qm_vop_dqalloc(ip, uid, gid, ip->i_d.di_projid,
+		error = xfs_qm_vop_dqalloc(ip, uid, gid, ip->i_projid,
 					   qflags, &udqp, &gdqp, NULL);
 		if (error)
 			return error;
diff --git a/fs/xfs/xfs_itable.c b/fs/xfs/xfs_itable.c
index 16ca97a7ff00fb..97b3b794dd4ada 100644
--- a/fs/xfs/xfs_itable.c
+++ b/fs/xfs/xfs_itable.c
@@ -84,7 +84,7 @@ xfs_bulkstat_one_int(
 	/* xfs_iget returns the following without needing
 	 * further change.
 	 */
-	buf->bs_projectid = ip->i_d.di_projid;
+	buf->bs_projectid = ip->i_projid;
 	buf->bs_ino = ino;
 	buf->bs_uid = i_uid_read(inode);
 	buf->bs_gid = i_gid_read(inode);
diff --git a/fs/xfs/xfs_qm.c b/fs/xfs/xfs_qm.c
index d6cd833173447a..ea22dcf868b474 100644
--- a/fs/xfs/xfs_qm.c
+++ b/fs/xfs/xfs_qm.c
@@ -346,7 +346,7 @@ xfs_qm_dqattach_locked(
 	}
 
 	if (XFS_IS_PQUOTA_ON(mp) && !ip->i_pdquot) {
-		error = xfs_qm_dqattach_one(ip, ip->i_d.di_projid, XFS_DQ_PROJ,
+		error = xfs_qm_dqattach_one(ip, ip->i_projid, XFS_DQ_PROJ,
 				doalloc, &ip->i_pdquot);
 		if (error)
 			goto done;
@@ -1711,7 +1711,7 @@ xfs_qm_vop_dqalloc(
 		}
 	}
 	if ((flags & XFS_QMOPT_PQUOTA) && XFS_IS_PQUOTA_ON(mp)) {
-		if (ip->i_d.di_projid != prid) {
+		if (ip->i_projid != prid) {
 			xfs_iunlock(ip, lockflags);
 			error = xfs_qm_dqget(mp, (xfs_dqid_t)prid, XFS_DQ_PROJ,
 					true, &pq);
@@ -1844,7 +1844,7 @@ xfs_qm_vop_chown_reserve(
 	}
 
 	if (XFS_IS_PQUOTA_ON(ip->i_mount) && pdqp &&
-	    ip->i_d.di_projid != be32_to_cpu(pdqp->q_core.d_id)) {
+	    ip->i_projid != be32_to_cpu(pdqp->q_core.d_id)) {
 		pdq_delblks = pdqp;
 		if (delblks) {
 			ASSERT(ip->i_pdquot);
@@ -1942,7 +1942,7 @@ xfs_qm_vop_create_dqattach(
 	}
 	if (pdqp && XFS_IS_PQUOTA_ON(mp)) {
 		ASSERT(ip->i_pdquot == NULL);
-		ASSERT(ip->i_d.di_projid == be32_to_cpu(pdqp->q_core.d_id));
+		ASSERT(ip->i_projid == be32_to_cpu(pdqp->q_core.d_id));
 
 		ip->i_pdquot = xfs_qm_dqhold(pdqp);
 		xfs_trans_mod_dquot(tp, pdqp, XFS_TRANS_DQ_ICOUNT, 1);
diff --git a/fs/xfs/xfs_qm_bhv.c b/fs/xfs/xfs_qm_bhv.c
index fc2fa418919f7f..b616ad772a6df8 100644
--- a/fs/xfs/xfs_qm_bhv.c
+++ b/fs/xfs/xfs_qm_bhv.c
@@ -60,7 +60,7 @@ xfs_qm_statvfs(
 	struct xfs_mount	*mp = ip->i_mount;
 	struct xfs_dquot	*dqp;
 
-	if (!xfs_qm_dqget(mp, ip->i_d.di_projid, XFS_DQ_PROJ, false, &dqp)) {
+	if (!xfs_qm_dqget(mp, ip->i_projid, XFS_DQ_PROJ, false, &dqp)) {
 		xfs_fill_statvfs_from_dquot(statp, dqp);
 		xfs_qm_dqput(dqp);
 	}
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH 03/15] xfs: move the di_size field to struct xfs_inode
  2020-06-20  7:10 xfs inode structure cleanups v2 Christoph Hellwig
  2020-06-20  7:10 ` [PATCH 01/15] xfs: don't clear the "dinode core" in xfs_inode_alloc Christoph Hellwig
  2020-06-20  7:10 ` [PATCH 02/15] xfs: move the di_projid field to struct xfs_inode Christoph Hellwig
@ 2020-06-20  7:10 ` Christoph Hellwig
  2020-06-22  9:24   ` Chandan Babu R
  2020-06-30 17:45   ` Darrick J. Wong
  2020-06-20  7:10 ` [PATCH 04/15] xfs: move the di_nblocks " Christoph Hellwig
                   ` (12 subsequent siblings)
  15 siblings, 2 replies; 52+ messages in thread
From: Christoph Hellwig @ 2020-06-20  7:10 UTC (permalink / raw)
  To: linux-xfs

In preparation of removing the historic icinode struct, move the on-disk
size field into the containing xfs_inode structure.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/xfs/libxfs/xfs_bmap.c       |  2 +-
 fs/xfs/libxfs/xfs_dir2.c       | 14 +++++------
 fs/xfs/libxfs/xfs_dir2_block.c | 10 ++++----
 fs/xfs/libxfs/xfs_dir2_leaf.c  |  2 +-
 fs/xfs/libxfs/xfs_dir2_node.c  |  2 +-
 fs/xfs/libxfs/xfs_dir2_sf.c    | 46 +++++++++++++++++-----------------
 fs/xfs/libxfs/xfs_inode_buf.c  |  4 +--
 fs/xfs/libxfs/xfs_inode_buf.h  |  1 -
 fs/xfs/libxfs/xfs_inode_fork.c |  2 +-
 fs/xfs/scrub/dir.c             |  6 ++---
 fs/xfs/scrub/parent.c          |  2 +-
 fs/xfs/scrub/symlink.c         |  2 +-
 fs/xfs/xfs_aops.c              |  4 +--
 fs/xfs/xfs_bmap_util.c         |  6 ++---
 fs/xfs/xfs_dir2_readdir.c      |  2 +-
 fs/xfs/xfs_file.c              |  2 +-
 fs/xfs/xfs_inode.c             |  8 +++---
 fs/xfs/xfs_inode.h             |  5 ++--
 fs/xfs/xfs_inode_item.c        |  4 +--
 fs/xfs/xfs_iomap.c             |  2 +-
 fs/xfs/xfs_iops.c              | 12 ++++-----
 fs/xfs/xfs_itable.c            |  2 +-
 fs/xfs/xfs_pnfs.c              |  2 +-
 fs/xfs/xfs_qm_syscalls.c       |  2 +-
 fs/xfs/xfs_reflink.c           |  4 +--
 fs/xfs/xfs_rtalloc.c           |  8 +++---
 fs/xfs/xfs_symlink.c           | 16 ++++++------
 fs/xfs/xfs_trace.h             | 16 ++++++------
 28 files changed, 94 insertions(+), 94 deletions(-)

diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
index 667cdd0dfdf4a3..56d78f8ba55eb6 100644
--- a/fs/xfs/libxfs/xfs_bmap.c
+++ b/fs/xfs/libxfs/xfs_bmap.c
@@ -1445,7 +1445,7 @@ xfs_bmap_last_offset(
 
 /*
  * Returns whether the selected fork of the inode has exactly one
- * block or not.  For the data fork we check this matches di_size,
+ * block or not.  For the data fork we check this matches i_disk_size,
  * implying the file's range is 0..bsize-1.
  */
 int					/* 1=>1 block, 0=>otherwise */
diff --git a/fs/xfs/libxfs/xfs_dir2.c b/fs/xfs/libxfs/xfs_dir2.c
index 612a9c5e41b1c6..050bdcc4fe7376 100644
--- a/fs/xfs/libxfs/xfs_dir2.c
+++ b/fs/xfs/libxfs/xfs_dir2.c
@@ -179,9 +179,9 @@ xfs_dir_isempty(
 	xfs_dir2_sf_hdr_t	*sfp;
 
 	ASSERT(S_ISDIR(VFS_I(dp)->i_mode));
-	if (dp->i_d.di_size == 0)	/* might happen during shutdown. */
+	if (dp->i_disk_size == 0)	/* might happen during shutdown. */
 		return 1;
-	if (dp->i_d.di_size > XFS_IFORK_DSIZE(dp))
+	if (dp->i_disk_size > XFS_IFORK_DSIZE(dp))
 		return 0;
 	sfp = (xfs_dir2_sf_hdr_t *)dp->i_df.if_u1.if_data;
 	return !sfp->count;
@@ -584,8 +584,8 @@ xfs_dir2_grow_inode(
 		xfs_fsize_t	size;		/* directory file (data) size */
 
 		size = XFS_FSB_TO_B(mp, bno + count);
-		if (size > dp->i_d.di_size) {
-			dp->i_d.di_size = size;
+		if (size > dp->i_disk_size) {
+			dp->i_disk_size = size;
 			xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE);
 		}
 	}
@@ -608,7 +608,7 @@ xfs_dir2_isblock(
 	rval = XFS_FSB_TO_B(args->dp->i_mount, last) == args->geo->blksize;
 	if (XFS_IS_CORRUPT(args->dp->i_mount,
 			   rval != 0 &&
-			   args->dp->i_d.di_size != args->geo->blksize))
+			   args->dp->i_disk_size != args->geo->blksize))
 		return -EFSCORRUPTED;
 	*vp = rval;
 	return 0;
@@ -687,7 +687,7 @@ xfs_dir2_shrink_inode(
 	/*
 	 * If the block isn't the last one in the directory, we're done.
 	 */
-	if (dp->i_d.di_size > xfs_dir2_db_off_to_byte(args->geo, db + 1, 0))
+	if (dp->i_disk_size > xfs_dir2_db_off_to_byte(args->geo, db + 1, 0))
 		return 0;
 	bno = da;
 	if ((error = xfs_bmap_last_before(tp, dp, &bno, XFS_DATA_FORK))) {
@@ -703,7 +703,7 @@ xfs_dir2_shrink_inode(
 	/*
 	 * Set the size to the new last block.
 	 */
-	dp->i_d.di_size = XFS_FSB_TO_B(mp, bno);
+	dp->i_disk_size = XFS_FSB_TO_B(mp, bno);
 	xfs_trans_log_inode(tp, dp, XFS_ILOG_CORE);
 	return 0;
 }
diff --git a/fs/xfs/libxfs/xfs_dir2_block.c b/fs/xfs/libxfs/xfs_dir2_block.c
index 5b59d3f7746b34..7824af54637513 100644
--- a/fs/xfs/libxfs/xfs_dir2_block.c
+++ b/fs/xfs/libxfs/xfs_dir2_block.c
@@ -961,7 +961,7 @@ xfs_dir2_leaf_to_block(
 	 * been left behind during no-space-reservation operations.
 	 * These will show up in the leaf bests table.
 	 */
-	while (dp->i_d.di_size > args->geo->blksize) {
+	while (dp->i_disk_size > args->geo->blksize) {
 		int hdrsz;
 
 		hdrsz = args->geo->data_entry_offset;
@@ -1097,13 +1097,13 @@ xfs_dir2_sf_to_block(
 	trace_xfs_dir2_sf_to_block(args);
 
 	ASSERT(ifp->if_flags & XFS_IFINLINE);
-	ASSERT(dp->i_d.di_size >= offsetof(struct xfs_dir2_sf_hdr, parent));
+	ASSERT(dp->i_disk_size >= offsetof(struct xfs_dir2_sf_hdr, parent));
 
 	oldsfp = (xfs_dir2_sf_hdr_t *)ifp->if_u1.if_data;
 
-	ASSERT(ifp->if_bytes == dp->i_d.di_size);
+	ASSERT(ifp->if_bytes == dp->i_disk_size);
 	ASSERT(ifp->if_u1.if_data != NULL);
-	ASSERT(dp->i_d.di_size >= xfs_dir2_sf_hdr_size(oldsfp->i8count));
+	ASSERT(dp->i_disk_size >= xfs_dir2_sf_hdr_size(oldsfp->i8count));
 	ASSERT(dp->i_df.if_nextents == 0);
 
 	/*
@@ -1115,7 +1115,7 @@ xfs_dir2_sf_to_block(
 
 	xfs_idata_realloc(dp, -ifp->if_bytes, XFS_DATA_FORK);
 	xfs_bmap_local_to_extents_empty(tp, dp, XFS_DATA_FORK);
-	dp->i_d.di_size = 0;
+	dp->i_disk_size = 0;
 
 	/*
 	 * Add block 0 to the inode.
diff --git a/fs/xfs/libxfs/xfs_dir2_leaf.c b/fs/xfs/libxfs/xfs_dir2_leaf.c
index 95d2a3f92d75de..73fb3e1152e6d7 100644
--- a/fs/xfs/libxfs/xfs_dir2_leaf.c
+++ b/fs/xfs/libxfs/xfs_dir2_leaf.c
@@ -151,7 +151,7 @@ xfs_dir3_leaf_check_int(
 	/*
 	 * XXX (dgc): This value is not restrictive enough.
 	 * Should factor in the size of the bests table as well.
-	 * We can deduce a value for that from di_size.
+	 * We can deduce a value for that from i_disk_size.
 	 */
 	if (hdr->count > geo->leaf_max_ents)
 		return __this_address;
diff --git a/fs/xfs/libxfs/xfs_dir2_node.c b/fs/xfs/libxfs/xfs_dir2_node.c
index 6ac4aad98cd76c..3698030ca5e2f7 100644
--- a/fs/xfs/libxfs/xfs_dir2_node.c
+++ b/fs/xfs/libxfs/xfs_dir2_node.c
@@ -441,7 +441,7 @@ xfs_dir2_leaf_to_node(
 	leaf = lbp->b_addr;
 	ltp = xfs_dir2_leaf_tail_p(args->geo, leaf);
 	if (be32_to_cpu(ltp->bestcount) >
-				(uint)dp->i_d.di_size / args->geo->blksize) {
+				(uint)dp->i_disk_size / args->geo->blksize) {
 		xfs_buf_mark_corrupt(lbp);
 		return -EFSCORRUPTED;
 	}
diff --git a/fs/xfs/libxfs/xfs_dir2_sf.c b/fs/xfs/libxfs/xfs_dir2_sf.c
index 2463b5d7344724..00fee3943a09dc 100644
--- a/fs/xfs/libxfs/xfs_dir2_sf.c
+++ b/fs/xfs/libxfs/xfs_dir2_sf.c
@@ -344,7 +344,7 @@ xfs_dir2_block_to_sf(
 	ASSERT(dp->i_df.if_bytes == 0);
 	xfs_init_local_fork(dp, XFS_DATA_FORK, sfp, size);
 	dp->i_df.if_format = XFS_DINODE_FMT_LOCAL;
-	dp->i_d.di_size = size;
+	dp->i_disk_size = size;
 
 	logflags |= XFS_ILOG_DDATA;
 	xfs_dir2_sf_check(args);
@@ -367,7 +367,7 @@ xfs_dir2_sf_addname(
 	xfs_inode_t		*dp;		/* incore directory inode */
 	int			error;		/* error return value */
 	int			incr_isize;	/* total change in size */
-	int			new_isize;	/* di_size after adding name */
+	int			new_isize;	/* size after adding name */
 	int			objchange;	/* changing to 8-byte inodes */
 	xfs_dir2_data_aoff_t	offset = 0;	/* offset for new entry */
 	int			pick;		/* which algorithm to use */
@@ -379,11 +379,11 @@ xfs_dir2_sf_addname(
 	ASSERT(xfs_dir2_sf_lookup(args) == -ENOENT);
 	dp = args->dp;
 	ASSERT(dp->i_df.if_flags & XFS_IFINLINE);
-	ASSERT(dp->i_d.di_size >= offsetof(struct xfs_dir2_sf_hdr, parent));
-	ASSERT(dp->i_df.if_bytes == dp->i_d.di_size);
+	ASSERT(dp->i_disk_size >= offsetof(struct xfs_dir2_sf_hdr, parent));
+	ASSERT(dp->i_df.if_bytes == dp->i_disk_size);
 	ASSERT(dp->i_df.if_u1.if_data != NULL);
 	sfp = (xfs_dir2_sf_hdr_t *)dp->i_df.if_u1.if_data;
-	ASSERT(dp->i_d.di_size >= xfs_dir2_sf_hdr_size(sfp->i8count));
+	ASSERT(dp->i_disk_size >= xfs_dir2_sf_hdr_size(sfp->i8count));
 	/*
 	 * Compute entry (and change in) size.
 	 */
@@ -401,7 +401,7 @@ xfs_dir2_sf_addname(
 		objchange = 1;
 	}
 
-	new_isize = (int)dp->i_d.di_size + incr_isize;
+	new_isize = (int)dp->i_disk_size + incr_isize;
 	/*
 	 * Won't fit as shortform any more (due to size),
 	 * or the pick routine says it won't (due to offset values).
@@ -492,7 +492,7 @@ xfs_dir2_sf_addname_easy(
 	sfp->count++;
 	if (args->inumber > XFS_DIR2_MAX_SHORT_INUM)
 		sfp->i8count++;
-	dp->i_d.di_size = new_isize;
+	dp->i_disk_size = new_isize;
 	xfs_dir2_sf_check(args);
 }
 
@@ -519,7 +519,7 @@ xfs_dir2_sf_addname_hard(
 	int			nbytes;		/* temp for byte copies */
 	xfs_dir2_data_aoff_t	new_offset;	/* next offset value */
 	xfs_dir2_data_aoff_t	offset;		/* current offset value */
-	int			old_isize;	/* previous di_size */
+	int			old_isize;	/* previous size */
 	xfs_dir2_sf_entry_t	*oldsfep;	/* entry in original dir */
 	xfs_dir2_sf_hdr_t	*oldsfp;	/* original shortform dir */
 	xfs_dir2_sf_entry_t	*sfep;		/* entry in new dir */
@@ -529,7 +529,7 @@ xfs_dir2_sf_addname_hard(
 	 * Copy the old directory to the stack buffer.
 	 */
 	sfp = (xfs_dir2_sf_hdr_t *)dp->i_df.if_u1.if_data;
-	old_isize = (int)dp->i_d.di_size;
+	old_isize = (int)dp->i_disk_size;
 	buf = kmem_alloc(old_isize, 0);
 	oldsfp = (xfs_dir2_sf_hdr_t *)buf;
 	memcpy(oldsfp, sfp, old_isize);
@@ -586,7 +586,7 @@ xfs_dir2_sf_addname_hard(
 		memcpy(sfep, oldsfep, old_isize - nbytes);
 	}
 	kmem_free(buf);
-	dp->i_d.di_size = new_isize;
+	dp->i_disk_size = new_isize;
 	xfs_dir2_sf_check(args);
 }
 
@@ -697,7 +697,7 @@ xfs_dir2_sf_check(
 		ASSERT(xfs_dir2_sf_get_ftype(mp, sfep) < XFS_DIR3_FT_MAX);
 	}
 	ASSERT(i8count == sfp->i8count);
-	ASSERT((char *)sfep - (char *)sfp == dp->i_d.di_size);
+	ASSERT((char *)sfep - (char *)sfp == dp->i_disk_size);
 	ASSERT(offset +
 	       (sfp->count + 2) * (uint)sizeof(xfs_dir2_leaf_entry_t) +
 	       (uint)sizeof(xfs_dir2_block_tail_t) <= args->geo->blksize);
@@ -821,7 +821,7 @@ xfs_dir2_sf_create(
 	dp = args->dp;
 
 	ASSERT(dp != NULL);
-	ASSERT(dp->i_d.di_size == 0);
+	ASSERT(dp->i_disk_size == 0);
 	/*
 	 * If it's currently a zero-length extent file,
 	 * convert it to local format.
@@ -850,7 +850,7 @@ xfs_dir2_sf_create(
 	 */
 	xfs_dir2_sf_put_parent_ino(sfp, pino);
 	sfp->count = 0;
-	dp->i_d.di_size = size;
+	dp->i_disk_size = size;
 	xfs_dir2_sf_check(args);
 	xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE | XFS_ILOG_DDATA);
 	return 0;
@@ -878,11 +878,11 @@ xfs_dir2_sf_lookup(
 	xfs_dir2_sf_check(args);
 
 	ASSERT(dp->i_df.if_flags & XFS_IFINLINE);
-	ASSERT(dp->i_d.di_size >= offsetof(struct xfs_dir2_sf_hdr, parent));
-	ASSERT(dp->i_df.if_bytes == dp->i_d.di_size);
+	ASSERT(dp->i_disk_size >= offsetof(struct xfs_dir2_sf_hdr, parent));
+	ASSERT(dp->i_df.if_bytes == dp->i_disk_size);
 	ASSERT(dp->i_df.if_u1.if_data != NULL);
 	sfp = (xfs_dir2_sf_hdr_t *)dp->i_df.if_u1.if_data;
-	ASSERT(dp->i_d.di_size >= xfs_dir2_sf_hdr_size(sfp->i8count));
+	ASSERT(dp->i_disk_size >= xfs_dir2_sf_hdr_size(sfp->i8count));
 	/*
 	 * Special case for .
 	 */
@@ -955,7 +955,7 @@ xfs_dir2_sf_removename(
 	trace_xfs_dir2_sf_removename(args);
 
 	ASSERT(dp->i_df.if_flags & XFS_IFINLINE);
-	oldsize = (int)dp->i_d.di_size;
+	oldsize = (int)dp->i_disk_size;
 	ASSERT(oldsize >= offsetof(struct xfs_dir2_sf_hdr, parent));
 	ASSERT(dp->i_df.if_bytes == oldsize);
 	ASSERT(dp->i_df.if_u1.if_data != NULL);
@@ -995,7 +995,7 @@ xfs_dir2_sf_removename(
 	 * Fix up the header and file size.
 	 */
 	sfp->count--;
-	dp->i_d.di_size = newsize;
+	dp->i_disk_size = newsize;
 	/*
 	 * Reallocate, making it smaller.
 	 */
@@ -1054,11 +1054,11 @@ xfs_dir2_sf_replace(
 	trace_xfs_dir2_sf_replace(args);
 
 	ASSERT(dp->i_df.if_flags & XFS_IFINLINE);
-	ASSERT(dp->i_d.di_size >= offsetof(struct xfs_dir2_sf_hdr, parent));
-	ASSERT(dp->i_df.if_bytes == dp->i_d.di_size);
+	ASSERT(dp->i_disk_size >= offsetof(struct xfs_dir2_sf_hdr, parent));
+	ASSERT(dp->i_df.if_bytes == dp->i_disk_size);
 	ASSERT(dp->i_df.if_u1.if_data != NULL);
 	sfp = (xfs_dir2_sf_hdr_t *)dp->i_df.if_u1.if_data;
-	ASSERT(dp->i_d.di_size >= xfs_dir2_sf_hdr_size(sfp->i8count));
+	ASSERT(dp->i_disk_size >= xfs_dir2_sf_hdr_size(sfp->i8count));
 
 	/*
 	 * New inode number is large, and need to convert to 8-byte inodes.
@@ -1219,7 +1219,7 @@ xfs_dir2_sf_toino4(
 	 * Clean up the inode.
 	 */
 	kmem_free(buf);
-	dp->i_d.di_size = newsize;
+	dp->i_disk_size = newsize;
 	xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE | XFS_ILOG_DDATA);
 }
 
@@ -1292,6 +1292,6 @@ xfs_dir2_sf_toino8(
 	 * Clean up the inode.
 	 */
 	kmem_free(buf);
-	dp->i_d.di_size = newsize;
+	dp->i_disk_size = newsize;
 	xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE | XFS_ILOG_DDATA);
 }
diff --git a/fs/xfs/libxfs/xfs_inode_buf.c b/fs/xfs/libxfs/xfs_inode_buf.c
index b064cb8072c84a..c202de8bbdd427 100644
--- a/fs/xfs/libxfs/xfs_inode_buf.c
+++ b/fs/xfs/libxfs/xfs_inode_buf.c
@@ -241,7 +241,7 @@ xfs_inode_from_disk(
 	inode->i_ctime.tv_sec = (int)be32_to_cpu(from->di_ctime.t_sec);
 	inode->i_ctime.tv_nsec = (int)be32_to_cpu(from->di_ctime.t_nsec);
 
-	to->di_size = be64_to_cpu(from->di_size);
+	ip->i_disk_size = be64_to_cpu(from->di_size);
 	to->di_nblocks = be64_to_cpu(from->di_nblocks);
 	to->di_extsize = be32_to_cpu(from->di_extsize);
 	to->di_forkoff = from->di_forkoff;
@@ -304,7 +304,7 @@ xfs_inode_to_disk(
 	to->di_gen = cpu_to_be32(inode->i_generation);
 	to->di_mode = cpu_to_be16(inode->i_mode);
 
-	to->di_size = cpu_to_be64(from->di_size);
+	to->di_size = cpu_to_be64(ip->i_disk_size);
 	to->di_nblocks = cpu_to_be64(from->di_nblocks);
 	to->di_extsize = cpu_to_be32(from->di_extsize);
 	to->di_nextents = cpu_to_be32(xfs_ifork_nextents(&ip->i_df));
diff --git a/fs/xfs/libxfs/xfs_inode_buf.h b/fs/xfs/libxfs/xfs_inode_buf.h
index b826d81b356956..f187127d50e010 100644
--- a/fs/xfs/libxfs/xfs_inode_buf.h
+++ b/fs/xfs/libxfs/xfs_inode_buf.h
@@ -17,7 +17,6 @@ struct xfs_dinode;
  */
 struct xfs_icdinode {
 	uint16_t	di_flushiter;	/* incremented on flush */
-	xfs_fsize_t	di_size;	/* number of bytes in file */
 	xfs_rfsblock_t	di_nblocks;	/* # of direct & btree blocks used */
 	xfs_extlen_t	di_extsize;	/* basic/minimum extent size for file */
 	uint8_t		di_forkoff;	/* attr fork offs, <<3 for 64b align */
diff --git a/fs/xfs/libxfs/xfs_inode_fork.c b/fs/xfs/libxfs/xfs_inode_fork.c
index 28b366275ae0ed..d2029e12bda4de 100644
--- a/fs/xfs/libxfs/xfs_inode_fork.c
+++ b/fs/xfs/libxfs/xfs_inode_fork.c
@@ -240,7 +240,7 @@ xfs_iformat_data_fork(
 	case S_IFCHR:
 	case S_IFBLK:
 	case S_IFSOCK:
-		ip->i_d.di_size = 0;
+		ip->i_disk_size = 0;
 		inode->i_rdev = xfs_to_linux_dev_t(xfs_dinode_get_rdev(dip));
 		return 0;
 	case S_IFREG:
diff --git a/fs/xfs/scrub/dir.c b/fs/xfs/scrub/dir.c
index 7c432997edade4..d89aa8efb84545 100644
--- a/fs/xfs/scrub/dir.c
+++ b/fs/xfs/scrub/dir.c
@@ -523,7 +523,7 @@ xchk_directory_leaf1_bestfree(
 	 * There should be as many bestfree slots as there are dir data
 	 * blocks that can fit under i_size.
 	 */
-	if (bestcount != xfs_dir2_byte_to_db(geo, sc->ip->i_d.di_size)) {
+	if (bestcount != xfs_dir2_byte_to_db(geo, sc->ip->i_disk_size)) {
 		xchk_fblock_set_corrupt(sc, XFS_DATA_FORK, lblk);
 		goto out;
 	}
@@ -789,7 +789,7 @@ xchk_directory(
 		return -ENOENT;
 
 	/* Plausible size? */
-	if (sc->ip->i_d.di_size < xfs_dir2_sf_hdr_size(0)) {
+	if (sc->ip->i_disk_size < xfs_dir2_sf_hdr_size(0)) {
 		xchk_ino_set_corrupt(sc, sc->ip->i_ino);
 		goto out;
 	}
@@ -815,7 +815,7 @@ xchk_directory(
 	 * Userspace usually asks for a 32k buffer, so we will too.
 	 */
 	bufsize = (size_t)min_t(loff_t, XFS_READDIR_BUFSIZE,
-			sc->ip->i_d.di_size);
+			sc->ip->i_disk_size);
 
 	/*
 	 * Look up every name in this directory by hash.
diff --git a/fs/xfs/scrub/parent.c b/fs/xfs/scrub/parent.c
index 855aa8bcab64bd..766e870999a9a8 100644
--- a/fs/xfs/scrub/parent.c
+++ b/fs/xfs/scrub/parent.c
@@ -102,7 +102,7 @@ xchk_parent_count_parent_dentries(
 	 * scanned.
 	 */
 	bufsize = (size_t)min_t(loff_t, XFS_READDIR_BUFSIZE,
-			parent->i_d.di_size);
+			parent->i_disk_size);
 	oldpos = 0;
 	while (true) {
 		error = xfs_readdir(sc->tp, parent, &spc.dc, bufsize);
diff --git a/fs/xfs/scrub/symlink.c b/fs/xfs/scrub/symlink.c
index 5641ae512c9efc..9b751d79adf096 100644
--- a/fs/xfs/scrub/symlink.c
+++ b/fs/xfs/scrub/symlink.c
@@ -43,7 +43,7 @@ xchk_symlink(
 	if (!S_ISLNK(VFS_I(ip)->i_mode))
 		return -ENOENT;
 	ifp = XFS_IFORK_PTR(ip, XFS_DATA_FORK);
-	len = ip->i_d.di_size;
+	len = ip->i_disk_size;
 
 	/* Plausible size? */
 	if (len > XFS_SYMLINK_MAXLEN || len <= 0) {
diff --git a/fs/xfs/xfs_aops.c b/fs/xfs/xfs_aops.c
index 2834cbf1212e5a..18a497cc817c2a 100644
--- a/fs/xfs/xfs_aops.c
+++ b/fs/xfs/xfs_aops.c
@@ -36,7 +36,7 @@ XFS_WPC(struct iomap_writepage_ctx *ctx)
 static inline bool xfs_ioend_is_append(struct iomap_ioend *ioend)
 {
 	return ioend->io_offset + ioend->io_size >
-		XFS_I(ioend->io_inode)->i_d.di_size;
+		XFS_I(ioend->io_inode)->i_disk_size;
 }
 
 STATIC int
@@ -88,7 +88,7 @@ __xfs_setfilesize(
 
 	trace_xfs_setfilesize(ip, offset, size);
 
-	ip->i_d.di_size = isize;
+	ip->i_disk_size = isize;
 	xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);
 	xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
 
diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c
index e42553884c23cf..d199ecddc1ab19 100644
--- a/fs/xfs/xfs_bmap_util.c
+++ b/fs/xfs/xfs_bmap_util.c
@@ -423,7 +423,7 @@ xfs_getbmap(
 		break;
 	case XFS_DATA_FORK:
 		if (!(iflags & BMV_IF_DELALLOC) &&
-		    (ip->i_delayed_blks || XFS_ISIZE(ip) > ip->i_d.di_size)) {
+		    (ip->i_delayed_blks || XFS_ISIZE(ip) > ip->i_disk_size)) {
 			error = filemap_write_and_wait(VFS_I(ip)->i_mapping);
 			if (error)
 				goto out_unlock_iolock;
@@ -1656,8 +1656,8 @@ xfs_swap_extents(
 
 	/* Verify all data are being swapped */
 	if (sxp->sx_offset != 0 ||
-	    sxp->sx_length != ip->i_d.di_size ||
-	    sxp->sx_length != tip->i_d.di_size) {
+	    sxp->sx_length != ip->i_disk_size ||
+	    sxp->sx_length != tip->i_disk_size) {
 		error = -EFAULT;
 		goto out_trans_cancel;
 	}
diff --git a/fs/xfs/xfs_dir2_readdir.c b/fs/xfs/xfs_dir2_readdir.c
index 66deddd5e29698..03e7c39a07807a 100644
--- a/fs/xfs/xfs_dir2_readdir.c
+++ b/fs/xfs/xfs_dir2_readdir.c
@@ -58,7 +58,7 @@ xfs_dir2_sf_getdents(
 	struct xfs_da_geometry	*geo = args->geo;
 
 	ASSERT(dp->i_df.if_flags & XFS_IFINLINE);
-	ASSERT(dp->i_df.if_bytes == dp->i_d.di_size);
+	ASSERT(dp->i_df.if_bytes == dp->i_disk_size);
 	ASSERT(dp->i_df.if_u1.if_data != NULL);
 
 	sfp = (xfs_dir2_sf_hdr_t *)dp->i_df.if_u1.if_data;
diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c
index 403c90309a8ffe..14b533a8ce8e6a 100644
--- a/fs/xfs/xfs_file.c
+++ b/fs/xfs/xfs_file.c
@@ -1137,7 +1137,7 @@ xfs_file_readdir(
 	 * point we can change the ->readdir prototype to include the
 	 * buffer size.  For now we use the current glibc buffer size.
 	 */
-	bufsize = (size_t)min_t(loff_t, XFS_READDIR_BUFSIZE, ip->i_d.di_size);
+	bufsize = (size_t)min_t(loff_t, XFS_READDIR_BUFSIZE, ip->i_disk_size);
 
 	return xfs_readdir(NULL, ip, ctx, bufsize);
 }
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index 40e4d3ed29a798..723a911c8b6d81 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -825,7 +825,7 @@ xfs_ialloc(
 	    (inode->i_mode & S_ISGID) && !in_group_p(inode->i_gid))
 		inode->i_mode &= ~S_ISGID;
 
-	ip->i_d.di_size = 0;
+	ip->i_disk_size = 0;
 	ip->i_df.if_nextents = 0;
 	ASSERT(ip->i_d.di_nblocks == 0);
 
@@ -1675,7 +1675,7 @@ xfs_inactive_truncate(
 	 * of a system crash before the truncate completes. See the related
 	 * comment in xfs_vn_setattr_size() for details.
 	 */
-	ip->i_d.di_size = 0;
+	ip->i_disk_size = 0;
 	xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
 
 	error = xfs_itruncate_extents(&tp, ip, XFS_DATA_FORK, 0);
@@ -1831,7 +1831,7 @@ xfs_inactive(
 	}
 
 	if (S_ISREG(VFS_I(ip)->i_mode) &&
-	    (ip->i_d.di_size != 0 || XFS_ISIZE(ip) != 0 ||
+	    (ip->i_disk_size != 0 || XFS_ISIZE(ip) != 0 ||
 	     ip->i_df.if_nextents > 0 || ip->i_delayed_blks > 0))
 		truncate = 1;
 
@@ -2729,7 +2729,7 @@ xfs_ifree(
 	ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL));
 	ASSERT(VFS_I(ip)->i_nlink == 0);
 	ASSERT(ip->i_df.if_nextents == 0);
-	ASSERT(ip->i_d.di_size == 0 || !S_ISREG(VFS_I(ip)->i_mode));
+	ASSERT(ip->i_disk_size == 0 || !S_ISREG(VFS_I(ip)->i_mode));
 	ASSERT(ip->i_d.di_nblocks == 0);
 
 	/*
diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h
index 51ea9d53407863..61c41395536f07 100644
--- a/fs/xfs/xfs_inode.h
+++ b/fs/xfs/xfs_inode.h
@@ -54,6 +54,7 @@ typedef struct xfs_inode {
 	/* Miscellaneous state. */
 	unsigned long		i_flags;	/* see defined flags below */
 	uint64_t		i_delayed_blks;	/* count of delay alloc blks */
+	xfs_fsize_t		i_disk_size;	/* number of bytes in file */
 	uint32_t		i_projid;	/* owner's project id */
 
 	struct xfs_icdinode	i_d;		/* most of ondisk inode */
@@ -88,7 +89,7 @@ static inline xfs_fsize_t XFS_ISIZE(struct xfs_inode *ip)
 {
 	if (S_ISREG(VFS_I(ip)->i_mode))
 		return i_size_read(VFS_I(ip));
-	return ip->i_d.di_size;
+	return ip->i_disk_size;
 }
 
 /*
@@ -102,7 +103,7 @@ xfs_new_eof(struct xfs_inode *ip, xfs_fsize_t new_size)
 
 	if (new_size > i_size || new_size < 0)
 		new_size = i_size;
-	return new_size > ip->i_d.di_size ? new_size : 0;
+	return new_size > ip->i_disk_size ? new_size : 0;
 }
 
 /*
diff --git a/fs/xfs/xfs_inode_item.c b/fs/xfs/xfs_inode_item.c
index e546b4b58ce2e0..179f1c2de6bd0f 100644
--- a/fs/xfs/xfs_inode_item.c
+++ b/fs/xfs/xfs_inode_item.c
@@ -196,7 +196,7 @@ xfs_inode_item_format_data_fork(
 			 */
 			data_bytes = roundup(ip->i_df.if_bytes, 4);
 			ASSERT(ip->i_df.if_u1.if_data != NULL);
-			ASSERT(ip->i_d.di_size > 0);
+			ASSERT(ip->i_disk_size > 0);
 			xlog_copy_iovec(lv, vecp, XLOG_REG_TYPE_ILOCAL,
 					ip->i_df.if_u1.if_data, data_bytes);
 			ilf->ilf_dsize = (unsigned)data_bytes;
@@ -323,7 +323,7 @@ xfs_inode_to_log_dinode(
 	to->di_gen = inode->i_generation;
 	to->di_mode = inode->i_mode;
 
-	to->di_size = from->di_size;
+	to->di_size = ip->i_disk_size;
 	to->di_nblocks = from->di_nblocks;
 	to->di_extsize = from->di_extsize;
 	to->di_nextents = xfs_ifork_nextents(&ip->i_df);
diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c
index b9a8c3798e08fc..6e03963b6b300e 100644
--- a/fs/xfs/xfs_iomap.c
+++ b/fs/xfs/xfs_iomap.c
@@ -583,7 +583,7 @@ xfs_iomap_write_unwritten(
 			i_size_write(inode, i_size);
 		i_size = xfs_new_eof(ip, i_size);
 		if (i_size) {
-			ip->i_d.di_size = i_size;
+			ip->i_disk_size = i_size;
 			xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
 		}
 
diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
index 5440f555c9cc2c..1abee83d49cff9 100644
--- a/fs/xfs/xfs_iops.c
+++ b/fs/xfs/xfs_iops.c
@@ -935,8 +935,8 @@ xfs_setattr_size(
 	 * operation.
 	 *
 	 * And we update in-core i_size and truncate page cache beyond newsize
-	 * before writeback the [di_size, newsize] range, so we're guaranteed
-	 * not to write stale data past the new EOF on truncate down.
+	 * before writeback the [i_disk_size, newsize] range, so we're
+	 * guaranteed not to write stale data past the new EOF on truncate down.
 	 */
 	truncate_setsize(inode, newsize);
 
@@ -949,9 +949,9 @@ xfs_setattr_size(
 	 * otherwise those blocks may not be zeroed after a crash.
 	 */
 	if (did_zeroing ||
-	    (newsize > ip->i_d.di_size && oldsize != ip->i_d.di_size)) {
+	    (newsize > ip->i_disk_size && oldsize != ip->i_disk_size)) {
 		error = filemap_write_and_wait_range(VFS_I(ip)->i_mapping,
-						ip->i_d.di_size, newsize - 1);
+						ip->i_disk_size, newsize - 1);
 		if (error)
 			return error;
 	}
@@ -993,7 +993,7 @@ xfs_setattr_size(
 	 * permanent before actually freeing any blocks it doesn't matter if
 	 * they get written to.
 	 */
-	ip->i_d.di_size = newsize;
+	ip->i_disk_size = newsize;
 	xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
 
 	if (newsize <= oldsize) {
@@ -1323,7 +1323,7 @@ xfs_setup_inode(
 	/* make the inode look hashed for the writeback code */
 	inode_fake_hash(inode);
 
-	i_size_write(inode, ip->i_d.di_size);
+	i_size_write(inode, ip->i_disk_size);
 	xfs_diflags_to_iflags(ip, true);
 
 	if (S_ISDIR(inode->i_mode)) {
diff --git a/fs/xfs/xfs_itable.c b/fs/xfs/xfs_itable.c
index 97b3b794dd4ada..9f92514301b334 100644
--- a/fs/xfs/xfs_itable.c
+++ b/fs/xfs/xfs_itable.c
@@ -88,7 +88,7 @@ xfs_bulkstat_one_int(
 	buf->bs_ino = ino;
 	buf->bs_uid = i_uid_read(inode);
 	buf->bs_gid = i_gid_read(inode);
-	buf->bs_size = dic->di_size;
+	buf->bs_size = ip->i_disk_size;
 
 	buf->bs_nlink = inode->i_nlink;
 	buf->bs_atime = inode->i_atime.tv_sec;
diff --git a/fs/xfs/xfs_pnfs.c b/fs/xfs/xfs_pnfs.c
index b101feb2aab452..e6caca783764f9 100644
--- a/fs/xfs/xfs_pnfs.c
+++ b/fs/xfs/xfs_pnfs.c
@@ -286,7 +286,7 @@ xfs_fs_commit_blocks(
 	xfs_setattr_time(ip, iattr);
 	if (update_isize) {
 		i_size_write(inode, iattr->ia_size);
-		ip->i_d.di_size = iattr->ia_size;
+		ip->i_disk_size = iattr->ia_size;
 	}
 
 	xfs_trans_set_sync(tp);
diff --git a/fs/xfs/xfs_qm_syscalls.c b/fs/xfs/xfs_qm_syscalls.c
index 7effd7a2813656..08dec36095fae2 100644
--- a/fs/xfs/xfs_qm_syscalls.c
+++ b/fs/xfs/xfs_qm_syscalls.c
@@ -293,7 +293,7 @@ xfs_qm_scall_trunc_qfile(
 	xfs_ilock(ip, XFS_ILOCK_EXCL);
 	xfs_trans_ijoin(tp, ip, 0);
 
-	ip->i_d.di_size = 0;
+	ip->i_disk_size = 0;
 	xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
 
 	error = xfs_itruncate_extents(&tp, ip, XFS_DATA_FORK, 0);
diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c
index 107bf2a2f3448a..8598896156e29a 100644
--- a/fs/xfs/xfs_reflink.c
+++ b/fs/xfs/xfs_reflink.c
@@ -938,7 +938,7 @@ xfs_reflink_update_dest(
 	if (newlen > i_size_read(VFS_I(dest))) {
 		trace_xfs_reflink_update_inode_size(dest, newlen);
 		i_size_write(VFS_I(dest), newlen);
-		dest->i_d.di_size = newlen;
+		dest->i_disk_size = newlen;
 	}
 
 	if (cowextsize) {
@@ -1078,7 +1078,7 @@ xfs_reflink_remap_extent(
 		if (newlen > i_size_read(VFS_I(ip))) {
 			trace_xfs_reflink_update_inode_size(ip, newlen);
 			i_size_write(VFS_I(ip), newlen);
-			ip->i_d.di_size = newlen;
+			ip->i_disk_size = newlen;
 			xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
 		}
 
diff --git a/fs/xfs/xfs_rtalloc.c b/fs/xfs/xfs_rtalloc.c
index 6209e7b6b895b8..cc07d7d27dd7e0 100644
--- a/fs/xfs/xfs_rtalloc.c
+++ b/fs/xfs/xfs_rtalloc.c
@@ -941,8 +941,8 @@ xfs_growfs_rt(
 	 * Get the old block counts for bitmap and summary inodes.
 	 * These can't change since other growfs callers are locked out.
 	 */
-	rbmblocks = XFS_B_TO_FSB(mp, mp->m_rbmip->i_d.di_size);
-	rsumblocks = XFS_B_TO_FSB(mp, mp->m_rsumip->i_d.di_size);
+	rbmblocks = XFS_B_TO_FSB(mp, mp->m_rbmip->i_disk_size);
+	rsumblocks = XFS_B_TO_FSB(mp, mp->m_rsumip->i_disk_size);
 	/*
 	 * Allocate space to the bitmap and summary files, as necessary.
 	 */
@@ -1009,7 +1009,7 @@ xfs_growfs_rt(
 		/*
 		 * Update the bitmap inode's size.
 		 */
-		mp->m_rbmip->i_d.di_size =
+		mp->m_rbmip->i_disk_size =
 			nsbp->sb_rbmblocks * nsbp->sb_blocksize;
 		xfs_trans_log_inode(tp, mp->m_rbmip, XFS_ILOG_CORE);
 		/*
@@ -1020,7 +1020,7 @@ xfs_growfs_rt(
 		/*
 		 * Update the summary inode's size.
 		 */
-		mp->m_rsumip->i_d.di_size = nmp->m_rsumsize;
+		mp->m_rsumip->i_disk_size = nmp->m_rsumsize;
 		xfs_trans_log_inode(tp, mp->m_rsumip, XFS_ILOG_CORE);
 		/*
 		 * Copy summary data from old to new sizes.
diff --git a/fs/xfs/xfs_symlink.c b/fs/xfs/xfs_symlink.c
index 8e88a7ca387ea9..6b8980b1497c9a 100644
--- a/fs/xfs/xfs_symlink.c
+++ b/fs/xfs/xfs_symlink.c
@@ -33,7 +33,7 @@ xfs_readlink_bmap_ilocked(
 	struct xfs_buf		*bp;
 	xfs_daddr_t		d;
 	char			*cur_chunk;
-	int			pathlen = ip->i_d.di_size;
+	int			pathlen = ip->i_disk_size;
 	int			nmaps = XFS_SYMLINK_MAPS;
 	int			byte_cnt;
 	int			n;
@@ -86,7 +86,7 @@ xfs_readlink_bmap_ilocked(
 	}
 	ASSERT(pathlen == 0);
 
-	link[ip->i_d.di_size] = '\0';
+	link[ip->i_disk_size] = '\0';
 	error = 0;
 
  out:
@@ -111,7 +111,7 @@ xfs_readlink(
 
 	xfs_ilock(ip, XFS_ILOCK_SHARED);
 
-	pathlen = ip->i_d.di_size;
+	pathlen = ip->i_disk_size;
 	if (!pathlen)
 		goto out;
 
@@ -250,7 +250,7 @@ xfs_symlink(
 	if (pathlen <= XFS_IFORK_DSIZE(ip)) {
 		xfs_init_local_fork(ip, XFS_DATA_FORK, target_path, pathlen);
 
-		ip->i_d.di_size = pathlen;
+		ip->i_disk_size = pathlen;
 		ip->i_df.if_format = XFS_DINODE_FMT_LOCAL;
 		xfs_trans_log_inode(tp, ip, XFS_ILOG_DDATA | XFS_ILOG_CORE);
 	} else {
@@ -265,7 +265,7 @@ xfs_symlink(
 			goto out_trans_cancel;
 
 		resblks -= fs_blocks;
-		ip->i_d.di_size = pathlen;
+		ip->i_disk_size = pathlen;
 		xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
 
 		cur_chunk = target_path;
@@ -399,8 +399,8 @@ xfs_inactive_symlink_rmt(
 	 * locked for the second transaction.  In the error paths we need it
 	 * held so the cancel won't rele it, see below.
 	 */
-	size = (int)ip->i_d.di_size;
-	ip->i_d.di_size = 0;
+	size = (int)ip->i_disk_size;
+	ip->i_disk_size = 0;
 	VFS_I(ip)->i_mode = (VFS_I(ip)->i_mode & ~S_IFMT) | S_IFREG;
 	xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
 	/*
@@ -476,7 +476,7 @@ xfs_inactive_symlink(
 		return -EIO;
 
 	xfs_ilock(ip, XFS_ILOCK_EXCL);
-	pathlen = (int)ip->i_d.di_size;
+	pathlen = (int)ip->i_disk_size;
 	ASSERT(pathlen);
 
 	if (pathlen <= 0 || pathlen > XFS_SYMLINK_MAXLEN) {
diff --git a/fs/xfs/xfs_trace.h b/fs/xfs/xfs_trace.h
index 460136628a7959..5cc73db80ae0c0 100644
--- a/fs/xfs/xfs_trace.h
+++ b/fs/xfs/xfs_trace.h
@@ -1140,7 +1140,7 @@ DECLARE_EVENT_CLASS(xfs_file_class,
 	TP_fast_assign(
 		__entry->dev = VFS_I(ip)->i_sb->s_dev;
 		__entry->ino = ip->i_ino;
-		__entry->size = ip->i_d.di_size;
+		__entry->size = ip->i_disk_size;
 		__entry->offset = offset;
 		__entry->count = count;
 	),
@@ -1181,7 +1181,7 @@ DECLARE_EVENT_CLASS(xfs_imap_class,
 	TP_fast_assign(
 		__entry->dev = VFS_I(ip)->i_sb->s_dev;
 		__entry->ino = ip->i_ino;
-		__entry->size = ip->i_d.di_size;
+		__entry->size = ip->i_disk_size;
 		__entry->offset = offset;
 		__entry->count = count;
 		__entry->whichfork = whichfork;
@@ -1227,7 +1227,7 @@ DECLARE_EVENT_CLASS(xfs_simple_io_class,
 		__entry->dev = VFS_I(ip)->i_sb->s_dev;
 		__entry->ino = ip->i_ino;
 		__entry->isize = VFS_I(ip)->i_size;
-		__entry->disize = ip->i_d.di_size;
+		__entry->disize = ip->i_disk_size;
 		__entry->offset = offset;
 		__entry->count = count;
 	),
@@ -1265,7 +1265,7 @@ DECLARE_EVENT_CLASS(xfs_itrunc_class,
 	TP_fast_assign(
 		__entry->dev = VFS_I(ip)->i_sb->s_dev;
 		__entry->ino = ip->i_ino;
-		__entry->size = ip->i_d.di_size;
+		__entry->size = ip->i_disk_size;
 		__entry->new_size = new_size;
 	),
 	TP_printk("dev %d:%d ino 0x%llx size 0x%llx new_size 0x%llx",
@@ -1295,7 +1295,7 @@ TRACE_EVENT(xfs_pagecache_inval,
 	TP_fast_assign(
 		__entry->dev = VFS_I(ip)->i_sb->s_dev;
 		__entry->ino = ip->i_ino;
-		__entry->size = ip->i_d.di_size;
+		__entry->size = ip->i_disk_size;
 		__entry->start = start;
 		__entry->finish = finish;
 	),
@@ -1323,7 +1323,7 @@ TRACE_EVENT(xfs_bunmap,
 	TP_fast_assign(
 		__entry->dev = VFS_I(ip)->i_sb->s_dev;
 		__entry->ino = ip->i_ino;
-		__entry->size = ip->i_d.di_size;
+		__entry->size = ip->i_disk_size;
 		__entry->bno = bno;
 		__entry->len = len;
 		__entry->caller_ip = caller_ip;
@@ -2984,12 +2984,12 @@ DECLARE_EVENT_CLASS(xfs_double_io_class,
 		__entry->dev = VFS_I(src)->i_sb->s_dev;
 		__entry->src_ino = src->i_ino;
 		__entry->src_isize = VFS_I(src)->i_size;
-		__entry->src_disize = src->i_d.di_size;
+		__entry->src_disize = src->i_disk_size;
 		__entry->src_offset = soffset;
 		__entry->len = len;
 		__entry->dest_ino = dest->i_ino;
 		__entry->dest_isize = VFS_I(dest)->i_size;
-		__entry->dest_disize = dest->i_d.di_size;
+		__entry->dest_disize = dest->i_disk_size;
 		__entry->dest_offset = doffset;
 	),
 	TP_printk("dev %d:%d count %zd "
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH 04/15] xfs: move the di_nblocks field to struct xfs_inode
  2020-06-20  7:10 xfs inode structure cleanups v2 Christoph Hellwig
                   ` (2 preceding siblings ...)
  2020-06-20  7:10 ` [PATCH 03/15] xfs: move the di_size " Christoph Hellwig
@ 2020-06-20  7:10 ` Christoph Hellwig
  2020-06-22  9:33   ` Chandan Babu R
  2020-06-30 17:47   ` Darrick J. Wong
  2020-06-20  7:10 ` [PATCH 05/15] xfs: move the di_extsize " Christoph Hellwig
                   ` (11 subsequent siblings)
  15 siblings, 2 replies; 52+ messages in thread
From: Christoph Hellwig @ 2020-06-20  7:10 UTC (permalink / raw)
  To: linux-xfs

In preparation of removing the historic icinode struct, move the nblocks
field into the containing xfs_inode structure.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/xfs/libxfs/xfs_bmap.c       | 12 ++++++------
 fs/xfs/libxfs/xfs_bmap_btree.c |  4 ++--
 fs/xfs/libxfs/xfs_da_btree.c   |  4 ++--
 fs/xfs/libxfs/xfs_inode_buf.c  |  4 ++--
 fs/xfs/libxfs/xfs_inode_buf.h  |  1 -
 fs/xfs/libxfs/xfs_inode_fork.c |  2 +-
 fs/xfs/xfs_bmap_util.c         |  8 ++++----
 fs/xfs/xfs_icache.c            |  4 ++--
 fs/xfs/xfs_inode.c             |  8 ++++----
 fs/xfs/xfs_inode.h             |  1 +
 fs/xfs/xfs_inode_item.c        |  2 +-
 fs/xfs/xfs_iops.c              |  3 +--
 fs/xfs/xfs_itable.c            |  2 +-
 fs/xfs/xfs_qm.c                | 10 +++++-----
 fs/xfs/xfs_quotaops.c          |  2 +-
 15 files changed, 33 insertions(+), 34 deletions(-)

diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
index 56d78f8ba55eb6..54f3015f08285a 100644
--- a/fs/xfs/libxfs/xfs_bmap.c
+++ b/fs/xfs/libxfs/xfs_bmap.c
@@ -623,7 +623,7 @@ xfs_bmap_btree_to_extents(
 		return error;
 	xfs_rmap_ino_bmbt_owner(&oinfo, ip->i_ino, whichfork);
 	xfs_bmap_add_free(cur->bc_tp, cbno, 1, &oinfo);
-	ip->i_d.di_nblocks--;
+	ip->i_nblocks--;
 	xfs_trans_mod_dquot_byino(tp, ip, XFS_TRANS_DQ_BCOUNT, -1L);
 	xfs_trans_binval(tp, cbp);
 	if (cur->bc_bufs[0] == cbp)
@@ -725,7 +725,7 @@ xfs_bmap_extents_to_btree(
 	       args.agno >= XFS_FSB_TO_AGNO(mp, tp->t_firstblock));
 	tp->t_firstblock = args.fsbno;
 	cur->bc_ino.allocated++;
-	ip->i_d.di_nblocks++;
+	ip->i_nblocks++;
 	xfs_trans_mod_dquot_byino(tp, ip, XFS_TRANS_DQ_BCOUNT, 1L);
 	error = xfs_trans_get_buf(tp, mp->m_ddev_targp,
 			XFS_FSB_TO_DADDR(mp, args.fsbno),
@@ -907,7 +907,7 @@ xfs_bmap_local_to_extents(
 	xfs_iext_insert(ip, &icur, &rec, 0);
 
 	ifp->if_nextents = 1;
-	ip->i_d.di_nblocks = 1;
+	ip->i_nblocks = 1;
 	xfs_trans_mod_dquot_byino(tp, ip,
 		XFS_TRANS_DQ_BCOUNT, 1L);
 	flags |= xfs_ilog_fext(whichfork);
@@ -3448,7 +3448,7 @@ xfs_bmap_btalloc_accounting(
 	}
 
 	/* data/attr fork only */
-	ap->ip->i_d.di_nblocks += args->len;
+	ap->ip->i_nblocks += args->len;
 	xfs_trans_log_inode(ap->tp, ap->ip, XFS_ILOG_CORE);
 	if (ap->wasdel) {
 		ap->ip->i_delayed_blks -= args->len;
@@ -4659,7 +4659,7 @@ xfs_bmapi_remap(
 		ASSERT(got.br_startoff - bno >= len);
 	}
 
-	ip->i_d.di_nblocks += len;
+	ip->i_nblocks += len;
 	xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
 
 	if (ifp->if_flags & XFS_IFBROOT) {
@@ -5225,7 +5225,7 @@ xfs_bmap_del_extent_real(
 	 * Adjust inode # blocks in the file.
 	 */
 	if (nblks)
-		ip->i_d.di_nblocks -= nblks;
+		ip->i_nblocks -= nblks;
 	/*
 	 * Adjust quota data.
 	 */
diff --git a/fs/xfs/libxfs/xfs_bmap_btree.c b/fs/xfs/libxfs/xfs_bmap_btree.c
index d9c63f17d2decd..9ad4c6a1eec518 100644
--- a/fs/xfs/libxfs/xfs_bmap_btree.c
+++ b/fs/xfs/libxfs/xfs_bmap_btree.c
@@ -260,7 +260,7 @@ xfs_bmbt_alloc_block(
 	ASSERT(args.len == 1);
 	cur->bc_tp->t_firstblock = args.fsbno;
 	cur->bc_ino.allocated++;
-	cur->bc_ino.ip->i_d.di_nblocks++;
+	cur->bc_ino.ip->i_nblocks++;
 	xfs_trans_log_inode(args.tp, cur->bc_ino.ip, XFS_ILOG_CORE);
 	xfs_trans_mod_dquot_byino(args.tp, cur->bc_ino.ip,
 			XFS_TRANS_DQ_BCOUNT, 1L);
@@ -287,7 +287,7 @@ xfs_bmbt_free_block(
 
 	xfs_rmap_ino_bmbt_owner(&oinfo, ip->i_ino, cur->bc_ino.whichfork);
 	xfs_bmap_add_free(cur->bc_tp, fsbno, 1, &oinfo);
-	ip->i_d.di_nblocks--;
+	ip->i_nblocks--;
 
 	xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
 	xfs_trans_mod_dquot_byino(tp, ip, XFS_TRANS_DQ_BCOUNT, -1L);
diff --git a/fs/xfs/libxfs/xfs_da_btree.c b/fs/xfs/libxfs/xfs_da_btree.c
index 897749c41f36eb..55fadffb8752d3 100644
--- a/fs/xfs/libxfs/xfs_da_btree.c
+++ b/fs/xfs/libxfs/xfs_da_btree.c
@@ -2139,7 +2139,7 @@ xfs_da_grow_inode_int(
 	struct xfs_trans	*tp = args->trans;
 	struct xfs_inode	*dp = args->dp;
 	int			w = args->whichfork;
-	xfs_rfsblock_t		nblks = dp->i_d.di_nblocks;
+	xfs_rfsblock_t		nblks = dp->i_nblocks;
 	struct xfs_bmbt_irec	map, *mapp;
 	int			nmap, error, got, i, mapi;
 
@@ -2205,7 +2205,7 @@ xfs_da_grow_inode_int(
 	}
 
 	/* account for newly allocated blocks in reserved blocks total */
-	args->total -= dp->i_d.di_nblocks - nblks;
+	args->total -= dp->i_nblocks - nblks;
 
 out_free_map:
 	if (mapp != &map)
diff --git a/fs/xfs/libxfs/xfs_inode_buf.c b/fs/xfs/libxfs/xfs_inode_buf.c
index c202de8bbdd427..d1a15778e86a38 100644
--- a/fs/xfs/libxfs/xfs_inode_buf.c
+++ b/fs/xfs/libxfs/xfs_inode_buf.c
@@ -242,7 +242,7 @@ xfs_inode_from_disk(
 	inode->i_ctime.tv_nsec = (int)be32_to_cpu(from->di_ctime.t_nsec);
 
 	ip->i_disk_size = be64_to_cpu(from->di_size);
-	to->di_nblocks = be64_to_cpu(from->di_nblocks);
+	ip->i_nblocks = be64_to_cpu(from->di_nblocks);
 	to->di_extsize = be32_to_cpu(from->di_extsize);
 	to->di_forkoff = from->di_forkoff;
 	to->di_dmevmask	= be32_to_cpu(from->di_dmevmask);
@@ -305,7 +305,7 @@ xfs_inode_to_disk(
 	to->di_mode = cpu_to_be16(inode->i_mode);
 
 	to->di_size = cpu_to_be64(ip->i_disk_size);
-	to->di_nblocks = cpu_to_be64(from->di_nblocks);
+	to->di_nblocks = cpu_to_be64(ip->i_nblocks);
 	to->di_extsize = cpu_to_be32(from->di_extsize);
 	to->di_nextents = cpu_to_be32(xfs_ifork_nextents(&ip->i_df));
 	to->di_anextents = cpu_to_be16(xfs_ifork_nextents(ip->i_afp));
diff --git a/fs/xfs/libxfs/xfs_inode_buf.h b/fs/xfs/libxfs/xfs_inode_buf.h
index f187127d50e010..a322e1adf0a348 100644
--- a/fs/xfs/libxfs/xfs_inode_buf.h
+++ b/fs/xfs/libxfs/xfs_inode_buf.h
@@ -17,7 +17,6 @@ struct xfs_dinode;
  */
 struct xfs_icdinode {
 	uint16_t	di_flushiter;	/* incremented on flush */
-	xfs_rfsblock_t	di_nblocks;	/* # of direct & btree blocks used */
 	xfs_extlen_t	di_extsize;	/* basic/minimum extent size for file */
 	uint8_t		di_forkoff;	/* attr fork offs, <<3 for 64b align */
 	uint32_t	di_dmevmask;	/* DMIG event mask */
diff --git a/fs/xfs/libxfs/xfs_inode_fork.c b/fs/xfs/libxfs/xfs_inode_fork.c
index d2029e12bda4de..391836dd4814e0 100644
--- a/fs/xfs/libxfs/xfs_inode_fork.c
+++ b/fs/xfs/libxfs/xfs_inode_fork.c
@@ -192,7 +192,7 @@ xfs_iformat_btree(
 		     nrecs == 0 ||
 		     XFS_BMDR_SPACE_CALC(nrecs) >
 					XFS_DFORK_SIZE(dip, mp, whichfork) ||
-		     ifp->if_nextents > ip->i_d.di_nblocks) ||
+		     ifp->if_nextents > ip->i_nblocks) ||
 		     level == 0 || level > XFS_BTREE_MAXLEVELS) {
 		xfs_warn(mp, "corrupt inode %Lu (btree).",
 					(unsigned long long) ip->i_ino);
diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c
index d199ecddc1ab19..5eba039d72fb83 100644
--- a/fs/xfs/xfs_bmap_util.c
+++ b/fs/xfs/xfs_bmap_util.c
@@ -154,7 +154,7 @@ xfs_bmap_rtalloc(
 		ap->blkno *= mp->m_sb.sb_rextsize;
 		ralen *= mp->m_sb.sb_rextsize;
 		ap->length = ralen;
-		ap->ip->i_d.di_nblocks += ralen;
+		ap->ip->i_nblocks += ralen;
 		xfs_trans_log_inode(ap->tp, ap->ip, XFS_ILOG_CORE);
 		if (ap->wasdel)
 			ap->ip->i_delayed_blks -= ralen;
@@ -1469,9 +1469,9 @@ xfs_swap_extent_forks(
 	/*
 	 * Fix the on-disk inode values
 	 */
-	tmp = (uint64_t)ip->i_d.di_nblocks;
-	ip->i_d.di_nblocks = tip->i_d.di_nblocks - taforkblks + aforkblks;
-	tip->i_d.di_nblocks = tmp + taforkblks - aforkblks;
+	tmp = (uint64_t)ip->i_nblocks;
+	ip->i_nblocks = tip->i_nblocks - taforkblks + aforkblks;
+	tip->i_nblocks = tmp + taforkblks - aforkblks;
 
 	/*
 	 * The extents in the source inode could still contain speculative
diff --git a/fs/xfs/xfs_icache.c b/fs/xfs/xfs_icache.c
index a3bbd6e4bb6fc8..ad01e694f3ab9b 100644
--- a/fs/xfs/xfs_icache.c
+++ b/fs/xfs/xfs_icache.c
@@ -66,7 +66,7 @@ xfs_inode_alloc(
 	memset(&ip->i_df, 0, sizeof(ip->i_df));
 	ip->i_flags = 0;
 	ip->i_delayed_blks = 0;
-	ip->i_d.di_nblocks = 0;
+	ip->i_nblocks = 0;
 	ip->i_d.di_forkoff = 0;
 	ip->i_sick = 0;
 	ip->i_checked = 0;
@@ -331,7 +331,7 @@ xfs_iget_check_free_state(
 			return -EFSCORRUPTED;
 		}
 
-		if (ip->i_d.di_nblocks != 0) {
+		if (ip->i_nblocks != 0) {
 			xfs_warn(ip->i_mount,
 "Corruption detected! Free inode 0x%llx has blocks allocated!",
 				ip->i_ino);
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index 723a911c8b6d81..19d132acc499cb 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -827,7 +827,7 @@ xfs_ialloc(
 
 	ip->i_disk_size = 0;
 	ip->i_df.if_nextents = 0;
-	ASSERT(ip->i_d.di_nblocks == 0);
+	ASSERT(ip->i_nblocks == 0);
 
 	tv = current_time(inode);
 	inode->i_mtime = tv;
@@ -2730,7 +2730,7 @@ xfs_ifree(
 	ASSERT(VFS_I(ip)->i_nlink == 0);
 	ASSERT(ip->i_df.if_nextents == 0);
 	ASSERT(ip->i_disk_size == 0 || !S_ISREG(VFS_I(ip)->i_mode));
-	ASSERT(ip->i_d.di_nblocks == 0);
+	ASSERT(ip->i_nblocks == 0);
 
 	/*
 	 * Pull the on-disk inode from the AGI unlinked list.
@@ -3747,13 +3747,13 @@ xfs_iflush_int(
 		}
 	}
 	if (XFS_TEST_ERROR(ip->i_df.if_nextents + xfs_ifork_nextents(ip->i_afp) >
-				ip->i_d.di_nblocks, mp, XFS_ERRTAG_IFLUSH_5)) {
+				ip->i_nblocks, mp, XFS_ERRTAG_IFLUSH_5)) {
 		xfs_alert_tag(mp, XFS_PTAG_IFLUSH,
 			"%s: detected corrupt incore inode %Lu, "
 			"total extents = %d, nblocks = %Ld, ptr "PTR_FMT,
 			__func__, ip->i_ino,
 			ip->i_df.if_nextents + xfs_ifork_nextents(ip->i_afp),
-			ip->i_d.di_nblocks, ip);
+			ip->i_nblocks, ip);
 		goto flush_out;
 	}
 	if (XFS_TEST_ERROR(ip->i_d.di_forkoff > mp->m_sb.sb_inodesize,
diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h
index 61c41395536f07..828f49f109475e 100644
--- a/fs/xfs/xfs_inode.h
+++ b/fs/xfs/xfs_inode.h
@@ -55,6 +55,7 @@ typedef struct xfs_inode {
 	unsigned long		i_flags;	/* see defined flags below */
 	uint64_t		i_delayed_blks;	/* count of delay alloc blks */
 	xfs_fsize_t		i_disk_size;	/* number of bytes in file */
+	xfs_rfsblock_t		i_nblocks;	/* # of direct & btree blocks */
 	uint32_t		i_projid;	/* owner's project id */
 
 	struct xfs_icdinode	i_d;		/* most of ondisk inode */
diff --git a/fs/xfs/xfs_inode_item.c b/fs/xfs/xfs_inode_item.c
index 179f1c2de6bd0f..0980fa43472cf8 100644
--- a/fs/xfs/xfs_inode_item.c
+++ b/fs/xfs/xfs_inode_item.c
@@ -324,7 +324,7 @@ xfs_inode_to_log_dinode(
 	to->di_mode = inode->i_mode;
 
 	to->di_size = ip->i_disk_size;
-	to->di_nblocks = from->di_nblocks;
+	to->di_nblocks = ip->i_nblocks;
 	to->di_extsize = from->di_extsize;
 	to->di_nextents = xfs_ifork_nextents(&ip->i_df);
 	to->di_anextents = xfs_ifork_nextents(ip->i_afp);
diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
index 1abee83d49cff9..78159c57d82828 100644
--- a/fs/xfs/xfs_iops.c
+++ b/fs/xfs/xfs_iops.c
@@ -554,8 +554,7 @@ xfs_vn_getattr(
 	stat->atime = inode->i_atime;
 	stat->mtime = inode->i_mtime;
 	stat->ctime = inode->i_ctime;
-	stat->blocks =
-		XFS_FSB_TO_BB(mp, ip->i_d.di_nblocks + ip->i_delayed_blks);
+	stat->blocks = XFS_FSB_TO_BB(mp, ip->i_nblocks + ip->i_delayed_blks);
 
 	if (xfs_sb_version_has_v3inode(&mp->m_sb)) {
 		if (request_mask & STATX_BTIME) {
diff --git a/fs/xfs/xfs_itable.c b/fs/xfs/xfs_itable.c
index 9f92514301b334..7af144500bbfdb 100644
--- a/fs/xfs/xfs_itable.c
+++ b/fs/xfs/xfs_itable.c
@@ -130,7 +130,7 @@ xfs_bulkstat_one_int(
 	case XFS_DINODE_FMT_BTREE:
 		buf->bs_rdev = 0;
 		buf->bs_blksize = mp->m_sb.sb_blocksize;
-		buf->bs_blocks = dic->di_nblocks + ip->i_delayed_blks;
+		buf->bs_blocks = ip->i_nblocks + ip->i_delayed_blks;
 		break;
 	}
 	xfs_iunlock(ip, XFS_ILOCK_SHARED);
diff --git a/fs/xfs/xfs_qm.c b/fs/xfs/xfs_qm.c
index ea22dcf868b474..3af3b5f5d4f2ad 100644
--- a/fs/xfs/xfs_qm.c
+++ b/fs/xfs/xfs_qm.c
@@ -989,7 +989,7 @@ xfs_qm_reset_dqcounts_buf(
 	 * trans_reserve. But, this gets called during quotacheck, and that
 	 * happens only at mount time which is single threaded.
 	 */
-	if (qip->i_d.di_nblocks == 0)
+	if (qip->i_nblocks == 0)
 		return 0;
 
 	map = kmem_alloc(XFS_DQITER_MAP_SIZE * sizeof(*map), 0);
@@ -1171,7 +1171,7 @@ xfs_qm_dqusage_adjust(
 		xfs_bmap_count_leaves(ifp, &rtblks);
 	}
 
-	nblks = (xfs_qcnt_t)ip->i_d.di_nblocks - rtblks;
+	nblks = (xfs_qcnt_t)ip->i_nblocks - rtblks;
 
 	/*
 	 * Add the (disk blocks and inode) resources occupied by this
@@ -1774,11 +1774,11 @@ xfs_qm_vop_chown(
 	ASSERT(prevdq);
 	ASSERT(prevdq != newdq);
 
-	xfs_trans_mod_dquot(tp, prevdq, bfield, -(ip->i_d.di_nblocks));
+	xfs_trans_mod_dquot(tp, prevdq, bfield, -(ip->i_nblocks));
 	xfs_trans_mod_dquot(tp, prevdq, XFS_TRANS_DQ_ICOUNT, -1);
 
 	/* the sparkling new dquot */
-	xfs_trans_mod_dquot(tp, newdq, bfield, ip->i_d.di_nblocks);
+	xfs_trans_mod_dquot(tp, newdq, bfield, ip->i_nblocks);
 	xfs_trans_mod_dquot(tp, newdq, XFS_TRANS_DQ_ICOUNT, 1);
 
 	/*
@@ -1854,7 +1854,7 @@ xfs_qm_vop_chown_reserve(
 
 	error = xfs_trans_reserve_quota_bydquots(tp, ip->i_mount,
 				udq_delblks, gdq_delblks, pdq_delblks,
-				ip->i_d.di_nblocks, 1, flags | blkflags);
+				ip->i_nblocks, 1, flags | blkflags);
 	if (error)
 		return error;
 
diff --git a/fs/xfs/xfs_quotaops.c b/fs/xfs/xfs_quotaops.c
index bf809b77a31606..09a5290ad2bd1b 100644
--- a/fs/xfs/xfs_quotaops.c
+++ b/fs/xfs/xfs_quotaops.c
@@ -35,7 +35,7 @@ xfs_qm_fill_state(
 		tempqip = true;
 	}
 	tstate->flags |= QCI_SYSFILE;
-	tstate->blocks = ip->i_d.di_nblocks;
+	tstate->blocks = ip->i_nblocks;
 	tstate->nextents = ip->i_df.if_nextents;
 	tstate->spc_timelimit = (u32)defq->btimelimit;
 	tstate->ino_timelimit = (u32)defq->itimelimit;
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH 05/15] xfs: move the di_extsize field to struct xfs_inode
  2020-06-20  7:10 xfs inode structure cleanups v2 Christoph Hellwig
                   ` (3 preceding siblings ...)
  2020-06-20  7:10 ` [PATCH 04/15] xfs: move the di_nblocks " Christoph Hellwig
@ 2020-06-20  7:10 ` Christoph Hellwig
  2020-06-22  9:36   ` Chandan Babu R
  2020-06-30 17:47   ` Darrick J. Wong
  2020-06-20  7:10 ` [PATCH 06/15] xfs: move the di_cowextsize " Christoph Hellwig
                   ` (10 subsequent siblings)
  15 siblings, 2 replies; 52+ messages in thread
From: Christoph Hellwig @ 2020-06-20  7:10 UTC (permalink / raw)
  To: linux-xfs

In preparation of removing the historic icinode struct, move the extsize
field into the containing xfs_inode structure.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/xfs/libxfs/xfs_bmap.c      |  2 +-
 fs/xfs/libxfs/xfs_inode_buf.c |  4 ++--
 fs/xfs/libxfs/xfs_inode_buf.h |  1 -
 fs/xfs/xfs_inode.c            | 10 +++++-----
 fs/xfs/xfs_inode.h            |  1 +
 fs/xfs/xfs_inode_item.c       |  2 +-
 fs/xfs/xfs_ioctl.c            | 10 +++++-----
 fs/xfs/xfs_itable.c           |  2 +-
 8 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
index 54f3015f08285a..692159357ed8e5 100644
--- a/fs/xfs/libxfs/xfs_bmap.c
+++ b/fs/xfs/libxfs/xfs_bmap.c
@@ -2942,7 +2942,7 @@ xfs_bmap_add_extent_hole_real(
  */
 
 /*
- * Adjust the size of the new extent based on di_extsize and rt extsize.
+ * Adjust the size of the new extent based on i_extsize and rt extsize.
  */
 int
 xfs_bmap_extsize_align(
diff --git a/fs/xfs/libxfs/xfs_inode_buf.c b/fs/xfs/libxfs/xfs_inode_buf.c
index d1a15778e86a38..e51b15c44bb3e1 100644
--- a/fs/xfs/libxfs/xfs_inode_buf.c
+++ b/fs/xfs/libxfs/xfs_inode_buf.c
@@ -243,7 +243,7 @@ xfs_inode_from_disk(
 
 	ip->i_disk_size = be64_to_cpu(from->di_size);
 	ip->i_nblocks = be64_to_cpu(from->di_nblocks);
-	to->di_extsize = be32_to_cpu(from->di_extsize);
+	ip->i_extsize = be32_to_cpu(from->di_extsize);
 	to->di_forkoff = from->di_forkoff;
 	to->di_dmevmask	= be32_to_cpu(from->di_dmevmask);
 	to->di_dmstate	= be16_to_cpu(from->di_dmstate);
@@ -306,7 +306,7 @@ xfs_inode_to_disk(
 
 	to->di_size = cpu_to_be64(ip->i_disk_size);
 	to->di_nblocks = cpu_to_be64(ip->i_nblocks);
-	to->di_extsize = cpu_to_be32(from->di_extsize);
+	to->di_extsize = cpu_to_be32(ip->i_extsize);
 	to->di_nextents = cpu_to_be32(xfs_ifork_nextents(&ip->i_df));
 	to->di_anextents = cpu_to_be16(xfs_ifork_nextents(ip->i_afp));
 	to->di_forkoff = from->di_forkoff;
diff --git a/fs/xfs/libxfs/xfs_inode_buf.h b/fs/xfs/libxfs/xfs_inode_buf.h
index a322e1adf0a348..d420ea835c8390 100644
--- a/fs/xfs/libxfs/xfs_inode_buf.h
+++ b/fs/xfs/libxfs/xfs_inode_buf.h
@@ -17,7 +17,6 @@ struct xfs_dinode;
  */
 struct xfs_icdinode {
 	uint16_t	di_flushiter;	/* incremented on flush */
-	xfs_extlen_t	di_extsize;	/* basic/minimum extent size for file */
 	uint8_t		di_forkoff;	/* attr fork offs, <<3 for 64b align */
 	uint32_t	di_dmevmask;	/* DMIG event mask */
 	uint16_t	di_dmstate;	/* DMIG state info */
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index 19d132acc499cb..6d1891f902aaa9 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -61,8 +61,8 @@ xfs_get_extsz_hint(
 	 */
 	if (xfs_is_always_cow_inode(ip))
 		return 0;
-	if ((ip->i_d.di_flags & XFS_DIFLAG_EXTSIZE) && ip->i_d.di_extsize)
-		return ip->i_d.di_extsize;
+	if ((ip->i_d.di_flags & XFS_DIFLAG_EXTSIZE) && ip->i_extsize)
+		return ip->i_extsize;
 	if (XFS_IS_REALTIME_INODE(ip))
 		return ip->i_mount->m_sb.sb_rextsize;
 	return 0;
@@ -834,7 +834,7 @@ xfs_ialloc(
 	inode->i_atime = tv;
 	inode->i_ctime = tv;
 
-	ip->i_d.di_extsize = 0;
+	ip->i_extsize = 0;
 	ip->i_d.di_dmevmask = 0;
 	ip->i_d.di_dmstate = 0;
 	ip->i_d.di_flags = 0;
@@ -866,7 +866,7 @@ xfs_ialloc(
 					di_flags |= XFS_DIFLAG_RTINHERIT;
 				if (pip->i_d.di_flags & XFS_DIFLAG_EXTSZINHERIT) {
 					di_flags |= XFS_DIFLAG_EXTSZINHERIT;
-					ip->i_d.di_extsize = pip->i_d.di_extsize;
+					ip->i_extsize = pip->i_extsize;
 				}
 				if (pip->i_d.di_flags & XFS_DIFLAG_PROJINHERIT)
 					di_flags |= XFS_DIFLAG_PROJINHERIT;
@@ -875,7 +875,7 @@ xfs_ialloc(
 					di_flags |= XFS_DIFLAG_REALTIME;
 				if (pip->i_d.di_flags & XFS_DIFLAG_EXTSZINHERIT) {
 					di_flags |= XFS_DIFLAG_EXTSIZE;
-					ip->i_d.di_extsize = pip->i_d.di_extsize;
+					ip->i_extsize = pip->i_extsize;
 				}
 			}
 			if ((pip->i_d.di_flags & XFS_DIFLAG_NOATIME) &&
diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h
index 828f49f109475e..af90c6f745549b 100644
--- a/fs/xfs/xfs_inode.h
+++ b/fs/xfs/xfs_inode.h
@@ -57,6 +57,7 @@ typedef struct xfs_inode {
 	xfs_fsize_t		i_disk_size;	/* number of bytes in file */
 	xfs_rfsblock_t		i_nblocks;	/* # of direct & btree blocks */
 	uint32_t		i_projid;	/* owner's project id */
+	xfs_extlen_t		i_extsize;	/* basic/minimum extent size */
 
 	struct xfs_icdinode	i_d;		/* most of ondisk inode */
 
diff --git a/fs/xfs/xfs_inode_item.c b/fs/xfs/xfs_inode_item.c
index 0980fa43472cf8..8b8c99809f273e 100644
--- a/fs/xfs/xfs_inode_item.c
+++ b/fs/xfs/xfs_inode_item.c
@@ -325,7 +325,7 @@ xfs_inode_to_log_dinode(
 
 	to->di_size = ip->i_disk_size;
 	to->di_nblocks = ip->i_nblocks;
-	to->di_extsize = from->di_extsize;
+	to->di_extsize = ip->i_extsize;
 	to->di_nextents = xfs_ifork_nextents(&ip->i_df);
 	to->di_anextents = xfs_ifork_nextents(ip->i_afp);
 	to->di_forkoff = from->di_forkoff;
diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
index d93f4fc40fd99e..efe3b5bc1178dc 100644
--- a/fs/xfs/xfs_ioctl.c
+++ b/fs/xfs/xfs_ioctl.c
@@ -1107,7 +1107,7 @@ xfs_fill_fsxattr(
 	struct xfs_ifork	*ifp = attr ? ip->i_afp : &ip->i_df;
 
 	simple_fill_fsxattr(fa, xfs_ip2xflags(ip));
-	fa->fsx_extsize = ip->i_d.di_extsize << ip->i_mount->m_sb.sb_blocklog;
+	fa->fsx_extsize = ip->i_extsize << ip->i_mount->m_sb.sb_blocklog;
 	fa->fsx_cowextsize = ip->i_d.di_cowextsize <<
 			ip->i_mount->m_sb.sb_blocklog;
 	fa->fsx_projid = ip->i_projid;
@@ -1209,7 +1209,7 @@ xfs_ioctl_setattr_xflags(
 	/* If realtime flag is set then must have realtime device */
 	if (fa->fsx_xflags & FS_XFLAG_REALTIME) {
 		if (mp->m_sb.sb_rblocks == 0 || mp->m_sb.sb_rextsize == 0 ||
-		    (ip->i_d.di_extsize % mp->m_sb.sb_rextsize))
+		    (ip->i_extsize % mp->m_sb.sb_rextsize))
 			return -EINVAL;
 	}
 
@@ -1381,7 +1381,7 @@ xfs_ioctl_setattr_check_extsize(
 	xfs_fsblock_t		extsize_fsb;
 
 	if (S_ISREG(VFS_I(ip)->i_mode) && ip->i_df.if_nextents &&
-	    ((ip->i_d.di_extsize << mp->m_sb.sb_blocklog) != fa->fsx_extsize))
+	    ((ip->i_extsize << mp->m_sb.sb_blocklog) != fa->fsx_extsize))
 		return -EINVAL;
 
 	if (fa->fsx_extsize == 0)
@@ -1569,9 +1569,9 @@ xfs_ioctl_setattr(
 	 * are set on the inode then unconditionally clear the extent size hint.
 	 */
 	if (ip->i_d.di_flags & (XFS_DIFLAG_EXTSIZE | XFS_DIFLAG_EXTSZINHERIT))
-		ip->i_d.di_extsize = fa->fsx_extsize >> mp->m_sb.sb_blocklog;
+		ip->i_extsize = fa->fsx_extsize >> mp->m_sb.sb_blocklog;
 	else
-		ip->i_d.di_extsize = 0;
+		ip->i_extsize = 0;
 	if (xfs_sb_version_has_v3inode(&mp->m_sb) &&
 	    (ip->i_d.di_flags2 & XFS_DIFLAG2_COWEXTSIZE))
 		ip->i_d.di_cowextsize = fa->fsx_cowextsize >>
diff --git a/fs/xfs/xfs_itable.c b/fs/xfs/xfs_itable.c
index 7af144500bbfdb..b0f0c19fd7822e 100644
--- a/fs/xfs/xfs_itable.c
+++ b/fs/xfs/xfs_itable.c
@@ -103,7 +103,7 @@ xfs_bulkstat_one_int(
 	buf->bs_mode = inode->i_mode;
 
 	buf->bs_xflags = xfs_ip2xflags(ip);
-	buf->bs_extsize_blks = dic->di_extsize;
+	buf->bs_extsize_blks = ip->i_extsize;
 	buf->bs_extents = xfs_ifork_nextents(&ip->i_df);
 	xfs_bulkstat_health(ip, buf);
 	buf->bs_aextents = xfs_ifork_nextents(ip->i_afp);
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH 06/15] xfs: move the di_cowextsize field to struct xfs_inode
  2020-06-20  7:10 xfs inode structure cleanups v2 Christoph Hellwig
                   ` (4 preceding siblings ...)
  2020-06-20  7:10 ` [PATCH 05/15] xfs: move the di_extsize " Christoph Hellwig
@ 2020-06-20  7:10 ` Christoph Hellwig
  2020-06-22  9:47   ` Chandan Babu R
  2020-06-30 17:48   ` Darrick J. Wong
  2020-06-20  7:10 ` [PATCH 07/15] xfs: move the di_flushiter " Christoph Hellwig
                   ` (9 subsequent siblings)
  15 siblings, 2 replies; 52+ messages in thread
From: Christoph Hellwig @ 2020-06-20  7:10 UTC (permalink / raw)
  To: linux-xfs

In preparation of removing the historic icinode struct, move the
cowextsize field into the containing xfs_inode structure.  Also
switch to use the xfs_extlen_t instead of a uint32_t.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/xfs/libxfs/xfs_inode_buf.c | 4 ++--
 fs/xfs/libxfs/xfs_inode_buf.h | 1 -
 fs/xfs/xfs_file.c             | 2 +-
 fs/xfs/xfs_inode.c            | 6 +++---
 fs/xfs/xfs_inode.h            | 1 +
 fs/xfs/xfs_inode_item.c       | 2 +-
 fs/xfs/xfs_ioctl.c            | 8 +++-----
 fs/xfs/xfs_itable.c           | 2 +-
 fs/xfs/xfs_reflink.c          | 2 +-
 9 files changed, 13 insertions(+), 15 deletions(-)

diff --git a/fs/xfs/libxfs/xfs_inode_buf.c b/fs/xfs/libxfs/xfs_inode_buf.c
index e51b15c44bb3e1..860e35611e001a 100644
--- a/fs/xfs/libxfs/xfs_inode_buf.c
+++ b/fs/xfs/libxfs/xfs_inode_buf.c
@@ -255,7 +255,7 @@ xfs_inode_from_disk(
 		to->di_crtime.tv_sec = be32_to_cpu(from->di_crtime.t_sec);
 		to->di_crtime.tv_nsec = be32_to_cpu(from->di_crtime.t_nsec);
 		to->di_flags2 = be64_to_cpu(from->di_flags2);
-		to->di_cowextsize = be32_to_cpu(from->di_cowextsize);
+		ip->i_cowextsize = be32_to_cpu(from->di_cowextsize);
 	}
 
 	error = xfs_iformat_data_fork(ip, from);
@@ -321,7 +321,7 @@ xfs_inode_to_disk(
 		to->di_crtime.t_sec = cpu_to_be32(from->di_crtime.tv_sec);
 		to->di_crtime.t_nsec = cpu_to_be32(from->di_crtime.tv_nsec);
 		to->di_flags2 = cpu_to_be64(from->di_flags2);
-		to->di_cowextsize = cpu_to_be32(from->di_cowextsize);
+		to->di_cowextsize = cpu_to_be32(ip->i_cowextsize);
 		to->di_ino = cpu_to_be64(ip->i_ino);
 		to->di_lsn = cpu_to_be64(lsn);
 		memset(to->di_pad2, 0, sizeof(to->di_pad2));
diff --git a/fs/xfs/libxfs/xfs_inode_buf.h b/fs/xfs/libxfs/xfs_inode_buf.h
index d420ea835c8390..663a97fa78f05f 100644
--- a/fs/xfs/libxfs/xfs_inode_buf.h
+++ b/fs/xfs/libxfs/xfs_inode_buf.h
@@ -23,7 +23,6 @@ struct xfs_icdinode {
 	uint16_t	di_flags;	/* random flags, XFS_DIFLAG_... */
 
 	uint64_t	di_flags2;	/* more random flags */
-	uint32_t	di_cowextsize;	/* basic cow extent size for file */
 
 	struct timespec64 di_crtime;	/* time created */
 };
diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c
index 14b533a8ce8e6a..b0384306d6622f 100644
--- a/fs/xfs/xfs_file.c
+++ b/fs/xfs/xfs_file.c
@@ -1055,7 +1055,7 @@ xfs_file_remap_range(
 	    (src->i_d.di_flags2 & XFS_DIFLAG2_COWEXTSIZE) &&
 	    pos_out == 0 && len >= i_size_read(inode_out) &&
 	    !(dest->i_d.di_flags2 & XFS_DIFLAG2_COWEXTSIZE))
-		cowextsize = src->i_d.di_cowextsize;
+		cowextsize = src->i_cowextsize;
 
 	ret = xfs_reflink_update_dest(dest, pos_out + len, cowextsize,
 			remap_flags);
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index 6d1891f902aaa9..f1893824cd4e2f 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -82,7 +82,7 @@ xfs_get_cowextsz_hint(
 
 	a = 0;
 	if (ip->i_d.di_flags2 & XFS_DIFLAG2_COWEXTSIZE)
-		a = ip->i_d.di_cowextsize;
+		a = ip->i_cowextsize;
 	b = xfs_get_extsz_hint(ip);
 
 	a = max(a, b);
@@ -842,7 +842,7 @@ xfs_ialloc(
 	if (xfs_sb_version_has_v3inode(&mp->m_sb)) {
 		inode_set_iversion(inode, 1);
 		ip->i_d.di_flags2 = 0;
-		ip->i_d.di_cowextsize = 0;
+		ip->i_cowextsize = 0;
 		ip->i_d.di_crtime = tv;
 	}
 
@@ -901,7 +901,7 @@ xfs_ialloc(
 		if (pip && (pip->i_d.di_flags2 & XFS_DIFLAG2_ANY)) {
 			if (pip->i_d.di_flags2 & XFS_DIFLAG2_COWEXTSIZE) {
 				ip->i_d.di_flags2 |= XFS_DIFLAG2_COWEXTSIZE;
-				ip->i_d.di_cowextsize = pip->i_d.di_cowextsize;
+				ip->i_cowextsize = pip->i_cowextsize;
 			}
 			if (pip->i_d.di_flags2 & XFS_DIFLAG2_DAX)
 				ip->i_d.di_flags2 |= XFS_DIFLAG2_DAX;
diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h
index af90c6f745549b..2cdb7b6b298852 100644
--- a/fs/xfs/xfs_inode.h
+++ b/fs/xfs/xfs_inode.h
@@ -58,6 +58,7 @@ typedef struct xfs_inode {
 	xfs_rfsblock_t		i_nblocks;	/* # of direct & btree blocks */
 	uint32_t		i_projid;	/* owner's project id */
 	xfs_extlen_t		i_extsize;	/* basic/minimum extent size */
+	xfs_extlen_t		i_cowextsize;	/* basic cow extent size */
 
 	struct xfs_icdinode	i_d;		/* most of ondisk inode */
 
diff --git a/fs/xfs/xfs_inode_item.c b/fs/xfs/xfs_inode_item.c
index 8b8c99809f273e..ab0d8cf8ceb6ab 100644
--- a/fs/xfs/xfs_inode_item.c
+++ b/fs/xfs/xfs_inode_item.c
@@ -343,7 +343,7 @@ xfs_inode_to_log_dinode(
 		to->di_crtime.t_sec = from->di_crtime.tv_sec;
 		to->di_crtime.t_nsec = from->di_crtime.tv_nsec;
 		to->di_flags2 = from->di_flags2;
-		to->di_cowextsize = from->di_cowextsize;
+		to->di_cowextsize = ip->i_cowextsize;
 		to->di_ino = ip->i_ino;
 		to->di_lsn = lsn;
 		memset(to->di_pad2, 0, sizeof(to->di_pad2));
diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
index efe3b5bc1178dc..a1937900ad84be 100644
--- a/fs/xfs/xfs_ioctl.c
+++ b/fs/xfs/xfs_ioctl.c
@@ -1108,8 +1108,7 @@ xfs_fill_fsxattr(
 
 	simple_fill_fsxattr(fa, xfs_ip2xflags(ip));
 	fa->fsx_extsize = ip->i_extsize << ip->i_mount->m_sb.sb_blocklog;
-	fa->fsx_cowextsize = ip->i_d.di_cowextsize <<
-			ip->i_mount->m_sb.sb_blocklog;
+	fa->fsx_cowextsize = ip->i_cowextsize << ip->i_mount->m_sb.sb_blocklog;
 	fa->fsx_projid = ip->i_projid;
 	if (ifp && (ifp->if_flags & XFS_IFEXTENTS))
 		fa->fsx_nextents = xfs_iext_count(ifp);
@@ -1574,10 +1573,9 @@ xfs_ioctl_setattr(
 		ip->i_extsize = 0;
 	if (xfs_sb_version_has_v3inode(&mp->m_sb) &&
 	    (ip->i_d.di_flags2 & XFS_DIFLAG2_COWEXTSIZE))
-		ip->i_d.di_cowextsize = fa->fsx_cowextsize >>
-				mp->m_sb.sb_blocklog;
+		ip->i_cowextsize = fa->fsx_cowextsize >> mp->m_sb.sb_blocklog;
 	else
-		ip->i_d.di_cowextsize = 0;
+		ip->i_cowextsize = 0;
 
 	code = xfs_trans_commit(tp);
 
diff --git a/fs/xfs/xfs_itable.c b/fs/xfs/xfs_itable.c
index b0f0c19fd7822e..7937af9f2ea779 100644
--- a/fs/xfs/xfs_itable.c
+++ b/fs/xfs/xfs_itable.c
@@ -112,7 +112,7 @@ xfs_bulkstat_one_int(
 
 	if (xfs_sb_version_has_v3inode(&mp->m_sb)) {
 		if (dic->di_flags2 & XFS_DIFLAG2_COWEXTSIZE)
-			buf->bs_cowextsize_blks = dic->di_cowextsize;
+			buf->bs_cowextsize_blks = ip->i_cowextsize;
 	}
 
 	switch (ip->i_df.if_format) {
diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c
index 8598896156e29a..0e07fa7e43117e 100644
--- a/fs/xfs/xfs_reflink.c
+++ b/fs/xfs/xfs_reflink.c
@@ -942,7 +942,7 @@ xfs_reflink_update_dest(
 	}
 
 	if (cowextsize) {
-		dest->i_d.di_cowextsize = cowextsize;
+		dest->i_cowextsize = cowextsize;
 		dest->i_d.di_flags2 |= XFS_DIFLAG2_COWEXTSIZE;
 	}
 
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH 07/15] xfs: move the di_flushiter field to struct xfs_inode
  2020-06-20  7:10 xfs inode structure cleanups v2 Christoph Hellwig
                   ` (5 preceding siblings ...)
  2020-06-20  7:10 ` [PATCH 06/15] xfs: move the di_cowextsize " Christoph Hellwig
@ 2020-06-20  7:10 ` Christoph Hellwig
  2020-06-22  9:49   ` Chandan Babu R
  2020-06-30 17:48   ` Darrick J. Wong
  2020-06-20  7:10 ` [PATCH 08/15] xfs: use a union for i_cowextsize and i_flushiter Christoph Hellwig
                   ` (8 subsequent siblings)
  15 siblings, 2 replies; 52+ messages in thread
From: Christoph Hellwig @ 2020-06-20  7:10 UTC (permalink / raw)
  To: linux-xfs

In preparation of removing the historic icinode struct, move the
flushiter field into the containing xfs_inode structure.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/xfs/libxfs/xfs_inode_buf.c |  4 ++--
 fs/xfs/libxfs/xfs_inode_buf.h |  1 -
 fs/xfs/xfs_icache.c           |  2 +-
 fs/xfs/xfs_inode.c            | 19 +++++++++----------
 fs/xfs/xfs_inode.h            |  1 +
 fs/xfs/xfs_inode_item.c       |  2 +-
 6 files changed, 14 insertions(+), 15 deletions(-)

diff --git a/fs/xfs/libxfs/xfs_inode_buf.c b/fs/xfs/libxfs/xfs_inode_buf.c
index 860e35611e001a..03bd7cdd0ddc81 100644
--- a/fs/xfs/libxfs/xfs_inode_buf.c
+++ b/fs/xfs/libxfs/xfs_inode_buf.c
@@ -205,7 +205,7 @@ xfs_inode_from_disk(
 	 * inode. If the inode is unused, mode is zero and we shouldn't mess
 	 * with the unitialized part of it.
 	 */
-	to->di_flushiter = be16_to_cpu(from->di_flushiter);
+	ip->i_flushiter = be16_to_cpu(from->di_flushiter);
 	inode->i_generation = be32_to_cpu(from->di_gen);
 	inode->i_mode = be16_to_cpu(from->di_mode);
 	if (!inode->i_mode)
@@ -329,7 +329,7 @@ xfs_inode_to_disk(
 		to->di_flushiter = 0;
 	} else {
 		to->di_version = 2;
-		to->di_flushiter = cpu_to_be16(from->di_flushiter);
+		to->di_flushiter = cpu_to_be16(ip->i_flushiter);
 	}
 }
 
diff --git a/fs/xfs/libxfs/xfs_inode_buf.h b/fs/xfs/libxfs/xfs_inode_buf.h
index 663a97fa78f05f..8cc96f2766ff4f 100644
--- a/fs/xfs/libxfs/xfs_inode_buf.h
+++ b/fs/xfs/libxfs/xfs_inode_buf.h
@@ -16,7 +16,6 @@ struct xfs_dinode;
  * format specific structures at the appropriate time.
  */
 struct xfs_icdinode {
-	uint16_t	di_flushiter;	/* incremented on flush */
 	uint8_t		di_forkoff;	/* attr fork offs, <<3 for 64b align */
 	uint32_t	di_dmevmask;	/* DMIG event mask */
 	uint16_t	di_dmstate;	/* DMIG state info */
diff --git a/fs/xfs/xfs_icache.c b/fs/xfs/xfs_icache.c
index ad01e694f3ab9b..e6b40f7035aa5a 100644
--- a/fs/xfs/xfs_icache.c
+++ b/fs/xfs/xfs_icache.c
@@ -521,7 +521,7 @@ xfs_iget_cache_miss(
 	 * simply build the new inode core with a random generation number.
 	 *
 	 * For version 4 (and older) superblocks, log recovery is dependent on
-	 * the di_flushiter field being initialised from the current on-disk
+	 * the i_flushiter field being initialised from the current on-disk
 	 * value and hence we must also read the inode off disk even when
 	 * initializing new inodes.
 	 */
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index f1893824cd4e2f..5e0336e0dbae44 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -3765,16 +3765,15 @@ xfs_iflush_int(
 	}
 
 	/*
-	 * Inode item log recovery for v2 inodes are dependent on the
-	 * di_flushiter count for correct sequencing. We bump the flush
-	 * iteration count so we can detect flushes which postdate a log record
-	 * during recovery. This is redundant as we now log every change and
-	 * hence this can't happen but we need to still do it to ensure
-	 * backwards compatibility with old kernels that predate logging all
-	 * inode changes.
+	 * Inode item log recovery for v2 inodes are dependent on the flushiter
+	 * count for correct sequencing.  We bump the flush iteration count so
+	 * we can detect flushes which postdate a log record during recovery.
+	 * This is redundant as we now log every change and hence this can't
+	 * happen but we need to still do it to ensure backwards compatibility
+	 * with old kernels that predate logging all inode changes.
 	 */
 	if (!xfs_sb_version_has_v3inode(&mp->m_sb))
-		ip->i_d.di_flushiter++;
+		ip->i_flushiter++;
 
 	/*
 	 * If there are inline format data / attr forks attached to this inode,
@@ -3795,8 +3794,8 @@ xfs_iflush_int(
 	xfs_inode_to_disk(ip, dip, iip->ili_item.li_lsn);
 
 	/* Wrap, we never let the log put out DI_MAX_FLUSH */
-	if (ip->i_d.di_flushiter == DI_MAX_FLUSH)
-		ip->i_d.di_flushiter = 0;
+	if (ip->i_flushiter == DI_MAX_FLUSH)
+		ip->i_flushiter = 0;
 
 	xfs_iflush_fork(ip, dip, iip, XFS_DATA_FORK);
 	if (XFS_IFORK_Q(ip))
diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h
index 2cdb7b6b298852..581618ea1156da 100644
--- a/fs/xfs/xfs_inode.h
+++ b/fs/xfs/xfs_inode.h
@@ -59,6 +59,7 @@ typedef struct xfs_inode {
 	uint32_t		i_projid;	/* owner's project id */
 	xfs_extlen_t		i_extsize;	/* basic/minimum extent size */
 	xfs_extlen_t		i_cowextsize;	/* basic cow extent size */
+	uint16_t		i_flushiter;	/* incremented on flush */
 
 	struct xfs_icdinode	i_d;		/* most of ondisk inode */
 
diff --git a/fs/xfs/xfs_inode_item.c b/fs/xfs/xfs_inode_item.c
index ab0d8cf8ceb6ab..8357fe37d3eb8a 100644
--- a/fs/xfs/xfs_inode_item.c
+++ b/fs/xfs/xfs_inode_item.c
@@ -351,7 +351,7 @@ xfs_inode_to_log_dinode(
 		to->di_flushiter = 0;
 	} else {
 		to->di_version = 2;
-		to->di_flushiter = from->di_flushiter;
+		to->di_flushiter = ip->i_flushiter;
 	}
 }
 
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH 08/15] xfs: use a union for i_cowextsize and i_flushiter
  2020-06-20  7:10 xfs inode structure cleanups v2 Christoph Hellwig
                   ` (6 preceding siblings ...)
  2020-06-20  7:10 ` [PATCH 07/15] xfs: move the di_flushiter " Christoph Hellwig
@ 2020-06-20  7:10 ` Christoph Hellwig
  2020-06-22 10:53   ` Chandan Babu R
  2020-06-30 17:51   ` Darrick J. Wong
  2020-06-20  7:10 ` [PATCH 09/15] xfs: cleanup xfs_fill_fsxattr Christoph Hellwig
                   ` (7 subsequent siblings)
  15 siblings, 2 replies; 52+ messages in thread
From: Christoph Hellwig @ 2020-06-20  7:10 UTC (permalink / raw)
  To: linux-xfs

The i_cowextsize field is only used for v3 inodes, and the i_flushiter
field is only used for v1/v2 inodes.  Use a union to pack the inode a
littler better after adding a few missing guards around their usage.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/xfs/libxfs/xfs_inode_buf.c | 3 ++-
 fs/xfs/xfs_inode.c            | 6 ++++--
 fs/xfs/xfs_inode.h            | 7 +++++--
 fs/xfs/xfs_ioctl.c            | 6 +++++-
 4 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/fs/xfs/libxfs/xfs_inode_buf.c b/fs/xfs/libxfs/xfs_inode_buf.c
index 03bd7cdd0ddc81..8c4b7bd69285fa 100644
--- a/fs/xfs/libxfs/xfs_inode_buf.c
+++ b/fs/xfs/libxfs/xfs_inode_buf.c
@@ -205,7 +205,8 @@ xfs_inode_from_disk(
 	 * inode. If the inode is unused, mode is zero and we shouldn't mess
 	 * with the unitialized part of it.
 	 */
-	ip->i_flushiter = be16_to_cpu(from->di_flushiter);
+	if (!xfs_sb_version_has_v3inode(&ip->i_mount->m_sb))
+		ip->i_flushiter = be16_to_cpu(from->di_flushiter);
 	inode->i_generation = be32_to_cpu(from->di_gen);
 	inode->i_mode = be16_to_cpu(from->di_mode);
 	if (!inode->i_mode)
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index 5e0336e0dbae44..fd111e05c0bb2e 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -3794,8 +3794,10 @@ xfs_iflush_int(
 	xfs_inode_to_disk(ip, dip, iip->ili_item.li_lsn);
 
 	/* Wrap, we never let the log put out DI_MAX_FLUSH */
-	if (ip->i_flushiter == DI_MAX_FLUSH)
-		ip->i_flushiter = 0;
+	if (!xfs_sb_version_has_v3inode(&mp->m_sb)) {
+		if (ip->i_flushiter == DI_MAX_FLUSH)
+			ip->i_flushiter = 0;
+	}
 
 	xfs_iflush_fork(ip, dip, iip, XFS_DATA_FORK);
 	if (XFS_IFORK_Q(ip))
diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h
index 581618ea1156da..a0444b9ce3f792 100644
--- a/fs/xfs/xfs_inode.h
+++ b/fs/xfs/xfs_inode.h
@@ -58,8 +58,11 @@ typedef struct xfs_inode {
 	xfs_rfsblock_t		i_nblocks;	/* # of direct & btree blocks */
 	uint32_t		i_projid;	/* owner's project id */
 	xfs_extlen_t		i_extsize;	/* basic/minimum extent size */
-	xfs_extlen_t		i_cowextsize;	/* basic cow extent size */
-	uint16_t		i_flushiter;	/* incremented on flush */
+	/* cowextsize is only used for v3 inodes, flushiter for v1/2 */
+	union {
+		xfs_extlen_t	i_cowextsize;	/* basic cow extent size */
+		uint16_t	i_flushiter;	/* incremented on flush */
+	};
 
 	struct xfs_icdinode	i_d;		/* most of ondisk inode */
 
diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
index a1937900ad84be..60544dd0f875b8 100644
--- a/fs/xfs/xfs_ioctl.c
+++ b/fs/xfs/xfs_ioctl.c
@@ -1108,7 +1108,11 @@ xfs_fill_fsxattr(
 
 	simple_fill_fsxattr(fa, xfs_ip2xflags(ip));
 	fa->fsx_extsize = ip->i_extsize << ip->i_mount->m_sb.sb_blocklog;
-	fa->fsx_cowextsize = ip->i_cowextsize << ip->i_mount->m_sb.sb_blocklog;
+	if (xfs_sb_version_has_v3inode(&ip->i_mount->m_sb) &&
+	    (ip->i_d.di_flags2 & XFS_DIFLAG2_COWEXTSIZE)) {
+		fa->fsx_cowextsize =
+			ip->i_cowextsize << ip->i_mount->m_sb.sb_blocklog;
+	}
 	fa->fsx_projid = ip->i_projid;
 	if (ifp && (ifp->if_flags & XFS_IFEXTENTS))
 		fa->fsx_nextents = xfs_iext_count(ifp);
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH 09/15] xfs: cleanup xfs_fill_fsxattr
  2020-06-20  7:10 xfs inode structure cleanups v2 Christoph Hellwig
                   ` (7 preceding siblings ...)
  2020-06-20  7:10 ` [PATCH 08/15] xfs: use a union for i_cowextsize and i_flushiter Christoph Hellwig
@ 2020-06-20  7:10 ` Christoph Hellwig
  2020-06-22 11:01   ` Chandan Babu R
  2020-06-30 17:52   ` Darrick J. Wong
  2020-06-20  7:10 ` [PATCH 10/15] xfs: move the di_forkoff field to struct xfs_inode Christoph Hellwig
                   ` (6 subsequent siblings)
  15 siblings, 2 replies; 52+ messages in thread
From: Christoph Hellwig @ 2020-06-20  7:10 UTC (permalink / raw)
  To: linux-xfs

Add a local xfs_mount variable, and use the XFS_FSB_TO_B helper.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/xfs/xfs_ioctl.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
index 60544dd0f875b8..cabc86ed6756bc 100644
--- a/fs/xfs/xfs_ioctl.c
+++ b/fs/xfs/xfs_ioctl.c
@@ -1104,15 +1104,14 @@ xfs_fill_fsxattr(
 	bool			attr,
 	struct fsxattr		*fa)
 {
+	struct xfs_mount	*mp = ip->i_mount;
 	struct xfs_ifork	*ifp = attr ? ip->i_afp : &ip->i_df;
 
 	simple_fill_fsxattr(fa, xfs_ip2xflags(ip));
-	fa->fsx_extsize = ip->i_extsize << ip->i_mount->m_sb.sb_blocklog;
-	if (xfs_sb_version_has_v3inode(&ip->i_mount->m_sb) &&
-	    (ip->i_d.di_flags2 & XFS_DIFLAG2_COWEXTSIZE)) {
-		fa->fsx_cowextsize =
-			ip->i_cowextsize << ip->i_mount->m_sb.sb_blocklog;
-	}
+	fa->fsx_extsize = XFS_FSB_TO_B(mp, ip->i_extsize);
+	if (xfs_sb_version_has_v3inode(&mp->m_sb) &&
+	    (ip->i_d.di_flags2 & XFS_DIFLAG2_COWEXTSIZE))
+		fa->fsx_cowextsize = XFS_FSB_TO_B(mp, ip->i_cowextsize);
 	fa->fsx_projid = ip->i_projid;
 	if (ifp && (ifp->if_flags & XFS_IFEXTENTS))
 		fa->fsx_nextents = xfs_iext_count(ifp);
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH 10/15] xfs: move the di_forkoff field to struct xfs_inode
  2020-06-20  7:10 xfs inode structure cleanups v2 Christoph Hellwig
                   ` (8 preceding siblings ...)
  2020-06-20  7:10 ` [PATCH 09/15] xfs: cleanup xfs_fill_fsxattr Christoph Hellwig
@ 2020-06-20  7:10 ` Christoph Hellwig
  2020-06-22 12:15   ` Chandan Babu R
  2020-06-30 17:52   ` Darrick J. Wong
  2020-06-20  7:10 ` [PATCH 11/15] xfs: move the di_flags " Christoph Hellwig
                   ` (5 subsequent siblings)
  15 siblings, 2 replies; 52+ messages in thread
From: Christoph Hellwig @ 2020-06-20  7:10 UTC (permalink / raw)
  To: linux-xfs

In preparation of removing the historic icinode struct, move the
forkoff field into the containing xfs_inode structure.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/xfs/libxfs/xfs_attr_leaf.c  | 22 +++++++++++-----------
 fs/xfs/libxfs/xfs_bmap.c       | 32 ++++++++++++++++----------------
 fs/xfs/libxfs/xfs_inode_buf.c  |  4 ++--
 fs/xfs/libxfs/xfs_inode_buf.h  |  1 -
 fs/xfs/libxfs/xfs_inode_fork.h |  4 ++--
 fs/xfs/xfs_icache.c            |  2 +-
 fs/xfs/xfs_inode.c             |  8 ++++----
 fs/xfs/xfs_inode.h             |  1 +
 fs/xfs/xfs_inode_item.c        |  2 +-
 9 files changed, 38 insertions(+), 38 deletions(-)

diff --git a/fs/xfs/libxfs/xfs_attr_leaf.c b/fs/xfs/libxfs/xfs_attr_leaf.c
index 2f7e89e4be3e3f..3dca59de331fdf 100644
--- a/fs/xfs/libxfs/xfs_attr_leaf.c
+++ b/fs/xfs/libxfs/xfs_attr_leaf.c
@@ -518,10 +518,10 @@ xfs_attr_copy_value(
  * Query whether the requested number of additional bytes of extended
  * attribute space will be able to fit inline.
  *
- * Returns zero if not, else the di_forkoff fork offset to be used in the
+ * Returns zero if not, else the i_forkoff fork offset to be used in the
  * literal area for attribute data once the new bytes have been added.
  *
- * di_forkoff must be 8 byte aligned, hence is stored as a >>3 value;
+ * i_forkoff must be 8 byte aligned, hence is stored as a >>3 value;
  * special case for dev/uuid inodes, they have fixed size data forks.
  */
 int
@@ -554,7 +554,7 @@ xfs_attr_shortform_bytesfit(
 	 * literal area rebalancing.
 	 */
 	if (bytes <= XFS_IFORK_ASIZE(dp))
-		return dp->i_d.di_forkoff;
+		return dp->i_forkoff;
 
 	/*
 	 * For attr2 we can try to move the forkoff if there is space in the
@@ -575,7 +575,7 @@ xfs_attr_shortform_bytesfit(
 		 * minimum offset only needs to be the space required for
 		 * the btree root.
 		 */
-		if (!dp->i_d.di_forkoff && dp->i_df.if_bytes >
+		if (!dp->i_forkoff && dp->i_df.if_bytes >
 		    xfs_default_attroffset(dp))
 			dsize = XFS_BMDR_SPACE_CALC(MINDBTPTRS);
 		break;
@@ -586,10 +586,10 @@ xfs_attr_shortform_bytesfit(
 		 * minforkoff to where the btree root can finish so we have
 		 * plenty of room for attrs
 		 */
-		if (dp->i_d.di_forkoff) {
-			if (offset < dp->i_d.di_forkoff)
+		if (dp->i_forkoff) {
+			if (offset < dp->i_forkoff)
 				return 0;
-			return dp->i_d.di_forkoff;
+			return dp->i_forkoff;
 		}
 		dsize = XFS_BMAP_BROOT_SPACE(mp, dp->i_df.if_broot);
 		break;
@@ -677,7 +677,7 @@ xfs_attr_shortform_add(xfs_da_args_t *args, int forkoff)
 
 	dp = args->dp;
 	mp = dp->i_mount;
-	dp->i_d.di_forkoff = forkoff;
+	dp->i_forkoff = forkoff;
 
 	ifp = dp->i_afp;
 	ASSERT(ifp->if_flags & XFS_IFINLINE);
@@ -720,7 +720,7 @@ xfs_attr_fork_remove(
 	xfs_idestroy_fork(ip->i_afp);
 	kmem_cache_free(xfs_ifork_zone, ip->i_afp);
 	ip->i_afp = NULL;
-	ip->i_d.di_forkoff = 0;
+	ip->i_forkoff = 0;
 	xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
 }
 
@@ -775,8 +775,8 @@ xfs_attr_shortform_remove(xfs_da_args_t *args)
 		xfs_attr_fork_remove(dp, args->trans);
 	} else {
 		xfs_idata_realloc(dp, -size, XFS_ATTR_FORK);
-		dp->i_d.di_forkoff = xfs_attr_shortform_bytesfit(dp, totsize);
-		ASSERT(dp->i_d.di_forkoff);
+		dp->i_forkoff = xfs_attr_shortform_bytesfit(dp, totsize);
+		ASSERT(dp->i_forkoff);
 		ASSERT(totsize > sizeof(xfs_attr_sf_hdr_t) ||
 				(args->op_flags & XFS_DA_OP_ADDNAME) ||
 				!(mp->m_flags & XFS_MOUNT_ATTR2) ||
diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
index 692159357ed8e5..7e7e4459a606f1 100644
--- a/fs/xfs/libxfs/xfs_bmap.c
+++ b/fs/xfs/libxfs/xfs_bmap.c
@@ -66,13 +66,13 @@ xfs_bmap_compute_maxlevels(
 	 * either a signed 32-bit number for the data fork, or a signed 16-bit
 	 * number for the attr fork.
 	 *
-	 * Note that we can no longer assume that if we are in ATTR1 that
-	 * the fork offset of all the inodes will be
-	 * (xfs_default_attroffset(ip) >> 3) because we could have mounted
-	 * with ATTR2 and then mounted back with ATTR1, keeping the
-	 * di_forkoff's fixed but probably at various positions. Therefore,
-	 * for both ATTR1 and ATTR2 we have to assume the worst case scenario
-	 * of a minimum size available.
+	 * Note that we can no longer assume that if we are in ATTR1 that the
+	 * fork offset of all the inodes will be
+	 * (xfs_default_attroffset(ip) >> 3) because we could have mounted with
+	 * ATTR2 and then mounted back with ATTR1, keeping the i_forkoff's fixed
+	 * but probably at various positions. Therefore, for both ATTR1 and
+	 * ATTR2 we have to assume the worst case scenario of a minimum size
+	 * available.
 	 */
 	if (whichfork == XFS_DATA_FORK) {
 		maxleafents = MAXEXTNUM;
@@ -205,9 +205,9 @@ xfs_default_attroffset(
 }
 
 /*
- * Helper routine to reset inode di_forkoff field when switching
- * attribute fork from local to extent format - we reset it where
- * possible to make space available for inline data fork extents.
+ * Helper routine to reset inode i_forkoff field when switching attribute fork
+ * from local to extent format - we reset it where possible to make space
+ * available for inline data fork extents.
  */
 STATIC void
 xfs_bmap_forkoff_reset(
@@ -219,8 +219,8 @@ xfs_bmap_forkoff_reset(
 	    ip->i_df.if_format != XFS_DINODE_FMT_BTREE) {
 		uint	dfl_forkoff = xfs_default_attroffset(ip) >> 3;
 
-		if (dfl_forkoff > ip->i_d.di_forkoff)
-			ip->i_d.di_forkoff = dfl_forkoff;
+		if (dfl_forkoff > ip->i_forkoff)
+			ip->i_forkoff = dfl_forkoff;
 	}
 }
 
@@ -1035,14 +1035,14 @@ xfs_bmap_set_attrforkoff(
 {
 	switch (ip->i_df.if_format) {
 	case XFS_DINODE_FMT_DEV:
-		ip->i_d.di_forkoff = roundup(sizeof(xfs_dev_t), 8) >> 3;
+		ip->i_forkoff = roundup(sizeof(xfs_dev_t), 8) >> 3;
 		break;
 	case XFS_DINODE_FMT_LOCAL:
 	case XFS_DINODE_FMT_EXTENTS:
 	case XFS_DINODE_FMT_BTREE:
-		ip->i_d.di_forkoff = xfs_attr_shortform_bytesfit(ip, size);
-		if (!ip->i_d.di_forkoff)
-			ip->i_d.di_forkoff = xfs_default_attroffset(ip) >> 3;
+		ip->i_forkoff = xfs_attr_shortform_bytesfit(ip, size);
+		if (!ip->i_forkoff)
+			ip->i_forkoff = xfs_default_attroffset(ip) >> 3;
 		else if ((ip->i_mount->m_flags & XFS_MOUNT_ATTR2) && version)
 			*version = 2;
 		break;
diff --git a/fs/xfs/libxfs/xfs_inode_buf.c b/fs/xfs/libxfs/xfs_inode_buf.c
index 8c4b7bd69285fa..69a6844b1698d0 100644
--- a/fs/xfs/libxfs/xfs_inode_buf.c
+++ b/fs/xfs/libxfs/xfs_inode_buf.c
@@ -245,7 +245,7 @@ xfs_inode_from_disk(
 	ip->i_disk_size = be64_to_cpu(from->di_size);
 	ip->i_nblocks = be64_to_cpu(from->di_nblocks);
 	ip->i_extsize = be32_to_cpu(from->di_extsize);
-	to->di_forkoff = from->di_forkoff;
+	ip->i_forkoff = from->di_forkoff;
 	to->di_dmevmask	= be32_to_cpu(from->di_dmevmask);
 	to->di_dmstate	= be16_to_cpu(from->di_dmstate);
 	to->di_flags	= be16_to_cpu(from->di_flags);
@@ -310,7 +310,7 @@ xfs_inode_to_disk(
 	to->di_extsize = cpu_to_be32(ip->i_extsize);
 	to->di_nextents = cpu_to_be32(xfs_ifork_nextents(&ip->i_df));
 	to->di_anextents = cpu_to_be16(xfs_ifork_nextents(ip->i_afp));
-	to->di_forkoff = from->di_forkoff;
+	to->di_forkoff = ip->i_forkoff;
 	to->di_aformat = xfs_ifork_format(ip->i_afp);
 	to->di_dmevmask = cpu_to_be32(from->di_dmevmask);
 	to->di_dmstate = cpu_to_be16(from->di_dmstate);
diff --git a/fs/xfs/libxfs/xfs_inode_buf.h b/fs/xfs/libxfs/xfs_inode_buf.h
index 8cc96f2766ff4f..032486dbf82757 100644
--- a/fs/xfs/libxfs/xfs_inode_buf.h
+++ b/fs/xfs/libxfs/xfs_inode_buf.h
@@ -16,7 +16,6 @@ struct xfs_dinode;
  * format specific structures at the appropriate time.
  */
 struct xfs_icdinode {
-	uint8_t		di_forkoff;	/* attr fork offs, <<3 for 64b align */
 	uint32_t	di_dmevmask;	/* DMIG event mask */
 	uint16_t	di_dmstate;	/* DMIG state info */
 	uint16_t	di_flags;	/* random flags, XFS_DIFLAG_... */
diff --git a/fs/xfs/libxfs/xfs_inode_fork.h b/fs/xfs/libxfs/xfs_inode_fork.h
index a4953e95c4f3f6..7d6982b23446c2 100644
--- a/fs/xfs/libxfs/xfs_inode_fork.h
+++ b/fs/xfs/libxfs/xfs_inode_fork.h
@@ -38,8 +38,8 @@ struct xfs_ifork {
  * Fork handling.
  */
 
-#define XFS_IFORK_Q(ip)			((ip)->i_d.di_forkoff != 0)
-#define XFS_IFORK_BOFF(ip)		((int)((ip)->i_d.di_forkoff << 3))
+#define XFS_IFORK_Q(ip)			((ip)->i_forkoff != 0)
+#define XFS_IFORK_BOFF(ip)		((int)((ip)->i_forkoff << 3))
 
 #define XFS_IFORK_PTR(ip,w)		\
 	((w) == XFS_DATA_FORK ? \
diff --git a/fs/xfs/xfs_icache.c b/fs/xfs/xfs_icache.c
index e6b40f7035aa5a..ccd437432aa963 100644
--- a/fs/xfs/xfs_icache.c
+++ b/fs/xfs/xfs_icache.c
@@ -67,7 +67,7 @@ xfs_inode_alloc(
 	ip->i_flags = 0;
 	ip->i_delayed_blks = 0;
 	ip->i_nblocks = 0;
-	ip->i_d.di_forkoff = 0;
+	ip->i_forkoff = 0;
 	ip->i_sick = 0;
 	ip->i_checked = 0;
 	INIT_WORK(&ip->i_ioend_work, xfs_end_io);
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index fd111e05c0bb2e..764f91610d1496 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -1858,7 +1858,7 @@ xfs_inactive(
 	}
 
 	ASSERT(!ip->i_afp);
-	ASSERT(ip->i_d.di_forkoff == 0);
+	ASSERT(ip->i_forkoff == 0);
 
 	/*
 	 * Free the inode.
@@ -2758,7 +2758,7 @@ xfs_ifree(
 	ip->i_d.di_flags = 0;
 	ip->i_d.di_flags2 = 0;
 	ip->i_d.di_dmevmask = 0;
-	ip->i_d.di_forkoff = 0;		/* mark the attr fork not in use */
+	ip->i_forkoff = 0;		/* mark the attr fork not in use */
 	ip->i_df.if_format = XFS_DINODE_FMT_EXTENTS;
 
 	/* Don't attempt to replay owner changes for a deleted inode */
@@ -3756,11 +3756,11 @@ xfs_iflush_int(
 			ip->i_nblocks, ip);
 		goto flush_out;
 	}
-	if (XFS_TEST_ERROR(ip->i_d.di_forkoff > mp->m_sb.sb_inodesize,
+	if (XFS_TEST_ERROR(ip->i_forkoff > mp->m_sb.sb_inodesize,
 				mp, XFS_ERRTAG_IFLUSH_6)) {
 		xfs_alert_tag(mp, XFS_PTAG_IFLUSH,
 			"%s: bad inode %Lu, forkoff 0x%x, ptr "PTR_FMT,
-			__func__, ip->i_ino, ip->i_d.di_forkoff, ip);
+			__func__, ip->i_ino, ip->i_forkoff, ip);
 		goto flush_out;
 	}
 
diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h
index a0444b9ce3f792..31440ab88cf141 100644
--- a/fs/xfs/xfs_inode.h
+++ b/fs/xfs/xfs_inode.h
@@ -63,6 +63,7 @@ typedef struct xfs_inode {
 		xfs_extlen_t	i_cowextsize;	/* basic cow extent size */
 		uint16_t	i_flushiter;	/* incremented on flush */
 	};
+	uint8_t			i_forkoff;	/* attr fork offset >> 3 */
 
 	struct xfs_icdinode	i_d;		/* most of ondisk inode */
 
diff --git a/fs/xfs/xfs_inode_item.c b/fs/xfs/xfs_inode_item.c
index 8357fe37d3eb8a..a83ddc4e029f0f 100644
--- a/fs/xfs/xfs_inode_item.c
+++ b/fs/xfs/xfs_inode_item.c
@@ -328,7 +328,7 @@ xfs_inode_to_log_dinode(
 	to->di_extsize = ip->i_extsize;
 	to->di_nextents = xfs_ifork_nextents(&ip->i_df);
 	to->di_anextents = xfs_ifork_nextents(ip->i_afp);
-	to->di_forkoff = from->di_forkoff;
+	to->di_forkoff = ip->i_forkoff;
 	to->di_aformat = xfs_ifork_format(ip->i_afp);
 	to->di_dmevmask = from->di_dmevmask;
 	to->di_dmstate = from->di_dmstate;
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH 11/15] xfs: move the di_flags field to struct xfs_inode
  2020-06-20  7:10 xfs inode structure cleanups v2 Christoph Hellwig
                   ` (9 preceding siblings ...)
  2020-06-20  7:10 ` [PATCH 10/15] xfs: move the di_forkoff field to struct xfs_inode Christoph Hellwig
@ 2020-06-20  7:10 ` Christoph Hellwig
  2020-06-22 12:41   ` Chandan Babu R
  2020-06-30 17:53   ` Darrick J. Wong
  2020-06-20  7:10 ` [PATCH 12/15] xfs: move the di_flags2 " Christoph Hellwig
                   ` (4 subsequent siblings)
  15 siblings, 2 replies; 52+ messages in thread
From: Christoph Hellwig @ 2020-06-20  7:10 UTC (permalink / raw)
  To: linux-xfs

In preparation of removing the historic icinode struct, move the flags
field into the containing xfs_inode structure.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/xfs/libxfs/xfs_bmap_btree.c |  2 +-
 fs/xfs/libxfs/xfs_inode_buf.c  |  4 ++--
 fs/xfs/libxfs/xfs_inode_buf.h  |  1 -
 fs/xfs/libxfs/xfs_rtbitmap.c   |  4 ++--
 fs/xfs/scrub/common.c          |  2 +-
 fs/xfs/xfs_bmap_util.c         |  4 ++--
 fs/xfs/xfs_file.c              |  4 ++--
 fs/xfs/xfs_filestream.h        |  2 +-
 fs/xfs/xfs_inode.c             | 38 +++++++++++++++++-----------------
 fs/xfs/xfs_inode.h             |  3 ++-
 fs/xfs/xfs_inode_item.c        |  2 +-
 fs/xfs/xfs_ioctl.c             |  9 ++++----
 fs/xfs/xfs_iops.c              |  6 +++---
 fs/xfs/xfs_linux.h             |  2 +-
 fs/xfs/xfs_rtalloc.c           |  4 ++--
 fs/xfs/xfs_super.c             |  4 ++--
 fs/xfs/xfs_symlink.c           |  2 +-
 17 files changed, 46 insertions(+), 47 deletions(-)

diff --git a/fs/xfs/libxfs/xfs_bmap_btree.c b/fs/xfs/libxfs/xfs_bmap_btree.c
index 9ad4c6a1eec518..d32f3a94c936e6 100644
--- a/fs/xfs/libxfs/xfs_bmap_btree.c
+++ b/fs/xfs/libxfs/xfs_bmap_btree.c
@@ -183,7 +183,7 @@ xfs_bmbt_update_cursor(
 	struct xfs_btree_cur	*dst)
 {
 	ASSERT((dst->bc_tp->t_firstblock != NULLFSBLOCK) ||
-	       (dst->bc_ino.ip->i_d.di_flags & XFS_DIFLAG_REALTIME));
+	       (dst->bc_ino.ip->i_diflags & XFS_DIFLAG_REALTIME));
 
 	dst->bc_ino.allocated += src->bc_ino.allocated;
 	dst->bc_tp->t_firstblock = src->bc_tp->t_firstblock;
diff --git a/fs/xfs/libxfs/xfs_inode_buf.c b/fs/xfs/libxfs/xfs_inode_buf.c
index 69a6844b1698d0..bb9c4775ecaa5c 100644
--- a/fs/xfs/libxfs/xfs_inode_buf.c
+++ b/fs/xfs/libxfs/xfs_inode_buf.c
@@ -248,7 +248,7 @@ xfs_inode_from_disk(
 	ip->i_forkoff = from->di_forkoff;
 	to->di_dmevmask	= be32_to_cpu(from->di_dmevmask);
 	to->di_dmstate	= be16_to_cpu(from->di_dmstate);
-	to->di_flags	= be16_to_cpu(from->di_flags);
+	ip->i_diflags	= be16_to_cpu(from->di_flags);
 
 	if (xfs_sb_version_has_v3inode(&ip->i_mount->m_sb)) {
 		inode_set_iversion_queried(inode,
@@ -314,7 +314,7 @@ xfs_inode_to_disk(
 	to->di_aformat = xfs_ifork_format(ip->i_afp);
 	to->di_dmevmask = cpu_to_be32(from->di_dmevmask);
 	to->di_dmstate = cpu_to_be16(from->di_dmstate);
-	to->di_flags = cpu_to_be16(from->di_flags);
+	to->di_flags = cpu_to_be16(ip->i_diflags);
 
 	if (xfs_sb_version_has_v3inode(&ip->i_mount->m_sb)) {
 		to->di_version = 3;
diff --git a/fs/xfs/libxfs/xfs_inode_buf.h b/fs/xfs/libxfs/xfs_inode_buf.h
index 032486dbf82757..5c6a6ac521b11d 100644
--- a/fs/xfs/libxfs/xfs_inode_buf.h
+++ b/fs/xfs/libxfs/xfs_inode_buf.h
@@ -18,7 +18,6 @@ struct xfs_dinode;
 struct xfs_icdinode {
 	uint32_t	di_dmevmask;	/* DMIG event mask */
 	uint16_t	di_dmstate;	/* DMIG state info */
-	uint16_t	di_flags;	/* random flags, XFS_DIFLAG_... */
 
 	uint64_t	di_flags2;	/* more random flags */
 
diff --git a/fs/xfs/libxfs/xfs_rtbitmap.c b/fs/xfs/libxfs/xfs_rtbitmap.c
index 9498ced947be9e..57381b9aca00ac 100644
--- a/fs/xfs/libxfs/xfs_rtbitmap.c
+++ b/fs/xfs/libxfs/xfs_rtbitmap.c
@@ -997,8 +997,8 @@ xfs_rtfree_extent(
 	 */
 	if (tp->t_frextents_delta + mp->m_sb.sb_frextents ==
 	    mp->m_sb.sb_rextents) {
-		if (!(mp->m_rbmip->i_d.di_flags & XFS_DIFLAG_NEWRTBM))
-			mp->m_rbmip->i_d.di_flags |= XFS_DIFLAG_NEWRTBM;
+		if (!(mp->m_rbmip->i_diflags & XFS_DIFLAG_NEWRTBM))
+			mp->m_rbmip->i_diflags |= XFS_DIFLAG_NEWRTBM;
 		*(uint64_t *)&VFS_I(mp->m_rbmip)->i_atime = 0;
 		xfs_trans_log_inode(tp, mp->m_rbmip, XFS_ILOG_CORE);
 	}
diff --git a/fs/xfs/scrub/common.c b/fs/xfs/scrub/common.c
index 18876056e5e02a..254dc813696de4 100644
--- a/fs/xfs/scrub/common.c
+++ b/fs/xfs/scrub/common.c
@@ -835,7 +835,7 @@ xchk_metadata_inode_forks(
 		return 0;
 
 	/* Metadata inodes don't live on the rt device. */
-	if (sc->ip->i_d.di_flags & XFS_DIFLAG_REALTIME) {
+	if (sc->ip->i_diflags & XFS_DIFLAG_REALTIME) {
 		xchk_ino_set_corrupt(sc, sc->ip->i_ino);
 		return 0;
 	}
diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c
index 5eba039d72fb83..0b944aad75e618 100644
--- a/fs/xfs/xfs_bmap_util.c
+++ b/fs/xfs/xfs_bmap_util.c
@@ -439,7 +439,7 @@ xfs_getbmap(
 		}
 
 		if (xfs_get_extsz_hint(ip) ||
-		    (ip->i_d.di_flags &
+		    (ip->i_diflags &
 		     (XFS_DIFLAG_PREALLOC | XFS_DIFLAG_APPEND)))
 			max_len = mp->m_super->s_maxbytes;
 		else
@@ -620,7 +620,7 @@ xfs_can_free_eofblocks(struct xfs_inode *ip, bool force)
 	 * Do not free real preallocated or append-only files unless the file
 	 * has delalloc blocks and we are forced to remove them.
 	 */
-	if (ip->i_d.di_flags & (XFS_DIFLAG_PREALLOC | XFS_DIFLAG_APPEND))
+	if (ip->i_diflags & (XFS_DIFLAG_PREALLOC | XFS_DIFLAG_APPEND))
 		if (!force || ip->i_delayed_blks == 0)
 			return false;
 
diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c
index b0384306d6622f..4f08793f3d6db4 100644
--- a/fs/xfs/xfs_file.c
+++ b/fs/xfs/xfs_file.c
@@ -56,9 +56,9 @@ xfs_update_prealloc_flags(
 	}
 
 	if (flags & XFS_PREALLOC_SET)
-		ip->i_d.di_flags |= XFS_DIFLAG_PREALLOC;
+		ip->i_diflags |= XFS_DIFLAG_PREALLOC;
 	if (flags & XFS_PREALLOC_CLEAR)
-		ip->i_d.di_flags &= ~XFS_DIFLAG_PREALLOC;
+		ip->i_diflags &= ~XFS_DIFLAG_PREALLOC;
 
 	xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
 	if (flags & XFS_PREALLOC_SYNC)
diff --git a/fs/xfs/xfs_filestream.h b/fs/xfs/xfs_filestream.h
index 5cc7665e93c92b..3af963743e4d0b 100644
--- a/fs/xfs/xfs_filestream.h
+++ b/fs/xfs/xfs_filestream.h
@@ -22,7 +22,7 @@ xfs_inode_is_filestream(
 	struct xfs_inode	*ip)
 {
 	return (ip->i_mount->m_flags & XFS_MOUNT_FILESTREAMS) ||
-		(ip->i_d.di_flags & XFS_DIFLAG_FILESTREAM);
+		(ip->i_diflags & XFS_DIFLAG_FILESTREAM);
 }
 
 #endif /* __XFS_FILESTREAM_H__ */
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index 764f91610d1496..479342ac8851f4 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -61,7 +61,7 @@ xfs_get_extsz_hint(
 	 */
 	if (xfs_is_always_cow_inode(ip))
 		return 0;
-	if ((ip->i_d.di_flags & XFS_DIFLAG_EXTSIZE) && ip->i_extsize)
+	if ((ip->i_diflags & XFS_DIFLAG_EXTSIZE) && ip->i_extsize)
 		return ip->i_extsize;
 	if (XFS_IS_REALTIME_INODE(ip))
 		return ip->i_mount->m_sb.sb_rextsize;
@@ -673,7 +673,7 @@ xfs_ip2xflags(
 {
 	struct xfs_icdinode	*dic = &ip->i_d;
 
-	return _xfs_dic2xflags(dic->di_flags, dic->di_flags2, XFS_IFORK_Q(ip));
+	return _xfs_dic2xflags(ip->i_diflags, dic->di_flags2, XFS_IFORK_Q(ip));
 }
 
 /*
@@ -837,7 +837,7 @@ xfs_ialloc(
 	ip->i_extsize = 0;
 	ip->i_d.di_dmevmask = 0;
 	ip->i_d.di_dmstate = 0;
-	ip->i_d.di_flags = 0;
+	ip->i_diflags = 0;
 
 	if (xfs_sb_version_has_v3inode(&mp->m_sb)) {
 		inode_set_iversion(inode, 1);
@@ -858,45 +858,45 @@ xfs_ialloc(
 		break;
 	case S_IFREG:
 	case S_IFDIR:
-		if (pip && (pip->i_d.di_flags & XFS_DIFLAG_ANY)) {
+		if (pip && (pip->i_diflags & XFS_DIFLAG_ANY)) {
 			uint		di_flags = 0;
 
 			if (S_ISDIR(mode)) {
-				if (pip->i_d.di_flags & XFS_DIFLAG_RTINHERIT)
+				if (pip->i_diflags & XFS_DIFLAG_RTINHERIT)
 					di_flags |= XFS_DIFLAG_RTINHERIT;
-				if (pip->i_d.di_flags & XFS_DIFLAG_EXTSZINHERIT) {
+				if (pip->i_diflags & XFS_DIFLAG_EXTSZINHERIT) {
 					di_flags |= XFS_DIFLAG_EXTSZINHERIT;
 					ip->i_extsize = pip->i_extsize;
 				}
-				if (pip->i_d.di_flags & XFS_DIFLAG_PROJINHERIT)
+				if (pip->i_diflags & XFS_DIFLAG_PROJINHERIT)
 					di_flags |= XFS_DIFLAG_PROJINHERIT;
 			} else if (S_ISREG(mode)) {
-				if (pip->i_d.di_flags & XFS_DIFLAG_RTINHERIT)
+				if (pip->i_diflags & XFS_DIFLAG_RTINHERIT)
 					di_flags |= XFS_DIFLAG_REALTIME;
-				if (pip->i_d.di_flags & XFS_DIFLAG_EXTSZINHERIT) {
+				if (pip->i_diflags & XFS_DIFLAG_EXTSZINHERIT) {
 					di_flags |= XFS_DIFLAG_EXTSIZE;
 					ip->i_extsize = pip->i_extsize;
 				}
 			}
-			if ((pip->i_d.di_flags & XFS_DIFLAG_NOATIME) &&
+			if ((pip->i_diflags & XFS_DIFLAG_NOATIME) &&
 			    xfs_inherit_noatime)
 				di_flags |= XFS_DIFLAG_NOATIME;
-			if ((pip->i_d.di_flags & XFS_DIFLAG_NODUMP) &&
+			if ((pip->i_diflags & XFS_DIFLAG_NODUMP) &&
 			    xfs_inherit_nodump)
 				di_flags |= XFS_DIFLAG_NODUMP;
-			if ((pip->i_d.di_flags & XFS_DIFLAG_SYNC) &&
+			if ((pip->i_diflags & XFS_DIFLAG_SYNC) &&
 			    xfs_inherit_sync)
 				di_flags |= XFS_DIFLAG_SYNC;
-			if ((pip->i_d.di_flags & XFS_DIFLAG_NOSYMLINKS) &&
+			if ((pip->i_diflags & XFS_DIFLAG_NOSYMLINKS) &&
 			    xfs_inherit_nosymlinks)
 				di_flags |= XFS_DIFLAG_NOSYMLINKS;
-			if ((pip->i_d.di_flags & XFS_DIFLAG_NODEFRAG) &&
+			if ((pip->i_diflags & XFS_DIFLAG_NODEFRAG) &&
 			    xfs_inherit_nodefrag)
 				di_flags |= XFS_DIFLAG_NODEFRAG;
-			if (pip->i_d.di_flags & XFS_DIFLAG_FILESTREAM)
+			if (pip->i_diflags & XFS_DIFLAG_FILESTREAM)
 				di_flags |= XFS_DIFLAG_FILESTREAM;
 
-			ip->i_d.di_flags |= di_flags;
+			ip->i_diflags |= di_flags;
 		}
 		if (pip && (pip->i_d.di_flags2 & XFS_DIFLAG2_ANY)) {
 			if (pip->i_d.di_flags2 & XFS_DIFLAG2_COWEXTSIZE) {
@@ -1397,7 +1397,7 @@ xfs_link(
 	 * creation in our tree when the project IDs are the same; else
 	 * the tree quota mechanism could be circumvented.
 	 */
-	if (unlikely((tdp->i_d.di_flags & XFS_DIFLAG_PROJINHERIT) &&
+	if (unlikely((tdp->i_diflags & XFS_DIFLAG_PROJINHERIT) &&
 		     tdp->i_projid != sip->i_projid)) {
 		error = -EXDEV;
 		goto error_return;
@@ -2755,7 +2755,7 @@ xfs_ifree(
 	}
 
 	VFS_I(ip)->i_mode = 0;		/* mark incore inode as free */
-	ip->i_d.di_flags = 0;
+	ip->i_diflags = 0;
 	ip->i_d.di_flags2 = 0;
 	ip->i_d.di_dmevmask = 0;
 	ip->i_forkoff = 0;		/* mark the attr fork not in use */
@@ -3263,7 +3263,7 @@ xfs_rename(
 	 * into our tree when the project IDs are the same; else the
 	 * tree quota mechanism would be circumvented.
 	 */
-	if (unlikely((target_dp->i_d.di_flags & XFS_DIFLAG_PROJINHERIT) &&
+	if (unlikely((target_dp->i_diflags & XFS_DIFLAG_PROJINHERIT) &&
 		     target_dp->i_projid != src_ip->i_projid)) {
 		error = -EXDEV;
 		goto out_trans_cancel;
diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h
index 31440ab88cf141..7673c841d89154 100644
--- a/fs/xfs/xfs_inode.h
+++ b/fs/xfs/xfs_inode.h
@@ -64,6 +64,7 @@ typedef struct xfs_inode {
 		uint16_t	i_flushiter;	/* incremented on flush */
 	};
 	uint8_t			i_forkoff;	/* attr fork offset >> 3 */
+	uint16_t		i_diflags;	/* XFS_DIFLAG_... */
 
 	struct xfs_icdinode	i_d;		/* most of ondisk inode */
 
@@ -184,7 +185,7 @@ xfs_iflags_test_and_set(xfs_inode_t *ip, unsigned short flags)
 static inline prid_t
 xfs_get_initial_prid(struct xfs_inode *dp)
 {
-	if (dp->i_d.di_flags & XFS_DIFLAG_PROJINHERIT)
+	if (dp->i_diflags & XFS_DIFLAG_PROJINHERIT)
 		return dp->i_projid;
 
 	return XFS_PROJID_DEFAULT;
diff --git a/fs/xfs/xfs_inode_item.c b/fs/xfs/xfs_inode_item.c
index a83ddc4e029f0f..6af8e829dd0172 100644
--- a/fs/xfs/xfs_inode_item.c
+++ b/fs/xfs/xfs_inode_item.c
@@ -332,7 +332,7 @@ xfs_inode_to_log_dinode(
 	to->di_aformat = xfs_ifork_format(ip->i_afp);
 	to->di_dmevmask = from->di_dmevmask;
 	to->di_dmstate = from->di_dmstate;
-	to->di_flags = from->di_flags;
+	to->di_flags = ip->i_diflags;
 
 	/* log a dummy value to ensure log structure is fully initialised */
 	to->di_next_unlinked = NULLAGINO;
diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
index cabc86ed6756bc..326991f4d98096 100644
--- a/fs/xfs/xfs_ioctl.c
+++ b/fs/xfs/xfs_ioctl.c
@@ -1143,7 +1143,7 @@ xfs_flags2diflags(
 {
 	/* can't set PREALLOC this way, just preserve it */
 	uint16_t		di_flags =
-		(ip->i_d.di_flags & XFS_DIFLAG_PREALLOC);
+		(ip->i_diflags & XFS_DIFLAG_PREALLOC);
 
 	if (xflags & FS_XFLAG_IMMUTABLE)
 		di_flags |= XFS_DIFLAG_IMMUTABLE;
@@ -1228,7 +1228,7 @@ xfs_ioctl_setattr_xflags(
 	if (di_flags2 && !xfs_sb_version_has_v3inode(&mp->m_sb))
 		return -EINVAL;
 
-	ip->i_d.di_flags = xfs_flags2diflags(ip, fa->fsx_xflags);
+	ip->i_diflags = xfs_flags2diflags(ip, fa->fsx_xflags);
 	ip->i_d.di_flags2 = di_flags2;
 
 	xfs_diflags_to_iflags(ip, false);
@@ -1570,7 +1570,7 @@ xfs_ioctl_setattr(
 	 * extent size hint should be set on the inode. If no extent size flags
 	 * are set on the inode then unconditionally clear the extent size hint.
 	 */
-	if (ip->i_d.di_flags & (XFS_DIFLAG_EXTSIZE | XFS_DIFLAG_EXTSZINHERIT))
+	if (ip->i_diflags & (XFS_DIFLAG_EXTSIZE | XFS_DIFLAG_EXTSZINHERIT))
 		ip->i_extsize = fa->fsx_extsize >> mp->m_sb.sb_blocklog;
 	else
 		ip->i_extsize = 0;
@@ -1622,9 +1622,8 @@ xfs_ioc_getxflags(
 	xfs_inode_t		*ip,
 	void			__user *arg)
 {
-	unsigned int		flags;
+	unsigned int		flags = xfs_di2lxflags(ip->i_diflags);
 
-	flags = xfs_di2lxflags(ip->i_d.di_flags);
 	if (copy_to_user(arg, &flags, sizeof(flags)))
 		return -EFAULT;
 	return 0;
diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
index 78159c57d82828..f37154fc9828fd 100644
--- a/fs/xfs/xfs_iops.c
+++ b/fs/xfs/xfs_iops.c
@@ -567,11 +567,11 @@ xfs_vn_getattr(
 	 * Note: If you add another clause to set an attribute flag, please
 	 * update attributes_mask below.
 	 */
-	if (ip->i_d.di_flags & XFS_DIFLAG_IMMUTABLE)
+	if (ip->i_diflags & XFS_DIFLAG_IMMUTABLE)
 		stat->attributes |= STATX_ATTR_IMMUTABLE;
-	if (ip->i_d.di_flags & XFS_DIFLAG_APPEND)
+	if (ip->i_diflags & XFS_DIFLAG_APPEND)
 		stat->attributes |= STATX_ATTR_APPEND;
-	if (ip->i_d.di_flags & XFS_DIFLAG_NODUMP)
+	if (ip->i_diflags & XFS_DIFLAG_NODUMP)
 		stat->attributes |= STATX_ATTR_NODUMP;
 
 	stat->attributes_mask |= (STATX_ATTR_IMMUTABLE |
diff --git a/fs/xfs/xfs_linux.h b/fs/xfs/xfs_linux.h
index 9f70d2f68e059b..95cc3386ac3b4f 100644
--- a/fs/xfs/xfs_linux.h
+++ b/fs/xfs/xfs_linux.h
@@ -233,7 +233,7 @@ int xfs_rw_bdev(struct block_device *bdev, sector_t sector, unsigned int count,
  * configured realtime device.
  */
 #define XFS_IS_REALTIME_INODE(ip)			\
-	(((ip)->i_d.di_flags & XFS_DIFLAG_REALTIME) &&	\
+	(((ip)->i_diflags & XFS_DIFLAG_REALTIME) &&	\
 	 (ip)->i_mount->m_rtdev_targp)
 #define XFS_IS_REALTIME_MOUNT(mp) ((mp)->m_rtdev_targp ? 1 : 0)
 #else
diff --git a/fs/xfs/xfs_rtalloc.c b/fs/xfs/xfs_rtalloc.c
index cc07d7d27dd7e0..592a1160200f5e 100644
--- a/fs/xfs/xfs_rtalloc.c
+++ b/fs/xfs/xfs_rtalloc.c
@@ -1281,8 +1281,8 @@ xfs_rtpick_extent(
 	ASSERT(xfs_isilocked(mp->m_rbmip, XFS_ILOCK_EXCL));
 
 	seqp = (uint64_t *)&VFS_I(mp->m_rbmip)->i_atime;
-	if (!(mp->m_rbmip->i_d.di_flags & XFS_DIFLAG_NEWRTBM)) {
-		mp->m_rbmip->i_d.di_flags |= XFS_DIFLAG_NEWRTBM;
+	if (!(mp->m_rbmip->i_diflags & XFS_DIFLAG_NEWRTBM)) {
+		mp->m_rbmip->i_diflags |= XFS_DIFLAG_NEWRTBM;
 		*seqp = 0;
 	}
 	seq = *seqp;
diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
index fa58cb07c8fdfe..06a01528543aef 100644
--- a/fs/xfs/xfs_super.c
+++ b/fs/xfs/xfs_super.c
@@ -828,13 +828,13 @@ xfs_fs_statfs(
 	statp->f_ffree = max_t(int64_t, ffree, 0);
 
 
-	if ((ip->i_d.di_flags & XFS_DIFLAG_PROJINHERIT) &&
+	if ((ip->i_diflags & XFS_DIFLAG_PROJINHERIT) &&
 	    ((mp->m_qflags & (XFS_PQUOTA_ACCT|XFS_PQUOTA_ENFD))) ==
 			      (XFS_PQUOTA_ACCT|XFS_PQUOTA_ENFD))
 		xfs_qm_statvfs(ip, statp);
 
 	if (XFS_IS_REALTIME_MOUNT(mp) &&
-	    (ip->i_d.di_flags & (XFS_DIFLAG_RTINHERIT | XFS_DIFLAG_REALTIME))) {
+	    (ip->i_diflags & (XFS_DIFLAG_RTINHERIT | XFS_DIFLAG_REALTIME))) {
 		statp->f_blocks = sbp->sb_rblocks;
 		statp->f_bavail = statp->f_bfree =
 			sbp->sb_frextents * sbp->sb_rextsize;
diff --git a/fs/xfs/xfs_symlink.c b/fs/xfs/xfs_symlink.c
index 6b8980b1497c9a..dc86e3117f73f0 100644
--- a/fs/xfs/xfs_symlink.c
+++ b/fs/xfs/xfs_symlink.c
@@ -207,7 +207,7 @@ xfs_symlink(
 	/*
 	 * Check whether the directory allows new symlinks or not.
 	 */
-	if (dp->i_d.di_flags & XFS_DIFLAG_NOSYMLINKS) {
+	if (dp->i_diflags & XFS_DIFLAG_NOSYMLINKS) {
 		error = -EPERM;
 		goto out_trans_cancel;
 	}
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH 12/15] xfs: move the di_flags2 field to struct xfs_inode
  2020-06-20  7:10 xfs inode structure cleanups v2 Christoph Hellwig
                   ` (10 preceding siblings ...)
  2020-06-20  7:10 ` [PATCH 11/15] xfs: move the di_flags " Christoph Hellwig
@ 2020-06-20  7:10 ` Christoph Hellwig
  2020-06-22 12:51   ` Chandan Babu R
  2020-06-30 17:54   ` Darrick J. Wong
  2020-06-20  7:11 ` [PATCH 13/15] xfs: move the di_crtime " Christoph Hellwig
                   ` (3 subsequent siblings)
  15 siblings, 2 replies; 52+ messages in thread
From: Christoph Hellwig @ 2020-06-20  7:10 UTC (permalink / raw)
  To: linux-xfs

In preparation of removing the historic icinode struct, move the flags2
field into the containing xfs_inode structure.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/xfs/libxfs/xfs_inode_buf.c |  4 ++--
 fs/xfs/libxfs/xfs_inode_buf.h |  2 --
 fs/xfs/xfs_bmap_util.c        | 24 ++++++++++++------------
 fs/xfs/xfs_file.c             |  4 ++--
 fs/xfs/xfs_inode.c            | 22 ++++++++++------------
 fs/xfs/xfs_inode.h            |  3 ++-
 fs/xfs/xfs_inode_item.c       |  2 +-
 fs/xfs/xfs_ioctl.c            | 23 +++++++++++------------
 fs/xfs/xfs_iops.c             |  2 +-
 fs/xfs/xfs_itable.c           |  2 +-
 fs/xfs/xfs_reflink.c          |  8 ++++----
 11 files changed, 46 insertions(+), 50 deletions(-)

diff --git a/fs/xfs/libxfs/xfs_inode_buf.c b/fs/xfs/libxfs/xfs_inode_buf.c
index bb9c4775ecaa5c..79e470933abfa8 100644
--- a/fs/xfs/libxfs/xfs_inode_buf.c
+++ b/fs/xfs/libxfs/xfs_inode_buf.c
@@ -255,7 +255,7 @@ xfs_inode_from_disk(
 					   be64_to_cpu(from->di_changecount));
 		to->di_crtime.tv_sec = be32_to_cpu(from->di_crtime.t_sec);
 		to->di_crtime.tv_nsec = be32_to_cpu(from->di_crtime.t_nsec);
-		to->di_flags2 = be64_to_cpu(from->di_flags2);
+		ip->i_diflags2 = be64_to_cpu(from->di_flags2);
 		ip->i_cowextsize = be32_to_cpu(from->di_cowextsize);
 	}
 
@@ -321,7 +321,7 @@ xfs_inode_to_disk(
 		to->di_changecount = cpu_to_be64(inode_peek_iversion(inode));
 		to->di_crtime.t_sec = cpu_to_be32(from->di_crtime.tv_sec);
 		to->di_crtime.t_nsec = cpu_to_be32(from->di_crtime.tv_nsec);
-		to->di_flags2 = cpu_to_be64(from->di_flags2);
+		to->di_flags2 = cpu_to_be64(ip->i_diflags2);
 		to->di_cowextsize = cpu_to_be32(ip->i_cowextsize);
 		to->di_ino = cpu_to_be64(ip->i_ino);
 		to->di_lsn = cpu_to_be64(lsn);
diff --git a/fs/xfs/libxfs/xfs_inode_buf.h b/fs/xfs/libxfs/xfs_inode_buf.h
index 5c6a6ac521b11d..4bfad6d6d5710a 100644
--- a/fs/xfs/libxfs/xfs_inode_buf.h
+++ b/fs/xfs/libxfs/xfs_inode_buf.h
@@ -19,8 +19,6 @@ struct xfs_icdinode {
 	uint32_t	di_dmevmask;	/* DMIG event mask */
 	uint16_t	di_dmstate;	/* DMIG state info */
 
-	uint64_t	di_flags2;	/* more random flags */
-
 	struct timespec64 di_crtime;	/* time created */
 };
 
diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c
index 0b944aad75e618..8f85a4131983a6 100644
--- a/fs/xfs/xfs_bmap_util.c
+++ b/fs/xfs/xfs_bmap_util.c
@@ -1332,9 +1332,9 @@ xfs_swap_extent_rmap(
 	 * rmap functions when we go to fix up the rmaps.  The flags
 	 * will be switch for reals later.
 	 */
-	tip_flags2 = tip->i_d.di_flags2;
-	if (ip->i_d.di_flags2 & XFS_DIFLAG2_REFLINK)
-		tip->i_d.di_flags2 |= XFS_DIFLAG2_REFLINK;
+	tip_flags2 = tip->i_diflags2;
+	if (ip->i_diflags2 & XFS_DIFLAG2_REFLINK)
+		tip->i_diflags2 |= XFS_DIFLAG2_REFLINK;
 
 	offset_fsb = 0;
 	end_fsb = XFS_B_TO_FSB(ip->i_mount, i_size_read(VFS_I(ip)));
@@ -1405,12 +1405,12 @@ xfs_swap_extent_rmap(
 		offset_fsb += ilen;
 	}
 
-	tip->i_d.di_flags2 = tip_flags2;
+	tip->i_diflags2 = tip_flags2;
 	return 0;
 
 out:
 	trace_xfs_swap_extent_rmap_error(ip, error, _RET_IP_);
-	tip->i_d.di_flags2 = tip_flags2;
+	tip->i_diflags2 = tip_flags2;
 	return error;
 }
 
@@ -1708,13 +1708,13 @@ xfs_swap_extents(
 		goto out_trans_cancel;
 
 	/* Do we have to swap reflink flags? */
-	if ((ip->i_d.di_flags2 & XFS_DIFLAG2_REFLINK) ^
-	    (tip->i_d.di_flags2 & XFS_DIFLAG2_REFLINK)) {
-		f = ip->i_d.di_flags2 & XFS_DIFLAG2_REFLINK;
-		ip->i_d.di_flags2 &= ~XFS_DIFLAG2_REFLINK;
-		ip->i_d.di_flags2 |= tip->i_d.di_flags2 & XFS_DIFLAG2_REFLINK;
-		tip->i_d.di_flags2 &= ~XFS_DIFLAG2_REFLINK;
-		tip->i_d.di_flags2 |= f & XFS_DIFLAG2_REFLINK;
+	if ((ip->i_diflags2 & XFS_DIFLAG2_REFLINK) ^
+	    (tip->i_diflags2 & XFS_DIFLAG2_REFLINK)) {
+		f = ip->i_diflags2 & XFS_DIFLAG2_REFLINK;
+		ip->i_diflags2 &= ~XFS_DIFLAG2_REFLINK;
+		ip->i_diflags2 |= tip->i_diflags2 & XFS_DIFLAG2_REFLINK;
+		tip->i_diflags2 &= ~XFS_DIFLAG2_REFLINK;
+		tip->i_diflags2 |= f & XFS_DIFLAG2_REFLINK;
 	}
 
 	/* Swap the cow forks. */
diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c
index 4f08793f3d6db4..193352df48f6bd 100644
--- a/fs/xfs/xfs_file.c
+++ b/fs/xfs/xfs_file.c
@@ -1052,9 +1052,9 @@ xfs_file_remap_range(
 	 */
 	cowextsize = 0;
 	if (pos_in == 0 && len == i_size_read(inode_in) &&
-	    (src->i_d.di_flags2 & XFS_DIFLAG2_COWEXTSIZE) &&
+	    (src->i_diflags2 & XFS_DIFLAG2_COWEXTSIZE) &&
 	    pos_out == 0 && len >= i_size_read(inode_out) &&
-	    !(dest->i_d.di_flags2 & XFS_DIFLAG2_COWEXTSIZE))
+	    !(dest->i_diflags2 & XFS_DIFLAG2_COWEXTSIZE))
 		cowextsize = src->i_cowextsize;
 
 	ret = xfs_reflink_update_dest(dest, pos_out + len, cowextsize,
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index 479342ac8851f4..593e8c5c2fd658 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -81,7 +81,7 @@ xfs_get_cowextsz_hint(
 	xfs_extlen_t		a, b;
 
 	a = 0;
-	if (ip->i_d.di_flags2 & XFS_DIFLAG2_COWEXTSIZE)
+	if (ip->i_diflags2 & XFS_DIFLAG2_COWEXTSIZE)
 		a = ip->i_cowextsize;
 	b = xfs_get_extsz_hint(ip);
 
@@ -671,9 +671,7 @@ uint
 xfs_ip2xflags(
 	struct xfs_inode	*ip)
 {
-	struct xfs_icdinode	*dic = &ip->i_d;
-
-	return _xfs_dic2xflags(ip->i_diflags, dic->di_flags2, XFS_IFORK_Q(ip));
+	return _xfs_dic2xflags(ip->i_diflags, ip->i_diflags2, XFS_IFORK_Q(ip));
 }
 
 /*
@@ -841,7 +839,7 @@ xfs_ialloc(
 
 	if (xfs_sb_version_has_v3inode(&mp->m_sb)) {
 		inode_set_iversion(inode, 1);
-		ip->i_d.di_flags2 = 0;
+		ip->i_diflags2 = 0;
 		ip->i_cowextsize = 0;
 		ip->i_d.di_crtime = tv;
 	}
@@ -898,13 +896,13 @@ xfs_ialloc(
 
 			ip->i_diflags |= di_flags;
 		}
-		if (pip && (pip->i_d.di_flags2 & XFS_DIFLAG2_ANY)) {
-			if (pip->i_d.di_flags2 & XFS_DIFLAG2_COWEXTSIZE) {
-				ip->i_d.di_flags2 |= XFS_DIFLAG2_COWEXTSIZE;
+		if (pip && (pip->i_diflags2 & XFS_DIFLAG2_ANY)) {
+			if (pip->i_diflags2 & XFS_DIFLAG2_COWEXTSIZE) {
+				ip->i_diflags2 |= XFS_DIFLAG2_COWEXTSIZE;
 				ip->i_cowextsize = pip->i_cowextsize;
 			}
-			if (pip->i_d.di_flags2 & XFS_DIFLAG2_DAX)
-				ip->i_d.di_flags2 |= XFS_DIFLAG2_DAX;
+			if (pip->i_diflags2 & XFS_DIFLAG2_DAX)
+				ip->i_diflags2 |= XFS_DIFLAG2_DAX;
 		}
 		/* FALLTHROUGH */
 	case S_IFLNK:
@@ -1456,7 +1454,7 @@ xfs_itruncate_clear_reflink_flags(
 	dfork = XFS_IFORK_PTR(ip, XFS_DATA_FORK);
 	cfork = XFS_IFORK_PTR(ip, XFS_COW_FORK);
 	if (dfork->if_bytes == 0 && cfork->if_bytes == 0)
-		ip->i_d.di_flags2 &= ~XFS_DIFLAG2_REFLINK;
+		ip->i_diflags2 &= ~XFS_DIFLAG2_REFLINK;
 	if (cfork->if_bytes == 0)
 		xfs_inode_clear_cowblocks_tag(ip);
 }
@@ -2756,7 +2754,7 @@ xfs_ifree(
 
 	VFS_I(ip)->i_mode = 0;		/* mark incore inode as free */
 	ip->i_diflags = 0;
-	ip->i_d.di_flags2 = 0;
+	ip->i_diflags2 = 0;
 	ip->i_d.di_dmevmask = 0;
 	ip->i_forkoff = 0;		/* mark the attr fork not in use */
 	ip->i_df.if_format = XFS_DINODE_FMT_EXTENTS;
diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h
index 7673c841d89154..709f04fadde65e 100644
--- a/fs/xfs/xfs_inode.h
+++ b/fs/xfs/xfs_inode.h
@@ -65,6 +65,7 @@ typedef struct xfs_inode {
 	};
 	uint8_t			i_forkoff;	/* attr fork offset >> 3 */
 	uint16_t		i_diflags;	/* XFS_DIFLAG_... */
+	uint64_t		i_diflags2;	/* XFS_DIFLAG2_... */
 
 	struct xfs_icdinode	i_d;		/* most of ondisk inode */
 
@@ -193,7 +194,7 @@ xfs_get_initial_prid(struct xfs_inode *dp)
 
 static inline bool xfs_is_reflink_inode(struct xfs_inode *ip)
 {
-	return ip->i_d.di_flags2 & XFS_DIFLAG2_REFLINK;
+	return ip->i_diflags2 & XFS_DIFLAG2_REFLINK;
 }
 
 /*
diff --git a/fs/xfs/xfs_inode_item.c b/fs/xfs/xfs_inode_item.c
index 6af8e829dd0172..04e671d2957ca2 100644
--- a/fs/xfs/xfs_inode_item.c
+++ b/fs/xfs/xfs_inode_item.c
@@ -342,7 +342,7 @@ xfs_inode_to_log_dinode(
 		to->di_changecount = inode_peek_iversion(inode);
 		to->di_crtime.t_sec = from->di_crtime.tv_sec;
 		to->di_crtime.t_nsec = from->di_crtime.tv_nsec;
-		to->di_flags2 = from->di_flags2;
+		to->di_flags2 = ip->i_diflags2;
 		to->di_cowextsize = ip->i_cowextsize;
 		to->di_ino = ip->i_ino;
 		to->di_lsn = lsn;
diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
index 326991f4d98096..d05b86e7930e84 100644
--- a/fs/xfs/xfs_ioctl.c
+++ b/fs/xfs/xfs_ioctl.c
@@ -1110,7 +1110,7 @@ xfs_fill_fsxattr(
 	simple_fill_fsxattr(fa, xfs_ip2xflags(ip));
 	fa->fsx_extsize = XFS_FSB_TO_B(mp, ip->i_extsize);
 	if (xfs_sb_version_has_v3inode(&mp->m_sb) &&
-	    (ip->i_d.di_flags2 & XFS_DIFLAG2_COWEXTSIZE))
+	    (ip->i_diflags2 & XFS_DIFLAG2_COWEXTSIZE))
 		fa->fsx_cowextsize = XFS_FSB_TO_B(mp, ip->i_cowextsize);
 	fa->fsx_projid = ip->i_projid;
 	if (ifp && (ifp->if_flags & XFS_IFEXTENTS))
@@ -1183,15 +1183,14 @@ xfs_flags2diflags2(
 	struct xfs_inode	*ip,
 	unsigned int		xflags)
 {
-	uint64_t		di_flags2 =
-		(ip->i_d.di_flags2 & XFS_DIFLAG2_REFLINK);
+	uint64_t		i_flags2 = (ip->i_diflags2 & XFS_DIFLAG2_REFLINK);
 
 	if (xflags & FS_XFLAG_DAX)
-		di_flags2 |= XFS_DIFLAG2_DAX;
+		i_flags2 |= XFS_DIFLAG2_DAX;
 	if (xflags & FS_XFLAG_COWEXTSIZE)
-		di_flags2 |= XFS_DIFLAG2_COWEXTSIZE;
+		i_flags2 |= XFS_DIFLAG2_COWEXTSIZE;
 
-	return di_flags2;
+	return i_flags2;
 }
 
 static int
@@ -1201,7 +1200,7 @@ xfs_ioctl_setattr_xflags(
 	struct fsxattr		*fa)
 {
 	struct xfs_mount	*mp = ip->i_mount;
-	uint64_t		di_flags2;
+	uint64_t		i_flags2;
 
 	/* Can't change realtime flag if any extents are allocated. */
 	if ((ip->i_df.if_nextents || ip->i_delayed_blks) &&
@@ -1217,19 +1216,19 @@ xfs_ioctl_setattr_xflags(
 
 	/* Clear reflink if we are actually able to set the rt flag. */
 	if ((fa->fsx_xflags & FS_XFLAG_REALTIME) && xfs_is_reflink_inode(ip))
-		ip->i_d.di_flags2 &= ~XFS_DIFLAG2_REFLINK;
+		ip->i_diflags2 &= ~XFS_DIFLAG2_REFLINK;
 
 	/* Don't allow us to set DAX mode for a reflinked file for now. */
 	if ((fa->fsx_xflags & FS_XFLAG_DAX) && xfs_is_reflink_inode(ip))
 		return -EINVAL;
 
 	/* diflags2 only valid for v3 inodes. */
-	di_flags2 = xfs_flags2diflags2(ip, fa->fsx_xflags);
-	if (di_flags2 && !xfs_sb_version_has_v3inode(&mp->m_sb))
+	i_flags2 = xfs_flags2diflags2(ip, fa->fsx_xflags);
+	if (i_flags2 && !xfs_sb_version_has_v3inode(&mp->m_sb))
 		return -EINVAL;
 
 	ip->i_diflags = xfs_flags2diflags(ip, fa->fsx_xflags);
-	ip->i_d.di_flags2 = di_flags2;
+	ip->i_diflags2 = i_flags2;
 
 	xfs_diflags_to_iflags(ip, false);
 	xfs_trans_ichgtime(tp, ip, XFS_ICHGTIME_CHG);
@@ -1575,7 +1574,7 @@ xfs_ioctl_setattr(
 	else
 		ip->i_extsize = 0;
 	if (xfs_sb_version_has_v3inode(&mp->m_sb) &&
-	    (ip->i_d.di_flags2 & XFS_DIFLAG2_COWEXTSIZE))
+	    (ip->i_diflags2 & XFS_DIFLAG2_COWEXTSIZE))
 		ip->i_cowextsize = fa->fsx_cowextsize >> mp->m_sb.sb_blocklog;
 	else
 		ip->i_cowextsize = 0;
diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
index f37154fc9828fd..3642f9935cae3f 100644
--- a/fs/xfs/xfs_iops.c
+++ b/fs/xfs/xfs_iops.c
@@ -1265,7 +1265,7 @@ xfs_inode_should_enable_dax(
 		return false;
 	if (ip->i_mount->m_flags & XFS_MOUNT_DAX_ALWAYS)
 		return true;
-	if (ip->i_d.di_flags2 & XFS_DIFLAG2_DAX)
+	if (ip->i_diflags2 & XFS_DIFLAG2_DAX)
 		return true;
 	return false;
 }
diff --git a/fs/xfs/xfs_itable.c b/fs/xfs/xfs_itable.c
index 7937af9f2ea779..4d1509437c3576 100644
--- a/fs/xfs/xfs_itable.c
+++ b/fs/xfs/xfs_itable.c
@@ -111,7 +111,7 @@ xfs_bulkstat_one_int(
 	buf->bs_version = XFS_BULKSTAT_VERSION_V5;
 
 	if (xfs_sb_version_has_v3inode(&mp->m_sb)) {
-		if (dic->di_flags2 & XFS_DIFLAG2_COWEXTSIZE)
+		if (ip->i_diflags2 & XFS_DIFLAG2_COWEXTSIZE)
 			buf->bs_cowextsize_blks = ip->i_cowextsize;
 	}
 
diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c
index 0e07fa7e43117e..476ba54d84a9a3 100644
--- a/fs/xfs/xfs_reflink.c
+++ b/fs/xfs/xfs_reflink.c
@@ -882,7 +882,7 @@ xfs_reflink_set_inode_flag(
 	if (!xfs_is_reflink_inode(src)) {
 		trace_xfs_reflink_set_inode_flag(src);
 		xfs_trans_ijoin(tp, src, XFS_ILOCK_EXCL);
-		src->i_d.di_flags2 |= XFS_DIFLAG2_REFLINK;
+		src->i_diflags2 |= XFS_DIFLAG2_REFLINK;
 		xfs_trans_log_inode(tp, src, XFS_ILOG_CORE);
 		xfs_ifork_init_cow(src);
 	} else
@@ -894,7 +894,7 @@ xfs_reflink_set_inode_flag(
 	if (!xfs_is_reflink_inode(dest)) {
 		trace_xfs_reflink_set_inode_flag(dest);
 		xfs_trans_ijoin(tp, dest, XFS_ILOCK_EXCL);
-		dest->i_d.di_flags2 |= XFS_DIFLAG2_REFLINK;
+		dest->i_diflags2 |= XFS_DIFLAG2_REFLINK;
 		xfs_trans_log_inode(tp, dest, XFS_ILOG_CORE);
 		xfs_ifork_init_cow(dest);
 	} else
@@ -943,7 +943,7 @@ xfs_reflink_update_dest(
 
 	if (cowextsize) {
 		dest->i_cowextsize = cowextsize;
-		dest->i_d.di_flags2 |= XFS_DIFLAG2_COWEXTSIZE;
+		dest->i_diflags2 |= XFS_DIFLAG2_COWEXTSIZE;
 	}
 
 	xfs_trans_log_inode(tp, dest, XFS_ILOG_CORE);
@@ -1463,7 +1463,7 @@ xfs_reflink_clear_inode_flag(
 
 	/* Clear the inode flag. */
 	trace_xfs_reflink_unset_inode_flag(ip);
-	ip->i_d.di_flags2 &= ~XFS_DIFLAG2_REFLINK;
+	ip->i_diflags2 &= ~XFS_DIFLAG2_REFLINK;
 	xfs_inode_clear_cowblocks_tag(ip);
 	xfs_trans_log_inode(*tpp, ip, XFS_ILOG_CORE);
 
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH 13/15] xfs: move the di_crtime field to struct xfs_inode
  2020-06-20  7:10 xfs inode structure cleanups v2 Christoph Hellwig
                   ` (11 preceding siblings ...)
  2020-06-20  7:10 ` [PATCH 12/15] xfs: move the di_flags2 " Christoph Hellwig
@ 2020-06-20  7:11 ` Christoph Hellwig
  2020-06-22 12:54   ` Chandan Babu R
  2020-06-30 17:55   ` Darrick J. Wong
  2020-06-20  7:11 ` [PATCH 14/15] xfs: move the di_dmevmask " Christoph Hellwig
                   ` (2 subsequent siblings)
  15 siblings, 2 replies; 52+ messages in thread
From: Christoph Hellwig @ 2020-06-20  7:11 UTC (permalink / raw)
  To: linux-xfs

In preparation of removing the historic icinode struct, move the crtime
field into the containing xfs_inode structure.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/xfs/libxfs/xfs_inode_buf.c   | 8 ++++----
 fs/xfs/libxfs/xfs_inode_buf.h   | 2 --
 fs/xfs/libxfs/xfs_trans_inode.c | 2 +-
 fs/xfs/xfs_inode.c              | 2 +-
 fs/xfs/xfs_inode.h              | 1 +
 fs/xfs/xfs_inode_item.c         | 4 ++--
 fs/xfs/xfs_iops.c               | 2 +-
 fs/xfs/xfs_itable.c             | 4 ++--
 8 files changed, 12 insertions(+), 13 deletions(-)

diff --git a/fs/xfs/libxfs/xfs_inode_buf.c b/fs/xfs/libxfs/xfs_inode_buf.c
index 79e470933abfa8..af595ee23635aa 100644
--- a/fs/xfs/libxfs/xfs_inode_buf.c
+++ b/fs/xfs/libxfs/xfs_inode_buf.c
@@ -253,8 +253,8 @@ xfs_inode_from_disk(
 	if (xfs_sb_version_has_v3inode(&ip->i_mount->m_sb)) {
 		inode_set_iversion_queried(inode,
 					   be64_to_cpu(from->di_changecount));
-		to->di_crtime.tv_sec = be32_to_cpu(from->di_crtime.t_sec);
-		to->di_crtime.tv_nsec = be32_to_cpu(from->di_crtime.t_nsec);
+		ip->i_crtime.tv_sec = be32_to_cpu(from->di_crtime.t_sec);
+		ip->i_crtime.tv_nsec = be32_to_cpu(from->di_crtime.t_nsec);
 		ip->i_diflags2 = be64_to_cpu(from->di_flags2);
 		ip->i_cowextsize = be32_to_cpu(from->di_cowextsize);
 	}
@@ -319,8 +319,8 @@ xfs_inode_to_disk(
 	if (xfs_sb_version_has_v3inode(&ip->i_mount->m_sb)) {
 		to->di_version = 3;
 		to->di_changecount = cpu_to_be64(inode_peek_iversion(inode));
-		to->di_crtime.t_sec = cpu_to_be32(from->di_crtime.tv_sec);
-		to->di_crtime.t_nsec = cpu_to_be32(from->di_crtime.tv_nsec);
+		to->di_crtime.t_sec = cpu_to_be32(ip->i_crtime.tv_sec);
+		to->di_crtime.t_nsec = cpu_to_be32(ip->i_crtime.tv_nsec);
 		to->di_flags2 = cpu_to_be64(ip->i_diflags2);
 		to->di_cowextsize = cpu_to_be32(ip->i_cowextsize);
 		to->di_ino = cpu_to_be64(ip->i_ino);
diff --git a/fs/xfs/libxfs/xfs_inode_buf.h b/fs/xfs/libxfs/xfs_inode_buf.h
index 4bfad6d6d5710a..2a8e7a7ed8d18d 100644
--- a/fs/xfs/libxfs/xfs_inode_buf.h
+++ b/fs/xfs/libxfs/xfs_inode_buf.h
@@ -18,8 +18,6 @@ struct xfs_dinode;
 struct xfs_icdinode {
 	uint32_t	di_dmevmask;	/* DMIG event mask */
 	uint16_t	di_dmstate;	/* DMIG state info */
-
-	struct timespec64 di_crtime;	/* time created */
 };
 
 /*
diff --git a/fs/xfs/libxfs/xfs_trans_inode.c b/fs/xfs/libxfs/xfs_trans_inode.c
index b5dfb665484223..3c690829634cdc 100644
--- a/fs/xfs/libxfs/xfs_trans_inode.c
+++ b/fs/xfs/libxfs/xfs_trans_inode.c
@@ -67,7 +67,7 @@ xfs_trans_ichgtime(
 	if (flags & XFS_ICHGTIME_CHG)
 		inode->i_ctime = tv;
 	if (flags & XFS_ICHGTIME_CREATE)
-		ip->i_d.di_crtime = tv;
+		ip->i_crtime = tv;
 }
 
 /*
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index 593e8c5c2fd658..59f11314750a46 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -841,7 +841,7 @@ xfs_ialloc(
 		inode_set_iversion(inode, 1);
 		ip->i_diflags2 = 0;
 		ip->i_cowextsize = 0;
-		ip->i_d.di_crtime = tv;
+		ip->i_crtime = tv;
 	}
 
 	flags = XFS_ILOG_CORE;
diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h
index 709f04fadde65e..106a8d6cc010cb 100644
--- a/fs/xfs/xfs_inode.h
+++ b/fs/xfs/xfs_inode.h
@@ -66,6 +66,7 @@ typedef struct xfs_inode {
 	uint8_t			i_forkoff;	/* attr fork offset >> 3 */
 	uint16_t		i_diflags;	/* XFS_DIFLAG_... */
 	uint64_t		i_diflags2;	/* XFS_DIFLAG2_... */
+	struct timespec64	i_crtime;	/* time created */
 
 	struct xfs_icdinode	i_d;		/* most of ondisk inode */
 
diff --git a/fs/xfs/xfs_inode_item.c b/fs/xfs/xfs_inode_item.c
index 04e671d2957ca2..dff3bc6a33720a 100644
--- a/fs/xfs/xfs_inode_item.c
+++ b/fs/xfs/xfs_inode_item.c
@@ -340,8 +340,8 @@ xfs_inode_to_log_dinode(
 	if (xfs_sb_version_has_v3inode(&ip->i_mount->m_sb)) {
 		to->di_version = 3;
 		to->di_changecount = inode_peek_iversion(inode);
-		to->di_crtime.t_sec = from->di_crtime.tv_sec;
-		to->di_crtime.t_nsec = from->di_crtime.tv_nsec;
+		to->di_crtime.t_sec = ip->i_crtime.tv_sec;
+		to->di_crtime.t_nsec = ip->i_crtime.tv_nsec;
 		to->di_flags2 = ip->i_diflags2;
 		to->di_cowextsize = ip->i_cowextsize;
 		to->di_ino = ip->i_ino;
diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
index 3642f9935cae3f..6aace9c6586ca5 100644
--- a/fs/xfs/xfs_iops.c
+++ b/fs/xfs/xfs_iops.c
@@ -559,7 +559,7 @@ xfs_vn_getattr(
 	if (xfs_sb_version_has_v3inode(&mp->m_sb)) {
 		if (request_mask & STATX_BTIME) {
 			stat->result_mask |= STATX_BTIME;
-			stat->btime = ip->i_d.di_crtime;
+			stat->btime = ip->i_crtime;
 		}
 	}
 
diff --git a/fs/xfs/xfs_itable.c b/fs/xfs/xfs_itable.c
index 4d1509437c3576..7945c6c4844940 100644
--- a/fs/xfs/xfs_itable.c
+++ b/fs/xfs/xfs_itable.c
@@ -97,8 +97,8 @@ xfs_bulkstat_one_int(
 	buf->bs_mtime_nsec = inode->i_mtime.tv_nsec;
 	buf->bs_ctime = inode->i_ctime.tv_sec;
 	buf->bs_ctime_nsec = inode->i_ctime.tv_nsec;
-	buf->bs_btime = dic->di_crtime.tv_sec;
-	buf->bs_btime_nsec = dic->di_crtime.tv_nsec;
+	buf->bs_btime = ip->i_crtime.tv_sec;
+	buf->bs_btime_nsec = ip->i_crtime.tv_nsec;
 	buf->bs_gen = inode->i_generation;
 	buf->bs_mode = inode->i_mode;
 
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH 14/15] xfs: move the di_dmevmask field to struct xfs_inode
  2020-06-20  7:10 xfs inode structure cleanups v2 Christoph Hellwig
                   ` (12 preceding siblings ...)
  2020-06-20  7:11 ` [PATCH 13/15] xfs: move the di_crtime " Christoph Hellwig
@ 2020-06-20  7:11 ` Christoph Hellwig
  2020-06-22 12:58   ` Chandan Babu R
  2020-06-30 17:55   ` Darrick J. Wong
  2020-06-20  7:11 ` [PATCH 15/15] xfs: move the di_dmstate " Christoph Hellwig
  2020-06-30 18:01 ` xfs inode structure cleanups v2 Darrick J. Wong
  15 siblings, 2 replies; 52+ messages in thread
From: Christoph Hellwig @ 2020-06-20  7:11 UTC (permalink / raw)
  To: linux-xfs

In preparation of removing the historic icinode struct, move the
dmevmask field into the containing xfs_inode structure.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/xfs/libxfs/xfs_inode_buf.c | 4 ++--
 fs/xfs/libxfs/xfs_inode_buf.h | 1 -
 fs/xfs/xfs_inode.c            | 4 ++--
 fs/xfs/xfs_inode.h            | 1 +
 fs/xfs/xfs_inode_item.c       | 2 +-
 fs/xfs/xfs_log_recover.c      | 2 +-
 6 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/fs/xfs/libxfs/xfs_inode_buf.c b/fs/xfs/libxfs/xfs_inode_buf.c
index af595ee23635aa..d361803102d0e1 100644
--- a/fs/xfs/libxfs/xfs_inode_buf.c
+++ b/fs/xfs/libxfs/xfs_inode_buf.c
@@ -246,7 +246,7 @@ xfs_inode_from_disk(
 	ip->i_nblocks = be64_to_cpu(from->di_nblocks);
 	ip->i_extsize = be32_to_cpu(from->di_extsize);
 	ip->i_forkoff = from->di_forkoff;
-	to->di_dmevmask	= be32_to_cpu(from->di_dmevmask);
+	ip->i_dmevmask	= be32_to_cpu(from->di_dmevmask);
 	to->di_dmstate	= be16_to_cpu(from->di_dmstate);
 	ip->i_diflags	= be16_to_cpu(from->di_flags);
 
@@ -312,7 +312,7 @@ xfs_inode_to_disk(
 	to->di_anextents = cpu_to_be16(xfs_ifork_nextents(ip->i_afp));
 	to->di_forkoff = ip->i_forkoff;
 	to->di_aformat = xfs_ifork_format(ip->i_afp);
-	to->di_dmevmask = cpu_to_be32(from->di_dmevmask);
+	to->di_dmevmask = cpu_to_be32(ip->i_dmevmask);
 	to->di_dmstate = cpu_to_be16(from->di_dmstate);
 	to->di_flags = cpu_to_be16(ip->i_diflags);
 
diff --git a/fs/xfs/libxfs/xfs_inode_buf.h b/fs/xfs/libxfs/xfs_inode_buf.h
index 2a8e7a7ed8d18d..0cfc1aaff6c6f3 100644
--- a/fs/xfs/libxfs/xfs_inode_buf.h
+++ b/fs/xfs/libxfs/xfs_inode_buf.h
@@ -16,7 +16,6 @@ struct xfs_dinode;
  * format specific structures at the appropriate time.
  */
 struct xfs_icdinode {
-	uint32_t	di_dmevmask;	/* DMIG event mask */
 	uint16_t	di_dmstate;	/* DMIG state info */
 };
 
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index 59f11314750a46..db48c910c8d7b0 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -833,7 +833,7 @@ xfs_ialloc(
 	inode->i_ctime = tv;
 
 	ip->i_extsize = 0;
-	ip->i_d.di_dmevmask = 0;
+	ip->i_dmevmask = 0;
 	ip->i_d.di_dmstate = 0;
 	ip->i_diflags = 0;
 
@@ -2755,7 +2755,7 @@ xfs_ifree(
 	VFS_I(ip)->i_mode = 0;		/* mark incore inode as free */
 	ip->i_diflags = 0;
 	ip->i_diflags2 = 0;
-	ip->i_d.di_dmevmask = 0;
+	ip->i_dmevmask = 0;
 	ip->i_forkoff = 0;		/* mark the attr fork not in use */
 	ip->i_df.if_format = XFS_DINODE_FMT_EXTENTS;
 
diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h
index 106a8d6cc010cb..e64df2e7438aa0 100644
--- a/fs/xfs/xfs_inode.h
+++ b/fs/xfs/xfs_inode.h
@@ -67,6 +67,7 @@ typedef struct xfs_inode {
 	uint16_t		i_diflags;	/* XFS_DIFLAG_... */
 	uint64_t		i_diflags2;	/* XFS_DIFLAG2_... */
 	struct timespec64	i_crtime;	/* time created */
+	uint32_t		i_dmevmask;	/* DMIG event mask */
 
 	struct xfs_icdinode	i_d;		/* most of ondisk inode */
 
diff --git a/fs/xfs/xfs_inode_item.c b/fs/xfs/xfs_inode_item.c
index dff3bc6a33720a..9b7860025c497d 100644
--- a/fs/xfs/xfs_inode_item.c
+++ b/fs/xfs/xfs_inode_item.c
@@ -330,7 +330,7 @@ xfs_inode_to_log_dinode(
 	to->di_anextents = xfs_ifork_nextents(ip->i_afp);
 	to->di_forkoff = ip->i_forkoff;
 	to->di_aformat = xfs_ifork_format(ip->i_afp);
-	to->di_dmevmask = from->di_dmevmask;
+	to->di_dmevmask = ip->i_dmevmask;
 	to->di_dmstate = from->di_dmstate;
 	to->di_flags = ip->i_diflags;
 
diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c
index ec015df55b77a9..d096b8c4013814 100644
--- a/fs/xfs/xfs_log_recover.c
+++ b/fs/xfs/xfs_log_recover.c
@@ -2720,7 +2720,7 @@ xlog_recover_process_one_iunlink(
 	 * Prevent any DMAPI event from being sent when the reference on
 	 * the inode is dropped.
 	 */
-	ip->i_d.di_dmevmask = 0;
+	ip->i_dmevmask = 0;
 
 	xfs_irele(ip);
 	return agino;
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH 15/15] xfs: move the di_dmstate field to struct xfs_inode
  2020-06-20  7:10 xfs inode structure cleanups v2 Christoph Hellwig
                   ` (13 preceding siblings ...)
  2020-06-20  7:11 ` [PATCH 14/15] xfs: move the di_dmevmask " Christoph Hellwig
@ 2020-06-20  7:11 ` Christoph Hellwig
  2020-06-22 13:18   ` Chandan Babu R
  2020-06-30 17:56   ` Darrick J. Wong
  2020-06-30 18:01 ` xfs inode structure cleanups v2 Darrick J. Wong
  15 siblings, 2 replies; 52+ messages in thread
From: Christoph Hellwig @ 2020-06-20  7:11 UTC (permalink / raw)
  To: linux-xfs

Move the di_dmstate into struct xfs_inode, and thus finally kill of
the xfs_icdinode structure.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/xfs/libxfs/xfs_inode_buf.c |  6 ++----
 fs/xfs/libxfs/xfs_inode_buf.h | 10 ----------
 fs/xfs/xfs_inode.c            |  2 +-
 fs/xfs/xfs_inode.h            |  3 +--
 fs/xfs/xfs_inode_item.c       |  3 +--
 fs/xfs/xfs_itable.c           |  3 ---
 6 files changed, 5 insertions(+), 22 deletions(-)

diff --git a/fs/xfs/libxfs/xfs_inode_buf.c b/fs/xfs/libxfs/xfs_inode_buf.c
index d361803102d0e1..e4e96a47e0bab6 100644
--- a/fs/xfs/libxfs/xfs_inode_buf.c
+++ b/fs/xfs/libxfs/xfs_inode_buf.c
@@ -185,7 +185,6 @@ xfs_inode_from_disk(
 	struct xfs_inode	*ip,
 	struct xfs_dinode	*from)
 {
-	struct xfs_icdinode	*to = &ip->i_d;
 	struct inode		*inode = VFS_I(ip);
 	int			error;
 	xfs_failaddr_t		fa;
@@ -247,7 +246,7 @@ xfs_inode_from_disk(
 	ip->i_extsize = be32_to_cpu(from->di_extsize);
 	ip->i_forkoff = from->di_forkoff;
 	ip->i_dmevmask	= be32_to_cpu(from->di_dmevmask);
-	to->di_dmstate	= be16_to_cpu(from->di_dmstate);
+	ip->i_dmstate	= be16_to_cpu(from->di_dmstate);
 	ip->i_diflags	= be16_to_cpu(from->di_flags);
 
 	if (xfs_sb_version_has_v3inode(&ip->i_mount->m_sb)) {
@@ -282,7 +281,6 @@ xfs_inode_to_disk(
 	struct xfs_dinode	*to,
 	xfs_lsn_t		lsn)
 {
-	struct xfs_icdinode	*from = &ip->i_d;
 	struct inode		*inode = VFS_I(ip);
 
 	to->di_magic = cpu_to_be16(XFS_DINODE_MAGIC);
@@ -313,7 +311,7 @@ xfs_inode_to_disk(
 	to->di_forkoff = ip->i_forkoff;
 	to->di_aformat = xfs_ifork_format(ip->i_afp);
 	to->di_dmevmask = cpu_to_be32(ip->i_dmevmask);
-	to->di_dmstate = cpu_to_be16(from->di_dmstate);
+	to->di_dmstate = cpu_to_be16(ip->i_dmstate);
 	to->di_flags = cpu_to_be16(ip->i_diflags);
 
 	if (xfs_sb_version_has_v3inode(&ip->i_mount->m_sb)) {
diff --git a/fs/xfs/libxfs/xfs_inode_buf.h b/fs/xfs/libxfs/xfs_inode_buf.h
index 0cfc1aaff6c6f3..834c8b3e917370 100644
--- a/fs/xfs/libxfs/xfs_inode_buf.h
+++ b/fs/xfs/libxfs/xfs_inode_buf.h
@@ -9,16 +9,6 @@
 struct xfs_inode;
 struct xfs_dinode;
 
-/*
- * In memory representation of the XFS inode. This is held in the in-core struct
- * xfs_inode and represents the current on disk values but the structure is not
- * in on-disk format.  That is, this structure is always translated to on-disk
- * format specific structures at the appropriate time.
- */
-struct xfs_icdinode {
-	uint16_t	di_dmstate;	/* DMIG state info */
-};
-
 /*
  * Inode location information.  Stored in the inode and passed to
  * xfs_imap_to_bp() to get a buffer and dinode for a given inode.
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index db48c910c8d7b0..79436ed0b14e89 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -834,7 +834,7 @@ xfs_ialloc(
 
 	ip->i_extsize = 0;
 	ip->i_dmevmask = 0;
-	ip->i_d.di_dmstate = 0;
+	ip->i_dmstate = 0;
 	ip->i_diflags = 0;
 
 	if (xfs_sb_version_has_v3inode(&mp->m_sb)) {
diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h
index e64df2e7438aa0..f0537ead8bad90 100644
--- a/fs/xfs/xfs_inode.h
+++ b/fs/xfs/xfs_inode.h
@@ -68,8 +68,7 @@ typedef struct xfs_inode {
 	uint64_t		i_diflags2;	/* XFS_DIFLAG2_... */
 	struct timespec64	i_crtime;	/* time created */
 	uint32_t		i_dmevmask;	/* DMIG event mask */
-
-	struct xfs_icdinode	i_d;		/* most of ondisk inode */
+	uint16_t		i_dmstate;	/* DMIG state info */
 
 	/* VFS inode */
 	struct inode		i_vnode;	/* embedded VFS inode */
diff --git a/fs/xfs/xfs_inode_item.c b/fs/xfs/xfs_inode_item.c
index 9b7860025c497d..628f8190abddca 100644
--- a/fs/xfs/xfs_inode_item.c
+++ b/fs/xfs/xfs_inode_item.c
@@ -301,7 +301,6 @@ xfs_inode_to_log_dinode(
 	struct xfs_log_dinode	*to,
 	xfs_lsn_t		lsn)
 {
-	struct xfs_icdinode	*from = &ip->i_d;
 	struct inode		*inode = VFS_I(ip);
 
 	to->di_magic = XFS_DINODE_MAGIC;
@@ -331,7 +330,7 @@ xfs_inode_to_log_dinode(
 	to->di_forkoff = ip->i_forkoff;
 	to->di_aformat = xfs_ifork_format(ip->i_afp);
 	to->di_dmevmask = ip->i_dmevmask;
-	to->di_dmstate = from->di_dmstate;
+	to->di_dmstate = ip->i_dmstate;
 	to->di_flags = ip->i_diflags;
 
 	/* log a dummy value to ensure log structure is fully initialised */
diff --git a/fs/xfs/xfs_itable.c b/fs/xfs/xfs_itable.c
index 7945c6c4844940..cd1f09e57b9483 100644
--- a/fs/xfs/xfs_itable.c
+++ b/fs/xfs/xfs_itable.c
@@ -58,7 +58,6 @@ xfs_bulkstat_one_int(
 	xfs_ino_t		ino,
 	struct xfs_bstat_chunk	*bc)
 {
-	struct xfs_icdinode	*dic;		/* dinode core info pointer */
 	struct xfs_inode	*ip;		/* incore inode pointer */
 	struct inode		*inode;
 	struct xfs_bulkstat	*buf = bc->buf;
@@ -79,8 +78,6 @@ xfs_bulkstat_one_int(
 	ASSERT(ip->i_imap.im_blkno != 0);
 	inode = VFS_I(ip);
 
-	dic = &ip->i_d;
-
 	/* xfs_iget returns the following without needing
 	 * further change.
 	 */
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 52+ messages in thread

* Re: [PATCH 01/15] xfs: don't clear the "dinode core" in xfs_inode_alloc
  2020-06-20  7:10 ` [PATCH 01/15] xfs: don't clear the "dinode core" in xfs_inode_alloc Christoph Hellwig
@ 2020-06-22  7:11   ` Chandan Babu R
  2020-06-30 17:58   ` Darrick J. Wong
  1 sibling, 0 replies; 52+ messages in thread
From: Chandan Babu R @ 2020-06-22  7:11 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: linux-xfs

On Saturday 20 June 2020 12:40:48 PM IST Christoph Hellwig wrote:
> The xfs_icdinode structure just contains a random mix of inode field,
> which are all read from the on-disk inode and mostly not looked at
> before reading the inode or initializing a new inode cluster.  The
> only exceptions are the forkoff and blocks field, which are used
> in sanity checks for freshly allocated inodes.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  fs/xfs/xfs_icache.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/xfs/xfs_icache.c b/fs/xfs/xfs_icache.c
> index 0a5ac6f9a58349..660e7abd4e8b76 100644
> --- a/fs/xfs/xfs_icache.c
> +++ b/fs/xfs/xfs_icache.c
> @@ -66,7 +66,8 @@ xfs_inode_alloc(
>  	memset(&ip->i_df, 0, sizeof(ip->i_df));
>  	ip->i_flags = 0;
>  	ip->i_delayed_blks = 0;
> -	memset(&ip->i_d, 0, sizeof(ip->i_d));
> +	ip->i_d.di_nblocks = 0;
> +	ip->i_d.di_forkoff = 0;
>  	ip->i_sick = 0;
>  	ip->i_checked = 0;
>  	INIT_WORK(&ip->i_ioend_work, xfs_end_io);
> 

i_d.di_nblocks is accessed by xfs_iget_check_free_state() and
i_d.di_forkoff is being accessed by xfs_setup_inode(). Hence,

Reviewed-by: Chandan Babu R <chandanrlinux@gmail.com>

-- 
chandan




^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH 02/15] xfs: move the di_projid field to struct xfs_inode
  2020-06-20  7:10 ` [PATCH 02/15] xfs: move the di_projid field to struct xfs_inode Christoph Hellwig
@ 2020-06-22  7:55   ` Chandan Babu R
  2020-06-30 17:44   ` Darrick J. Wong
  1 sibling, 0 replies; 52+ messages in thread
From: Chandan Babu R @ 2020-06-22  7:55 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: linux-xfs

On Saturday 20 June 2020 12:40:49 PM IST Christoph Hellwig wrote:
> In preparation of removing the historic icinode struct, move the projid
> field into the containing xfs_inode structure.
>

The changes look good to me.

Reviewed-by: Chandan Babu R <chandanrlinux@gmail.com>

> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  fs/xfs/libxfs/xfs_inode_buf.c | 8 ++++----
>  fs/xfs/libxfs/xfs_inode_buf.h | 1 -
>  fs/xfs/xfs_bmap_util.c        | 2 +-
>  fs/xfs/xfs_dquot.c            | 2 +-
>  fs/xfs/xfs_icache.c           | 4 ++--
>  fs/xfs/xfs_inode.c            | 6 +++---
>  fs/xfs/xfs_inode.h            | 3 ++-
>  fs/xfs/xfs_inode_item.c       | 4 ++--
>  fs/xfs/xfs_ioctl.c            | 8 ++++----
>  fs/xfs/xfs_iops.c             | 2 +-
>  fs/xfs/xfs_itable.c           | 2 +-
>  fs/xfs/xfs_qm.c               | 8 ++++----
>  fs/xfs/xfs_qm_bhv.c           | 2 +-
>  13 files changed, 26 insertions(+), 26 deletions(-)
> 
> diff --git a/fs/xfs/libxfs/xfs_inode_buf.c b/fs/xfs/libxfs/xfs_inode_buf.c
> index 6f84ea85fdd837..b064cb8072c84a 100644
> --- a/fs/xfs/libxfs/xfs_inode_buf.c
> +++ b/fs/xfs/libxfs/xfs_inode_buf.c
> @@ -218,10 +218,10 @@ xfs_inode_from_disk(
>  	 */
>  	if (unlikely(from->di_version == 1)) {
>  		set_nlink(inode, be16_to_cpu(from->di_onlink));
> -		to->di_projid = 0;
> +		ip->i_projid = 0;
>  	} else {
>  		set_nlink(inode, be32_to_cpu(from->di_nlink));
> -		to->di_projid = (prid_t)be16_to_cpu(from->di_projid_hi) << 16 |
> +		ip->i_projid = (prid_t)be16_to_cpu(from->di_projid_hi) << 16 |
>  					be16_to_cpu(from->di_projid_lo);
>  	}
>  
> @@ -290,8 +290,8 @@ xfs_inode_to_disk(
>  	to->di_format = xfs_ifork_format(&ip->i_df);
>  	to->di_uid = cpu_to_be32(i_uid_read(inode));
>  	to->di_gid = cpu_to_be32(i_gid_read(inode));
> -	to->di_projid_lo = cpu_to_be16(from->di_projid & 0xffff);
> -	to->di_projid_hi = cpu_to_be16(from->di_projid >> 16);
> +	to->di_projid_lo = cpu_to_be16(ip->i_projid & 0xffff);
> +	to->di_projid_hi = cpu_to_be16(ip->i_projid >> 16);
>  
>  	memset(to->di_pad, 0, sizeof(to->di_pad));
>  	to->di_atime.t_sec = cpu_to_be32(inode->i_atime.tv_sec);
> diff --git a/fs/xfs/libxfs/xfs_inode_buf.h b/fs/xfs/libxfs/xfs_inode_buf.h
> index 865ac493c72a24..b826d81b356956 100644
> --- a/fs/xfs/libxfs/xfs_inode_buf.h
> +++ b/fs/xfs/libxfs/xfs_inode_buf.h
> @@ -17,7 +17,6 @@ struct xfs_dinode;
>   */
>  struct xfs_icdinode {
>  	uint16_t	di_flushiter;	/* incremented on flush */
> -	uint32_t	di_projid;	/* owner's project id */
>  	xfs_fsize_t	di_size;	/* number of bytes in file */
>  	xfs_rfsblock_t	di_nblocks;	/* # of direct & btree blocks used */
>  	xfs_extlen_t	di_extsize;	/* basic/minimum extent size for file */
> diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c
> index f37f5cc4b19ffe..e42553884c23cf 100644
> --- a/fs/xfs/xfs_bmap_util.c
> +++ b/fs/xfs/xfs_bmap_util.c
> @@ -1217,7 +1217,7 @@ xfs_swap_extents_check_format(
>  	if (XFS_IS_QUOTA_ON(ip->i_mount) &&
>  	    (!uid_eq(VFS_I(ip)->i_uid, VFS_I(tip)->i_uid) ||
>  	     !gid_eq(VFS_I(ip)->i_gid, VFS_I(tip)->i_gid) ||
> -	     ip->i_d.di_projid != tip->i_d.di_projid))
> +	     ip->i_projid != tip->i_projid))
>  		return -EINVAL;
>  
>  	/* Should never get a local format */
> diff --git a/fs/xfs/xfs_dquot.c b/fs/xfs/xfs_dquot.c
> index d5b7f03e93c8db..912b978a6a72d5 100644
> --- a/fs/xfs/xfs_dquot.c
> +++ b/fs/xfs/xfs_dquot.c
> @@ -868,7 +868,7 @@ xfs_qm_id_for_quotatype(
>  	case XFS_DQ_GROUP:
>  		return i_gid_read(VFS_I(ip));
>  	case XFS_DQ_PROJ:
> -		return ip->i_d.di_projid;
> +		return ip->i_projid;
>  	}
>  	ASSERT(0);
>  	return 0;
> diff --git a/fs/xfs/xfs_icache.c b/fs/xfs/xfs_icache.c
> index 660e7abd4e8b76..a3bbd6e4bb6fc8 100644
> --- a/fs/xfs/xfs_icache.c
> +++ b/fs/xfs/xfs_icache.c
> @@ -1439,7 +1439,7 @@ xfs_inode_match_id(
>  		return false;
>  
>  	if ((eofb->eof_flags & XFS_EOF_FLAGS_PRID) &&
> -	    ip->i_d.di_projid != eofb->eof_prid)
> +	    ip->i_projid != eofb->eof_prid)
>  		return false;
>  
>  	return true;
> @@ -1463,7 +1463,7 @@ xfs_inode_match_id_union(
>  		return true;
>  
>  	if ((eofb->eof_flags & XFS_EOF_FLAGS_PRID) &&
> -	    ip->i_d.di_projid == eofb->eof_prid)
> +	    ip->i_projid == eofb->eof_prid)
>  		return true;
>  
>  	return false;
> diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
> index 88a9e496480216..40e4d3ed29a798 100644
> --- a/fs/xfs/xfs_inode.c
> +++ b/fs/xfs/xfs_inode.c
> @@ -806,7 +806,7 @@ xfs_ialloc(
>  	set_nlink(inode, nlink);
>  	inode->i_uid = current_fsuid();
>  	inode->i_rdev = rdev;
> -	ip->i_d.di_projid = prid;
> +	ip->i_projid = prid;
>  
>  	if (pip && XFS_INHERIT_GID(pip)) {
>  		inode->i_gid = VFS_I(pip)->i_gid;
> @@ -1398,7 +1398,7 @@ xfs_link(
>  	 * the tree quota mechanism could be circumvented.
>  	 */
>  	if (unlikely((tdp->i_d.di_flags & XFS_DIFLAG_PROJINHERIT) &&
> -		     tdp->i_d.di_projid != sip->i_d.di_projid)) {
> +		     tdp->i_projid != sip->i_projid)) {
>  		error = -EXDEV;
>  		goto error_return;
>  	}
> @@ -3264,7 +3264,7 @@ xfs_rename(
>  	 * tree quota mechanism would be circumvented.
>  	 */
>  	if (unlikely((target_dp->i_d.di_flags & XFS_DIFLAG_PROJINHERIT) &&
> -		     target_dp->i_d.di_projid != src_ip->i_d.di_projid)) {
> +		     target_dp->i_projid != src_ip->i_projid)) {
>  		error = -EXDEV;
>  		goto out_trans_cancel;
>  	}
> diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h
> index dadcf19458960d..51ea9d53407863 100644
> --- a/fs/xfs/xfs_inode.h
> +++ b/fs/xfs/xfs_inode.h
> @@ -54,6 +54,7 @@ typedef struct xfs_inode {
>  	/* Miscellaneous state. */
>  	unsigned long		i_flags;	/* see defined flags below */
>  	uint64_t		i_delayed_blks;	/* count of delay alloc blks */
> +	uint32_t		i_projid;	/* owner's project id */
>  
>  	struct xfs_icdinode	i_d;		/* most of ondisk inode */
>  
> @@ -175,7 +176,7 @@ static inline prid_t
>  xfs_get_initial_prid(struct xfs_inode *dp)
>  {
>  	if (dp->i_d.di_flags & XFS_DIFLAG_PROJINHERIT)
> -		return dp->i_d.di_projid;
> +		return dp->i_projid;
>  
>  	return XFS_PROJID_DEFAULT;
>  }
> diff --git a/fs/xfs/xfs_inode_item.c b/fs/xfs/xfs_inode_item.c
> index ba47bf65b772be..e546b4b58ce2e0 100644
> --- a/fs/xfs/xfs_inode_item.c
> +++ b/fs/xfs/xfs_inode_item.c
> @@ -308,8 +308,8 @@ xfs_inode_to_log_dinode(
>  	to->di_format = xfs_ifork_format(&ip->i_df);
>  	to->di_uid = i_uid_read(inode);
>  	to->di_gid = i_gid_read(inode);
> -	to->di_projid_lo = from->di_projid & 0xffff;
> -	to->di_projid_hi = from->di_projid >> 16;
> +	to->di_projid_lo = ip->i_projid & 0xffff;
> +	to->di_projid_hi = ip->i_projid >> 16;
>  
>  	memset(to->di_pad, 0, sizeof(to->di_pad));
>  	memset(to->di_pad3, 0, sizeof(to->di_pad3));
> diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
> index a40f88cf3ab786..d93f4fc40fd99e 100644
> --- a/fs/xfs/xfs_ioctl.c
> +++ b/fs/xfs/xfs_ioctl.c
> @@ -1110,7 +1110,7 @@ xfs_fill_fsxattr(
>  	fa->fsx_extsize = ip->i_d.di_extsize << ip->i_mount->m_sb.sb_blocklog;
>  	fa->fsx_cowextsize = ip->i_d.di_cowextsize <<
>  			ip->i_mount->m_sb.sb_blocklog;
> -	fa->fsx_projid = ip->i_d.di_projid;
> +	fa->fsx_projid = ip->i_projid;
>  	if (ifp && (ifp->if_flags & XFS_IFEXTENTS))
>  		fa->fsx_nextents = xfs_iext_count(ifp);
>  	else
> @@ -1518,7 +1518,7 @@ xfs_ioctl_setattr(
>  	}
>  
>  	if (XFS_IS_QUOTA_RUNNING(mp) && XFS_IS_PQUOTA_ON(mp) &&
> -	    ip->i_d.di_projid != fa->fsx_projid) {
> +	    ip->i_projid != fa->fsx_projid) {
>  		code = xfs_qm_vop_chown_reserve(tp, ip, NULL, NULL, pdqp,
>  				capable(CAP_FOWNER) ?  XFS_QMOPT_FORCE_RES : 0);
>  		if (code)	/* out of quota */
> @@ -1555,12 +1555,12 @@ xfs_ioctl_setattr(
>  		VFS_I(ip)->i_mode &= ~(S_ISUID|S_ISGID);
>  
>  	/* Change the ownerships and register project quota modifications */
> -	if (ip->i_d.di_projid != fa->fsx_projid) {
> +	if (ip->i_projid != fa->fsx_projid) {
>  		if (XFS_IS_QUOTA_RUNNING(mp) && XFS_IS_PQUOTA_ON(mp)) {
>  			olddquot = xfs_qm_vop_chown(tp, ip,
>  						&ip->i_pdquot, pdqp);
>  		}
> -		ip->i_d.di_projid = fa->fsx_projid;
> +		ip->i_projid = fa->fsx_projid;
>  	}
>  
>  	/*
> diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
> index d66528fa365707..5440f555c9cc2c 100644
> --- a/fs/xfs/xfs_iops.c
> +++ b/fs/xfs/xfs_iops.c
> @@ -696,7 +696,7 @@ xfs_setattr_nonsize(
>  		 */
>  		ASSERT(udqp == NULL);
>  		ASSERT(gdqp == NULL);
> -		error = xfs_qm_vop_dqalloc(ip, uid, gid, ip->i_d.di_projid,
> +		error = xfs_qm_vop_dqalloc(ip, uid, gid, ip->i_projid,
>  					   qflags, &udqp, &gdqp, NULL);
>  		if (error)
>  			return error;
> diff --git a/fs/xfs/xfs_itable.c b/fs/xfs/xfs_itable.c
> index 16ca97a7ff00fb..97b3b794dd4ada 100644
> --- a/fs/xfs/xfs_itable.c
> +++ b/fs/xfs/xfs_itable.c
> @@ -84,7 +84,7 @@ xfs_bulkstat_one_int(
>  	/* xfs_iget returns the following without needing
>  	 * further change.
>  	 */
> -	buf->bs_projectid = ip->i_d.di_projid;
> +	buf->bs_projectid = ip->i_projid;
>  	buf->bs_ino = ino;
>  	buf->bs_uid = i_uid_read(inode);
>  	buf->bs_gid = i_gid_read(inode);
> diff --git a/fs/xfs/xfs_qm.c b/fs/xfs/xfs_qm.c
> index d6cd833173447a..ea22dcf868b474 100644
> --- a/fs/xfs/xfs_qm.c
> +++ b/fs/xfs/xfs_qm.c
> @@ -346,7 +346,7 @@ xfs_qm_dqattach_locked(
>  	}
>  
>  	if (XFS_IS_PQUOTA_ON(mp) && !ip->i_pdquot) {
> -		error = xfs_qm_dqattach_one(ip, ip->i_d.di_projid, XFS_DQ_PROJ,
> +		error = xfs_qm_dqattach_one(ip, ip->i_projid, XFS_DQ_PROJ,
>  				doalloc, &ip->i_pdquot);
>  		if (error)
>  			goto done;
> @@ -1711,7 +1711,7 @@ xfs_qm_vop_dqalloc(
>  		}
>  	}
>  	if ((flags & XFS_QMOPT_PQUOTA) && XFS_IS_PQUOTA_ON(mp)) {
> -		if (ip->i_d.di_projid != prid) {
> +		if (ip->i_projid != prid) {
>  			xfs_iunlock(ip, lockflags);
>  			error = xfs_qm_dqget(mp, (xfs_dqid_t)prid, XFS_DQ_PROJ,
>  					true, &pq);
> @@ -1844,7 +1844,7 @@ xfs_qm_vop_chown_reserve(
>  	}
>  
>  	if (XFS_IS_PQUOTA_ON(ip->i_mount) && pdqp &&
> -	    ip->i_d.di_projid != be32_to_cpu(pdqp->q_core.d_id)) {
> +	    ip->i_projid != be32_to_cpu(pdqp->q_core.d_id)) {
>  		pdq_delblks = pdqp;
>  		if (delblks) {
>  			ASSERT(ip->i_pdquot);
> @@ -1942,7 +1942,7 @@ xfs_qm_vop_create_dqattach(
>  	}
>  	if (pdqp && XFS_IS_PQUOTA_ON(mp)) {
>  		ASSERT(ip->i_pdquot == NULL);
> -		ASSERT(ip->i_d.di_projid == be32_to_cpu(pdqp->q_core.d_id));
> +		ASSERT(ip->i_projid == be32_to_cpu(pdqp->q_core.d_id));
>  
>  		ip->i_pdquot = xfs_qm_dqhold(pdqp);
>  		xfs_trans_mod_dquot(tp, pdqp, XFS_TRANS_DQ_ICOUNT, 1);
> diff --git a/fs/xfs/xfs_qm_bhv.c b/fs/xfs/xfs_qm_bhv.c
> index fc2fa418919f7f..b616ad772a6df8 100644
> --- a/fs/xfs/xfs_qm_bhv.c
> +++ b/fs/xfs/xfs_qm_bhv.c
> @@ -60,7 +60,7 @@ xfs_qm_statvfs(
>  	struct xfs_mount	*mp = ip->i_mount;
>  	struct xfs_dquot	*dqp;
>  
> -	if (!xfs_qm_dqget(mp, ip->i_d.di_projid, XFS_DQ_PROJ, false, &dqp)) {
> +	if (!xfs_qm_dqget(mp, ip->i_projid, XFS_DQ_PROJ, false, &dqp)) {
>  		xfs_fill_statvfs_from_dquot(statp, dqp);
>  		xfs_qm_dqput(dqp);
>  	}
> 


-- 
chandan




^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH 03/15] xfs: move the di_size field to struct xfs_inode
  2020-06-20  7:10 ` [PATCH 03/15] xfs: move the di_size " Christoph Hellwig
@ 2020-06-22  9:24   ` Chandan Babu R
  2020-06-30 17:45   ` Darrick J. Wong
  1 sibling, 0 replies; 52+ messages in thread
From: Chandan Babu R @ 2020-06-22  9:24 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: linux-xfs

On Saturday 20 June 2020 12:40:50 PM IST Christoph Hellwig wrote:
> In preparation of removing the historic icinode struct, move the on-disk
> size field into the containing xfs_inode structure.
>

The changes look good to me.

Reviewed-by: Chandan Babu R <chandanrlinux@gmail.com>

> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  fs/xfs/libxfs/xfs_bmap.c       |  2 +-
>  fs/xfs/libxfs/xfs_dir2.c       | 14 +++++------
>  fs/xfs/libxfs/xfs_dir2_block.c | 10 ++++----
>  fs/xfs/libxfs/xfs_dir2_leaf.c  |  2 +-
>  fs/xfs/libxfs/xfs_dir2_node.c  |  2 +-
>  fs/xfs/libxfs/xfs_dir2_sf.c    | 46 +++++++++++++++++-----------------
>  fs/xfs/libxfs/xfs_inode_buf.c  |  4 +--
>  fs/xfs/libxfs/xfs_inode_buf.h  |  1 -
>  fs/xfs/libxfs/xfs_inode_fork.c |  2 +-
>  fs/xfs/scrub/dir.c             |  6 ++---
>  fs/xfs/scrub/parent.c          |  2 +-
>  fs/xfs/scrub/symlink.c         |  2 +-
>  fs/xfs/xfs_aops.c              |  4 +--
>  fs/xfs/xfs_bmap_util.c         |  6 ++---
>  fs/xfs/xfs_dir2_readdir.c      |  2 +-
>  fs/xfs/xfs_file.c              |  2 +-
>  fs/xfs/xfs_inode.c             |  8 +++---
>  fs/xfs/xfs_inode.h             |  5 ++--
>  fs/xfs/xfs_inode_item.c        |  4 +--
>  fs/xfs/xfs_iomap.c             |  2 +-
>  fs/xfs/xfs_iops.c              | 12 ++++-----
>  fs/xfs/xfs_itable.c            |  2 +-
>  fs/xfs/xfs_pnfs.c              |  2 +-
>  fs/xfs/xfs_qm_syscalls.c       |  2 +-
>  fs/xfs/xfs_reflink.c           |  4 +--
>  fs/xfs/xfs_rtalloc.c           |  8 +++---
>  fs/xfs/xfs_symlink.c           | 16 ++++++------
>  fs/xfs/xfs_trace.h             | 16 ++++++------
>  28 files changed, 94 insertions(+), 94 deletions(-)
> 
> diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
> index 667cdd0dfdf4a3..56d78f8ba55eb6 100644
> --- a/fs/xfs/libxfs/xfs_bmap.c
> +++ b/fs/xfs/libxfs/xfs_bmap.c
> @@ -1445,7 +1445,7 @@ xfs_bmap_last_offset(
>  
>  /*
>   * Returns whether the selected fork of the inode has exactly one
> - * block or not.  For the data fork we check this matches di_size,
> + * block or not.  For the data fork we check this matches i_disk_size,
>   * implying the file's range is 0..bsize-1.
>   */
>  int					/* 1=>1 block, 0=>otherwise */
> diff --git a/fs/xfs/libxfs/xfs_dir2.c b/fs/xfs/libxfs/xfs_dir2.c
> index 612a9c5e41b1c6..050bdcc4fe7376 100644
> --- a/fs/xfs/libxfs/xfs_dir2.c
> +++ b/fs/xfs/libxfs/xfs_dir2.c
> @@ -179,9 +179,9 @@ xfs_dir_isempty(
>  	xfs_dir2_sf_hdr_t	*sfp;
>  
>  	ASSERT(S_ISDIR(VFS_I(dp)->i_mode));
> -	if (dp->i_d.di_size == 0)	/* might happen during shutdown. */
> +	if (dp->i_disk_size == 0)	/* might happen during shutdown. */
>  		return 1;
> -	if (dp->i_d.di_size > XFS_IFORK_DSIZE(dp))
> +	if (dp->i_disk_size > XFS_IFORK_DSIZE(dp))
>  		return 0;
>  	sfp = (xfs_dir2_sf_hdr_t *)dp->i_df.if_u1.if_data;
>  	return !sfp->count;
> @@ -584,8 +584,8 @@ xfs_dir2_grow_inode(
>  		xfs_fsize_t	size;		/* directory file (data) size */
>  
>  		size = XFS_FSB_TO_B(mp, bno + count);
> -		if (size > dp->i_d.di_size) {
> -			dp->i_d.di_size = size;
> +		if (size > dp->i_disk_size) {
> +			dp->i_disk_size = size;
>  			xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE);
>  		}
>  	}
> @@ -608,7 +608,7 @@ xfs_dir2_isblock(
>  	rval = XFS_FSB_TO_B(args->dp->i_mount, last) == args->geo->blksize;
>  	if (XFS_IS_CORRUPT(args->dp->i_mount,
>  			   rval != 0 &&
> -			   args->dp->i_d.di_size != args->geo->blksize))
> +			   args->dp->i_disk_size != args->geo->blksize))
>  		return -EFSCORRUPTED;
>  	*vp = rval;
>  	return 0;
> @@ -687,7 +687,7 @@ xfs_dir2_shrink_inode(
>  	/*
>  	 * If the block isn't the last one in the directory, we're done.
>  	 */
> -	if (dp->i_d.di_size > xfs_dir2_db_off_to_byte(args->geo, db + 1, 0))
> +	if (dp->i_disk_size > xfs_dir2_db_off_to_byte(args->geo, db + 1, 0))
>  		return 0;
>  	bno = da;
>  	if ((error = xfs_bmap_last_before(tp, dp, &bno, XFS_DATA_FORK))) {
> @@ -703,7 +703,7 @@ xfs_dir2_shrink_inode(
>  	/*
>  	 * Set the size to the new last block.
>  	 */
> -	dp->i_d.di_size = XFS_FSB_TO_B(mp, bno);
> +	dp->i_disk_size = XFS_FSB_TO_B(mp, bno);
>  	xfs_trans_log_inode(tp, dp, XFS_ILOG_CORE);
>  	return 0;
>  }
> diff --git a/fs/xfs/libxfs/xfs_dir2_block.c b/fs/xfs/libxfs/xfs_dir2_block.c
> index 5b59d3f7746b34..7824af54637513 100644
> --- a/fs/xfs/libxfs/xfs_dir2_block.c
> +++ b/fs/xfs/libxfs/xfs_dir2_block.c
> @@ -961,7 +961,7 @@ xfs_dir2_leaf_to_block(
>  	 * been left behind during no-space-reservation operations.
>  	 * These will show up in the leaf bests table.
>  	 */
> -	while (dp->i_d.di_size > args->geo->blksize) {
> +	while (dp->i_disk_size > args->geo->blksize) {
>  		int hdrsz;
>  
>  		hdrsz = args->geo->data_entry_offset;
> @@ -1097,13 +1097,13 @@ xfs_dir2_sf_to_block(
>  	trace_xfs_dir2_sf_to_block(args);
>  
>  	ASSERT(ifp->if_flags & XFS_IFINLINE);
> -	ASSERT(dp->i_d.di_size >= offsetof(struct xfs_dir2_sf_hdr, parent));
> +	ASSERT(dp->i_disk_size >= offsetof(struct xfs_dir2_sf_hdr, parent));
>  
>  	oldsfp = (xfs_dir2_sf_hdr_t *)ifp->if_u1.if_data;
>  
> -	ASSERT(ifp->if_bytes == dp->i_d.di_size);
> +	ASSERT(ifp->if_bytes == dp->i_disk_size);
>  	ASSERT(ifp->if_u1.if_data != NULL);
> -	ASSERT(dp->i_d.di_size >= xfs_dir2_sf_hdr_size(oldsfp->i8count));
> +	ASSERT(dp->i_disk_size >= xfs_dir2_sf_hdr_size(oldsfp->i8count));
>  	ASSERT(dp->i_df.if_nextents == 0);
>  
>  	/*
> @@ -1115,7 +1115,7 @@ xfs_dir2_sf_to_block(
>  
>  	xfs_idata_realloc(dp, -ifp->if_bytes, XFS_DATA_FORK);
>  	xfs_bmap_local_to_extents_empty(tp, dp, XFS_DATA_FORK);
> -	dp->i_d.di_size = 0;
> +	dp->i_disk_size = 0;
>  
>  	/*
>  	 * Add block 0 to the inode.
> diff --git a/fs/xfs/libxfs/xfs_dir2_leaf.c b/fs/xfs/libxfs/xfs_dir2_leaf.c
> index 95d2a3f92d75de..73fb3e1152e6d7 100644
> --- a/fs/xfs/libxfs/xfs_dir2_leaf.c
> +++ b/fs/xfs/libxfs/xfs_dir2_leaf.c
> @@ -151,7 +151,7 @@ xfs_dir3_leaf_check_int(
>  	/*
>  	 * XXX (dgc): This value is not restrictive enough.
>  	 * Should factor in the size of the bests table as well.
> -	 * We can deduce a value for that from di_size.
> +	 * We can deduce a value for that from i_disk_size.
>  	 */
>  	if (hdr->count > geo->leaf_max_ents)
>  		return __this_address;
> diff --git a/fs/xfs/libxfs/xfs_dir2_node.c b/fs/xfs/libxfs/xfs_dir2_node.c
> index 6ac4aad98cd76c..3698030ca5e2f7 100644
> --- a/fs/xfs/libxfs/xfs_dir2_node.c
> +++ b/fs/xfs/libxfs/xfs_dir2_node.c
> @@ -441,7 +441,7 @@ xfs_dir2_leaf_to_node(
>  	leaf = lbp->b_addr;
>  	ltp = xfs_dir2_leaf_tail_p(args->geo, leaf);
>  	if (be32_to_cpu(ltp->bestcount) >
> -				(uint)dp->i_d.di_size / args->geo->blksize) {
> +				(uint)dp->i_disk_size / args->geo->blksize) {
>  		xfs_buf_mark_corrupt(lbp);
>  		return -EFSCORRUPTED;
>  	}
> diff --git a/fs/xfs/libxfs/xfs_dir2_sf.c b/fs/xfs/libxfs/xfs_dir2_sf.c
> index 2463b5d7344724..00fee3943a09dc 100644
> --- a/fs/xfs/libxfs/xfs_dir2_sf.c
> +++ b/fs/xfs/libxfs/xfs_dir2_sf.c
> @@ -344,7 +344,7 @@ xfs_dir2_block_to_sf(
>  	ASSERT(dp->i_df.if_bytes == 0);
>  	xfs_init_local_fork(dp, XFS_DATA_FORK, sfp, size);
>  	dp->i_df.if_format = XFS_DINODE_FMT_LOCAL;
> -	dp->i_d.di_size = size;
> +	dp->i_disk_size = size;
>  
>  	logflags |= XFS_ILOG_DDATA;
>  	xfs_dir2_sf_check(args);
> @@ -367,7 +367,7 @@ xfs_dir2_sf_addname(
>  	xfs_inode_t		*dp;		/* incore directory inode */
>  	int			error;		/* error return value */
>  	int			incr_isize;	/* total change in size */
> -	int			new_isize;	/* di_size after adding name */
> +	int			new_isize;	/* size after adding name */
>  	int			objchange;	/* changing to 8-byte inodes */
>  	xfs_dir2_data_aoff_t	offset = 0;	/* offset for new entry */
>  	int			pick;		/* which algorithm to use */
> @@ -379,11 +379,11 @@ xfs_dir2_sf_addname(
>  	ASSERT(xfs_dir2_sf_lookup(args) == -ENOENT);
>  	dp = args->dp;
>  	ASSERT(dp->i_df.if_flags & XFS_IFINLINE);
> -	ASSERT(dp->i_d.di_size >= offsetof(struct xfs_dir2_sf_hdr, parent));
> -	ASSERT(dp->i_df.if_bytes == dp->i_d.di_size);
> +	ASSERT(dp->i_disk_size >= offsetof(struct xfs_dir2_sf_hdr, parent));
> +	ASSERT(dp->i_df.if_bytes == dp->i_disk_size);
>  	ASSERT(dp->i_df.if_u1.if_data != NULL);
>  	sfp = (xfs_dir2_sf_hdr_t *)dp->i_df.if_u1.if_data;
> -	ASSERT(dp->i_d.di_size >= xfs_dir2_sf_hdr_size(sfp->i8count));
> +	ASSERT(dp->i_disk_size >= xfs_dir2_sf_hdr_size(sfp->i8count));
>  	/*
>  	 * Compute entry (and change in) size.
>  	 */
> @@ -401,7 +401,7 @@ xfs_dir2_sf_addname(
>  		objchange = 1;
>  	}
>  
> -	new_isize = (int)dp->i_d.di_size + incr_isize;
> +	new_isize = (int)dp->i_disk_size + incr_isize;
>  	/*
>  	 * Won't fit as shortform any more (due to size),
>  	 * or the pick routine says it won't (due to offset values).
> @@ -492,7 +492,7 @@ xfs_dir2_sf_addname_easy(
>  	sfp->count++;
>  	if (args->inumber > XFS_DIR2_MAX_SHORT_INUM)
>  		sfp->i8count++;
> -	dp->i_d.di_size = new_isize;
> +	dp->i_disk_size = new_isize;
>  	xfs_dir2_sf_check(args);
>  }
>  
> @@ -519,7 +519,7 @@ xfs_dir2_sf_addname_hard(
>  	int			nbytes;		/* temp for byte copies */
>  	xfs_dir2_data_aoff_t	new_offset;	/* next offset value */
>  	xfs_dir2_data_aoff_t	offset;		/* current offset value */
> -	int			old_isize;	/* previous di_size */
> +	int			old_isize;	/* previous size */
>  	xfs_dir2_sf_entry_t	*oldsfep;	/* entry in original dir */
>  	xfs_dir2_sf_hdr_t	*oldsfp;	/* original shortform dir */
>  	xfs_dir2_sf_entry_t	*sfep;		/* entry in new dir */
> @@ -529,7 +529,7 @@ xfs_dir2_sf_addname_hard(
>  	 * Copy the old directory to the stack buffer.
>  	 */
>  	sfp = (xfs_dir2_sf_hdr_t *)dp->i_df.if_u1.if_data;
> -	old_isize = (int)dp->i_d.di_size;
> +	old_isize = (int)dp->i_disk_size;
>  	buf = kmem_alloc(old_isize, 0);
>  	oldsfp = (xfs_dir2_sf_hdr_t *)buf;
>  	memcpy(oldsfp, sfp, old_isize);
> @@ -586,7 +586,7 @@ xfs_dir2_sf_addname_hard(
>  		memcpy(sfep, oldsfep, old_isize - nbytes);
>  	}
>  	kmem_free(buf);
> -	dp->i_d.di_size = new_isize;
> +	dp->i_disk_size = new_isize;
>  	xfs_dir2_sf_check(args);
>  }
>  
> @@ -697,7 +697,7 @@ xfs_dir2_sf_check(
>  		ASSERT(xfs_dir2_sf_get_ftype(mp, sfep) < XFS_DIR3_FT_MAX);
>  	}
>  	ASSERT(i8count == sfp->i8count);
> -	ASSERT((char *)sfep - (char *)sfp == dp->i_d.di_size);
> +	ASSERT((char *)sfep - (char *)sfp == dp->i_disk_size);
>  	ASSERT(offset +
>  	       (sfp->count + 2) * (uint)sizeof(xfs_dir2_leaf_entry_t) +
>  	       (uint)sizeof(xfs_dir2_block_tail_t) <= args->geo->blksize);
> @@ -821,7 +821,7 @@ xfs_dir2_sf_create(
>  	dp = args->dp;
>  
>  	ASSERT(dp != NULL);
> -	ASSERT(dp->i_d.di_size == 0);
> +	ASSERT(dp->i_disk_size == 0);
>  	/*
>  	 * If it's currently a zero-length extent file,
>  	 * convert it to local format.
> @@ -850,7 +850,7 @@ xfs_dir2_sf_create(
>  	 */
>  	xfs_dir2_sf_put_parent_ino(sfp, pino);
>  	sfp->count = 0;
> -	dp->i_d.di_size = size;
> +	dp->i_disk_size = size;
>  	xfs_dir2_sf_check(args);
>  	xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE | XFS_ILOG_DDATA);
>  	return 0;
> @@ -878,11 +878,11 @@ xfs_dir2_sf_lookup(
>  	xfs_dir2_sf_check(args);
>  
>  	ASSERT(dp->i_df.if_flags & XFS_IFINLINE);
> -	ASSERT(dp->i_d.di_size >= offsetof(struct xfs_dir2_sf_hdr, parent));
> -	ASSERT(dp->i_df.if_bytes == dp->i_d.di_size);
> +	ASSERT(dp->i_disk_size >= offsetof(struct xfs_dir2_sf_hdr, parent));
> +	ASSERT(dp->i_df.if_bytes == dp->i_disk_size);
>  	ASSERT(dp->i_df.if_u1.if_data != NULL);
>  	sfp = (xfs_dir2_sf_hdr_t *)dp->i_df.if_u1.if_data;
> -	ASSERT(dp->i_d.di_size >= xfs_dir2_sf_hdr_size(sfp->i8count));
> +	ASSERT(dp->i_disk_size >= xfs_dir2_sf_hdr_size(sfp->i8count));
>  	/*
>  	 * Special case for .
>  	 */
> @@ -955,7 +955,7 @@ xfs_dir2_sf_removename(
>  	trace_xfs_dir2_sf_removename(args);
>  
>  	ASSERT(dp->i_df.if_flags & XFS_IFINLINE);
> -	oldsize = (int)dp->i_d.di_size;
> +	oldsize = (int)dp->i_disk_size;
>  	ASSERT(oldsize >= offsetof(struct xfs_dir2_sf_hdr, parent));
>  	ASSERT(dp->i_df.if_bytes == oldsize);
>  	ASSERT(dp->i_df.if_u1.if_data != NULL);
> @@ -995,7 +995,7 @@ xfs_dir2_sf_removename(
>  	 * Fix up the header and file size.
>  	 */
>  	sfp->count--;
> -	dp->i_d.di_size = newsize;
> +	dp->i_disk_size = newsize;
>  	/*
>  	 * Reallocate, making it smaller.
>  	 */
> @@ -1054,11 +1054,11 @@ xfs_dir2_sf_replace(
>  	trace_xfs_dir2_sf_replace(args);
>  
>  	ASSERT(dp->i_df.if_flags & XFS_IFINLINE);
> -	ASSERT(dp->i_d.di_size >= offsetof(struct xfs_dir2_sf_hdr, parent));
> -	ASSERT(dp->i_df.if_bytes == dp->i_d.di_size);
> +	ASSERT(dp->i_disk_size >= offsetof(struct xfs_dir2_sf_hdr, parent));
> +	ASSERT(dp->i_df.if_bytes == dp->i_disk_size);
>  	ASSERT(dp->i_df.if_u1.if_data != NULL);
>  	sfp = (xfs_dir2_sf_hdr_t *)dp->i_df.if_u1.if_data;
> -	ASSERT(dp->i_d.di_size >= xfs_dir2_sf_hdr_size(sfp->i8count));
> +	ASSERT(dp->i_disk_size >= xfs_dir2_sf_hdr_size(sfp->i8count));
>  
>  	/*
>  	 * New inode number is large, and need to convert to 8-byte inodes.
> @@ -1219,7 +1219,7 @@ xfs_dir2_sf_toino4(
>  	 * Clean up the inode.
>  	 */
>  	kmem_free(buf);
> -	dp->i_d.di_size = newsize;
> +	dp->i_disk_size = newsize;
>  	xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE | XFS_ILOG_DDATA);
>  }
>  
> @@ -1292,6 +1292,6 @@ xfs_dir2_sf_toino8(
>  	 * Clean up the inode.
>  	 */
>  	kmem_free(buf);
> -	dp->i_d.di_size = newsize;
> +	dp->i_disk_size = newsize;
>  	xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE | XFS_ILOG_DDATA);
>  }
> diff --git a/fs/xfs/libxfs/xfs_inode_buf.c b/fs/xfs/libxfs/xfs_inode_buf.c
> index b064cb8072c84a..c202de8bbdd427 100644
> --- a/fs/xfs/libxfs/xfs_inode_buf.c
> +++ b/fs/xfs/libxfs/xfs_inode_buf.c
> @@ -241,7 +241,7 @@ xfs_inode_from_disk(
>  	inode->i_ctime.tv_sec = (int)be32_to_cpu(from->di_ctime.t_sec);
>  	inode->i_ctime.tv_nsec = (int)be32_to_cpu(from->di_ctime.t_nsec);
>  
> -	to->di_size = be64_to_cpu(from->di_size);
> +	ip->i_disk_size = be64_to_cpu(from->di_size);
>  	to->di_nblocks = be64_to_cpu(from->di_nblocks);
>  	to->di_extsize = be32_to_cpu(from->di_extsize);
>  	to->di_forkoff = from->di_forkoff;
> @@ -304,7 +304,7 @@ xfs_inode_to_disk(
>  	to->di_gen = cpu_to_be32(inode->i_generation);
>  	to->di_mode = cpu_to_be16(inode->i_mode);
>  
> -	to->di_size = cpu_to_be64(from->di_size);
> +	to->di_size = cpu_to_be64(ip->i_disk_size);
>  	to->di_nblocks = cpu_to_be64(from->di_nblocks);
>  	to->di_extsize = cpu_to_be32(from->di_extsize);
>  	to->di_nextents = cpu_to_be32(xfs_ifork_nextents(&ip->i_df));
> diff --git a/fs/xfs/libxfs/xfs_inode_buf.h b/fs/xfs/libxfs/xfs_inode_buf.h
> index b826d81b356956..f187127d50e010 100644
> --- a/fs/xfs/libxfs/xfs_inode_buf.h
> +++ b/fs/xfs/libxfs/xfs_inode_buf.h
> @@ -17,7 +17,6 @@ struct xfs_dinode;
>   */
>  struct xfs_icdinode {
>  	uint16_t	di_flushiter;	/* incremented on flush */
> -	xfs_fsize_t	di_size;	/* number of bytes in file */
>  	xfs_rfsblock_t	di_nblocks;	/* # of direct & btree blocks used */
>  	xfs_extlen_t	di_extsize;	/* basic/minimum extent size for file */
>  	uint8_t		di_forkoff;	/* attr fork offs, <<3 for 64b align */
> diff --git a/fs/xfs/libxfs/xfs_inode_fork.c b/fs/xfs/libxfs/xfs_inode_fork.c
> index 28b366275ae0ed..d2029e12bda4de 100644
> --- a/fs/xfs/libxfs/xfs_inode_fork.c
> +++ b/fs/xfs/libxfs/xfs_inode_fork.c
> @@ -240,7 +240,7 @@ xfs_iformat_data_fork(
>  	case S_IFCHR:
>  	case S_IFBLK:
>  	case S_IFSOCK:
> -		ip->i_d.di_size = 0;
> +		ip->i_disk_size = 0;
>  		inode->i_rdev = xfs_to_linux_dev_t(xfs_dinode_get_rdev(dip));
>  		return 0;
>  	case S_IFREG:
> diff --git a/fs/xfs/scrub/dir.c b/fs/xfs/scrub/dir.c
> index 7c432997edade4..d89aa8efb84545 100644
> --- a/fs/xfs/scrub/dir.c
> +++ b/fs/xfs/scrub/dir.c
> @@ -523,7 +523,7 @@ xchk_directory_leaf1_bestfree(
>  	 * There should be as many bestfree slots as there are dir data
>  	 * blocks that can fit under i_size.
>  	 */
> -	if (bestcount != xfs_dir2_byte_to_db(geo, sc->ip->i_d.di_size)) {
> +	if (bestcount != xfs_dir2_byte_to_db(geo, sc->ip->i_disk_size)) {
>  		xchk_fblock_set_corrupt(sc, XFS_DATA_FORK, lblk);
>  		goto out;
>  	}
> @@ -789,7 +789,7 @@ xchk_directory(
>  		return -ENOENT;
>  
>  	/* Plausible size? */
> -	if (sc->ip->i_d.di_size < xfs_dir2_sf_hdr_size(0)) {
> +	if (sc->ip->i_disk_size < xfs_dir2_sf_hdr_size(0)) {
>  		xchk_ino_set_corrupt(sc, sc->ip->i_ino);
>  		goto out;
>  	}
> @@ -815,7 +815,7 @@ xchk_directory(
>  	 * Userspace usually asks for a 32k buffer, so we will too.
>  	 */
>  	bufsize = (size_t)min_t(loff_t, XFS_READDIR_BUFSIZE,
> -			sc->ip->i_d.di_size);
> +			sc->ip->i_disk_size);
>  
>  	/*
>  	 * Look up every name in this directory by hash.
> diff --git a/fs/xfs/scrub/parent.c b/fs/xfs/scrub/parent.c
> index 855aa8bcab64bd..766e870999a9a8 100644
> --- a/fs/xfs/scrub/parent.c
> +++ b/fs/xfs/scrub/parent.c
> @@ -102,7 +102,7 @@ xchk_parent_count_parent_dentries(
>  	 * scanned.
>  	 */
>  	bufsize = (size_t)min_t(loff_t, XFS_READDIR_BUFSIZE,
> -			parent->i_d.di_size);
> +			parent->i_disk_size);
>  	oldpos = 0;
>  	while (true) {
>  		error = xfs_readdir(sc->tp, parent, &spc.dc, bufsize);
> diff --git a/fs/xfs/scrub/symlink.c b/fs/xfs/scrub/symlink.c
> index 5641ae512c9efc..9b751d79adf096 100644
> --- a/fs/xfs/scrub/symlink.c
> +++ b/fs/xfs/scrub/symlink.c
> @@ -43,7 +43,7 @@ xchk_symlink(
>  	if (!S_ISLNK(VFS_I(ip)->i_mode))
>  		return -ENOENT;
>  	ifp = XFS_IFORK_PTR(ip, XFS_DATA_FORK);
> -	len = ip->i_d.di_size;
> +	len = ip->i_disk_size;
>  
>  	/* Plausible size? */
>  	if (len > XFS_SYMLINK_MAXLEN || len <= 0) {
> diff --git a/fs/xfs/xfs_aops.c b/fs/xfs/xfs_aops.c
> index 2834cbf1212e5a..18a497cc817c2a 100644
> --- a/fs/xfs/xfs_aops.c
> +++ b/fs/xfs/xfs_aops.c
> @@ -36,7 +36,7 @@ XFS_WPC(struct iomap_writepage_ctx *ctx)
>  static inline bool xfs_ioend_is_append(struct iomap_ioend *ioend)
>  {
>  	return ioend->io_offset + ioend->io_size >
> -		XFS_I(ioend->io_inode)->i_d.di_size;
> +		XFS_I(ioend->io_inode)->i_disk_size;
>  }
>  
>  STATIC int
> @@ -88,7 +88,7 @@ __xfs_setfilesize(
>  
>  	trace_xfs_setfilesize(ip, offset, size);
>  
> -	ip->i_d.di_size = isize;
> +	ip->i_disk_size = isize;
>  	xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);
>  	xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
>  
> diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c
> index e42553884c23cf..d199ecddc1ab19 100644
> --- a/fs/xfs/xfs_bmap_util.c
> +++ b/fs/xfs/xfs_bmap_util.c
> @@ -423,7 +423,7 @@ xfs_getbmap(
>  		break;
>  	case XFS_DATA_FORK:
>  		if (!(iflags & BMV_IF_DELALLOC) &&
> -		    (ip->i_delayed_blks || XFS_ISIZE(ip) > ip->i_d.di_size)) {
> +		    (ip->i_delayed_blks || XFS_ISIZE(ip) > ip->i_disk_size)) {
>  			error = filemap_write_and_wait(VFS_I(ip)->i_mapping);
>  			if (error)
>  				goto out_unlock_iolock;
> @@ -1656,8 +1656,8 @@ xfs_swap_extents(
>  
>  	/* Verify all data are being swapped */
>  	if (sxp->sx_offset != 0 ||
> -	    sxp->sx_length != ip->i_d.di_size ||
> -	    sxp->sx_length != tip->i_d.di_size) {
> +	    sxp->sx_length != ip->i_disk_size ||
> +	    sxp->sx_length != tip->i_disk_size) {
>  		error = -EFAULT;
>  		goto out_trans_cancel;
>  	}
> diff --git a/fs/xfs/xfs_dir2_readdir.c b/fs/xfs/xfs_dir2_readdir.c
> index 66deddd5e29698..03e7c39a07807a 100644
> --- a/fs/xfs/xfs_dir2_readdir.c
> +++ b/fs/xfs/xfs_dir2_readdir.c
> @@ -58,7 +58,7 @@ xfs_dir2_sf_getdents(
>  	struct xfs_da_geometry	*geo = args->geo;
>  
>  	ASSERT(dp->i_df.if_flags & XFS_IFINLINE);
> -	ASSERT(dp->i_df.if_bytes == dp->i_d.di_size);
> +	ASSERT(dp->i_df.if_bytes == dp->i_disk_size);
>  	ASSERT(dp->i_df.if_u1.if_data != NULL);
>  
>  	sfp = (xfs_dir2_sf_hdr_t *)dp->i_df.if_u1.if_data;
> diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c
> index 403c90309a8ffe..14b533a8ce8e6a 100644
> --- a/fs/xfs/xfs_file.c
> +++ b/fs/xfs/xfs_file.c
> @@ -1137,7 +1137,7 @@ xfs_file_readdir(
>  	 * point we can change the ->readdir prototype to include the
>  	 * buffer size.  For now we use the current glibc buffer size.
>  	 */
> -	bufsize = (size_t)min_t(loff_t, XFS_READDIR_BUFSIZE, ip->i_d.di_size);
> +	bufsize = (size_t)min_t(loff_t, XFS_READDIR_BUFSIZE, ip->i_disk_size);
>  
>  	return xfs_readdir(NULL, ip, ctx, bufsize);
>  }
> diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
> index 40e4d3ed29a798..723a911c8b6d81 100644
> --- a/fs/xfs/xfs_inode.c
> +++ b/fs/xfs/xfs_inode.c
> @@ -825,7 +825,7 @@ xfs_ialloc(
>  	    (inode->i_mode & S_ISGID) && !in_group_p(inode->i_gid))
>  		inode->i_mode &= ~S_ISGID;
>  
> -	ip->i_d.di_size = 0;
> +	ip->i_disk_size = 0;
>  	ip->i_df.if_nextents = 0;
>  	ASSERT(ip->i_d.di_nblocks == 0);
>  
> @@ -1675,7 +1675,7 @@ xfs_inactive_truncate(
>  	 * of a system crash before the truncate completes. See the related
>  	 * comment in xfs_vn_setattr_size() for details.
>  	 */
> -	ip->i_d.di_size = 0;
> +	ip->i_disk_size = 0;
>  	xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
>  
>  	error = xfs_itruncate_extents(&tp, ip, XFS_DATA_FORK, 0);
> @@ -1831,7 +1831,7 @@ xfs_inactive(
>  	}
>  
>  	if (S_ISREG(VFS_I(ip)->i_mode) &&
> -	    (ip->i_d.di_size != 0 || XFS_ISIZE(ip) != 0 ||
> +	    (ip->i_disk_size != 0 || XFS_ISIZE(ip) != 0 ||
>  	     ip->i_df.if_nextents > 0 || ip->i_delayed_blks > 0))
>  		truncate = 1;
>  
> @@ -2729,7 +2729,7 @@ xfs_ifree(
>  	ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL));
>  	ASSERT(VFS_I(ip)->i_nlink == 0);
>  	ASSERT(ip->i_df.if_nextents == 0);
> -	ASSERT(ip->i_d.di_size == 0 || !S_ISREG(VFS_I(ip)->i_mode));
> +	ASSERT(ip->i_disk_size == 0 || !S_ISREG(VFS_I(ip)->i_mode));
>  	ASSERT(ip->i_d.di_nblocks == 0);
>  
>  	/*
> diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h
> index 51ea9d53407863..61c41395536f07 100644
> --- a/fs/xfs/xfs_inode.h
> +++ b/fs/xfs/xfs_inode.h
> @@ -54,6 +54,7 @@ typedef struct xfs_inode {
>  	/* Miscellaneous state. */
>  	unsigned long		i_flags;	/* see defined flags below */
>  	uint64_t		i_delayed_blks;	/* count of delay alloc blks */
> +	xfs_fsize_t		i_disk_size;	/* number of bytes in file */
>  	uint32_t		i_projid;	/* owner's project id */
>  
>  	struct xfs_icdinode	i_d;		/* most of ondisk inode */
> @@ -88,7 +89,7 @@ static inline xfs_fsize_t XFS_ISIZE(struct xfs_inode *ip)
>  {
>  	if (S_ISREG(VFS_I(ip)->i_mode))
>  		return i_size_read(VFS_I(ip));
> -	return ip->i_d.di_size;
> +	return ip->i_disk_size;
>  }
>  
>  /*
> @@ -102,7 +103,7 @@ xfs_new_eof(struct xfs_inode *ip, xfs_fsize_t new_size)
>  
>  	if (new_size > i_size || new_size < 0)
>  		new_size = i_size;
> -	return new_size > ip->i_d.di_size ? new_size : 0;
> +	return new_size > ip->i_disk_size ? new_size : 0;
>  }
>  
>  /*
> diff --git a/fs/xfs/xfs_inode_item.c b/fs/xfs/xfs_inode_item.c
> index e546b4b58ce2e0..179f1c2de6bd0f 100644
> --- a/fs/xfs/xfs_inode_item.c
> +++ b/fs/xfs/xfs_inode_item.c
> @@ -196,7 +196,7 @@ xfs_inode_item_format_data_fork(
>  			 */
>  			data_bytes = roundup(ip->i_df.if_bytes, 4);
>  			ASSERT(ip->i_df.if_u1.if_data != NULL);
> -			ASSERT(ip->i_d.di_size > 0);
> +			ASSERT(ip->i_disk_size > 0);
>  			xlog_copy_iovec(lv, vecp, XLOG_REG_TYPE_ILOCAL,
>  					ip->i_df.if_u1.if_data, data_bytes);
>  			ilf->ilf_dsize = (unsigned)data_bytes;
> @@ -323,7 +323,7 @@ xfs_inode_to_log_dinode(
>  	to->di_gen = inode->i_generation;
>  	to->di_mode = inode->i_mode;
>  
> -	to->di_size = from->di_size;
> +	to->di_size = ip->i_disk_size;
>  	to->di_nblocks = from->di_nblocks;
>  	to->di_extsize = from->di_extsize;
>  	to->di_nextents = xfs_ifork_nextents(&ip->i_df);
> diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c
> index b9a8c3798e08fc..6e03963b6b300e 100644
> --- a/fs/xfs/xfs_iomap.c
> +++ b/fs/xfs/xfs_iomap.c
> @@ -583,7 +583,7 @@ xfs_iomap_write_unwritten(
>  			i_size_write(inode, i_size);
>  		i_size = xfs_new_eof(ip, i_size);
>  		if (i_size) {
> -			ip->i_d.di_size = i_size;
> +			ip->i_disk_size = i_size;
>  			xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
>  		}
>  
> diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
> index 5440f555c9cc2c..1abee83d49cff9 100644
> --- a/fs/xfs/xfs_iops.c
> +++ b/fs/xfs/xfs_iops.c
> @@ -935,8 +935,8 @@ xfs_setattr_size(
>  	 * operation.
>  	 *
>  	 * And we update in-core i_size and truncate page cache beyond newsize
> -	 * before writeback the [di_size, newsize] range, so we're guaranteed
> -	 * not to write stale data past the new EOF on truncate down.
> +	 * before writeback the [i_disk_size, newsize] range, so we're
> +	 * guaranteed not to write stale data past the new EOF on truncate down.
>  	 */
>  	truncate_setsize(inode, newsize);
>  
> @@ -949,9 +949,9 @@ xfs_setattr_size(
>  	 * otherwise those blocks may not be zeroed after a crash.
>  	 */
>  	if (did_zeroing ||
> -	    (newsize > ip->i_d.di_size && oldsize != ip->i_d.di_size)) {
> +	    (newsize > ip->i_disk_size && oldsize != ip->i_disk_size)) {
>  		error = filemap_write_and_wait_range(VFS_I(ip)->i_mapping,
> -						ip->i_d.di_size, newsize - 1);
> +						ip->i_disk_size, newsize - 1);
>  		if (error)
>  			return error;
>  	}
> @@ -993,7 +993,7 @@ xfs_setattr_size(
>  	 * permanent before actually freeing any blocks it doesn't matter if
>  	 * they get written to.
>  	 */
> -	ip->i_d.di_size = newsize;
> +	ip->i_disk_size = newsize;
>  	xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
>  
>  	if (newsize <= oldsize) {
> @@ -1323,7 +1323,7 @@ xfs_setup_inode(
>  	/* make the inode look hashed for the writeback code */
>  	inode_fake_hash(inode);
>  
> -	i_size_write(inode, ip->i_d.di_size);
> +	i_size_write(inode, ip->i_disk_size);
>  	xfs_diflags_to_iflags(ip, true);
>  
>  	if (S_ISDIR(inode->i_mode)) {
> diff --git a/fs/xfs/xfs_itable.c b/fs/xfs/xfs_itable.c
> index 97b3b794dd4ada..9f92514301b334 100644
> --- a/fs/xfs/xfs_itable.c
> +++ b/fs/xfs/xfs_itable.c
> @@ -88,7 +88,7 @@ xfs_bulkstat_one_int(
>  	buf->bs_ino = ino;
>  	buf->bs_uid = i_uid_read(inode);
>  	buf->bs_gid = i_gid_read(inode);
> -	buf->bs_size = dic->di_size;
> +	buf->bs_size = ip->i_disk_size;
>  
>  	buf->bs_nlink = inode->i_nlink;
>  	buf->bs_atime = inode->i_atime.tv_sec;
> diff --git a/fs/xfs/xfs_pnfs.c b/fs/xfs/xfs_pnfs.c
> index b101feb2aab452..e6caca783764f9 100644
> --- a/fs/xfs/xfs_pnfs.c
> +++ b/fs/xfs/xfs_pnfs.c
> @@ -286,7 +286,7 @@ xfs_fs_commit_blocks(
>  	xfs_setattr_time(ip, iattr);
>  	if (update_isize) {
>  		i_size_write(inode, iattr->ia_size);
> -		ip->i_d.di_size = iattr->ia_size;
> +		ip->i_disk_size = iattr->ia_size;
>  	}
>  
>  	xfs_trans_set_sync(tp);
> diff --git a/fs/xfs/xfs_qm_syscalls.c b/fs/xfs/xfs_qm_syscalls.c
> index 7effd7a2813656..08dec36095fae2 100644
> --- a/fs/xfs/xfs_qm_syscalls.c
> +++ b/fs/xfs/xfs_qm_syscalls.c
> @@ -293,7 +293,7 @@ xfs_qm_scall_trunc_qfile(
>  	xfs_ilock(ip, XFS_ILOCK_EXCL);
>  	xfs_trans_ijoin(tp, ip, 0);
>  
> -	ip->i_d.di_size = 0;
> +	ip->i_disk_size = 0;
>  	xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
>  
>  	error = xfs_itruncate_extents(&tp, ip, XFS_DATA_FORK, 0);
> diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c
> index 107bf2a2f3448a..8598896156e29a 100644
> --- a/fs/xfs/xfs_reflink.c
> +++ b/fs/xfs/xfs_reflink.c
> @@ -938,7 +938,7 @@ xfs_reflink_update_dest(
>  	if (newlen > i_size_read(VFS_I(dest))) {
>  		trace_xfs_reflink_update_inode_size(dest, newlen);
>  		i_size_write(VFS_I(dest), newlen);
> -		dest->i_d.di_size = newlen;
> +		dest->i_disk_size = newlen;
>  	}
>  
>  	if (cowextsize) {
> @@ -1078,7 +1078,7 @@ xfs_reflink_remap_extent(
>  		if (newlen > i_size_read(VFS_I(ip))) {
>  			trace_xfs_reflink_update_inode_size(ip, newlen);
>  			i_size_write(VFS_I(ip), newlen);
> -			ip->i_d.di_size = newlen;
> +			ip->i_disk_size = newlen;
>  			xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
>  		}
>  
> diff --git a/fs/xfs/xfs_rtalloc.c b/fs/xfs/xfs_rtalloc.c
> index 6209e7b6b895b8..cc07d7d27dd7e0 100644
> --- a/fs/xfs/xfs_rtalloc.c
> +++ b/fs/xfs/xfs_rtalloc.c
> @@ -941,8 +941,8 @@ xfs_growfs_rt(
>  	 * Get the old block counts for bitmap and summary inodes.
>  	 * These can't change since other growfs callers are locked out.
>  	 */
> -	rbmblocks = XFS_B_TO_FSB(mp, mp->m_rbmip->i_d.di_size);
> -	rsumblocks = XFS_B_TO_FSB(mp, mp->m_rsumip->i_d.di_size);
> +	rbmblocks = XFS_B_TO_FSB(mp, mp->m_rbmip->i_disk_size);
> +	rsumblocks = XFS_B_TO_FSB(mp, mp->m_rsumip->i_disk_size);
>  	/*
>  	 * Allocate space to the bitmap and summary files, as necessary.
>  	 */
> @@ -1009,7 +1009,7 @@ xfs_growfs_rt(
>  		/*
>  		 * Update the bitmap inode's size.
>  		 */
> -		mp->m_rbmip->i_d.di_size =
> +		mp->m_rbmip->i_disk_size =
>  			nsbp->sb_rbmblocks * nsbp->sb_blocksize;
>  		xfs_trans_log_inode(tp, mp->m_rbmip, XFS_ILOG_CORE);
>  		/*
> @@ -1020,7 +1020,7 @@ xfs_growfs_rt(
>  		/*
>  		 * Update the summary inode's size.
>  		 */
> -		mp->m_rsumip->i_d.di_size = nmp->m_rsumsize;
> +		mp->m_rsumip->i_disk_size = nmp->m_rsumsize;
>  		xfs_trans_log_inode(tp, mp->m_rsumip, XFS_ILOG_CORE);
>  		/*
>  		 * Copy summary data from old to new sizes.
> diff --git a/fs/xfs/xfs_symlink.c b/fs/xfs/xfs_symlink.c
> index 8e88a7ca387ea9..6b8980b1497c9a 100644
> --- a/fs/xfs/xfs_symlink.c
> +++ b/fs/xfs/xfs_symlink.c
> @@ -33,7 +33,7 @@ xfs_readlink_bmap_ilocked(
>  	struct xfs_buf		*bp;
>  	xfs_daddr_t		d;
>  	char			*cur_chunk;
> -	int			pathlen = ip->i_d.di_size;
> +	int			pathlen = ip->i_disk_size;
>  	int			nmaps = XFS_SYMLINK_MAPS;
>  	int			byte_cnt;
>  	int			n;
> @@ -86,7 +86,7 @@ xfs_readlink_bmap_ilocked(
>  	}
>  	ASSERT(pathlen == 0);
>  
> -	link[ip->i_d.di_size] = '\0';
> +	link[ip->i_disk_size] = '\0';
>  	error = 0;
>  
>   out:
> @@ -111,7 +111,7 @@ xfs_readlink(
>  
>  	xfs_ilock(ip, XFS_ILOCK_SHARED);
>  
> -	pathlen = ip->i_d.di_size;
> +	pathlen = ip->i_disk_size;
>  	if (!pathlen)
>  		goto out;
>  
> @@ -250,7 +250,7 @@ xfs_symlink(
>  	if (pathlen <= XFS_IFORK_DSIZE(ip)) {
>  		xfs_init_local_fork(ip, XFS_DATA_FORK, target_path, pathlen);
>  
> -		ip->i_d.di_size = pathlen;
> +		ip->i_disk_size = pathlen;
>  		ip->i_df.if_format = XFS_DINODE_FMT_LOCAL;
>  		xfs_trans_log_inode(tp, ip, XFS_ILOG_DDATA | XFS_ILOG_CORE);
>  	} else {
> @@ -265,7 +265,7 @@ xfs_symlink(
>  			goto out_trans_cancel;
>  
>  		resblks -= fs_blocks;
> -		ip->i_d.di_size = pathlen;
> +		ip->i_disk_size = pathlen;
>  		xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
>  
>  		cur_chunk = target_path;
> @@ -399,8 +399,8 @@ xfs_inactive_symlink_rmt(
>  	 * locked for the second transaction.  In the error paths we need it
>  	 * held so the cancel won't rele it, see below.
>  	 */
> -	size = (int)ip->i_d.di_size;
> -	ip->i_d.di_size = 0;
> +	size = (int)ip->i_disk_size;
> +	ip->i_disk_size = 0;
>  	VFS_I(ip)->i_mode = (VFS_I(ip)->i_mode & ~S_IFMT) | S_IFREG;
>  	xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
>  	/*
> @@ -476,7 +476,7 @@ xfs_inactive_symlink(
>  		return -EIO;
>  
>  	xfs_ilock(ip, XFS_ILOCK_EXCL);
> -	pathlen = (int)ip->i_d.di_size;
> +	pathlen = (int)ip->i_disk_size;
>  	ASSERT(pathlen);
>  
>  	if (pathlen <= 0 || pathlen > XFS_SYMLINK_MAXLEN) {
> diff --git a/fs/xfs/xfs_trace.h b/fs/xfs/xfs_trace.h
> index 460136628a7959..5cc73db80ae0c0 100644
> --- a/fs/xfs/xfs_trace.h
> +++ b/fs/xfs/xfs_trace.h
> @@ -1140,7 +1140,7 @@ DECLARE_EVENT_CLASS(xfs_file_class,
>  	TP_fast_assign(
>  		__entry->dev = VFS_I(ip)->i_sb->s_dev;
>  		__entry->ino = ip->i_ino;
> -		__entry->size = ip->i_d.di_size;
> +		__entry->size = ip->i_disk_size;
>  		__entry->offset = offset;
>  		__entry->count = count;
>  	),
> @@ -1181,7 +1181,7 @@ DECLARE_EVENT_CLASS(xfs_imap_class,
>  	TP_fast_assign(
>  		__entry->dev = VFS_I(ip)->i_sb->s_dev;
>  		__entry->ino = ip->i_ino;
> -		__entry->size = ip->i_d.di_size;
> +		__entry->size = ip->i_disk_size;
>  		__entry->offset = offset;
>  		__entry->count = count;
>  		__entry->whichfork = whichfork;
> @@ -1227,7 +1227,7 @@ DECLARE_EVENT_CLASS(xfs_simple_io_class,
>  		__entry->dev = VFS_I(ip)->i_sb->s_dev;
>  		__entry->ino = ip->i_ino;
>  		__entry->isize = VFS_I(ip)->i_size;
> -		__entry->disize = ip->i_d.di_size;
> +		__entry->disize = ip->i_disk_size;
>  		__entry->offset = offset;
>  		__entry->count = count;
>  	),
> @@ -1265,7 +1265,7 @@ DECLARE_EVENT_CLASS(xfs_itrunc_class,
>  	TP_fast_assign(
>  		__entry->dev = VFS_I(ip)->i_sb->s_dev;
>  		__entry->ino = ip->i_ino;
> -		__entry->size = ip->i_d.di_size;
> +		__entry->size = ip->i_disk_size;
>  		__entry->new_size = new_size;
>  	),
>  	TP_printk("dev %d:%d ino 0x%llx size 0x%llx new_size 0x%llx",
> @@ -1295,7 +1295,7 @@ TRACE_EVENT(xfs_pagecache_inval,
>  	TP_fast_assign(
>  		__entry->dev = VFS_I(ip)->i_sb->s_dev;
>  		__entry->ino = ip->i_ino;
> -		__entry->size = ip->i_d.di_size;
> +		__entry->size = ip->i_disk_size;
>  		__entry->start = start;
>  		__entry->finish = finish;
>  	),
> @@ -1323,7 +1323,7 @@ TRACE_EVENT(xfs_bunmap,
>  	TP_fast_assign(
>  		__entry->dev = VFS_I(ip)->i_sb->s_dev;
>  		__entry->ino = ip->i_ino;
> -		__entry->size = ip->i_d.di_size;
> +		__entry->size = ip->i_disk_size;
>  		__entry->bno = bno;
>  		__entry->len = len;
>  		__entry->caller_ip = caller_ip;
> @@ -2984,12 +2984,12 @@ DECLARE_EVENT_CLASS(xfs_double_io_class,
>  		__entry->dev = VFS_I(src)->i_sb->s_dev;
>  		__entry->src_ino = src->i_ino;
>  		__entry->src_isize = VFS_I(src)->i_size;
> -		__entry->src_disize = src->i_d.di_size;
> +		__entry->src_disize = src->i_disk_size;
>  		__entry->src_offset = soffset;
>  		__entry->len = len;
>  		__entry->dest_ino = dest->i_ino;
>  		__entry->dest_isize = VFS_I(dest)->i_size;
> -		__entry->dest_disize = dest->i_d.di_size;
> +		__entry->dest_disize = dest->i_disk_size;
>  		__entry->dest_offset = doffset;
>  	),
>  	TP_printk("dev %d:%d count %zd "
> 


-- 
chandan




^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH 04/15] xfs: move the di_nblocks field to struct xfs_inode
  2020-06-20  7:10 ` [PATCH 04/15] xfs: move the di_nblocks " Christoph Hellwig
@ 2020-06-22  9:33   ` Chandan Babu R
  2020-06-30 17:47   ` Darrick J. Wong
  1 sibling, 0 replies; 52+ messages in thread
From: Chandan Babu R @ 2020-06-22  9:33 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: linux-xfs

On Saturday 20 June 2020 12:40:51 PM IST Christoph Hellwig wrote:
> In preparation of removing the historic icinode struct, move the nblocks
> field into the containing xfs_inode structure.
>

The changes look good to me.

Reviewed-by: Chandan Babu R <chandanrlinux@gmail.com>

> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  fs/xfs/libxfs/xfs_bmap.c       | 12 ++++++------
>  fs/xfs/libxfs/xfs_bmap_btree.c |  4 ++--
>  fs/xfs/libxfs/xfs_da_btree.c   |  4 ++--
>  fs/xfs/libxfs/xfs_inode_buf.c  |  4 ++--
>  fs/xfs/libxfs/xfs_inode_buf.h  |  1 -
>  fs/xfs/libxfs/xfs_inode_fork.c |  2 +-
>  fs/xfs/xfs_bmap_util.c         |  8 ++++----
>  fs/xfs/xfs_icache.c            |  4 ++--
>  fs/xfs/xfs_inode.c             |  8 ++++----
>  fs/xfs/xfs_inode.h             |  1 +
>  fs/xfs/xfs_inode_item.c        |  2 +-
>  fs/xfs/xfs_iops.c              |  3 +--
>  fs/xfs/xfs_itable.c            |  2 +-
>  fs/xfs/xfs_qm.c                | 10 +++++-----
>  fs/xfs/xfs_quotaops.c          |  2 +-
>  15 files changed, 33 insertions(+), 34 deletions(-)
> 
> diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
> index 56d78f8ba55eb6..54f3015f08285a 100644
> --- a/fs/xfs/libxfs/xfs_bmap.c
> +++ b/fs/xfs/libxfs/xfs_bmap.c
> @@ -623,7 +623,7 @@ xfs_bmap_btree_to_extents(
>  		return error;
>  	xfs_rmap_ino_bmbt_owner(&oinfo, ip->i_ino, whichfork);
>  	xfs_bmap_add_free(cur->bc_tp, cbno, 1, &oinfo);
> -	ip->i_d.di_nblocks--;
> +	ip->i_nblocks--;
>  	xfs_trans_mod_dquot_byino(tp, ip, XFS_TRANS_DQ_BCOUNT, -1L);
>  	xfs_trans_binval(tp, cbp);
>  	if (cur->bc_bufs[0] == cbp)
> @@ -725,7 +725,7 @@ xfs_bmap_extents_to_btree(
>  	       args.agno >= XFS_FSB_TO_AGNO(mp, tp->t_firstblock));
>  	tp->t_firstblock = args.fsbno;
>  	cur->bc_ino.allocated++;
> -	ip->i_d.di_nblocks++;
> +	ip->i_nblocks++;
>  	xfs_trans_mod_dquot_byino(tp, ip, XFS_TRANS_DQ_BCOUNT, 1L);
>  	error = xfs_trans_get_buf(tp, mp->m_ddev_targp,
>  			XFS_FSB_TO_DADDR(mp, args.fsbno),
> @@ -907,7 +907,7 @@ xfs_bmap_local_to_extents(
>  	xfs_iext_insert(ip, &icur, &rec, 0);
>  
>  	ifp->if_nextents = 1;
> -	ip->i_d.di_nblocks = 1;
> +	ip->i_nblocks = 1;
>  	xfs_trans_mod_dquot_byino(tp, ip,
>  		XFS_TRANS_DQ_BCOUNT, 1L);
>  	flags |= xfs_ilog_fext(whichfork);
> @@ -3448,7 +3448,7 @@ xfs_bmap_btalloc_accounting(
>  	}
>  
>  	/* data/attr fork only */
> -	ap->ip->i_d.di_nblocks += args->len;
> +	ap->ip->i_nblocks += args->len;
>  	xfs_trans_log_inode(ap->tp, ap->ip, XFS_ILOG_CORE);
>  	if (ap->wasdel) {
>  		ap->ip->i_delayed_blks -= args->len;
> @@ -4659,7 +4659,7 @@ xfs_bmapi_remap(
>  		ASSERT(got.br_startoff - bno >= len);
>  	}
>  
> -	ip->i_d.di_nblocks += len;
> +	ip->i_nblocks += len;
>  	xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
>  
>  	if (ifp->if_flags & XFS_IFBROOT) {
> @@ -5225,7 +5225,7 @@ xfs_bmap_del_extent_real(
>  	 * Adjust inode # blocks in the file.
>  	 */
>  	if (nblks)
> -		ip->i_d.di_nblocks -= nblks;
> +		ip->i_nblocks -= nblks;
>  	/*
>  	 * Adjust quota data.
>  	 */
> diff --git a/fs/xfs/libxfs/xfs_bmap_btree.c b/fs/xfs/libxfs/xfs_bmap_btree.c
> index d9c63f17d2decd..9ad4c6a1eec518 100644
> --- a/fs/xfs/libxfs/xfs_bmap_btree.c
> +++ b/fs/xfs/libxfs/xfs_bmap_btree.c
> @@ -260,7 +260,7 @@ xfs_bmbt_alloc_block(
>  	ASSERT(args.len == 1);
>  	cur->bc_tp->t_firstblock = args.fsbno;
>  	cur->bc_ino.allocated++;
> -	cur->bc_ino.ip->i_d.di_nblocks++;
> +	cur->bc_ino.ip->i_nblocks++;
>  	xfs_trans_log_inode(args.tp, cur->bc_ino.ip, XFS_ILOG_CORE);
>  	xfs_trans_mod_dquot_byino(args.tp, cur->bc_ino.ip,
>  			XFS_TRANS_DQ_BCOUNT, 1L);
> @@ -287,7 +287,7 @@ xfs_bmbt_free_block(
>  
>  	xfs_rmap_ino_bmbt_owner(&oinfo, ip->i_ino, cur->bc_ino.whichfork);
>  	xfs_bmap_add_free(cur->bc_tp, fsbno, 1, &oinfo);
> -	ip->i_d.di_nblocks--;
> +	ip->i_nblocks--;
>  
>  	xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
>  	xfs_trans_mod_dquot_byino(tp, ip, XFS_TRANS_DQ_BCOUNT, -1L);
> diff --git a/fs/xfs/libxfs/xfs_da_btree.c b/fs/xfs/libxfs/xfs_da_btree.c
> index 897749c41f36eb..55fadffb8752d3 100644
> --- a/fs/xfs/libxfs/xfs_da_btree.c
> +++ b/fs/xfs/libxfs/xfs_da_btree.c
> @@ -2139,7 +2139,7 @@ xfs_da_grow_inode_int(
>  	struct xfs_trans	*tp = args->trans;
>  	struct xfs_inode	*dp = args->dp;
>  	int			w = args->whichfork;
> -	xfs_rfsblock_t		nblks = dp->i_d.di_nblocks;
> +	xfs_rfsblock_t		nblks = dp->i_nblocks;
>  	struct xfs_bmbt_irec	map, *mapp;
>  	int			nmap, error, got, i, mapi;
>  
> @@ -2205,7 +2205,7 @@ xfs_da_grow_inode_int(
>  	}
>  
>  	/* account for newly allocated blocks in reserved blocks total */
> -	args->total -= dp->i_d.di_nblocks - nblks;
> +	args->total -= dp->i_nblocks - nblks;
>  
>  out_free_map:
>  	if (mapp != &map)
> diff --git a/fs/xfs/libxfs/xfs_inode_buf.c b/fs/xfs/libxfs/xfs_inode_buf.c
> index c202de8bbdd427..d1a15778e86a38 100644
> --- a/fs/xfs/libxfs/xfs_inode_buf.c
> +++ b/fs/xfs/libxfs/xfs_inode_buf.c
> @@ -242,7 +242,7 @@ xfs_inode_from_disk(
>  	inode->i_ctime.tv_nsec = (int)be32_to_cpu(from->di_ctime.t_nsec);
>  
>  	ip->i_disk_size = be64_to_cpu(from->di_size);
> -	to->di_nblocks = be64_to_cpu(from->di_nblocks);
> +	ip->i_nblocks = be64_to_cpu(from->di_nblocks);
>  	to->di_extsize = be32_to_cpu(from->di_extsize);
>  	to->di_forkoff = from->di_forkoff;
>  	to->di_dmevmask	= be32_to_cpu(from->di_dmevmask);
> @@ -305,7 +305,7 @@ xfs_inode_to_disk(
>  	to->di_mode = cpu_to_be16(inode->i_mode);
>  
>  	to->di_size = cpu_to_be64(ip->i_disk_size);
> -	to->di_nblocks = cpu_to_be64(from->di_nblocks);
> +	to->di_nblocks = cpu_to_be64(ip->i_nblocks);
>  	to->di_extsize = cpu_to_be32(from->di_extsize);
>  	to->di_nextents = cpu_to_be32(xfs_ifork_nextents(&ip->i_df));
>  	to->di_anextents = cpu_to_be16(xfs_ifork_nextents(ip->i_afp));
> diff --git a/fs/xfs/libxfs/xfs_inode_buf.h b/fs/xfs/libxfs/xfs_inode_buf.h
> index f187127d50e010..a322e1adf0a348 100644
> --- a/fs/xfs/libxfs/xfs_inode_buf.h
> +++ b/fs/xfs/libxfs/xfs_inode_buf.h
> @@ -17,7 +17,6 @@ struct xfs_dinode;
>   */
>  struct xfs_icdinode {
>  	uint16_t	di_flushiter;	/* incremented on flush */
> -	xfs_rfsblock_t	di_nblocks;	/* # of direct & btree blocks used */
>  	xfs_extlen_t	di_extsize;	/* basic/minimum extent size for file */
>  	uint8_t		di_forkoff;	/* attr fork offs, <<3 for 64b align */
>  	uint32_t	di_dmevmask;	/* DMIG event mask */
> diff --git a/fs/xfs/libxfs/xfs_inode_fork.c b/fs/xfs/libxfs/xfs_inode_fork.c
> index d2029e12bda4de..391836dd4814e0 100644
> --- a/fs/xfs/libxfs/xfs_inode_fork.c
> +++ b/fs/xfs/libxfs/xfs_inode_fork.c
> @@ -192,7 +192,7 @@ xfs_iformat_btree(
>  		     nrecs == 0 ||
>  		     XFS_BMDR_SPACE_CALC(nrecs) >
>  					XFS_DFORK_SIZE(dip, mp, whichfork) ||
> -		     ifp->if_nextents > ip->i_d.di_nblocks) ||
> +		     ifp->if_nextents > ip->i_nblocks) ||
>  		     level == 0 || level > XFS_BTREE_MAXLEVELS) {
>  		xfs_warn(mp, "corrupt inode %Lu (btree).",
>  					(unsigned long long) ip->i_ino);
> diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c
> index d199ecddc1ab19..5eba039d72fb83 100644
> --- a/fs/xfs/xfs_bmap_util.c
> +++ b/fs/xfs/xfs_bmap_util.c
> @@ -154,7 +154,7 @@ xfs_bmap_rtalloc(
>  		ap->blkno *= mp->m_sb.sb_rextsize;
>  		ralen *= mp->m_sb.sb_rextsize;
>  		ap->length = ralen;
> -		ap->ip->i_d.di_nblocks += ralen;
> +		ap->ip->i_nblocks += ralen;
>  		xfs_trans_log_inode(ap->tp, ap->ip, XFS_ILOG_CORE);
>  		if (ap->wasdel)
>  			ap->ip->i_delayed_blks -= ralen;
> @@ -1469,9 +1469,9 @@ xfs_swap_extent_forks(
>  	/*
>  	 * Fix the on-disk inode values
>  	 */
> -	tmp = (uint64_t)ip->i_d.di_nblocks;
> -	ip->i_d.di_nblocks = tip->i_d.di_nblocks - taforkblks + aforkblks;
> -	tip->i_d.di_nblocks = tmp + taforkblks - aforkblks;
> +	tmp = (uint64_t)ip->i_nblocks;
> +	ip->i_nblocks = tip->i_nblocks - taforkblks + aforkblks;
> +	tip->i_nblocks = tmp + taforkblks - aforkblks;
>  
>  	/*
>  	 * The extents in the source inode could still contain speculative
> diff --git a/fs/xfs/xfs_icache.c b/fs/xfs/xfs_icache.c
> index a3bbd6e4bb6fc8..ad01e694f3ab9b 100644
> --- a/fs/xfs/xfs_icache.c
> +++ b/fs/xfs/xfs_icache.c
> @@ -66,7 +66,7 @@ xfs_inode_alloc(
>  	memset(&ip->i_df, 0, sizeof(ip->i_df));
>  	ip->i_flags = 0;
>  	ip->i_delayed_blks = 0;
> -	ip->i_d.di_nblocks = 0;
> +	ip->i_nblocks = 0;
>  	ip->i_d.di_forkoff = 0;
>  	ip->i_sick = 0;
>  	ip->i_checked = 0;
> @@ -331,7 +331,7 @@ xfs_iget_check_free_state(
>  			return -EFSCORRUPTED;
>  		}
>  
> -		if (ip->i_d.di_nblocks != 0) {
> +		if (ip->i_nblocks != 0) {
>  			xfs_warn(ip->i_mount,
>  "Corruption detected! Free inode 0x%llx has blocks allocated!",
>  				ip->i_ino);
> diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
> index 723a911c8b6d81..19d132acc499cb 100644
> --- a/fs/xfs/xfs_inode.c
> +++ b/fs/xfs/xfs_inode.c
> @@ -827,7 +827,7 @@ xfs_ialloc(
>  
>  	ip->i_disk_size = 0;
>  	ip->i_df.if_nextents = 0;
> -	ASSERT(ip->i_d.di_nblocks == 0);
> +	ASSERT(ip->i_nblocks == 0);
>  
>  	tv = current_time(inode);
>  	inode->i_mtime = tv;
> @@ -2730,7 +2730,7 @@ xfs_ifree(
>  	ASSERT(VFS_I(ip)->i_nlink == 0);
>  	ASSERT(ip->i_df.if_nextents == 0);
>  	ASSERT(ip->i_disk_size == 0 || !S_ISREG(VFS_I(ip)->i_mode));
> -	ASSERT(ip->i_d.di_nblocks == 0);
> +	ASSERT(ip->i_nblocks == 0);
>  
>  	/*
>  	 * Pull the on-disk inode from the AGI unlinked list.
> @@ -3747,13 +3747,13 @@ xfs_iflush_int(
>  		}
>  	}
>  	if (XFS_TEST_ERROR(ip->i_df.if_nextents + xfs_ifork_nextents(ip->i_afp) >
> -				ip->i_d.di_nblocks, mp, XFS_ERRTAG_IFLUSH_5)) {
> +				ip->i_nblocks, mp, XFS_ERRTAG_IFLUSH_5)) {
>  		xfs_alert_tag(mp, XFS_PTAG_IFLUSH,
>  			"%s: detected corrupt incore inode %Lu, "
>  			"total extents = %d, nblocks = %Ld, ptr "PTR_FMT,
>  			__func__, ip->i_ino,
>  			ip->i_df.if_nextents + xfs_ifork_nextents(ip->i_afp),
> -			ip->i_d.di_nblocks, ip);
> +			ip->i_nblocks, ip);
>  		goto flush_out;
>  	}
>  	if (XFS_TEST_ERROR(ip->i_d.di_forkoff > mp->m_sb.sb_inodesize,
> diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h
> index 61c41395536f07..828f49f109475e 100644
> --- a/fs/xfs/xfs_inode.h
> +++ b/fs/xfs/xfs_inode.h
> @@ -55,6 +55,7 @@ typedef struct xfs_inode {
>  	unsigned long		i_flags;	/* see defined flags below */
>  	uint64_t		i_delayed_blks;	/* count of delay alloc blks */
>  	xfs_fsize_t		i_disk_size;	/* number of bytes in file */
> +	xfs_rfsblock_t		i_nblocks;	/* # of direct & btree blocks */
>  	uint32_t		i_projid;	/* owner's project id */
>  
>  	struct xfs_icdinode	i_d;		/* most of ondisk inode */
> diff --git a/fs/xfs/xfs_inode_item.c b/fs/xfs/xfs_inode_item.c
> index 179f1c2de6bd0f..0980fa43472cf8 100644
> --- a/fs/xfs/xfs_inode_item.c
> +++ b/fs/xfs/xfs_inode_item.c
> @@ -324,7 +324,7 @@ xfs_inode_to_log_dinode(
>  	to->di_mode = inode->i_mode;
>  
>  	to->di_size = ip->i_disk_size;
> -	to->di_nblocks = from->di_nblocks;
> +	to->di_nblocks = ip->i_nblocks;
>  	to->di_extsize = from->di_extsize;
>  	to->di_nextents = xfs_ifork_nextents(&ip->i_df);
>  	to->di_anextents = xfs_ifork_nextents(ip->i_afp);
> diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
> index 1abee83d49cff9..78159c57d82828 100644
> --- a/fs/xfs/xfs_iops.c
> +++ b/fs/xfs/xfs_iops.c
> @@ -554,8 +554,7 @@ xfs_vn_getattr(
>  	stat->atime = inode->i_atime;
>  	stat->mtime = inode->i_mtime;
>  	stat->ctime = inode->i_ctime;
> -	stat->blocks =
> -		XFS_FSB_TO_BB(mp, ip->i_d.di_nblocks + ip->i_delayed_blks);
> +	stat->blocks = XFS_FSB_TO_BB(mp, ip->i_nblocks + ip->i_delayed_blks);
>  
>  	if (xfs_sb_version_has_v3inode(&mp->m_sb)) {
>  		if (request_mask & STATX_BTIME) {
> diff --git a/fs/xfs/xfs_itable.c b/fs/xfs/xfs_itable.c
> index 9f92514301b334..7af144500bbfdb 100644
> --- a/fs/xfs/xfs_itable.c
> +++ b/fs/xfs/xfs_itable.c
> @@ -130,7 +130,7 @@ xfs_bulkstat_one_int(
>  	case XFS_DINODE_FMT_BTREE:
>  		buf->bs_rdev = 0;
>  		buf->bs_blksize = mp->m_sb.sb_blocksize;
> -		buf->bs_blocks = dic->di_nblocks + ip->i_delayed_blks;
> +		buf->bs_blocks = ip->i_nblocks + ip->i_delayed_blks;
>  		break;
>  	}
>  	xfs_iunlock(ip, XFS_ILOCK_SHARED);
> diff --git a/fs/xfs/xfs_qm.c b/fs/xfs/xfs_qm.c
> index ea22dcf868b474..3af3b5f5d4f2ad 100644
> --- a/fs/xfs/xfs_qm.c
> +++ b/fs/xfs/xfs_qm.c
> @@ -989,7 +989,7 @@ xfs_qm_reset_dqcounts_buf(
>  	 * trans_reserve. But, this gets called during quotacheck, and that
>  	 * happens only at mount time which is single threaded.
>  	 */
> -	if (qip->i_d.di_nblocks == 0)
> +	if (qip->i_nblocks == 0)
>  		return 0;
>  
>  	map = kmem_alloc(XFS_DQITER_MAP_SIZE * sizeof(*map), 0);
> @@ -1171,7 +1171,7 @@ xfs_qm_dqusage_adjust(
>  		xfs_bmap_count_leaves(ifp, &rtblks);
>  	}
>  
> -	nblks = (xfs_qcnt_t)ip->i_d.di_nblocks - rtblks;
> +	nblks = (xfs_qcnt_t)ip->i_nblocks - rtblks;
>  
>  	/*
>  	 * Add the (disk blocks and inode) resources occupied by this
> @@ -1774,11 +1774,11 @@ xfs_qm_vop_chown(
>  	ASSERT(prevdq);
>  	ASSERT(prevdq != newdq);
>  
> -	xfs_trans_mod_dquot(tp, prevdq, bfield, -(ip->i_d.di_nblocks));
> +	xfs_trans_mod_dquot(tp, prevdq, bfield, -(ip->i_nblocks));
>  	xfs_trans_mod_dquot(tp, prevdq, XFS_TRANS_DQ_ICOUNT, -1);
>  
>  	/* the sparkling new dquot */
> -	xfs_trans_mod_dquot(tp, newdq, bfield, ip->i_d.di_nblocks);
> +	xfs_trans_mod_dquot(tp, newdq, bfield, ip->i_nblocks);
>  	xfs_trans_mod_dquot(tp, newdq, XFS_TRANS_DQ_ICOUNT, 1);
>  
>  	/*
> @@ -1854,7 +1854,7 @@ xfs_qm_vop_chown_reserve(
>  
>  	error = xfs_trans_reserve_quota_bydquots(tp, ip->i_mount,
>  				udq_delblks, gdq_delblks, pdq_delblks,
> -				ip->i_d.di_nblocks, 1, flags | blkflags);
> +				ip->i_nblocks, 1, flags | blkflags);
>  	if (error)
>  		return error;
>  
> diff --git a/fs/xfs/xfs_quotaops.c b/fs/xfs/xfs_quotaops.c
> index bf809b77a31606..09a5290ad2bd1b 100644
> --- a/fs/xfs/xfs_quotaops.c
> +++ b/fs/xfs/xfs_quotaops.c
> @@ -35,7 +35,7 @@ xfs_qm_fill_state(
>  		tempqip = true;
>  	}
>  	tstate->flags |= QCI_SYSFILE;
> -	tstate->blocks = ip->i_d.di_nblocks;
> +	tstate->blocks = ip->i_nblocks;
>  	tstate->nextents = ip->i_df.if_nextents;
>  	tstate->spc_timelimit = (u32)defq->btimelimit;
>  	tstate->ino_timelimit = (u32)defq->itimelimit;
> 


-- 
chandan




^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH 05/15] xfs: move the di_extsize field to struct xfs_inode
  2020-06-20  7:10 ` [PATCH 05/15] xfs: move the di_extsize " Christoph Hellwig
@ 2020-06-22  9:36   ` Chandan Babu R
  2020-06-30 17:47   ` Darrick J. Wong
  1 sibling, 0 replies; 52+ messages in thread
From: Chandan Babu R @ 2020-06-22  9:36 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: linux-xfs

On Saturday 20 June 2020 12:40:52 PM IST Christoph Hellwig wrote:
> In preparation of removing the historic icinode struct, move the extsize
> field into the containing xfs_inode structure.
>

The changes look good to me.

Reviewed-by: Chandan Babu R <chandanrlinux@gmail.com>

> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  fs/xfs/libxfs/xfs_bmap.c      |  2 +-
>  fs/xfs/libxfs/xfs_inode_buf.c |  4 ++--
>  fs/xfs/libxfs/xfs_inode_buf.h |  1 -
>  fs/xfs/xfs_inode.c            | 10 +++++-----
>  fs/xfs/xfs_inode.h            |  1 +
>  fs/xfs/xfs_inode_item.c       |  2 +-
>  fs/xfs/xfs_ioctl.c            | 10 +++++-----
>  fs/xfs/xfs_itable.c           |  2 +-
>  8 files changed, 16 insertions(+), 16 deletions(-)
> 
> diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
> index 54f3015f08285a..692159357ed8e5 100644
> --- a/fs/xfs/libxfs/xfs_bmap.c
> +++ b/fs/xfs/libxfs/xfs_bmap.c
> @@ -2942,7 +2942,7 @@ xfs_bmap_add_extent_hole_real(
>   */
>  
>  /*
> - * Adjust the size of the new extent based on di_extsize and rt extsize.
> + * Adjust the size of the new extent based on i_extsize and rt extsize.
>   */
>  int
>  xfs_bmap_extsize_align(
> diff --git a/fs/xfs/libxfs/xfs_inode_buf.c b/fs/xfs/libxfs/xfs_inode_buf.c
> index d1a15778e86a38..e51b15c44bb3e1 100644
> --- a/fs/xfs/libxfs/xfs_inode_buf.c
> +++ b/fs/xfs/libxfs/xfs_inode_buf.c
> @@ -243,7 +243,7 @@ xfs_inode_from_disk(
>  
>  	ip->i_disk_size = be64_to_cpu(from->di_size);
>  	ip->i_nblocks = be64_to_cpu(from->di_nblocks);
> -	to->di_extsize = be32_to_cpu(from->di_extsize);
> +	ip->i_extsize = be32_to_cpu(from->di_extsize);
>  	to->di_forkoff = from->di_forkoff;
>  	to->di_dmevmask	= be32_to_cpu(from->di_dmevmask);
>  	to->di_dmstate	= be16_to_cpu(from->di_dmstate);
> @@ -306,7 +306,7 @@ xfs_inode_to_disk(
>  
>  	to->di_size = cpu_to_be64(ip->i_disk_size);
>  	to->di_nblocks = cpu_to_be64(ip->i_nblocks);
> -	to->di_extsize = cpu_to_be32(from->di_extsize);
> +	to->di_extsize = cpu_to_be32(ip->i_extsize);
>  	to->di_nextents = cpu_to_be32(xfs_ifork_nextents(&ip->i_df));
>  	to->di_anextents = cpu_to_be16(xfs_ifork_nextents(ip->i_afp));
>  	to->di_forkoff = from->di_forkoff;
> diff --git a/fs/xfs/libxfs/xfs_inode_buf.h b/fs/xfs/libxfs/xfs_inode_buf.h
> index a322e1adf0a348..d420ea835c8390 100644
> --- a/fs/xfs/libxfs/xfs_inode_buf.h
> +++ b/fs/xfs/libxfs/xfs_inode_buf.h
> @@ -17,7 +17,6 @@ struct xfs_dinode;
>   */
>  struct xfs_icdinode {
>  	uint16_t	di_flushiter;	/* incremented on flush */
> -	xfs_extlen_t	di_extsize;	/* basic/minimum extent size for file */
>  	uint8_t		di_forkoff;	/* attr fork offs, <<3 for 64b align */
>  	uint32_t	di_dmevmask;	/* DMIG event mask */
>  	uint16_t	di_dmstate;	/* DMIG state info */
> diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
> index 19d132acc499cb..6d1891f902aaa9 100644
> --- a/fs/xfs/xfs_inode.c
> +++ b/fs/xfs/xfs_inode.c
> @@ -61,8 +61,8 @@ xfs_get_extsz_hint(
>  	 */
>  	if (xfs_is_always_cow_inode(ip))
>  		return 0;
> -	if ((ip->i_d.di_flags & XFS_DIFLAG_EXTSIZE) && ip->i_d.di_extsize)
> -		return ip->i_d.di_extsize;
> +	if ((ip->i_d.di_flags & XFS_DIFLAG_EXTSIZE) && ip->i_extsize)
> +		return ip->i_extsize;
>  	if (XFS_IS_REALTIME_INODE(ip))
>  		return ip->i_mount->m_sb.sb_rextsize;
>  	return 0;
> @@ -834,7 +834,7 @@ xfs_ialloc(
>  	inode->i_atime = tv;
>  	inode->i_ctime = tv;
>  
> -	ip->i_d.di_extsize = 0;
> +	ip->i_extsize = 0;
>  	ip->i_d.di_dmevmask = 0;
>  	ip->i_d.di_dmstate = 0;
>  	ip->i_d.di_flags = 0;
> @@ -866,7 +866,7 @@ xfs_ialloc(
>  					di_flags |= XFS_DIFLAG_RTINHERIT;
>  				if (pip->i_d.di_flags & XFS_DIFLAG_EXTSZINHERIT) {
>  					di_flags |= XFS_DIFLAG_EXTSZINHERIT;
> -					ip->i_d.di_extsize = pip->i_d.di_extsize;
> +					ip->i_extsize = pip->i_extsize;
>  				}
>  				if (pip->i_d.di_flags & XFS_DIFLAG_PROJINHERIT)
>  					di_flags |= XFS_DIFLAG_PROJINHERIT;
> @@ -875,7 +875,7 @@ xfs_ialloc(
>  					di_flags |= XFS_DIFLAG_REALTIME;
>  				if (pip->i_d.di_flags & XFS_DIFLAG_EXTSZINHERIT) {
>  					di_flags |= XFS_DIFLAG_EXTSIZE;
> -					ip->i_d.di_extsize = pip->i_d.di_extsize;
> +					ip->i_extsize = pip->i_extsize;
>  				}
>  			}
>  			if ((pip->i_d.di_flags & XFS_DIFLAG_NOATIME) &&
> diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h
> index 828f49f109475e..af90c6f745549b 100644
> --- a/fs/xfs/xfs_inode.h
> +++ b/fs/xfs/xfs_inode.h
> @@ -57,6 +57,7 @@ typedef struct xfs_inode {
>  	xfs_fsize_t		i_disk_size;	/* number of bytes in file */
>  	xfs_rfsblock_t		i_nblocks;	/* # of direct & btree blocks */
>  	uint32_t		i_projid;	/* owner's project id */
> +	xfs_extlen_t		i_extsize;	/* basic/minimum extent size */
>  
>  	struct xfs_icdinode	i_d;		/* most of ondisk inode */
>  
> diff --git a/fs/xfs/xfs_inode_item.c b/fs/xfs/xfs_inode_item.c
> index 0980fa43472cf8..8b8c99809f273e 100644
> --- a/fs/xfs/xfs_inode_item.c
> +++ b/fs/xfs/xfs_inode_item.c
> @@ -325,7 +325,7 @@ xfs_inode_to_log_dinode(
>  
>  	to->di_size = ip->i_disk_size;
>  	to->di_nblocks = ip->i_nblocks;
> -	to->di_extsize = from->di_extsize;
> +	to->di_extsize = ip->i_extsize;
>  	to->di_nextents = xfs_ifork_nextents(&ip->i_df);
>  	to->di_anextents = xfs_ifork_nextents(ip->i_afp);
>  	to->di_forkoff = from->di_forkoff;
> diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
> index d93f4fc40fd99e..efe3b5bc1178dc 100644
> --- a/fs/xfs/xfs_ioctl.c
> +++ b/fs/xfs/xfs_ioctl.c
> @@ -1107,7 +1107,7 @@ xfs_fill_fsxattr(
>  	struct xfs_ifork	*ifp = attr ? ip->i_afp : &ip->i_df;
>  
>  	simple_fill_fsxattr(fa, xfs_ip2xflags(ip));
> -	fa->fsx_extsize = ip->i_d.di_extsize << ip->i_mount->m_sb.sb_blocklog;
> +	fa->fsx_extsize = ip->i_extsize << ip->i_mount->m_sb.sb_blocklog;
>  	fa->fsx_cowextsize = ip->i_d.di_cowextsize <<
>  			ip->i_mount->m_sb.sb_blocklog;
>  	fa->fsx_projid = ip->i_projid;
> @@ -1209,7 +1209,7 @@ xfs_ioctl_setattr_xflags(
>  	/* If realtime flag is set then must have realtime device */
>  	if (fa->fsx_xflags & FS_XFLAG_REALTIME) {
>  		if (mp->m_sb.sb_rblocks == 0 || mp->m_sb.sb_rextsize == 0 ||
> -		    (ip->i_d.di_extsize % mp->m_sb.sb_rextsize))
> +		    (ip->i_extsize % mp->m_sb.sb_rextsize))
>  			return -EINVAL;
>  	}
>  
> @@ -1381,7 +1381,7 @@ xfs_ioctl_setattr_check_extsize(
>  	xfs_fsblock_t		extsize_fsb;
>  
>  	if (S_ISREG(VFS_I(ip)->i_mode) && ip->i_df.if_nextents &&
> -	    ((ip->i_d.di_extsize << mp->m_sb.sb_blocklog) != fa->fsx_extsize))
> +	    ((ip->i_extsize << mp->m_sb.sb_blocklog) != fa->fsx_extsize))
>  		return -EINVAL;
>  
>  	if (fa->fsx_extsize == 0)
> @@ -1569,9 +1569,9 @@ xfs_ioctl_setattr(
>  	 * are set on the inode then unconditionally clear the extent size hint.
>  	 */
>  	if (ip->i_d.di_flags & (XFS_DIFLAG_EXTSIZE | XFS_DIFLAG_EXTSZINHERIT))
> -		ip->i_d.di_extsize = fa->fsx_extsize >> mp->m_sb.sb_blocklog;
> +		ip->i_extsize = fa->fsx_extsize >> mp->m_sb.sb_blocklog;
>  	else
> -		ip->i_d.di_extsize = 0;
> +		ip->i_extsize = 0;
>  	if (xfs_sb_version_has_v3inode(&mp->m_sb) &&
>  	    (ip->i_d.di_flags2 & XFS_DIFLAG2_COWEXTSIZE))
>  		ip->i_d.di_cowextsize = fa->fsx_cowextsize >>
> diff --git a/fs/xfs/xfs_itable.c b/fs/xfs/xfs_itable.c
> index 7af144500bbfdb..b0f0c19fd7822e 100644
> --- a/fs/xfs/xfs_itable.c
> +++ b/fs/xfs/xfs_itable.c
> @@ -103,7 +103,7 @@ xfs_bulkstat_one_int(
>  	buf->bs_mode = inode->i_mode;
>  
>  	buf->bs_xflags = xfs_ip2xflags(ip);
> -	buf->bs_extsize_blks = dic->di_extsize;
> +	buf->bs_extsize_blks = ip->i_extsize;
>  	buf->bs_extents = xfs_ifork_nextents(&ip->i_df);
>  	xfs_bulkstat_health(ip, buf);
>  	buf->bs_aextents = xfs_ifork_nextents(ip->i_afp);
> 


-- 
chandan




^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH 06/15] xfs: move the di_cowextsize field to struct xfs_inode
  2020-06-20  7:10 ` [PATCH 06/15] xfs: move the di_cowextsize " Christoph Hellwig
@ 2020-06-22  9:47   ` Chandan Babu R
  2020-06-30 17:48   ` Darrick J. Wong
  1 sibling, 0 replies; 52+ messages in thread
From: Chandan Babu R @ 2020-06-22  9:47 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: linux-xfs

On Saturday 20 June 2020 12:40:53 PM IST Christoph Hellwig wrote:
> In preparation of removing the historic icinode struct, move the
> cowextsize field into the containing xfs_inode structure.  Also
> switch to use the xfs_extlen_t instead of a uint32_t.
>

The changes look good to me.

Reviewed-by: Chandan Babu R <chandanrlinux@gmail.com>

> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  fs/xfs/libxfs/xfs_inode_buf.c | 4 ++--
>  fs/xfs/libxfs/xfs_inode_buf.h | 1 -
>  fs/xfs/xfs_file.c             | 2 +-
>  fs/xfs/xfs_inode.c            | 6 +++---
>  fs/xfs/xfs_inode.h            | 1 +
>  fs/xfs/xfs_inode_item.c       | 2 +-
>  fs/xfs/xfs_ioctl.c            | 8 +++-----
>  fs/xfs/xfs_itable.c           | 2 +-
>  fs/xfs/xfs_reflink.c          | 2 +-
>  9 files changed, 13 insertions(+), 15 deletions(-)
> 
> diff --git a/fs/xfs/libxfs/xfs_inode_buf.c b/fs/xfs/libxfs/xfs_inode_buf.c
> index e51b15c44bb3e1..860e35611e001a 100644
> --- a/fs/xfs/libxfs/xfs_inode_buf.c
> +++ b/fs/xfs/libxfs/xfs_inode_buf.c
> @@ -255,7 +255,7 @@ xfs_inode_from_disk(
>  		to->di_crtime.tv_sec = be32_to_cpu(from->di_crtime.t_sec);
>  		to->di_crtime.tv_nsec = be32_to_cpu(from->di_crtime.t_nsec);
>  		to->di_flags2 = be64_to_cpu(from->di_flags2);
> -		to->di_cowextsize = be32_to_cpu(from->di_cowextsize);
> +		ip->i_cowextsize = be32_to_cpu(from->di_cowextsize);
>  	}
>  
>  	error = xfs_iformat_data_fork(ip, from);
> @@ -321,7 +321,7 @@ xfs_inode_to_disk(
>  		to->di_crtime.t_sec = cpu_to_be32(from->di_crtime.tv_sec);
>  		to->di_crtime.t_nsec = cpu_to_be32(from->di_crtime.tv_nsec);
>  		to->di_flags2 = cpu_to_be64(from->di_flags2);
> -		to->di_cowextsize = cpu_to_be32(from->di_cowextsize);
> +		to->di_cowextsize = cpu_to_be32(ip->i_cowextsize);
>  		to->di_ino = cpu_to_be64(ip->i_ino);
>  		to->di_lsn = cpu_to_be64(lsn);
>  		memset(to->di_pad2, 0, sizeof(to->di_pad2));
> diff --git a/fs/xfs/libxfs/xfs_inode_buf.h b/fs/xfs/libxfs/xfs_inode_buf.h
> index d420ea835c8390..663a97fa78f05f 100644
> --- a/fs/xfs/libxfs/xfs_inode_buf.h
> +++ b/fs/xfs/libxfs/xfs_inode_buf.h
> @@ -23,7 +23,6 @@ struct xfs_icdinode {
>  	uint16_t	di_flags;	/* random flags, XFS_DIFLAG_... */
>  
>  	uint64_t	di_flags2;	/* more random flags */
> -	uint32_t	di_cowextsize;	/* basic cow extent size for file */
>  
>  	struct timespec64 di_crtime;	/* time created */
>  };
> diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c
> index 14b533a8ce8e6a..b0384306d6622f 100644
> --- a/fs/xfs/xfs_file.c
> +++ b/fs/xfs/xfs_file.c
> @@ -1055,7 +1055,7 @@ xfs_file_remap_range(
>  	    (src->i_d.di_flags2 & XFS_DIFLAG2_COWEXTSIZE) &&
>  	    pos_out == 0 && len >= i_size_read(inode_out) &&
>  	    !(dest->i_d.di_flags2 & XFS_DIFLAG2_COWEXTSIZE))
> -		cowextsize = src->i_d.di_cowextsize;
> +		cowextsize = src->i_cowextsize;
>  
>  	ret = xfs_reflink_update_dest(dest, pos_out + len, cowextsize,
>  			remap_flags);
> diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
> index 6d1891f902aaa9..f1893824cd4e2f 100644
> --- a/fs/xfs/xfs_inode.c
> +++ b/fs/xfs/xfs_inode.c
> @@ -82,7 +82,7 @@ xfs_get_cowextsz_hint(
>  
>  	a = 0;
>  	if (ip->i_d.di_flags2 & XFS_DIFLAG2_COWEXTSIZE)
> -		a = ip->i_d.di_cowextsize;
> +		a = ip->i_cowextsize;
>  	b = xfs_get_extsz_hint(ip);
>  
>  	a = max(a, b);
> @@ -842,7 +842,7 @@ xfs_ialloc(
>  	if (xfs_sb_version_has_v3inode(&mp->m_sb)) {
>  		inode_set_iversion(inode, 1);
>  		ip->i_d.di_flags2 = 0;
> -		ip->i_d.di_cowextsize = 0;
> +		ip->i_cowextsize = 0;
>  		ip->i_d.di_crtime = tv;
>  	}
>  
> @@ -901,7 +901,7 @@ xfs_ialloc(
>  		if (pip && (pip->i_d.di_flags2 & XFS_DIFLAG2_ANY)) {
>  			if (pip->i_d.di_flags2 & XFS_DIFLAG2_COWEXTSIZE) {
>  				ip->i_d.di_flags2 |= XFS_DIFLAG2_COWEXTSIZE;
> -				ip->i_d.di_cowextsize = pip->i_d.di_cowextsize;
> +				ip->i_cowextsize = pip->i_cowextsize;
>  			}
>  			if (pip->i_d.di_flags2 & XFS_DIFLAG2_DAX)
>  				ip->i_d.di_flags2 |= XFS_DIFLAG2_DAX;
> diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h
> index af90c6f745549b..2cdb7b6b298852 100644
> --- a/fs/xfs/xfs_inode.h
> +++ b/fs/xfs/xfs_inode.h
> @@ -58,6 +58,7 @@ typedef struct xfs_inode {
>  	xfs_rfsblock_t		i_nblocks;	/* # of direct & btree blocks */
>  	uint32_t		i_projid;	/* owner's project id */
>  	xfs_extlen_t		i_extsize;	/* basic/minimum extent size */
> +	xfs_extlen_t		i_cowextsize;	/* basic cow extent size */
>  
>  	struct xfs_icdinode	i_d;		/* most of ondisk inode */
>  
> diff --git a/fs/xfs/xfs_inode_item.c b/fs/xfs/xfs_inode_item.c
> index 8b8c99809f273e..ab0d8cf8ceb6ab 100644
> --- a/fs/xfs/xfs_inode_item.c
> +++ b/fs/xfs/xfs_inode_item.c
> @@ -343,7 +343,7 @@ xfs_inode_to_log_dinode(
>  		to->di_crtime.t_sec = from->di_crtime.tv_sec;
>  		to->di_crtime.t_nsec = from->di_crtime.tv_nsec;
>  		to->di_flags2 = from->di_flags2;
> -		to->di_cowextsize = from->di_cowextsize;
> +		to->di_cowextsize = ip->i_cowextsize;
>  		to->di_ino = ip->i_ino;
>  		to->di_lsn = lsn;
>  		memset(to->di_pad2, 0, sizeof(to->di_pad2));
> diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
> index efe3b5bc1178dc..a1937900ad84be 100644
> --- a/fs/xfs/xfs_ioctl.c
> +++ b/fs/xfs/xfs_ioctl.c
> @@ -1108,8 +1108,7 @@ xfs_fill_fsxattr(
>  
>  	simple_fill_fsxattr(fa, xfs_ip2xflags(ip));
>  	fa->fsx_extsize = ip->i_extsize << ip->i_mount->m_sb.sb_blocklog;
> -	fa->fsx_cowextsize = ip->i_d.di_cowextsize <<
> -			ip->i_mount->m_sb.sb_blocklog;
> +	fa->fsx_cowextsize = ip->i_cowextsize << ip->i_mount->m_sb.sb_blocklog;
>  	fa->fsx_projid = ip->i_projid;
>  	if (ifp && (ifp->if_flags & XFS_IFEXTENTS))
>  		fa->fsx_nextents = xfs_iext_count(ifp);
> @@ -1574,10 +1573,9 @@ xfs_ioctl_setattr(
>  		ip->i_extsize = 0;
>  	if (xfs_sb_version_has_v3inode(&mp->m_sb) &&
>  	    (ip->i_d.di_flags2 & XFS_DIFLAG2_COWEXTSIZE))
> -		ip->i_d.di_cowextsize = fa->fsx_cowextsize >>
> -				mp->m_sb.sb_blocklog;
> +		ip->i_cowextsize = fa->fsx_cowextsize >> mp->m_sb.sb_blocklog;
>  	else
> -		ip->i_d.di_cowextsize = 0;
> +		ip->i_cowextsize = 0;
>  
>  	code = xfs_trans_commit(tp);
>  
> diff --git a/fs/xfs/xfs_itable.c b/fs/xfs/xfs_itable.c
> index b0f0c19fd7822e..7937af9f2ea779 100644
> --- a/fs/xfs/xfs_itable.c
> +++ b/fs/xfs/xfs_itable.c
> @@ -112,7 +112,7 @@ xfs_bulkstat_one_int(
>  
>  	if (xfs_sb_version_has_v3inode(&mp->m_sb)) {
>  		if (dic->di_flags2 & XFS_DIFLAG2_COWEXTSIZE)
> -			buf->bs_cowextsize_blks = dic->di_cowextsize;
> +			buf->bs_cowextsize_blks = ip->i_cowextsize;
>  	}
>  
>  	switch (ip->i_df.if_format) {
> diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c
> index 8598896156e29a..0e07fa7e43117e 100644
> --- a/fs/xfs/xfs_reflink.c
> +++ b/fs/xfs/xfs_reflink.c
> @@ -942,7 +942,7 @@ xfs_reflink_update_dest(
>  	}
>  
>  	if (cowextsize) {
> -		dest->i_d.di_cowextsize = cowextsize;
> +		dest->i_cowextsize = cowextsize;
>  		dest->i_d.di_flags2 |= XFS_DIFLAG2_COWEXTSIZE;
>  	}
>  
> 


-- 
chandan




^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH 07/15] xfs: move the di_flushiter field to struct xfs_inode
  2020-06-20  7:10 ` [PATCH 07/15] xfs: move the di_flushiter " Christoph Hellwig
@ 2020-06-22  9:49   ` Chandan Babu R
  2020-06-30 17:48   ` Darrick J. Wong
  1 sibling, 0 replies; 52+ messages in thread
From: Chandan Babu R @ 2020-06-22  9:49 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: linux-xfs

On Saturday 20 June 2020 12:40:54 PM IST Christoph Hellwig wrote:
> In preparation of removing the historic icinode struct, move the
> flushiter field into the containing xfs_inode structure.
>

The changes look good to me.

Reviewed-by: Chandan Babu R <chandanrlinux@gmail.com>

> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  fs/xfs/libxfs/xfs_inode_buf.c |  4 ++--
>  fs/xfs/libxfs/xfs_inode_buf.h |  1 -
>  fs/xfs/xfs_icache.c           |  2 +-
>  fs/xfs/xfs_inode.c            | 19 +++++++++----------
>  fs/xfs/xfs_inode.h            |  1 +
>  fs/xfs/xfs_inode_item.c       |  2 +-
>  6 files changed, 14 insertions(+), 15 deletions(-)
> 
> diff --git a/fs/xfs/libxfs/xfs_inode_buf.c b/fs/xfs/libxfs/xfs_inode_buf.c
> index 860e35611e001a..03bd7cdd0ddc81 100644
> --- a/fs/xfs/libxfs/xfs_inode_buf.c
> +++ b/fs/xfs/libxfs/xfs_inode_buf.c
> @@ -205,7 +205,7 @@ xfs_inode_from_disk(
>  	 * inode. If the inode is unused, mode is zero and we shouldn't mess
>  	 * with the unitialized part of it.
>  	 */
> -	to->di_flushiter = be16_to_cpu(from->di_flushiter);
> +	ip->i_flushiter = be16_to_cpu(from->di_flushiter);
>  	inode->i_generation = be32_to_cpu(from->di_gen);
>  	inode->i_mode = be16_to_cpu(from->di_mode);
>  	if (!inode->i_mode)
> @@ -329,7 +329,7 @@ xfs_inode_to_disk(
>  		to->di_flushiter = 0;
>  	} else {
>  		to->di_version = 2;
> -		to->di_flushiter = cpu_to_be16(from->di_flushiter);
> +		to->di_flushiter = cpu_to_be16(ip->i_flushiter);
>  	}
>  }
>  
> diff --git a/fs/xfs/libxfs/xfs_inode_buf.h b/fs/xfs/libxfs/xfs_inode_buf.h
> index 663a97fa78f05f..8cc96f2766ff4f 100644
> --- a/fs/xfs/libxfs/xfs_inode_buf.h
> +++ b/fs/xfs/libxfs/xfs_inode_buf.h
> @@ -16,7 +16,6 @@ struct xfs_dinode;
>   * format specific structures at the appropriate time.
>   */
>  struct xfs_icdinode {
> -	uint16_t	di_flushiter;	/* incremented on flush */
>  	uint8_t		di_forkoff;	/* attr fork offs, <<3 for 64b align */
>  	uint32_t	di_dmevmask;	/* DMIG event mask */
>  	uint16_t	di_dmstate;	/* DMIG state info */
> diff --git a/fs/xfs/xfs_icache.c b/fs/xfs/xfs_icache.c
> index ad01e694f3ab9b..e6b40f7035aa5a 100644
> --- a/fs/xfs/xfs_icache.c
> +++ b/fs/xfs/xfs_icache.c
> @@ -521,7 +521,7 @@ xfs_iget_cache_miss(
>  	 * simply build the new inode core with a random generation number.
>  	 *
>  	 * For version 4 (and older) superblocks, log recovery is dependent on
> -	 * the di_flushiter field being initialised from the current on-disk
> +	 * the i_flushiter field being initialised from the current on-disk
>  	 * value and hence we must also read the inode off disk even when
>  	 * initializing new inodes.
>  	 */
> diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
> index f1893824cd4e2f..5e0336e0dbae44 100644
> --- a/fs/xfs/xfs_inode.c
> +++ b/fs/xfs/xfs_inode.c
> @@ -3765,16 +3765,15 @@ xfs_iflush_int(
>  	}
>  
>  	/*
> -	 * Inode item log recovery for v2 inodes are dependent on the
> -	 * di_flushiter count for correct sequencing. We bump the flush
> -	 * iteration count so we can detect flushes which postdate a log record
> -	 * during recovery. This is redundant as we now log every change and
> -	 * hence this can't happen but we need to still do it to ensure
> -	 * backwards compatibility with old kernels that predate logging all
> -	 * inode changes.
> +	 * Inode item log recovery for v2 inodes are dependent on the flushiter
> +	 * count for correct sequencing.  We bump the flush iteration count so
> +	 * we can detect flushes which postdate a log record during recovery.
> +	 * This is redundant as we now log every change and hence this can't
> +	 * happen but we need to still do it to ensure backwards compatibility
> +	 * with old kernels that predate logging all inode changes.
>  	 */
>  	if (!xfs_sb_version_has_v3inode(&mp->m_sb))
> -		ip->i_d.di_flushiter++;
> +		ip->i_flushiter++;
>  
>  	/*
>  	 * If there are inline format data / attr forks attached to this inode,
> @@ -3795,8 +3794,8 @@ xfs_iflush_int(
>  	xfs_inode_to_disk(ip, dip, iip->ili_item.li_lsn);
>  
>  	/* Wrap, we never let the log put out DI_MAX_FLUSH */
> -	if (ip->i_d.di_flushiter == DI_MAX_FLUSH)
> -		ip->i_d.di_flushiter = 0;
> +	if (ip->i_flushiter == DI_MAX_FLUSH)
> +		ip->i_flushiter = 0;
>  
>  	xfs_iflush_fork(ip, dip, iip, XFS_DATA_FORK);
>  	if (XFS_IFORK_Q(ip))
> diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h
> index 2cdb7b6b298852..581618ea1156da 100644
> --- a/fs/xfs/xfs_inode.h
> +++ b/fs/xfs/xfs_inode.h
> @@ -59,6 +59,7 @@ typedef struct xfs_inode {
>  	uint32_t		i_projid;	/* owner's project id */
>  	xfs_extlen_t		i_extsize;	/* basic/minimum extent size */
>  	xfs_extlen_t		i_cowextsize;	/* basic cow extent size */
> +	uint16_t		i_flushiter;	/* incremented on flush */
>  
>  	struct xfs_icdinode	i_d;		/* most of ondisk inode */
>  
> diff --git a/fs/xfs/xfs_inode_item.c b/fs/xfs/xfs_inode_item.c
> index ab0d8cf8ceb6ab..8357fe37d3eb8a 100644
> --- a/fs/xfs/xfs_inode_item.c
> +++ b/fs/xfs/xfs_inode_item.c
> @@ -351,7 +351,7 @@ xfs_inode_to_log_dinode(
>  		to->di_flushiter = 0;
>  	} else {
>  		to->di_version = 2;
> -		to->di_flushiter = from->di_flushiter;
> +		to->di_flushiter = ip->i_flushiter;
>  	}
>  }
>  
> 


-- 
chandan




^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH 08/15] xfs: use a union for i_cowextsize and i_flushiter
  2020-06-20  7:10 ` [PATCH 08/15] xfs: use a union for i_cowextsize and i_flushiter Christoph Hellwig
@ 2020-06-22 10:53   ` Chandan Babu R
  2020-06-30 17:51   ` Darrick J. Wong
  1 sibling, 0 replies; 52+ messages in thread
From: Chandan Babu R @ 2020-06-22 10:53 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: linux-xfs

On Saturday 20 June 2020 12:40:55 PM IST Christoph Hellwig wrote:
> The i_cowextsize field is only used for v3 inodes, and the i_flushiter
> field is only used for v1/v2 inodes.  Use a union to pack the inode a
> littler better after adding a few missing guards around their usage.
>

The changes look good to me.

Reviewed-by: Chandan Babu R <chandanrlinux@gmail.com>

> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  fs/xfs/libxfs/xfs_inode_buf.c | 3 ++-
>  fs/xfs/xfs_inode.c            | 6 ++++--
>  fs/xfs/xfs_inode.h            | 7 +++++--
>  fs/xfs/xfs_ioctl.c            | 6 +++++-
>  4 files changed, 16 insertions(+), 6 deletions(-)
> 
> diff --git a/fs/xfs/libxfs/xfs_inode_buf.c b/fs/xfs/libxfs/xfs_inode_buf.c
> index 03bd7cdd0ddc81..8c4b7bd69285fa 100644
> --- a/fs/xfs/libxfs/xfs_inode_buf.c
> +++ b/fs/xfs/libxfs/xfs_inode_buf.c
> @@ -205,7 +205,8 @@ xfs_inode_from_disk(
>  	 * inode. If the inode is unused, mode is zero and we shouldn't mess
>  	 * with the unitialized part of it.
>  	 */
> -	ip->i_flushiter = be16_to_cpu(from->di_flushiter);
> +	if (!xfs_sb_version_has_v3inode(&ip->i_mount->m_sb))
> +		ip->i_flushiter = be16_to_cpu(from->di_flushiter);
>  	inode->i_generation = be32_to_cpu(from->di_gen);
>  	inode->i_mode = be16_to_cpu(from->di_mode);
>  	if (!inode->i_mode)
> diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
> index 5e0336e0dbae44..fd111e05c0bb2e 100644
> --- a/fs/xfs/xfs_inode.c
> +++ b/fs/xfs/xfs_inode.c
> @@ -3794,8 +3794,10 @@ xfs_iflush_int(
>  	xfs_inode_to_disk(ip, dip, iip->ili_item.li_lsn);
>  
>  	/* Wrap, we never let the log put out DI_MAX_FLUSH */
> -	if (ip->i_flushiter == DI_MAX_FLUSH)
> -		ip->i_flushiter = 0;
> +	if (!xfs_sb_version_has_v3inode(&mp->m_sb)) {
> +		if (ip->i_flushiter == DI_MAX_FLUSH)
> +			ip->i_flushiter = 0;
> +	}
>  
>  	xfs_iflush_fork(ip, dip, iip, XFS_DATA_FORK);
>  	if (XFS_IFORK_Q(ip))
> diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h
> index 581618ea1156da..a0444b9ce3f792 100644
> --- a/fs/xfs/xfs_inode.h
> +++ b/fs/xfs/xfs_inode.h
> @@ -58,8 +58,11 @@ typedef struct xfs_inode {
>  	xfs_rfsblock_t		i_nblocks;	/* # of direct & btree blocks */
>  	uint32_t		i_projid;	/* owner's project id */
>  	xfs_extlen_t		i_extsize;	/* basic/minimum extent size */
> -	xfs_extlen_t		i_cowextsize;	/* basic cow extent size */
> -	uint16_t		i_flushiter;	/* incremented on flush */
> +	/* cowextsize is only used for v3 inodes, flushiter for v1/2 */
> +	union {
> +		xfs_extlen_t	i_cowextsize;	/* basic cow extent size */
> +		uint16_t	i_flushiter;	/* incremented on flush */
> +	};
>  
>  	struct xfs_icdinode	i_d;		/* most of ondisk inode */
>  
> diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
> index a1937900ad84be..60544dd0f875b8 100644
> --- a/fs/xfs/xfs_ioctl.c
> +++ b/fs/xfs/xfs_ioctl.c
> @@ -1108,7 +1108,11 @@ xfs_fill_fsxattr(
>  
>  	simple_fill_fsxattr(fa, xfs_ip2xflags(ip));
>  	fa->fsx_extsize = ip->i_extsize << ip->i_mount->m_sb.sb_blocklog;
> -	fa->fsx_cowextsize = ip->i_cowextsize << ip->i_mount->m_sb.sb_blocklog;
> +	if (xfs_sb_version_has_v3inode(&ip->i_mount->m_sb) &&
> +	    (ip->i_d.di_flags2 & XFS_DIFLAG2_COWEXTSIZE)) {
> +		fa->fsx_cowextsize =
> +			ip->i_cowextsize << ip->i_mount->m_sb.sb_blocklog;
> +	}
>  	fa->fsx_projid = ip->i_projid;
>  	if (ifp && (ifp->if_flags & XFS_IFEXTENTS))
>  		fa->fsx_nextents = xfs_iext_count(ifp);
> 


-- 
chandan




^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH 09/15] xfs: cleanup xfs_fill_fsxattr
  2020-06-20  7:10 ` [PATCH 09/15] xfs: cleanup xfs_fill_fsxattr Christoph Hellwig
@ 2020-06-22 11:01   ` Chandan Babu R
  2020-06-30 17:52   ` Darrick J. Wong
  1 sibling, 0 replies; 52+ messages in thread
From: Chandan Babu R @ 2020-06-22 11:01 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: linux-xfs

On Saturday 20 June 2020 12:40:56 PM IST Christoph Hellwig wrote:
> Add a local xfs_mount variable, and use the XFS_FSB_TO_B helper.
>

The changes look good to me.

Reviewed-by: Chandan Babu R <chandanrlinux@gmail.com>

> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  fs/xfs/xfs_ioctl.c | 11 +++++------
>  1 file changed, 5 insertions(+), 6 deletions(-)
> 
> diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
> index 60544dd0f875b8..cabc86ed6756bc 100644
> --- a/fs/xfs/xfs_ioctl.c
> +++ b/fs/xfs/xfs_ioctl.c
> @@ -1104,15 +1104,14 @@ xfs_fill_fsxattr(
>  	bool			attr,
>  	struct fsxattr		*fa)
>  {
> +	struct xfs_mount	*mp = ip->i_mount;
>  	struct xfs_ifork	*ifp = attr ? ip->i_afp : &ip->i_df;
>  
>  	simple_fill_fsxattr(fa, xfs_ip2xflags(ip));
> -	fa->fsx_extsize = ip->i_extsize << ip->i_mount->m_sb.sb_blocklog;
> -	if (xfs_sb_version_has_v3inode(&ip->i_mount->m_sb) &&
> -	    (ip->i_d.di_flags2 & XFS_DIFLAG2_COWEXTSIZE)) {
> -		fa->fsx_cowextsize =
> -			ip->i_cowextsize << ip->i_mount->m_sb.sb_blocklog;
> -	}
> +	fa->fsx_extsize = XFS_FSB_TO_B(mp, ip->i_extsize);
> +	if (xfs_sb_version_has_v3inode(&mp->m_sb) &&
> +	    (ip->i_d.di_flags2 & XFS_DIFLAG2_COWEXTSIZE))
> +		fa->fsx_cowextsize = XFS_FSB_TO_B(mp, ip->i_cowextsize);
>  	fa->fsx_projid = ip->i_projid;
>  	if (ifp && (ifp->if_flags & XFS_IFEXTENTS))
>  		fa->fsx_nextents = xfs_iext_count(ifp);
> 


-- 
chandan




^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH 10/15] xfs: move the di_forkoff field to struct xfs_inode
  2020-06-20  7:10 ` [PATCH 10/15] xfs: move the di_forkoff field to struct xfs_inode Christoph Hellwig
@ 2020-06-22 12:15   ` Chandan Babu R
  2020-06-30 17:52   ` Darrick J. Wong
  1 sibling, 0 replies; 52+ messages in thread
From: Chandan Babu R @ 2020-06-22 12:15 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: linux-xfs

On Saturday 20 June 2020 12:40:57 PM IST Christoph Hellwig wrote:
> In preparation of removing the historic icinode struct, move the
> forkoff field into the containing xfs_inode structure.
>

The changes look good to me.

Reviewed-by: Chandan Babu R <chandanrlinux@gmail.com>

> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  fs/xfs/libxfs/xfs_attr_leaf.c  | 22 +++++++++++-----------
>  fs/xfs/libxfs/xfs_bmap.c       | 32 ++++++++++++++++----------------
>  fs/xfs/libxfs/xfs_inode_buf.c  |  4 ++--
>  fs/xfs/libxfs/xfs_inode_buf.h  |  1 -
>  fs/xfs/libxfs/xfs_inode_fork.h |  4 ++--
>  fs/xfs/xfs_icache.c            |  2 +-
>  fs/xfs/xfs_inode.c             |  8 ++++----
>  fs/xfs/xfs_inode.h             |  1 +
>  fs/xfs/xfs_inode_item.c        |  2 +-
>  9 files changed, 38 insertions(+), 38 deletions(-)
> 
> diff --git a/fs/xfs/libxfs/xfs_attr_leaf.c b/fs/xfs/libxfs/xfs_attr_leaf.c
> index 2f7e89e4be3e3f..3dca59de331fdf 100644
> --- a/fs/xfs/libxfs/xfs_attr_leaf.c
> +++ b/fs/xfs/libxfs/xfs_attr_leaf.c
> @@ -518,10 +518,10 @@ xfs_attr_copy_value(
>   * Query whether the requested number of additional bytes of extended
>   * attribute space will be able to fit inline.
>   *
> - * Returns zero if not, else the di_forkoff fork offset to be used in the
> + * Returns zero if not, else the i_forkoff fork offset to be used in the
>   * literal area for attribute data once the new bytes have been added.
>   *
> - * di_forkoff must be 8 byte aligned, hence is stored as a >>3 value;
> + * i_forkoff must be 8 byte aligned, hence is stored as a >>3 value;
>   * special case for dev/uuid inodes, they have fixed size data forks.
>   */
>  int
> @@ -554,7 +554,7 @@ xfs_attr_shortform_bytesfit(
>  	 * literal area rebalancing.
>  	 */
>  	if (bytes <= XFS_IFORK_ASIZE(dp))
> -		return dp->i_d.di_forkoff;
> +		return dp->i_forkoff;
>  
>  	/*
>  	 * For attr2 we can try to move the forkoff if there is space in the
> @@ -575,7 +575,7 @@ xfs_attr_shortform_bytesfit(
>  		 * minimum offset only needs to be the space required for
>  		 * the btree root.
>  		 */
> -		if (!dp->i_d.di_forkoff && dp->i_df.if_bytes >
> +		if (!dp->i_forkoff && dp->i_df.if_bytes >
>  		    xfs_default_attroffset(dp))
>  			dsize = XFS_BMDR_SPACE_CALC(MINDBTPTRS);
>  		break;
> @@ -586,10 +586,10 @@ xfs_attr_shortform_bytesfit(
>  		 * minforkoff to where the btree root can finish so we have
>  		 * plenty of room for attrs
>  		 */
> -		if (dp->i_d.di_forkoff) {
> -			if (offset < dp->i_d.di_forkoff)
> +		if (dp->i_forkoff) {
> +			if (offset < dp->i_forkoff)
>  				return 0;
> -			return dp->i_d.di_forkoff;
> +			return dp->i_forkoff;
>  		}
>  		dsize = XFS_BMAP_BROOT_SPACE(mp, dp->i_df.if_broot);
>  		break;
> @@ -677,7 +677,7 @@ xfs_attr_shortform_add(xfs_da_args_t *args, int forkoff)
>  
>  	dp = args->dp;
>  	mp = dp->i_mount;
> -	dp->i_d.di_forkoff = forkoff;
> +	dp->i_forkoff = forkoff;
>  
>  	ifp = dp->i_afp;
>  	ASSERT(ifp->if_flags & XFS_IFINLINE);
> @@ -720,7 +720,7 @@ xfs_attr_fork_remove(
>  	xfs_idestroy_fork(ip->i_afp);
>  	kmem_cache_free(xfs_ifork_zone, ip->i_afp);
>  	ip->i_afp = NULL;
> -	ip->i_d.di_forkoff = 0;
> +	ip->i_forkoff = 0;
>  	xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
>  }
>  
> @@ -775,8 +775,8 @@ xfs_attr_shortform_remove(xfs_da_args_t *args)
>  		xfs_attr_fork_remove(dp, args->trans);
>  	} else {
>  		xfs_idata_realloc(dp, -size, XFS_ATTR_FORK);
> -		dp->i_d.di_forkoff = xfs_attr_shortform_bytesfit(dp, totsize);
> -		ASSERT(dp->i_d.di_forkoff);
> +		dp->i_forkoff = xfs_attr_shortform_bytesfit(dp, totsize);
> +		ASSERT(dp->i_forkoff);
>  		ASSERT(totsize > sizeof(xfs_attr_sf_hdr_t) ||
>  				(args->op_flags & XFS_DA_OP_ADDNAME) ||
>  				!(mp->m_flags & XFS_MOUNT_ATTR2) ||
> diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
> index 692159357ed8e5..7e7e4459a606f1 100644
> --- a/fs/xfs/libxfs/xfs_bmap.c
> +++ b/fs/xfs/libxfs/xfs_bmap.c
> @@ -66,13 +66,13 @@ xfs_bmap_compute_maxlevels(
>  	 * either a signed 32-bit number for the data fork, or a signed 16-bit
>  	 * number for the attr fork.
>  	 *
> -	 * Note that we can no longer assume that if we are in ATTR1 that
> -	 * the fork offset of all the inodes will be
> -	 * (xfs_default_attroffset(ip) >> 3) because we could have mounted
> -	 * with ATTR2 and then mounted back with ATTR1, keeping the
> -	 * di_forkoff's fixed but probably at various positions. Therefore,
> -	 * for both ATTR1 and ATTR2 we have to assume the worst case scenario
> -	 * of a minimum size available.
> +	 * Note that we can no longer assume that if we are in ATTR1 that the
> +	 * fork offset of all the inodes will be
> +	 * (xfs_default_attroffset(ip) >> 3) because we could have mounted with
> +	 * ATTR2 and then mounted back with ATTR1, keeping the i_forkoff's fixed
> +	 * but probably at various positions. Therefore, for both ATTR1 and
> +	 * ATTR2 we have to assume the worst case scenario of a minimum size
> +	 * available.
>  	 */
>  	if (whichfork == XFS_DATA_FORK) {
>  		maxleafents = MAXEXTNUM;
> @@ -205,9 +205,9 @@ xfs_default_attroffset(
>  }
>  
>  /*
> - * Helper routine to reset inode di_forkoff field when switching
> - * attribute fork from local to extent format - we reset it where
> - * possible to make space available for inline data fork extents.
> + * Helper routine to reset inode i_forkoff field when switching attribute fork
> + * from local to extent format - we reset it where possible to make space
> + * available for inline data fork extents.
>   */
>  STATIC void
>  xfs_bmap_forkoff_reset(
> @@ -219,8 +219,8 @@ xfs_bmap_forkoff_reset(
>  	    ip->i_df.if_format != XFS_DINODE_FMT_BTREE) {
>  		uint	dfl_forkoff = xfs_default_attroffset(ip) >> 3;
>  
> -		if (dfl_forkoff > ip->i_d.di_forkoff)
> -			ip->i_d.di_forkoff = dfl_forkoff;
> +		if (dfl_forkoff > ip->i_forkoff)
> +			ip->i_forkoff = dfl_forkoff;
>  	}
>  }
>  
> @@ -1035,14 +1035,14 @@ xfs_bmap_set_attrforkoff(
>  {
>  	switch (ip->i_df.if_format) {
>  	case XFS_DINODE_FMT_DEV:
> -		ip->i_d.di_forkoff = roundup(sizeof(xfs_dev_t), 8) >> 3;
> +		ip->i_forkoff = roundup(sizeof(xfs_dev_t), 8) >> 3;
>  		break;
>  	case XFS_DINODE_FMT_LOCAL:
>  	case XFS_DINODE_FMT_EXTENTS:
>  	case XFS_DINODE_FMT_BTREE:
> -		ip->i_d.di_forkoff = xfs_attr_shortform_bytesfit(ip, size);
> -		if (!ip->i_d.di_forkoff)
> -			ip->i_d.di_forkoff = xfs_default_attroffset(ip) >> 3;
> +		ip->i_forkoff = xfs_attr_shortform_bytesfit(ip, size);
> +		if (!ip->i_forkoff)
> +			ip->i_forkoff = xfs_default_attroffset(ip) >> 3;
>  		else if ((ip->i_mount->m_flags & XFS_MOUNT_ATTR2) && version)
>  			*version = 2;
>  		break;
> diff --git a/fs/xfs/libxfs/xfs_inode_buf.c b/fs/xfs/libxfs/xfs_inode_buf.c
> index 8c4b7bd69285fa..69a6844b1698d0 100644
> --- a/fs/xfs/libxfs/xfs_inode_buf.c
> +++ b/fs/xfs/libxfs/xfs_inode_buf.c
> @@ -245,7 +245,7 @@ xfs_inode_from_disk(
>  	ip->i_disk_size = be64_to_cpu(from->di_size);
>  	ip->i_nblocks = be64_to_cpu(from->di_nblocks);
>  	ip->i_extsize = be32_to_cpu(from->di_extsize);
> -	to->di_forkoff = from->di_forkoff;
> +	ip->i_forkoff = from->di_forkoff;
>  	to->di_dmevmask	= be32_to_cpu(from->di_dmevmask);
>  	to->di_dmstate	= be16_to_cpu(from->di_dmstate);
>  	to->di_flags	= be16_to_cpu(from->di_flags);
> @@ -310,7 +310,7 @@ xfs_inode_to_disk(
>  	to->di_extsize = cpu_to_be32(ip->i_extsize);
>  	to->di_nextents = cpu_to_be32(xfs_ifork_nextents(&ip->i_df));
>  	to->di_anextents = cpu_to_be16(xfs_ifork_nextents(ip->i_afp));
> -	to->di_forkoff = from->di_forkoff;
> +	to->di_forkoff = ip->i_forkoff;
>  	to->di_aformat = xfs_ifork_format(ip->i_afp);
>  	to->di_dmevmask = cpu_to_be32(from->di_dmevmask);
>  	to->di_dmstate = cpu_to_be16(from->di_dmstate);
> diff --git a/fs/xfs/libxfs/xfs_inode_buf.h b/fs/xfs/libxfs/xfs_inode_buf.h
> index 8cc96f2766ff4f..032486dbf82757 100644
> --- a/fs/xfs/libxfs/xfs_inode_buf.h
> +++ b/fs/xfs/libxfs/xfs_inode_buf.h
> @@ -16,7 +16,6 @@ struct xfs_dinode;
>   * format specific structures at the appropriate time.
>   */
>  struct xfs_icdinode {
> -	uint8_t		di_forkoff;	/* attr fork offs, <<3 for 64b align */
>  	uint32_t	di_dmevmask;	/* DMIG event mask */
>  	uint16_t	di_dmstate;	/* DMIG state info */
>  	uint16_t	di_flags;	/* random flags, XFS_DIFLAG_... */
> diff --git a/fs/xfs/libxfs/xfs_inode_fork.h b/fs/xfs/libxfs/xfs_inode_fork.h
> index a4953e95c4f3f6..7d6982b23446c2 100644
> --- a/fs/xfs/libxfs/xfs_inode_fork.h
> +++ b/fs/xfs/libxfs/xfs_inode_fork.h
> @@ -38,8 +38,8 @@ struct xfs_ifork {
>   * Fork handling.
>   */
>  
> -#define XFS_IFORK_Q(ip)			((ip)->i_d.di_forkoff != 0)
> -#define XFS_IFORK_BOFF(ip)		((int)((ip)->i_d.di_forkoff << 3))
> +#define XFS_IFORK_Q(ip)			((ip)->i_forkoff != 0)
> +#define XFS_IFORK_BOFF(ip)		((int)((ip)->i_forkoff << 3))
>  
>  #define XFS_IFORK_PTR(ip,w)		\
>  	((w) == XFS_DATA_FORK ? \
> diff --git a/fs/xfs/xfs_icache.c b/fs/xfs/xfs_icache.c
> index e6b40f7035aa5a..ccd437432aa963 100644
> --- a/fs/xfs/xfs_icache.c
> +++ b/fs/xfs/xfs_icache.c
> @@ -67,7 +67,7 @@ xfs_inode_alloc(
>  	ip->i_flags = 0;
>  	ip->i_delayed_blks = 0;
>  	ip->i_nblocks = 0;
> -	ip->i_d.di_forkoff = 0;
> +	ip->i_forkoff = 0;
>  	ip->i_sick = 0;
>  	ip->i_checked = 0;
>  	INIT_WORK(&ip->i_ioend_work, xfs_end_io);
> diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
> index fd111e05c0bb2e..764f91610d1496 100644
> --- a/fs/xfs/xfs_inode.c
> +++ b/fs/xfs/xfs_inode.c
> @@ -1858,7 +1858,7 @@ xfs_inactive(
>  	}
>  
>  	ASSERT(!ip->i_afp);
> -	ASSERT(ip->i_d.di_forkoff == 0);
> +	ASSERT(ip->i_forkoff == 0);
>  
>  	/*
>  	 * Free the inode.
> @@ -2758,7 +2758,7 @@ xfs_ifree(
>  	ip->i_d.di_flags = 0;
>  	ip->i_d.di_flags2 = 0;
>  	ip->i_d.di_dmevmask = 0;
> -	ip->i_d.di_forkoff = 0;		/* mark the attr fork not in use */
> +	ip->i_forkoff = 0;		/* mark the attr fork not in use */
>  	ip->i_df.if_format = XFS_DINODE_FMT_EXTENTS;
>  
>  	/* Don't attempt to replay owner changes for a deleted inode */
> @@ -3756,11 +3756,11 @@ xfs_iflush_int(
>  			ip->i_nblocks, ip);
>  		goto flush_out;
>  	}
> -	if (XFS_TEST_ERROR(ip->i_d.di_forkoff > mp->m_sb.sb_inodesize,
> +	if (XFS_TEST_ERROR(ip->i_forkoff > mp->m_sb.sb_inodesize,
>  				mp, XFS_ERRTAG_IFLUSH_6)) {
>  		xfs_alert_tag(mp, XFS_PTAG_IFLUSH,
>  			"%s: bad inode %Lu, forkoff 0x%x, ptr "PTR_FMT,
> -			__func__, ip->i_ino, ip->i_d.di_forkoff, ip);
> +			__func__, ip->i_ino, ip->i_forkoff, ip);
>  		goto flush_out;
>  	}
>  
> diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h
> index a0444b9ce3f792..31440ab88cf141 100644
> --- a/fs/xfs/xfs_inode.h
> +++ b/fs/xfs/xfs_inode.h
> @@ -63,6 +63,7 @@ typedef struct xfs_inode {
>  		xfs_extlen_t	i_cowextsize;	/* basic cow extent size */
>  		uint16_t	i_flushiter;	/* incremented on flush */
>  	};
> +	uint8_t			i_forkoff;	/* attr fork offset >> 3 */
>  
>  	struct xfs_icdinode	i_d;		/* most of ondisk inode */
>  
> diff --git a/fs/xfs/xfs_inode_item.c b/fs/xfs/xfs_inode_item.c
> index 8357fe37d3eb8a..a83ddc4e029f0f 100644
> --- a/fs/xfs/xfs_inode_item.c
> +++ b/fs/xfs/xfs_inode_item.c
> @@ -328,7 +328,7 @@ xfs_inode_to_log_dinode(
>  	to->di_extsize = ip->i_extsize;
>  	to->di_nextents = xfs_ifork_nextents(&ip->i_df);
>  	to->di_anextents = xfs_ifork_nextents(ip->i_afp);
> -	to->di_forkoff = from->di_forkoff;
> +	to->di_forkoff = ip->i_forkoff;
>  	to->di_aformat = xfs_ifork_format(ip->i_afp);
>  	to->di_dmevmask = from->di_dmevmask;
>  	to->di_dmstate = from->di_dmstate;
> 


-- 
chandan




^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH 11/15] xfs: move the di_flags field to struct xfs_inode
  2020-06-20  7:10 ` [PATCH 11/15] xfs: move the di_flags " Christoph Hellwig
@ 2020-06-22 12:41   ` Chandan Babu R
  2020-06-30 17:53   ` Darrick J. Wong
  1 sibling, 0 replies; 52+ messages in thread
From: Chandan Babu R @ 2020-06-22 12:41 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: linux-xfs

On Saturday 20 June 2020 12:40:58 PM IST Christoph Hellwig wrote:
> In preparation of removing the historic icinode struct, move the flags
> field into the containing xfs_inode structure.
>

The changes look good to me.

Reviewed-by: Chandan Babu R <chandanrlinux@gmail.com>

> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  fs/xfs/libxfs/xfs_bmap_btree.c |  2 +-
>  fs/xfs/libxfs/xfs_inode_buf.c  |  4 ++--
>  fs/xfs/libxfs/xfs_inode_buf.h  |  1 -
>  fs/xfs/libxfs/xfs_rtbitmap.c   |  4 ++--
>  fs/xfs/scrub/common.c          |  2 +-
>  fs/xfs/xfs_bmap_util.c         |  4 ++--
>  fs/xfs/xfs_file.c              |  4 ++--
>  fs/xfs/xfs_filestream.h        |  2 +-
>  fs/xfs/xfs_inode.c             | 38 +++++++++++++++++-----------------
>  fs/xfs/xfs_inode.h             |  3 ++-
>  fs/xfs/xfs_inode_item.c        |  2 +-
>  fs/xfs/xfs_ioctl.c             |  9 ++++----
>  fs/xfs/xfs_iops.c              |  6 +++---
>  fs/xfs/xfs_linux.h             |  2 +-
>  fs/xfs/xfs_rtalloc.c           |  4 ++--
>  fs/xfs/xfs_super.c             |  4 ++--
>  fs/xfs/xfs_symlink.c           |  2 +-
>  17 files changed, 46 insertions(+), 47 deletions(-)
> 
> diff --git a/fs/xfs/libxfs/xfs_bmap_btree.c b/fs/xfs/libxfs/xfs_bmap_btree.c
> index 9ad4c6a1eec518..d32f3a94c936e6 100644
> --- a/fs/xfs/libxfs/xfs_bmap_btree.c
> +++ b/fs/xfs/libxfs/xfs_bmap_btree.c
> @@ -183,7 +183,7 @@ xfs_bmbt_update_cursor(
>  	struct xfs_btree_cur	*dst)
>  {
>  	ASSERT((dst->bc_tp->t_firstblock != NULLFSBLOCK) ||
> -	       (dst->bc_ino.ip->i_d.di_flags & XFS_DIFLAG_REALTIME));
> +	       (dst->bc_ino.ip->i_diflags & XFS_DIFLAG_REALTIME));
>  
>  	dst->bc_ino.allocated += src->bc_ino.allocated;
>  	dst->bc_tp->t_firstblock = src->bc_tp->t_firstblock;
> diff --git a/fs/xfs/libxfs/xfs_inode_buf.c b/fs/xfs/libxfs/xfs_inode_buf.c
> index 69a6844b1698d0..bb9c4775ecaa5c 100644
> --- a/fs/xfs/libxfs/xfs_inode_buf.c
> +++ b/fs/xfs/libxfs/xfs_inode_buf.c
> @@ -248,7 +248,7 @@ xfs_inode_from_disk(
>  	ip->i_forkoff = from->di_forkoff;
>  	to->di_dmevmask	= be32_to_cpu(from->di_dmevmask);
>  	to->di_dmstate	= be16_to_cpu(from->di_dmstate);
> -	to->di_flags	= be16_to_cpu(from->di_flags);
> +	ip->i_diflags	= be16_to_cpu(from->di_flags);
>  
>  	if (xfs_sb_version_has_v3inode(&ip->i_mount->m_sb)) {
>  		inode_set_iversion_queried(inode,
> @@ -314,7 +314,7 @@ xfs_inode_to_disk(
>  	to->di_aformat = xfs_ifork_format(ip->i_afp);
>  	to->di_dmevmask = cpu_to_be32(from->di_dmevmask);
>  	to->di_dmstate = cpu_to_be16(from->di_dmstate);
> -	to->di_flags = cpu_to_be16(from->di_flags);
> +	to->di_flags = cpu_to_be16(ip->i_diflags);
>  
>  	if (xfs_sb_version_has_v3inode(&ip->i_mount->m_sb)) {
>  		to->di_version = 3;
> diff --git a/fs/xfs/libxfs/xfs_inode_buf.h b/fs/xfs/libxfs/xfs_inode_buf.h
> index 032486dbf82757..5c6a6ac521b11d 100644
> --- a/fs/xfs/libxfs/xfs_inode_buf.h
> +++ b/fs/xfs/libxfs/xfs_inode_buf.h
> @@ -18,7 +18,6 @@ struct xfs_dinode;
>  struct xfs_icdinode {
>  	uint32_t	di_dmevmask;	/* DMIG event mask */
>  	uint16_t	di_dmstate;	/* DMIG state info */
> -	uint16_t	di_flags;	/* random flags, XFS_DIFLAG_... */
>  
>  	uint64_t	di_flags2;	/* more random flags */
>  
> diff --git a/fs/xfs/libxfs/xfs_rtbitmap.c b/fs/xfs/libxfs/xfs_rtbitmap.c
> index 9498ced947be9e..57381b9aca00ac 100644
> --- a/fs/xfs/libxfs/xfs_rtbitmap.c
> +++ b/fs/xfs/libxfs/xfs_rtbitmap.c
> @@ -997,8 +997,8 @@ xfs_rtfree_extent(
>  	 */
>  	if (tp->t_frextents_delta + mp->m_sb.sb_frextents ==
>  	    mp->m_sb.sb_rextents) {
> -		if (!(mp->m_rbmip->i_d.di_flags & XFS_DIFLAG_NEWRTBM))
> -			mp->m_rbmip->i_d.di_flags |= XFS_DIFLAG_NEWRTBM;
> +		if (!(mp->m_rbmip->i_diflags & XFS_DIFLAG_NEWRTBM))
> +			mp->m_rbmip->i_diflags |= XFS_DIFLAG_NEWRTBM;
>  		*(uint64_t *)&VFS_I(mp->m_rbmip)->i_atime = 0;
>  		xfs_trans_log_inode(tp, mp->m_rbmip, XFS_ILOG_CORE);
>  	}
> diff --git a/fs/xfs/scrub/common.c b/fs/xfs/scrub/common.c
> index 18876056e5e02a..254dc813696de4 100644
> --- a/fs/xfs/scrub/common.c
> +++ b/fs/xfs/scrub/common.c
> @@ -835,7 +835,7 @@ xchk_metadata_inode_forks(
>  		return 0;
>  
>  	/* Metadata inodes don't live on the rt device. */
> -	if (sc->ip->i_d.di_flags & XFS_DIFLAG_REALTIME) {
> +	if (sc->ip->i_diflags & XFS_DIFLAG_REALTIME) {
>  		xchk_ino_set_corrupt(sc, sc->ip->i_ino);
>  		return 0;
>  	}
> diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c
> index 5eba039d72fb83..0b944aad75e618 100644
> --- a/fs/xfs/xfs_bmap_util.c
> +++ b/fs/xfs/xfs_bmap_util.c
> @@ -439,7 +439,7 @@ xfs_getbmap(
>  		}
>  
>  		if (xfs_get_extsz_hint(ip) ||
> -		    (ip->i_d.di_flags &
> +		    (ip->i_diflags &
>  		     (XFS_DIFLAG_PREALLOC | XFS_DIFLAG_APPEND)))
>  			max_len = mp->m_super->s_maxbytes;
>  		else
> @@ -620,7 +620,7 @@ xfs_can_free_eofblocks(struct xfs_inode *ip, bool force)
>  	 * Do not free real preallocated or append-only files unless the file
>  	 * has delalloc blocks and we are forced to remove them.
>  	 */
> -	if (ip->i_d.di_flags & (XFS_DIFLAG_PREALLOC | XFS_DIFLAG_APPEND))
> +	if (ip->i_diflags & (XFS_DIFLAG_PREALLOC | XFS_DIFLAG_APPEND))
>  		if (!force || ip->i_delayed_blks == 0)
>  			return false;
>  
> diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c
> index b0384306d6622f..4f08793f3d6db4 100644
> --- a/fs/xfs/xfs_file.c
> +++ b/fs/xfs/xfs_file.c
> @@ -56,9 +56,9 @@ xfs_update_prealloc_flags(
>  	}
>  
>  	if (flags & XFS_PREALLOC_SET)
> -		ip->i_d.di_flags |= XFS_DIFLAG_PREALLOC;
> +		ip->i_diflags |= XFS_DIFLAG_PREALLOC;
>  	if (flags & XFS_PREALLOC_CLEAR)
> -		ip->i_d.di_flags &= ~XFS_DIFLAG_PREALLOC;
> +		ip->i_diflags &= ~XFS_DIFLAG_PREALLOC;
>  
>  	xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
>  	if (flags & XFS_PREALLOC_SYNC)
> diff --git a/fs/xfs/xfs_filestream.h b/fs/xfs/xfs_filestream.h
> index 5cc7665e93c92b..3af963743e4d0b 100644
> --- a/fs/xfs/xfs_filestream.h
> +++ b/fs/xfs/xfs_filestream.h
> @@ -22,7 +22,7 @@ xfs_inode_is_filestream(
>  	struct xfs_inode	*ip)
>  {
>  	return (ip->i_mount->m_flags & XFS_MOUNT_FILESTREAMS) ||
> -		(ip->i_d.di_flags & XFS_DIFLAG_FILESTREAM);
> +		(ip->i_diflags & XFS_DIFLAG_FILESTREAM);
>  }
>  
>  #endif /* __XFS_FILESTREAM_H__ */
> diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
> index 764f91610d1496..479342ac8851f4 100644
> --- a/fs/xfs/xfs_inode.c
> +++ b/fs/xfs/xfs_inode.c
> @@ -61,7 +61,7 @@ xfs_get_extsz_hint(
>  	 */
>  	if (xfs_is_always_cow_inode(ip))
>  		return 0;
> -	if ((ip->i_d.di_flags & XFS_DIFLAG_EXTSIZE) && ip->i_extsize)
> +	if ((ip->i_diflags & XFS_DIFLAG_EXTSIZE) && ip->i_extsize)
>  		return ip->i_extsize;
>  	if (XFS_IS_REALTIME_INODE(ip))
>  		return ip->i_mount->m_sb.sb_rextsize;
> @@ -673,7 +673,7 @@ xfs_ip2xflags(
>  {
>  	struct xfs_icdinode	*dic = &ip->i_d;
>  
> -	return _xfs_dic2xflags(dic->di_flags, dic->di_flags2, XFS_IFORK_Q(ip));
> +	return _xfs_dic2xflags(ip->i_diflags, dic->di_flags2, XFS_IFORK_Q(ip));
>  }
>  
>  /*
> @@ -837,7 +837,7 @@ xfs_ialloc(
>  	ip->i_extsize = 0;
>  	ip->i_d.di_dmevmask = 0;
>  	ip->i_d.di_dmstate = 0;
> -	ip->i_d.di_flags = 0;
> +	ip->i_diflags = 0;
>  
>  	if (xfs_sb_version_has_v3inode(&mp->m_sb)) {
>  		inode_set_iversion(inode, 1);
> @@ -858,45 +858,45 @@ xfs_ialloc(
>  		break;
>  	case S_IFREG:
>  	case S_IFDIR:
> -		if (pip && (pip->i_d.di_flags & XFS_DIFLAG_ANY)) {
> +		if (pip && (pip->i_diflags & XFS_DIFLAG_ANY)) {
>  			uint		di_flags = 0;
>  
>  			if (S_ISDIR(mode)) {
> -				if (pip->i_d.di_flags & XFS_DIFLAG_RTINHERIT)
> +				if (pip->i_diflags & XFS_DIFLAG_RTINHERIT)
>  					di_flags |= XFS_DIFLAG_RTINHERIT;
> -				if (pip->i_d.di_flags & XFS_DIFLAG_EXTSZINHERIT) {
> +				if (pip->i_diflags & XFS_DIFLAG_EXTSZINHERIT) {
>  					di_flags |= XFS_DIFLAG_EXTSZINHERIT;
>  					ip->i_extsize = pip->i_extsize;
>  				}
> -				if (pip->i_d.di_flags & XFS_DIFLAG_PROJINHERIT)
> +				if (pip->i_diflags & XFS_DIFLAG_PROJINHERIT)
>  					di_flags |= XFS_DIFLAG_PROJINHERIT;
>  			} else if (S_ISREG(mode)) {
> -				if (pip->i_d.di_flags & XFS_DIFLAG_RTINHERIT)
> +				if (pip->i_diflags & XFS_DIFLAG_RTINHERIT)
>  					di_flags |= XFS_DIFLAG_REALTIME;
> -				if (pip->i_d.di_flags & XFS_DIFLAG_EXTSZINHERIT) {
> +				if (pip->i_diflags & XFS_DIFLAG_EXTSZINHERIT) {
>  					di_flags |= XFS_DIFLAG_EXTSIZE;
>  					ip->i_extsize = pip->i_extsize;
>  				}
>  			}
> -			if ((pip->i_d.di_flags & XFS_DIFLAG_NOATIME) &&
> +			if ((pip->i_diflags & XFS_DIFLAG_NOATIME) &&
>  			    xfs_inherit_noatime)
>  				di_flags |= XFS_DIFLAG_NOATIME;
> -			if ((pip->i_d.di_flags & XFS_DIFLAG_NODUMP) &&
> +			if ((pip->i_diflags & XFS_DIFLAG_NODUMP) &&
>  			    xfs_inherit_nodump)
>  				di_flags |= XFS_DIFLAG_NODUMP;
> -			if ((pip->i_d.di_flags & XFS_DIFLAG_SYNC) &&
> +			if ((pip->i_diflags & XFS_DIFLAG_SYNC) &&
>  			    xfs_inherit_sync)
>  				di_flags |= XFS_DIFLAG_SYNC;
> -			if ((pip->i_d.di_flags & XFS_DIFLAG_NOSYMLINKS) &&
> +			if ((pip->i_diflags & XFS_DIFLAG_NOSYMLINKS) &&
>  			    xfs_inherit_nosymlinks)
>  				di_flags |= XFS_DIFLAG_NOSYMLINKS;
> -			if ((pip->i_d.di_flags & XFS_DIFLAG_NODEFRAG) &&
> +			if ((pip->i_diflags & XFS_DIFLAG_NODEFRAG) &&
>  			    xfs_inherit_nodefrag)
>  				di_flags |= XFS_DIFLAG_NODEFRAG;
> -			if (pip->i_d.di_flags & XFS_DIFLAG_FILESTREAM)
> +			if (pip->i_diflags & XFS_DIFLAG_FILESTREAM)
>  				di_flags |= XFS_DIFLAG_FILESTREAM;
>  
> -			ip->i_d.di_flags |= di_flags;
> +			ip->i_diflags |= di_flags;
>  		}
>  		if (pip && (pip->i_d.di_flags2 & XFS_DIFLAG2_ANY)) {
>  			if (pip->i_d.di_flags2 & XFS_DIFLAG2_COWEXTSIZE) {
> @@ -1397,7 +1397,7 @@ xfs_link(
>  	 * creation in our tree when the project IDs are the same; else
>  	 * the tree quota mechanism could be circumvented.
>  	 */
> -	if (unlikely((tdp->i_d.di_flags & XFS_DIFLAG_PROJINHERIT) &&
> +	if (unlikely((tdp->i_diflags & XFS_DIFLAG_PROJINHERIT) &&
>  		     tdp->i_projid != sip->i_projid)) {
>  		error = -EXDEV;
>  		goto error_return;
> @@ -2755,7 +2755,7 @@ xfs_ifree(
>  	}
>  
>  	VFS_I(ip)->i_mode = 0;		/* mark incore inode as free */
> -	ip->i_d.di_flags = 0;
> +	ip->i_diflags = 0;
>  	ip->i_d.di_flags2 = 0;
>  	ip->i_d.di_dmevmask = 0;
>  	ip->i_forkoff = 0;		/* mark the attr fork not in use */
> @@ -3263,7 +3263,7 @@ xfs_rename(
>  	 * into our tree when the project IDs are the same; else the
>  	 * tree quota mechanism would be circumvented.
>  	 */
> -	if (unlikely((target_dp->i_d.di_flags & XFS_DIFLAG_PROJINHERIT) &&
> +	if (unlikely((target_dp->i_diflags & XFS_DIFLAG_PROJINHERIT) &&
>  		     target_dp->i_projid != src_ip->i_projid)) {
>  		error = -EXDEV;
>  		goto out_trans_cancel;
> diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h
> index 31440ab88cf141..7673c841d89154 100644
> --- a/fs/xfs/xfs_inode.h
> +++ b/fs/xfs/xfs_inode.h
> @@ -64,6 +64,7 @@ typedef struct xfs_inode {
>  		uint16_t	i_flushiter;	/* incremented on flush */
>  	};
>  	uint8_t			i_forkoff;	/* attr fork offset >> 3 */
> +	uint16_t		i_diflags;	/* XFS_DIFLAG_... */
>  
>  	struct xfs_icdinode	i_d;		/* most of ondisk inode */
>  
> @@ -184,7 +185,7 @@ xfs_iflags_test_and_set(xfs_inode_t *ip, unsigned short flags)
>  static inline prid_t
>  xfs_get_initial_prid(struct xfs_inode *dp)
>  {
> -	if (dp->i_d.di_flags & XFS_DIFLAG_PROJINHERIT)
> +	if (dp->i_diflags & XFS_DIFLAG_PROJINHERIT)
>  		return dp->i_projid;
>  
>  	return XFS_PROJID_DEFAULT;
> diff --git a/fs/xfs/xfs_inode_item.c b/fs/xfs/xfs_inode_item.c
> index a83ddc4e029f0f..6af8e829dd0172 100644
> --- a/fs/xfs/xfs_inode_item.c
> +++ b/fs/xfs/xfs_inode_item.c
> @@ -332,7 +332,7 @@ xfs_inode_to_log_dinode(
>  	to->di_aformat = xfs_ifork_format(ip->i_afp);
>  	to->di_dmevmask = from->di_dmevmask;
>  	to->di_dmstate = from->di_dmstate;
> -	to->di_flags = from->di_flags;
> +	to->di_flags = ip->i_diflags;
>  
>  	/* log a dummy value to ensure log structure is fully initialised */
>  	to->di_next_unlinked = NULLAGINO;
> diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
> index cabc86ed6756bc..326991f4d98096 100644
> --- a/fs/xfs/xfs_ioctl.c
> +++ b/fs/xfs/xfs_ioctl.c
> @@ -1143,7 +1143,7 @@ xfs_flags2diflags(
>  {
>  	/* can't set PREALLOC this way, just preserve it */
>  	uint16_t		di_flags =
> -		(ip->i_d.di_flags & XFS_DIFLAG_PREALLOC);
> +		(ip->i_diflags & XFS_DIFLAG_PREALLOC);
>  
>  	if (xflags & FS_XFLAG_IMMUTABLE)
>  		di_flags |= XFS_DIFLAG_IMMUTABLE;
> @@ -1228,7 +1228,7 @@ xfs_ioctl_setattr_xflags(
>  	if (di_flags2 && !xfs_sb_version_has_v3inode(&mp->m_sb))
>  		return -EINVAL;
>  
> -	ip->i_d.di_flags = xfs_flags2diflags(ip, fa->fsx_xflags);
> +	ip->i_diflags = xfs_flags2diflags(ip, fa->fsx_xflags);
>  	ip->i_d.di_flags2 = di_flags2;
>  
>  	xfs_diflags_to_iflags(ip, false);
> @@ -1570,7 +1570,7 @@ xfs_ioctl_setattr(
>  	 * extent size hint should be set on the inode. If no extent size flags
>  	 * are set on the inode then unconditionally clear the extent size hint.
>  	 */
> -	if (ip->i_d.di_flags & (XFS_DIFLAG_EXTSIZE | XFS_DIFLAG_EXTSZINHERIT))
> +	if (ip->i_diflags & (XFS_DIFLAG_EXTSIZE | XFS_DIFLAG_EXTSZINHERIT))
>  		ip->i_extsize = fa->fsx_extsize >> mp->m_sb.sb_blocklog;
>  	else
>  		ip->i_extsize = 0;
> @@ -1622,9 +1622,8 @@ xfs_ioc_getxflags(
>  	xfs_inode_t		*ip,
>  	void			__user *arg)
>  {
> -	unsigned int		flags;
> +	unsigned int		flags = xfs_di2lxflags(ip->i_diflags);
>  
> -	flags = xfs_di2lxflags(ip->i_d.di_flags);
>  	if (copy_to_user(arg, &flags, sizeof(flags)))
>  		return -EFAULT;
>  	return 0;
> diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
> index 78159c57d82828..f37154fc9828fd 100644
> --- a/fs/xfs/xfs_iops.c
> +++ b/fs/xfs/xfs_iops.c
> @@ -567,11 +567,11 @@ xfs_vn_getattr(
>  	 * Note: If you add another clause to set an attribute flag, please
>  	 * update attributes_mask below.
>  	 */
> -	if (ip->i_d.di_flags & XFS_DIFLAG_IMMUTABLE)
> +	if (ip->i_diflags & XFS_DIFLAG_IMMUTABLE)
>  		stat->attributes |= STATX_ATTR_IMMUTABLE;
> -	if (ip->i_d.di_flags & XFS_DIFLAG_APPEND)
> +	if (ip->i_diflags & XFS_DIFLAG_APPEND)
>  		stat->attributes |= STATX_ATTR_APPEND;
> -	if (ip->i_d.di_flags & XFS_DIFLAG_NODUMP)
> +	if (ip->i_diflags & XFS_DIFLAG_NODUMP)
>  		stat->attributes |= STATX_ATTR_NODUMP;
>  
>  	stat->attributes_mask |= (STATX_ATTR_IMMUTABLE |
> diff --git a/fs/xfs/xfs_linux.h b/fs/xfs/xfs_linux.h
> index 9f70d2f68e059b..95cc3386ac3b4f 100644
> --- a/fs/xfs/xfs_linux.h
> +++ b/fs/xfs/xfs_linux.h
> @@ -233,7 +233,7 @@ int xfs_rw_bdev(struct block_device *bdev, sector_t sector, unsigned int count,
>   * configured realtime device.
>   */
>  #define XFS_IS_REALTIME_INODE(ip)			\
> -	(((ip)->i_d.di_flags & XFS_DIFLAG_REALTIME) &&	\
> +	(((ip)->i_diflags & XFS_DIFLAG_REALTIME) &&	\
>  	 (ip)->i_mount->m_rtdev_targp)
>  #define XFS_IS_REALTIME_MOUNT(mp) ((mp)->m_rtdev_targp ? 1 : 0)
>  #else
> diff --git a/fs/xfs/xfs_rtalloc.c b/fs/xfs/xfs_rtalloc.c
> index cc07d7d27dd7e0..592a1160200f5e 100644
> --- a/fs/xfs/xfs_rtalloc.c
> +++ b/fs/xfs/xfs_rtalloc.c
> @@ -1281,8 +1281,8 @@ xfs_rtpick_extent(
>  	ASSERT(xfs_isilocked(mp->m_rbmip, XFS_ILOCK_EXCL));
>  
>  	seqp = (uint64_t *)&VFS_I(mp->m_rbmip)->i_atime;
> -	if (!(mp->m_rbmip->i_d.di_flags & XFS_DIFLAG_NEWRTBM)) {
> -		mp->m_rbmip->i_d.di_flags |= XFS_DIFLAG_NEWRTBM;
> +	if (!(mp->m_rbmip->i_diflags & XFS_DIFLAG_NEWRTBM)) {
> +		mp->m_rbmip->i_diflags |= XFS_DIFLAG_NEWRTBM;
>  		*seqp = 0;
>  	}
>  	seq = *seqp;
> diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
> index fa58cb07c8fdfe..06a01528543aef 100644
> --- a/fs/xfs/xfs_super.c
> +++ b/fs/xfs/xfs_super.c
> @@ -828,13 +828,13 @@ xfs_fs_statfs(
>  	statp->f_ffree = max_t(int64_t, ffree, 0);
>  
>  
> -	if ((ip->i_d.di_flags & XFS_DIFLAG_PROJINHERIT) &&
> +	if ((ip->i_diflags & XFS_DIFLAG_PROJINHERIT) &&
>  	    ((mp->m_qflags & (XFS_PQUOTA_ACCT|XFS_PQUOTA_ENFD))) ==
>  			      (XFS_PQUOTA_ACCT|XFS_PQUOTA_ENFD))
>  		xfs_qm_statvfs(ip, statp);
>  
>  	if (XFS_IS_REALTIME_MOUNT(mp) &&
> -	    (ip->i_d.di_flags & (XFS_DIFLAG_RTINHERIT | XFS_DIFLAG_REALTIME))) {
> +	    (ip->i_diflags & (XFS_DIFLAG_RTINHERIT | XFS_DIFLAG_REALTIME))) {
>  		statp->f_blocks = sbp->sb_rblocks;
>  		statp->f_bavail = statp->f_bfree =
>  			sbp->sb_frextents * sbp->sb_rextsize;
> diff --git a/fs/xfs/xfs_symlink.c b/fs/xfs/xfs_symlink.c
> index 6b8980b1497c9a..dc86e3117f73f0 100644
> --- a/fs/xfs/xfs_symlink.c
> +++ b/fs/xfs/xfs_symlink.c
> @@ -207,7 +207,7 @@ xfs_symlink(
>  	/*
>  	 * Check whether the directory allows new symlinks or not.
>  	 */
> -	if (dp->i_d.di_flags & XFS_DIFLAG_NOSYMLINKS) {
> +	if (dp->i_diflags & XFS_DIFLAG_NOSYMLINKS) {
>  		error = -EPERM;
>  		goto out_trans_cancel;
>  	}
> 


-- 
chandan




^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH 12/15] xfs: move the di_flags2 field to struct xfs_inode
  2020-06-20  7:10 ` [PATCH 12/15] xfs: move the di_flags2 " Christoph Hellwig
@ 2020-06-22 12:51   ` Chandan Babu R
  2020-06-22 13:23     ` Chandan Babu R
  2020-06-30 17:54   ` Darrick J. Wong
  1 sibling, 1 reply; 52+ messages in thread
From: Chandan Babu R @ 2020-06-22 12:51 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: linux-xfs

On Saturday 20 June 2020 12:40:59 PM IST Christoph Hellwig wrote:
> In preparation of removing the historic icinode struct, move the flags2
> field into the containing xfs_inode structure.
>

The changes look good to me.

Reviewed-by: Chandan Babu R <chandanrlinux@gmail.com>

> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  fs/xfs/libxfs/xfs_inode_buf.c |  4 ++--
>  fs/xfs/libxfs/xfs_inode_buf.h |  2 --
>  fs/xfs/xfs_bmap_util.c        | 24 ++++++++++++------------
>  fs/xfs/xfs_file.c             |  4 ++--
>  fs/xfs/xfs_inode.c            | 22 ++++++++++------------
>  fs/xfs/xfs_inode.h            |  3 ++-
>  fs/xfs/xfs_inode_item.c       |  2 +-
>  fs/xfs/xfs_ioctl.c            | 23 +++++++++++------------
>  fs/xfs/xfs_iops.c             |  2 +-
>  fs/xfs/xfs_itable.c           |  2 +-
>  fs/xfs/xfs_reflink.c          |  8 ++++----
>  11 files changed, 46 insertions(+), 50 deletions(-)
> 
> diff --git a/fs/xfs/libxfs/xfs_inode_buf.c b/fs/xfs/libxfs/xfs_inode_buf.c
> index bb9c4775ecaa5c..79e470933abfa8 100644
> --- a/fs/xfs/libxfs/xfs_inode_buf.c
> +++ b/fs/xfs/libxfs/xfs_inode_buf.c
> @@ -255,7 +255,7 @@ xfs_inode_from_disk(
>  					   be64_to_cpu(from->di_changecount));
>  		to->di_crtime.tv_sec = be32_to_cpu(from->di_crtime.t_sec);
>  		to->di_crtime.tv_nsec = be32_to_cpu(from->di_crtime.t_nsec);
> -		to->di_flags2 = be64_to_cpu(from->di_flags2);
> +		ip->i_diflags2 = be64_to_cpu(from->di_flags2);
>  		ip->i_cowextsize = be32_to_cpu(from->di_cowextsize);
>  	}
>  
> @@ -321,7 +321,7 @@ xfs_inode_to_disk(
>  		to->di_changecount = cpu_to_be64(inode_peek_iversion(inode));
>  		to->di_crtime.t_sec = cpu_to_be32(from->di_crtime.tv_sec);
>  		to->di_crtime.t_nsec = cpu_to_be32(from->di_crtime.tv_nsec);
> -		to->di_flags2 = cpu_to_be64(from->di_flags2);
> +		to->di_flags2 = cpu_to_be64(ip->i_diflags2);
>  		to->di_cowextsize = cpu_to_be32(ip->i_cowextsize);
>  		to->di_ino = cpu_to_be64(ip->i_ino);
>  		to->di_lsn = cpu_to_be64(lsn);
> diff --git a/fs/xfs/libxfs/xfs_inode_buf.h b/fs/xfs/libxfs/xfs_inode_buf.h
> index 5c6a6ac521b11d..4bfad6d6d5710a 100644
> --- a/fs/xfs/libxfs/xfs_inode_buf.h
> +++ b/fs/xfs/libxfs/xfs_inode_buf.h
> @@ -19,8 +19,6 @@ struct xfs_icdinode {
>  	uint32_t	di_dmevmask;	/* DMIG event mask */
>  	uint16_t	di_dmstate;	/* DMIG state info */
>  
> -	uint64_t	di_flags2;	/* more random flags */
> -
>  	struct timespec64 di_crtime;	/* time created */
>  };
>  
> diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c
> index 0b944aad75e618..8f85a4131983a6 100644
> --- a/fs/xfs/xfs_bmap_util.c
> +++ b/fs/xfs/xfs_bmap_util.c
> @@ -1332,9 +1332,9 @@ xfs_swap_extent_rmap(
>  	 * rmap functions when we go to fix up the rmaps.  The flags
>  	 * will be switch for reals later.
>  	 */
> -	tip_flags2 = tip->i_d.di_flags2;
> -	if (ip->i_d.di_flags2 & XFS_DIFLAG2_REFLINK)
> -		tip->i_d.di_flags2 |= XFS_DIFLAG2_REFLINK;
> +	tip_flags2 = tip->i_diflags2;
> +	if (ip->i_diflags2 & XFS_DIFLAG2_REFLINK)
> +		tip->i_diflags2 |= XFS_DIFLAG2_REFLINK;
>  
>  	offset_fsb = 0;
>  	end_fsb = XFS_B_TO_FSB(ip->i_mount, i_size_read(VFS_I(ip)));
> @@ -1405,12 +1405,12 @@ xfs_swap_extent_rmap(
>  		offset_fsb += ilen;
>  	}
>  
> -	tip->i_d.di_flags2 = tip_flags2;
> +	tip->i_diflags2 = tip_flags2;
>  	return 0;
>  
>  out:
>  	trace_xfs_swap_extent_rmap_error(ip, error, _RET_IP_);
> -	tip->i_d.di_flags2 = tip_flags2;
> +	tip->i_diflags2 = tip_flags2;
>  	return error;
>  }
>  
> @@ -1708,13 +1708,13 @@ xfs_swap_extents(
>  		goto out_trans_cancel;
>  
>  	/* Do we have to swap reflink flags? */
> -	if ((ip->i_d.di_flags2 & XFS_DIFLAG2_REFLINK) ^
> -	    (tip->i_d.di_flags2 & XFS_DIFLAG2_REFLINK)) {
> -		f = ip->i_d.di_flags2 & XFS_DIFLAG2_REFLINK;
> -		ip->i_d.di_flags2 &= ~XFS_DIFLAG2_REFLINK;
> -		ip->i_d.di_flags2 |= tip->i_d.di_flags2 & XFS_DIFLAG2_REFLINK;
> -		tip->i_d.di_flags2 &= ~XFS_DIFLAG2_REFLINK;
> -		tip->i_d.di_flags2 |= f & XFS_DIFLAG2_REFLINK;
> +	if ((ip->i_diflags2 & XFS_DIFLAG2_REFLINK) ^
> +	    (tip->i_diflags2 & XFS_DIFLAG2_REFLINK)) {
> +		f = ip->i_diflags2 & XFS_DIFLAG2_REFLINK;
> +		ip->i_diflags2 &= ~XFS_DIFLAG2_REFLINK;
> +		ip->i_diflags2 |= tip->i_diflags2 & XFS_DIFLAG2_REFLINK;
> +		tip->i_diflags2 &= ~XFS_DIFLAG2_REFLINK;
> +		tip->i_diflags2 |= f & XFS_DIFLAG2_REFLINK;
>  	}
>  
>  	/* Swap the cow forks. */
> diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c
> index 4f08793f3d6db4..193352df48f6bd 100644
> --- a/fs/xfs/xfs_file.c
> +++ b/fs/xfs/xfs_file.c
> @@ -1052,9 +1052,9 @@ xfs_file_remap_range(
>  	 */
>  	cowextsize = 0;
>  	if (pos_in == 0 && len == i_size_read(inode_in) &&
> -	    (src->i_d.di_flags2 & XFS_DIFLAG2_COWEXTSIZE) &&
> +	    (src->i_diflags2 & XFS_DIFLAG2_COWEXTSIZE) &&
>  	    pos_out == 0 && len >= i_size_read(inode_out) &&
> -	    !(dest->i_d.di_flags2 & XFS_DIFLAG2_COWEXTSIZE))
> +	    !(dest->i_diflags2 & XFS_DIFLAG2_COWEXTSIZE))
>  		cowextsize = src->i_cowextsize;
>  
>  	ret = xfs_reflink_update_dest(dest, pos_out + len, cowextsize,
> diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
> index 479342ac8851f4..593e8c5c2fd658 100644
> --- a/fs/xfs/xfs_inode.c
> +++ b/fs/xfs/xfs_inode.c
> @@ -81,7 +81,7 @@ xfs_get_cowextsz_hint(
>  	xfs_extlen_t		a, b;
>  
>  	a = 0;
> -	if (ip->i_d.di_flags2 & XFS_DIFLAG2_COWEXTSIZE)
> +	if (ip->i_diflags2 & XFS_DIFLAG2_COWEXTSIZE)
>  		a = ip->i_cowextsize;
>  	b = xfs_get_extsz_hint(ip);
>  
> @@ -671,9 +671,7 @@ uint
>  xfs_ip2xflags(
>  	struct xfs_inode	*ip)
>  {
> -	struct xfs_icdinode	*dic = &ip->i_d;
> -
> -	return _xfs_dic2xflags(ip->i_diflags, dic->di_flags2, XFS_IFORK_Q(ip));
> +	return _xfs_dic2xflags(ip->i_diflags, ip->i_diflags2, XFS_IFORK_Q(ip));
>  }
>  
>  /*
> @@ -841,7 +839,7 @@ xfs_ialloc(
>  
>  	if (xfs_sb_version_has_v3inode(&mp->m_sb)) {
>  		inode_set_iversion(inode, 1);
> -		ip->i_d.di_flags2 = 0;
> +		ip->i_diflags2 = 0;
>  		ip->i_cowextsize = 0;
>  		ip->i_d.di_crtime = tv;
>  	}
> @@ -898,13 +896,13 @@ xfs_ialloc(
>  
>  			ip->i_diflags |= di_flags;
>  		}
> -		if (pip && (pip->i_d.di_flags2 & XFS_DIFLAG2_ANY)) {
> -			if (pip->i_d.di_flags2 & XFS_DIFLAG2_COWEXTSIZE) {
> -				ip->i_d.di_flags2 |= XFS_DIFLAG2_COWEXTSIZE;
> +		if (pip && (pip->i_diflags2 & XFS_DIFLAG2_ANY)) {
> +			if (pip->i_diflags2 & XFS_DIFLAG2_COWEXTSIZE) {
> +				ip->i_diflags2 |= XFS_DIFLAG2_COWEXTSIZE;
>  				ip->i_cowextsize = pip->i_cowextsize;
>  			}
> -			if (pip->i_d.di_flags2 & XFS_DIFLAG2_DAX)
> -				ip->i_d.di_flags2 |= XFS_DIFLAG2_DAX;
> +			if (pip->i_diflags2 & XFS_DIFLAG2_DAX)
> +				ip->i_diflags2 |= XFS_DIFLAG2_DAX;
>  		}
>  		/* FALLTHROUGH */
>  	case S_IFLNK:
> @@ -1456,7 +1454,7 @@ xfs_itruncate_clear_reflink_flags(
>  	dfork = XFS_IFORK_PTR(ip, XFS_DATA_FORK);
>  	cfork = XFS_IFORK_PTR(ip, XFS_COW_FORK);
>  	if (dfork->if_bytes == 0 && cfork->if_bytes == 0)
> -		ip->i_d.di_flags2 &= ~XFS_DIFLAG2_REFLINK;
> +		ip->i_diflags2 &= ~XFS_DIFLAG2_REFLINK;
>  	if (cfork->if_bytes == 0)
>  		xfs_inode_clear_cowblocks_tag(ip);
>  }
> @@ -2756,7 +2754,7 @@ xfs_ifree(
>  
>  	VFS_I(ip)->i_mode = 0;		/* mark incore inode as free */
>  	ip->i_diflags = 0;
> -	ip->i_d.di_flags2 = 0;
> +	ip->i_diflags2 = 0;
>  	ip->i_d.di_dmevmask = 0;
>  	ip->i_forkoff = 0;		/* mark the attr fork not in use */
>  	ip->i_df.if_format = XFS_DINODE_FMT_EXTENTS;
> diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h
> index 7673c841d89154..709f04fadde65e 100644
> --- a/fs/xfs/xfs_inode.h
> +++ b/fs/xfs/xfs_inode.h
> @@ -65,6 +65,7 @@ typedef struct xfs_inode {
>  	};
>  	uint8_t			i_forkoff;	/* attr fork offset >> 3 */
>  	uint16_t		i_diflags;	/* XFS_DIFLAG_... */
> +	uint64_t		i_diflags2;	/* XFS_DIFLAG2_... */
>  
>  	struct xfs_icdinode	i_d;		/* most of ondisk inode */
>  
> @@ -193,7 +194,7 @@ xfs_get_initial_prid(struct xfs_inode *dp)
>  
>  static inline bool xfs_is_reflink_inode(struct xfs_inode *ip)
>  {
> -	return ip->i_d.di_flags2 & XFS_DIFLAG2_REFLINK;
> +	return ip->i_diflags2 & XFS_DIFLAG2_REFLINK;
>  }
>  
>  /*
> diff --git a/fs/xfs/xfs_inode_item.c b/fs/xfs/xfs_inode_item.c
> index 6af8e829dd0172..04e671d2957ca2 100644
> --- a/fs/xfs/xfs_inode_item.c
> +++ b/fs/xfs/xfs_inode_item.c
> @@ -342,7 +342,7 @@ xfs_inode_to_log_dinode(
>  		to->di_changecount = inode_peek_iversion(inode);
>  		to->di_crtime.t_sec = from->di_crtime.tv_sec;
>  		to->di_crtime.t_nsec = from->di_crtime.tv_nsec;
> -		to->di_flags2 = from->di_flags2;
> +		to->di_flags2 = ip->i_diflags2;
>  		to->di_cowextsize = ip->i_cowextsize;
>  		to->di_ino = ip->i_ino;
>  		to->di_lsn = lsn;
> diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
> index 326991f4d98096..d05b86e7930e84 100644
> --- a/fs/xfs/xfs_ioctl.c
> +++ b/fs/xfs/xfs_ioctl.c
> @@ -1110,7 +1110,7 @@ xfs_fill_fsxattr(
>  	simple_fill_fsxattr(fa, xfs_ip2xflags(ip));
>  	fa->fsx_extsize = XFS_FSB_TO_B(mp, ip->i_extsize);
>  	if (xfs_sb_version_has_v3inode(&mp->m_sb) &&
> -	    (ip->i_d.di_flags2 & XFS_DIFLAG2_COWEXTSIZE))
> +	    (ip->i_diflags2 & XFS_DIFLAG2_COWEXTSIZE))
>  		fa->fsx_cowextsize = XFS_FSB_TO_B(mp, ip->i_cowextsize);
>  	fa->fsx_projid = ip->i_projid;
>  	if (ifp && (ifp->if_flags & XFS_IFEXTENTS))
> @@ -1183,15 +1183,14 @@ xfs_flags2diflags2(
>  	struct xfs_inode	*ip,
>  	unsigned int		xflags)
>  {
> -	uint64_t		di_flags2 =
> -		(ip->i_d.di_flags2 & XFS_DIFLAG2_REFLINK);
> +	uint64_t		i_flags2 = (ip->i_diflags2 & XFS_DIFLAG2_REFLINK);
>  
>  	if (xflags & FS_XFLAG_DAX)
> -		di_flags2 |= XFS_DIFLAG2_DAX;
> +		i_flags2 |= XFS_DIFLAG2_DAX;
>  	if (xflags & FS_XFLAG_COWEXTSIZE)
> -		di_flags2 |= XFS_DIFLAG2_COWEXTSIZE;
> +		i_flags2 |= XFS_DIFLAG2_COWEXTSIZE;
>  
> -	return di_flags2;
> +	return i_flags2;
>  }
>  
>  static int
> @@ -1201,7 +1200,7 @@ xfs_ioctl_setattr_xflags(
>  	struct fsxattr		*fa)
>  {
>  	struct xfs_mount	*mp = ip->i_mount;
> -	uint64_t		di_flags2;
> +	uint64_t		i_flags2;
>  
>  	/* Can't change realtime flag if any extents are allocated. */
>  	if ((ip->i_df.if_nextents || ip->i_delayed_blks) &&
> @@ -1217,19 +1216,19 @@ xfs_ioctl_setattr_xflags(
>  
>  	/* Clear reflink if we are actually able to set the rt flag. */
>  	if ((fa->fsx_xflags & FS_XFLAG_REALTIME) && xfs_is_reflink_inode(ip))
> -		ip->i_d.di_flags2 &= ~XFS_DIFLAG2_REFLINK;
> +		ip->i_diflags2 &= ~XFS_DIFLAG2_REFLINK;
>  
>  	/* Don't allow us to set DAX mode for a reflinked file for now. */
>  	if ((fa->fsx_xflags & FS_XFLAG_DAX) && xfs_is_reflink_inode(ip))
>  		return -EINVAL;
>  
>  	/* diflags2 only valid for v3 inodes. */
> -	di_flags2 = xfs_flags2diflags2(ip, fa->fsx_xflags);
> -	if (di_flags2 && !xfs_sb_version_has_v3inode(&mp->m_sb))
> +	i_flags2 = xfs_flags2diflags2(ip, fa->fsx_xflags);
> +	if (i_flags2 && !xfs_sb_version_has_v3inode(&mp->m_sb))
>  		return -EINVAL;
>  
>  	ip->i_diflags = xfs_flags2diflags(ip, fa->fsx_xflags);
> -	ip->i_d.di_flags2 = di_flags2;
> +	ip->i_diflags2 = i_flags2;
>  
>  	xfs_diflags_to_iflags(ip, false);
>  	xfs_trans_ichgtime(tp, ip, XFS_ICHGTIME_CHG);
> @@ -1575,7 +1574,7 @@ xfs_ioctl_setattr(
>  	else
>  		ip->i_extsize = 0;
>  	if (xfs_sb_version_has_v3inode(&mp->m_sb) &&
> -	    (ip->i_d.di_flags2 & XFS_DIFLAG2_COWEXTSIZE))
> +	    (ip->i_diflags2 & XFS_DIFLAG2_COWEXTSIZE))
>  		ip->i_cowextsize = fa->fsx_cowextsize >> mp->m_sb.sb_blocklog;
>  	else
>  		ip->i_cowextsize = 0;
> diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
> index f37154fc9828fd..3642f9935cae3f 100644
> --- a/fs/xfs/xfs_iops.c
> +++ b/fs/xfs/xfs_iops.c
> @@ -1265,7 +1265,7 @@ xfs_inode_should_enable_dax(
>  		return false;
>  	if (ip->i_mount->m_flags & XFS_MOUNT_DAX_ALWAYS)
>  		return true;
> -	if (ip->i_d.di_flags2 & XFS_DIFLAG2_DAX)
> +	if (ip->i_diflags2 & XFS_DIFLAG2_DAX)
>  		return true;
>  	return false;
>  }
> diff --git a/fs/xfs/xfs_itable.c b/fs/xfs/xfs_itable.c
> index 7937af9f2ea779..4d1509437c3576 100644
> --- a/fs/xfs/xfs_itable.c
> +++ b/fs/xfs/xfs_itable.c
> @@ -111,7 +111,7 @@ xfs_bulkstat_one_int(
>  	buf->bs_version = XFS_BULKSTAT_VERSION_V5;
>  
>  	if (xfs_sb_version_has_v3inode(&mp->m_sb)) {
> -		if (dic->di_flags2 & XFS_DIFLAG2_COWEXTSIZE)
> +		if (ip->i_diflags2 & XFS_DIFLAG2_COWEXTSIZE)
>  			buf->bs_cowextsize_blks = ip->i_cowextsize;
>  	}
>  
> diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c
> index 0e07fa7e43117e..476ba54d84a9a3 100644
> --- a/fs/xfs/xfs_reflink.c
> +++ b/fs/xfs/xfs_reflink.c
> @@ -882,7 +882,7 @@ xfs_reflink_set_inode_flag(
>  	if (!xfs_is_reflink_inode(src)) {
>  		trace_xfs_reflink_set_inode_flag(src);
>  		xfs_trans_ijoin(tp, src, XFS_ILOCK_EXCL);
> -		src->i_d.di_flags2 |= XFS_DIFLAG2_REFLINK;
> +		src->i_diflags2 |= XFS_DIFLAG2_REFLINK;
>  		xfs_trans_log_inode(tp, src, XFS_ILOG_CORE);
>  		xfs_ifork_init_cow(src);
>  	} else
> @@ -894,7 +894,7 @@ xfs_reflink_set_inode_flag(
>  	if (!xfs_is_reflink_inode(dest)) {
>  		trace_xfs_reflink_set_inode_flag(dest);
>  		xfs_trans_ijoin(tp, dest, XFS_ILOCK_EXCL);
> -		dest->i_d.di_flags2 |= XFS_DIFLAG2_REFLINK;
> +		dest->i_diflags2 |= XFS_DIFLAG2_REFLINK;
>  		xfs_trans_log_inode(tp, dest, XFS_ILOG_CORE);
>  		xfs_ifork_init_cow(dest);
>  	} else
> @@ -943,7 +943,7 @@ xfs_reflink_update_dest(
>  
>  	if (cowextsize) {
>  		dest->i_cowextsize = cowextsize;
> -		dest->i_d.di_flags2 |= XFS_DIFLAG2_COWEXTSIZE;
> +		dest->i_diflags2 |= XFS_DIFLAG2_COWEXTSIZE;
>  	}
>  
>  	xfs_trans_log_inode(tp, dest, XFS_ILOG_CORE);
> @@ -1463,7 +1463,7 @@ xfs_reflink_clear_inode_flag(
>  
>  	/* Clear the inode flag. */
>  	trace_xfs_reflink_unset_inode_flag(ip);
> -	ip->i_d.di_flags2 &= ~XFS_DIFLAG2_REFLINK;
> +	ip->i_diflags2 &= ~XFS_DIFLAG2_REFLINK;
>  	xfs_inode_clear_cowblocks_tag(ip);
>  	xfs_trans_log_inode(*tpp, ip, XFS_ILOG_CORE);
>  
> 


-- 
chandan




^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH 13/15] xfs: move the di_crtime field to struct xfs_inode
  2020-06-20  7:11 ` [PATCH 13/15] xfs: move the di_crtime " Christoph Hellwig
@ 2020-06-22 12:54   ` Chandan Babu R
  2020-06-30 17:55   ` Darrick J. Wong
  1 sibling, 0 replies; 52+ messages in thread
From: Chandan Babu R @ 2020-06-22 12:54 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: linux-xfs

On Saturday 20 June 2020 12:41:00 PM IST Christoph Hellwig wrote:
> In preparation of removing the historic icinode struct, move the crtime
> field into the containing xfs_inode structure.
>

The changes look good to me.

Reviewed-by: Chandan Babu R <chandanrlinux@gmail.com>

> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  fs/xfs/libxfs/xfs_inode_buf.c   | 8 ++++----
>  fs/xfs/libxfs/xfs_inode_buf.h   | 2 --
>  fs/xfs/libxfs/xfs_trans_inode.c | 2 +-
>  fs/xfs/xfs_inode.c              | 2 +-
>  fs/xfs/xfs_inode.h              | 1 +
>  fs/xfs/xfs_inode_item.c         | 4 ++--
>  fs/xfs/xfs_iops.c               | 2 +-
>  fs/xfs/xfs_itable.c             | 4 ++--
>  8 files changed, 12 insertions(+), 13 deletions(-)
> 
> diff --git a/fs/xfs/libxfs/xfs_inode_buf.c b/fs/xfs/libxfs/xfs_inode_buf.c
> index 79e470933abfa8..af595ee23635aa 100644
> --- a/fs/xfs/libxfs/xfs_inode_buf.c
> +++ b/fs/xfs/libxfs/xfs_inode_buf.c
> @@ -253,8 +253,8 @@ xfs_inode_from_disk(
>  	if (xfs_sb_version_has_v3inode(&ip->i_mount->m_sb)) {
>  		inode_set_iversion_queried(inode,
>  					   be64_to_cpu(from->di_changecount));
> -		to->di_crtime.tv_sec = be32_to_cpu(from->di_crtime.t_sec);
> -		to->di_crtime.tv_nsec = be32_to_cpu(from->di_crtime.t_nsec);
> +		ip->i_crtime.tv_sec = be32_to_cpu(from->di_crtime.t_sec);
> +		ip->i_crtime.tv_nsec = be32_to_cpu(from->di_crtime.t_nsec);
>  		ip->i_diflags2 = be64_to_cpu(from->di_flags2);
>  		ip->i_cowextsize = be32_to_cpu(from->di_cowextsize);
>  	}
> @@ -319,8 +319,8 @@ xfs_inode_to_disk(
>  	if (xfs_sb_version_has_v3inode(&ip->i_mount->m_sb)) {
>  		to->di_version = 3;
>  		to->di_changecount = cpu_to_be64(inode_peek_iversion(inode));
> -		to->di_crtime.t_sec = cpu_to_be32(from->di_crtime.tv_sec);
> -		to->di_crtime.t_nsec = cpu_to_be32(from->di_crtime.tv_nsec);
> +		to->di_crtime.t_sec = cpu_to_be32(ip->i_crtime.tv_sec);
> +		to->di_crtime.t_nsec = cpu_to_be32(ip->i_crtime.tv_nsec);
>  		to->di_flags2 = cpu_to_be64(ip->i_diflags2);
>  		to->di_cowextsize = cpu_to_be32(ip->i_cowextsize);
>  		to->di_ino = cpu_to_be64(ip->i_ino);
> diff --git a/fs/xfs/libxfs/xfs_inode_buf.h b/fs/xfs/libxfs/xfs_inode_buf.h
> index 4bfad6d6d5710a..2a8e7a7ed8d18d 100644
> --- a/fs/xfs/libxfs/xfs_inode_buf.h
> +++ b/fs/xfs/libxfs/xfs_inode_buf.h
> @@ -18,8 +18,6 @@ struct xfs_dinode;
>  struct xfs_icdinode {
>  	uint32_t	di_dmevmask;	/* DMIG event mask */
>  	uint16_t	di_dmstate;	/* DMIG state info */
> -
> -	struct timespec64 di_crtime;	/* time created */
>  };
>  
>  /*
> diff --git a/fs/xfs/libxfs/xfs_trans_inode.c b/fs/xfs/libxfs/xfs_trans_inode.c
> index b5dfb665484223..3c690829634cdc 100644
> --- a/fs/xfs/libxfs/xfs_trans_inode.c
> +++ b/fs/xfs/libxfs/xfs_trans_inode.c
> @@ -67,7 +67,7 @@ xfs_trans_ichgtime(
>  	if (flags & XFS_ICHGTIME_CHG)
>  		inode->i_ctime = tv;
>  	if (flags & XFS_ICHGTIME_CREATE)
> -		ip->i_d.di_crtime = tv;
> +		ip->i_crtime = tv;
>  }
>  
>  /*
> diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
> index 593e8c5c2fd658..59f11314750a46 100644
> --- a/fs/xfs/xfs_inode.c
> +++ b/fs/xfs/xfs_inode.c
> @@ -841,7 +841,7 @@ xfs_ialloc(
>  		inode_set_iversion(inode, 1);
>  		ip->i_diflags2 = 0;
>  		ip->i_cowextsize = 0;
> -		ip->i_d.di_crtime = tv;
> +		ip->i_crtime = tv;
>  	}
>  
>  	flags = XFS_ILOG_CORE;
> diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h
> index 709f04fadde65e..106a8d6cc010cb 100644
> --- a/fs/xfs/xfs_inode.h
> +++ b/fs/xfs/xfs_inode.h
> @@ -66,6 +66,7 @@ typedef struct xfs_inode {
>  	uint8_t			i_forkoff;	/* attr fork offset >> 3 */
>  	uint16_t		i_diflags;	/* XFS_DIFLAG_... */
>  	uint64_t		i_diflags2;	/* XFS_DIFLAG2_... */
> +	struct timespec64	i_crtime;	/* time created */
>  
>  	struct xfs_icdinode	i_d;		/* most of ondisk inode */
>  
> diff --git a/fs/xfs/xfs_inode_item.c b/fs/xfs/xfs_inode_item.c
> index 04e671d2957ca2..dff3bc6a33720a 100644
> --- a/fs/xfs/xfs_inode_item.c
> +++ b/fs/xfs/xfs_inode_item.c
> @@ -340,8 +340,8 @@ xfs_inode_to_log_dinode(
>  	if (xfs_sb_version_has_v3inode(&ip->i_mount->m_sb)) {
>  		to->di_version = 3;
>  		to->di_changecount = inode_peek_iversion(inode);
> -		to->di_crtime.t_sec = from->di_crtime.tv_sec;
> -		to->di_crtime.t_nsec = from->di_crtime.tv_nsec;
> +		to->di_crtime.t_sec = ip->i_crtime.tv_sec;
> +		to->di_crtime.t_nsec = ip->i_crtime.tv_nsec;
>  		to->di_flags2 = ip->i_diflags2;
>  		to->di_cowextsize = ip->i_cowextsize;
>  		to->di_ino = ip->i_ino;
> diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
> index 3642f9935cae3f..6aace9c6586ca5 100644
> --- a/fs/xfs/xfs_iops.c
> +++ b/fs/xfs/xfs_iops.c
> @@ -559,7 +559,7 @@ xfs_vn_getattr(
>  	if (xfs_sb_version_has_v3inode(&mp->m_sb)) {
>  		if (request_mask & STATX_BTIME) {
>  			stat->result_mask |= STATX_BTIME;
> -			stat->btime = ip->i_d.di_crtime;
> +			stat->btime = ip->i_crtime;
>  		}
>  	}
>  
> diff --git a/fs/xfs/xfs_itable.c b/fs/xfs/xfs_itable.c
> index 4d1509437c3576..7945c6c4844940 100644
> --- a/fs/xfs/xfs_itable.c
> +++ b/fs/xfs/xfs_itable.c
> @@ -97,8 +97,8 @@ xfs_bulkstat_one_int(
>  	buf->bs_mtime_nsec = inode->i_mtime.tv_nsec;
>  	buf->bs_ctime = inode->i_ctime.tv_sec;
>  	buf->bs_ctime_nsec = inode->i_ctime.tv_nsec;
> -	buf->bs_btime = dic->di_crtime.tv_sec;
> -	buf->bs_btime_nsec = dic->di_crtime.tv_nsec;
> +	buf->bs_btime = ip->i_crtime.tv_sec;
> +	buf->bs_btime_nsec = ip->i_crtime.tv_nsec;
>  	buf->bs_gen = inode->i_generation;
>  	buf->bs_mode = inode->i_mode;
>  
> 


-- 
chandan




^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH 14/15] xfs: move the di_dmevmask field to struct xfs_inode
  2020-06-20  7:11 ` [PATCH 14/15] xfs: move the di_dmevmask " Christoph Hellwig
@ 2020-06-22 12:58   ` Chandan Babu R
  2020-06-30 17:55   ` Darrick J. Wong
  1 sibling, 0 replies; 52+ messages in thread
From: Chandan Babu R @ 2020-06-22 12:58 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: linux-xfs

On Saturday 20 June 2020 12:41:01 PM IST Christoph Hellwig wrote:
> In preparation of removing the historic icinode struct, move the
> dmevmask field into the containing xfs_inode structure.
>

The changes look good to me.

Reviewed-by: Chandan Babu R <chandanrlinux@gmail.com>


> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  fs/xfs/libxfs/xfs_inode_buf.c | 4 ++--
>  fs/xfs/libxfs/xfs_inode_buf.h | 1 -
>  fs/xfs/xfs_inode.c            | 4 ++--
>  fs/xfs/xfs_inode.h            | 1 +
>  fs/xfs/xfs_inode_item.c       | 2 +-
>  fs/xfs/xfs_log_recover.c      | 2 +-
>  6 files changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/fs/xfs/libxfs/xfs_inode_buf.c b/fs/xfs/libxfs/xfs_inode_buf.c
> index af595ee23635aa..d361803102d0e1 100644
> --- a/fs/xfs/libxfs/xfs_inode_buf.c
> +++ b/fs/xfs/libxfs/xfs_inode_buf.c
> @@ -246,7 +246,7 @@ xfs_inode_from_disk(
>  	ip->i_nblocks = be64_to_cpu(from->di_nblocks);
>  	ip->i_extsize = be32_to_cpu(from->di_extsize);
>  	ip->i_forkoff = from->di_forkoff;
> -	to->di_dmevmask	= be32_to_cpu(from->di_dmevmask);
> +	ip->i_dmevmask	= be32_to_cpu(from->di_dmevmask);
>  	to->di_dmstate	= be16_to_cpu(from->di_dmstate);
>  	ip->i_diflags	= be16_to_cpu(from->di_flags);
>  
> @@ -312,7 +312,7 @@ xfs_inode_to_disk(
>  	to->di_anextents = cpu_to_be16(xfs_ifork_nextents(ip->i_afp));
>  	to->di_forkoff = ip->i_forkoff;
>  	to->di_aformat = xfs_ifork_format(ip->i_afp);
> -	to->di_dmevmask = cpu_to_be32(from->di_dmevmask);
> +	to->di_dmevmask = cpu_to_be32(ip->i_dmevmask);
>  	to->di_dmstate = cpu_to_be16(from->di_dmstate);
>  	to->di_flags = cpu_to_be16(ip->i_diflags);
>  
> diff --git a/fs/xfs/libxfs/xfs_inode_buf.h b/fs/xfs/libxfs/xfs_inode_buf.h
> index 2a8e7a7ed8d18d..0cfc1aaff6c6f3 100644
> --- a/fs/xfs/libxfs/xfs_inode_buf.h
> +++ b/fs/xfs/libxfs/xfs_inode_buf.h
> @@ -16,7 +16,6 @@ struct xfs_dinode;
>   * format specific structures at the appropriate time.
>   */
>  struct xfs_icdinode {
> -	uint32_t	di_dmevmask;	/* DMIG event mask */
>  	uint16_t	di_dmstate;	/* DMIG state info */
>  };
>  
> diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
> index 59f11314750a46..db48c910c8d7b0 100644
> --- a/fs/xfs/xfs_inode.c
> +++ b/fs/xfs/xfs_inode.c
> @@ -833,7 +833,7 @@ xfs_ialloc(
>  	inode->i_ctime = tv;
>  
>  	ip->i_extsize = 0;
> -	ip->i_d.di_dmevmask = 0;
> +	ip->i_dmevmask = 0;
>  	ip->i_d.di_dmstate = 0;
>  	ip->i_diflags = 0;
>  
> @@ -2755,7 +2755,7 @@ xfs_ifree(
>  	VFS_I(ip)->i_mode = 0;		/* mark incore inode as free */
>  	ip->i_diflags = 0;
>  	ip->i_diflags2 = 0;
> -	ip->i_d.di_dmevmask = 0;
> +	ip->i_dmevmask = 0;
>  	ip->i_forkoff = 0;		/* mark the attr fork not in use */
>  	ip->i_df.if_format = XFS_DINODE_FMT_EXTENTS;
>  
> diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h
> index 106a8d6cc010cb..e64df2e7438aa0 100644
> --- a/fs/xfs/xfs_inode.h
> +++ b/fs/xfs/xfs_inode.h
> @@ -67,6 +67,7 @@ typedef struct xfs_inode {
>  	uint16_t		i_diflags;	/* XFS_DIFLAG_... */
>  	uint64_t		i_diflags2;	/* XFS_DIFLAG2_... */
>  	struct timespec64	i_crtime;	/* time created */
> +	uint32_t		i_dmevmask;	/* DMIG event mask */
>  
>  	struct xfs_icdinode	i_d;		/* most of ondisk inode */
>  
> diff --git a/fs/xfs/xfs_inode_item.c b/fs/xfs/xfs_inode_item.c
> index dff3bc6a33720a..9b7860025c497d 100644
> --- a/fs/xfs/xfs_inode_item.c
> +++ b/fs/xfs/xfs_inode_item.c
> @@ -330,7 +330,7 @@ xfs_inode_to_log_dinode(
>  	to->di_anextents = xfs_ifork_nextents(ip->i_afp);
>  	to->di_forkoff = ip->i_forkoff;
>  	to->di_aformat = xfs_ifork_format(ip->i_afp);
> -	to->di_dmevmask = from->di_dmevmask;
> +	to->di_dmevmask = ip->i_dmevmask;
>  	to->di_dmstate = from->di_dmstate;
>  	to->di_flags = ip->i_diflags;
>  
> diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c
> index ec015df55b77a9..d096b8c4013814 100644
> --- a/fs/xfs/xfs_log_recover.c
> +++ b/fs/xfs/xfs_log_recover.c
> @@ -2720,7 +2720,7 @@ xlog_recover_process_one_iunlink(
>  	 * Prevent any DMAPI event from being sent when the reference on
>  	 * the inode is dropped.
>  	 */
> -	ip->i_d.di_dmevmask = 0;
> +	ip->i_dmevmask = 0;
>  
>  	xfs_irele(ip);
>  	return agino;
> 


-- 
chandan




^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH 15/15] xfs: move the di_dmstate field to struct xfs_inode
  2020-06-20  7:11 ` [PATCH 15/15] xfs: move the di_dmstate " Christoph Hellwig
@ 2020-06-22 13:18   ` Chandan Babu R
  2020-06-30 17:56   ` Darrick J. Wong
  1 sibling, 0 replies; 52+ messages in thread
From: Chandan Babu R @ 2020-06-22 13:18 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: linux-xfs

On Saturday 20 June 2020 12:41:02 PM IST Christoph Hellwig wrote:
> Move the di_dmstate into struct xfs_inode, and thus finally kill of
> the xfs_icdinode structure.
>

The changes look good to me.

Reviewed-by: Chandan Babu R <chandanrlinux@gmail.com>

> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  fs/xfs/libxfs/xfs_inode_buf.c |  6 ++----
>  fs/xfs/libxfs/xfs_inode_buf.h | 10 ----------
>  fs/xfs/xfs_inode.c            |  2 +-
>  fs/xfs/xfs_inode.h            |  3 +--
>  fs/xfs/xfs_inode_item.c       |  3 +--
>  fs/xfs/xfs_itable.c           |  3 ---
>  6 files changed, 5 insertions(+), 22 deletions(-)
> 
> diff --git a/fs/xfs/libxfs/xfs_inode_buf.c b/fs/xfs/libxfs/xfs_inode_buf.c
> index d361803102d0e1..e4e96a47e0bab6 100644
> --- a/fs/xfs/libxfs/xfs_inode_buf.c
> +++ b/fs/xfs/libxfs/xfs_inode_buf.c
> @@ -185,7 +185,6 @@ xfs_inode_from_disk(
>  	struct xfs_inode	*ip,
>  	struct xfs_dinode	*from)
>  {
> -	struct xfs_icdinode	*to = &ip->i_d;
>  	struct inode		*inode = VFS_I(ip);
>  	int			error;
>  	xfs_failaddr_t		fa;
> @@ -247,7 +246,7 @@ xfs_inode_from_disk(
>  	ip->i_extsize = be32_to_cpu(from->di_extsize);
>  	ip->i_forkoff = from->di_forkoff;
>  	ip->i_dmevmask	= be32_to_cpu(from->di_dmevmask);
> -	to->di_dmstate	= be16_to_cpu(from->di_dmstate);
> +	ip->i_dmstate	= be16_to_cpu(from->di_dmstate);
>  	ip->i_diflags	= be16_to_cpu(from->di_flags);
>  
>  	if (xfs_sb_version_has_v3inode(&ip->i_mount->m_sb)) {
> @@ -282,7 +281,6 @@ xfs_inode_to_disk(
>  	struct xfs_dinode	*to,
>  	xfs_lsn_t		lsn)
>  {
> -	struct xfs_icdinode	*from = &ip->i_d;
>  	struct inode		*inode = VFS_I(ip);
>  
>  	to->di_magic = cpu_to_be16(XFS_DINODE_MAGIC);
> @@ -313,7 +311,7 @@ xfs_inode_to_disk(
>  	to->di_forkoff = ip->i_forkoff;
>  	to->di_aformat = xfs_ifork_format(ip->i_afp);
>  	to->di_dmevmask = cpu_to_be32(ip->i_dmevmask);
> -	to->di_dmstate = cpu_to_be16(from->di_dmstate);
> +	to->di_dmstate = cpu_to_be16(ip->i_dmstate);
>  	to->di_flags = cpu_to_be16(ip->i_diflags);
>  
>  	if (xfs_sb_version_has_v3inode(&ip->i_mount->m_sb)) {
> diff --git a/fs/xfs/libxfs/xfs_inode_buf.h b/fs/xfs/libxfs/xfs_inode_buf.h
> index 0cfc1aaff6c6f3..834c8b3e917370 100644
> --- a/fs/xfs/libxfs/xfs_inode_buf.h
> +++ b/fs/xfs/libxfs/xfs_inode_buf.h
> @@ -9,16 +9,6 @@
>  struct xfs_inode;
>  struct xfs_dinode;
>  
> -/*
> - * In memory representation of the XFS inode. This is held in the in-core struct
> - * xfs_inode and represents the current on disk values but the structure is not
> - * in on-disk format.  That is, this structure is always translated to on-disk
> - * format specific structures at the appropriate time.
> - */
> -struct xfs_icdinode {
> -	uint16_t	di_dmstate;	/* DMIG state info */
> -};
> -
>  /*
>   * Inode location information.  Stored in the inode and passed to
>   * xfs_imap_to_bp() to get a buffer and dinode for a given inode.
> diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
> index db48c910c8d7b0..79436ed0b14e89 100644
> --- a/fs/xfs/xfs_inode.c
> +++ b/fs/xfs/xfs_inode.c
> @@ -834,7 +834,7 @@ xfs_ialloc(
>  
>  	ip->i_extsize = 0;
>  	ip->i_dmevmask = 0;
> -	ip->i_d.di_dmstate = 0;
> +	ip->i_dmstate = 0;
>  	ip->i_diflags = 0;
>  
>  	if (xfs_sb_version_has_v3inode(&mp->m_sb)) {
> diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h
> index e64df2e7438aa0..f0537ead8bad90 100644
> --- a/fs/xfs/xfs_inode.h
> +++ b/fs/xfs/xfs_inode.h
> @@ -68,8 +68,7 @@ typedef struct xfs_inode {
>  	uint64_t		i_diflags2;	/* XFS_DIFLAG2_... */
>  	struct timespec64	i_crtime;	/* time created */
>  	uint32_t		i_dmevmask;	/* DMIG event mask */
> -
> -	struct xfs_icdinode	i_d;		/* most of ondisk inode */
> +	uint16_t		i_dmstate;	/* DMIG state info */
>  
>  	/* VFS inode */
>  	struct inode		i_vnode;	/* embedded VFS inode */
> diff --git a/fs/xfs/xfs_inode_item.c b/fs/xfs/xfs_inode_item.c
> index 9b7860025c497d..628f8190abddca 100644
> --- a/fs/xfs/xfs_inode_item.c
> +++ b/fs/xfs/xfs_inode_item.c
> @@ -301,7 +301,6 @@ xfs_inode_to_log_dinode(
>  	struct xfs_log_dinode	*to,
>  	xfs_lsn_t		lsn)
>  {
> -	struct xfs_icdinode	*from = &ip->i_d;
>  	struct inode		*inode = VFS_I(ip);
>  
>  	to->di_magic = XFS_DINODE_MAGIC;
> @@ -331,7 +330,7 @@ xfs_inode_to_log_dinode(
>  	to->di_forkoff = ip->i_forkoff;
>  	to->di_aformat = xfs_ifork_format(ip->i_afp);
>  	to->di_dmevmask = ip->i_dmevmask;
> -	to->di_dmstate = from->di_dmstate;
> +	to->di_dmstate = ip->i_dmstate;
>  	to->di_flags = ip->i_diflags;
>  
>  	/* log a dummy value to ensure log structure is fully initialised */
> diff --git a/fs/xfs/xfs_itable.c b/fs/xfs/xfs_itable.c
> index 7945c6c4844940..cd1f09e57b9483 100644
> --- a/fs/xfs/xfs_itable.c
> +++ b/fs/xfs/xfs_itable.c
> @@ -58,7 +58,6 @@ xfs_bulkstat_one_int(
>  	xfs_ino_t		ino,
>  	struct xfs_bstat_chunk	*bc)
>  {
> -	struct xfs_icdinode	*dic;		/* dinode core info pointer */
>  	struct xfs_inode	*ip;		/* incore inode pointer */
>  	struct inode		*inode;
>  	struct xfs_bulkstat	*buf = bc->buf;
> @@ -79,8 +78,6 @@ xfs_bulkstat_one_int(
>  	ASSERT(ip->i_imap.im_blkno != 0);
>  	inode = VFS_I(ip);
>  
> -	dic = &ip->i_d;
> -
>  	/* xfs_iget returns the following without needing
>  	 * further change.
>  	 */
> 


-- 
chandan




^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH 12/15] xfs: move the di_flags2 field to struct xfs_inode
  2020-06-22 12:51   ` Chandan Babu R
@ 2020-06-22 13:23     ` Chandan Babu R
  2020-06-24  7:25       ` Christoph Hellwig
  0 siblings, 1 reply; 52+ messages in thread
From: Chandan Babu R @ 2020-06-22 13:23 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: linux-xfs

On Monday 22 June 2020 6:21:37 PM IST Chandan Babu R wrote:
> On Saturday 20 June 2020 12:40:59 PM IST Christoph Hellwig wrote:
> > In preparation of removing the historic icinode struct, move the flags2
> > field into the containing xfs_inode structure.
> >
> 
> The changes look good to me.
> 
> Reviewed-by: Chandan Babu R <chandanrlinux@gmail.com>

The commit "fs/xfs: Update xfs_ioctl_setattr_dax_invalidate()"
(e4f9ba20d3b8c2b86ec71f326882e1a3c4e47953) adds the function
xfs_ioctl_setattr_prepare_dax() which refers to xfs_icdinode->di_flags2. A
rebase should solve this issue.

> 
> > Signed-off-by: Christoph Hellwig <hch@lst.de>
> > ---
> >  fs/xfs/libxfs/xfs_inode_buf.c |  4 ++--
> >  fs/xfs/libxfs/xfs_inode_buf.h |  2 --
> >  fs/xfs/xfs_bmap_util.c        | 24 ++++++++++++------------
> >  fs/xfs/xfs_file.c             |  4 ++--
> >  fs/xfs/xfs_inode.c            | 22 ++++++++++------------
> >  fs/xfs/xfs_inode.h            |  3 ++-
> >  fs/xfs/xfs_inode_item.c       |  2 +-
> >  fs/xfs/xfs_ioctl.c            | 23 +++++++++++------------
> >  fs/xfs/xfs_iops.c             |  2 +-
> >  fs/xfs/xfs_itable.c           |  2 +-
> >  fs/xfs/xfs_reflink.c          |  8 ++++----
> >  11 files changed, 46 insertions(+), 50 deletions(-)
> > 
> > diff --git a/fs/xfs/libxfs/xfs_inode_buf.c b/fs/xfs/libxfs/xfs_inode_buf.c
> > index bb9c4775ecaa5c..79e470933abfa8 100644
> > --- a/fs/xfs/libxfs/xfs_inode_buf.c
> > +++ b/fs/xfs/libxfs/xfs_inode_buf.c
> > @@ -255,7 +255,7 @@ xfs_inode_from_disk(
> >  					   be64_to_cpu(from->di_changecount));
> >  		to->di_crtime.tv_sec = be32_to_cpu(from->di_crtime.t_sec);
> >  		to->di_crtime.tv_nsec = be32_to_cpu(from->di_crtime.t_nsec);
> > -		to->di_flags2 = be64_to_cpu(from->di_flags2);
> > +		ip->i_diflags2 = be64_to_cpu(from->di_flags2);
> >  		ip->i_cowextsize = be32_to_cpu(from->di_cowextsize);
> >  	}
> >  
> > @@ -321,7 +321,7 @@ xfs_inode_to_disk(
> >  		to->di_changecount = cpu_to_be64(inode_peek_iversion(inode));
> >  		to->di_crtime.t_sec = cpu_to_be32(from->di_crtime.tv_sec);
> >  		to->di_crtime.t_nsec = cpu_to_be32(from->di_crtime.tv_nsec);
> > -		to->di_flags2 = cpu_to_be64(from->di_flags2);
> > +		to->di_flags2 = cpu_to_be64(ip->i_diflags2);
> >  		to->di_cowextsize = cpu_to_be32(ip->i_cowextsize);
> >  		to->di_ino = cpu_to_be64(ip->i_ino);
> >  		to->di_lsn = cpu_to_be64(lsn);
> > diff --git a/fs/xfs/libxfs/xfs_inode_buf.h b/fs/xfs/libxfs/xfs_inode_buf.h
> > index 5c6a6ac521b11d..4bfad6d6d5710a 100644
> > --- a/fs/xfs/libxfs/xfs_inode_buf.h
> > +++ b/fs/xfs/libxfs/xfs_inode_buf.h
> > @@ -19,8 +19,6 @@ struct xfs_icdinode {
> >  	uint32_t	di_dmevmask;	/* DMIG event mask */
> >  	uint16_t	di_dmstate;	/* DMIG state info */
> >  
> > -	uint64_t	di_flags2;	/* more random flags */
> > -
> >  	struct timespec64 di_crtime;	/* time created */
> >  };
> >  
> > diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c
> > index 0b944aad75e618..8f85a4131983a6 100644
> > --- a/fs/xfs/xfs_bmap_util.c
> > +++ b/fs/xfs/xfs_bmap_util.c
> > @@ -1332,9 +1332,9 @@ xfs_swap_extent_rmap(
> >  	 * rmap functions when we go to fix up the rmaps.  The flags
> >  	 * will be switch for reals later.
> >  	 */
> > -	tip_flags2 = tip->i_d.di_flags2;
> > -	if (ip->i_d.di_flags2 & XFS_DIFLAG2_REFLINK)
> > -		tip->i_d.di_flags2 |= XFS_DIFLAG2_REFLINK;
> > +	tip_flags2 = tip->i_diflags2;
> > +	if (ip->i_diflags2 & XFS_DIFLAG2_REFLINK)
> > +		tip->i_diflags2 |= XFS_DIFLAG2_REFLINK;
> >  
> >  	offset_fsb = 0;
> >  	end_fsb = XFS_B_TO_FSB(ip->i_mount, i_size_read(VFS_I(ip)));
> > @@ -1405,12 +1405,12 @@ xfs_swap_extent_rmap(
> >  		offset_fsb += ilen;
> >  	}
> >  
> > -	tip->i_d.di_flags2 = tip_flags2;
> > +	tip->i_diflags2 = tip_flags2;
> >  	return 0;
> >  
> >  out:
> >  	trace_xfs_swap_extent_rmap_error(ip, error, _RET_IP_);
> > -	tip->i_d.di_flags2 = tip_flags2;
> > +	tip->i_diflags2 = tip_flags2;
> >  	return error;
> >  }
> >  
> > @@ -1708,13 +1708,13 @@ xfs_swap_extents(
> >  		goto out_trans_cancel;
> >  
> >  	/* Do we have to swap reflink flags? */
> > -	if ((ip->i_d.di_flags2 & XFS_DIFLAG2_REFLINK) ^
> > -	    (tip->i_d.di_flags2 & XFS_DIFLAG2_REFLINK)) {
> > -		f = ip->i_d.di_flags2 & XFS_DIFLAG2_REFLINK;
> > -		ip->i_d.di_flags2 &= ~XFS_DIFLAG2_REFLINK;
> > -		ip->i_d.di_flags2 |= tip->i_d.di_flags2 & XFS_DIFLAG2_REFLINK;
> > -		tip->i_d.di_flags2 &= ~XFS_DIFLAG2_REFLINK;
> > -		tip->i_d.di_flags2 |= f & XFS_DIFLAG2_REFLINK;
> > +	if ((ip->i_diflags2 & XFS_DIFLAG2_REFLINK) ^
> > +	    (tip->i_diflags2 & XFS_DIFLAG2_REFLINK)) {
> > +		f = ip->i_diflags2 & XFS_DIFLAG2_REFLINK;
> > +		ip->i_diflags2 &= ~XFS_DIFLAG2_REFLINK;
> > +		ip->i_diflags2 |= tip->i_diflags2 & XFS_DIFLAG2_REFLINK;
> > +		tip->i_diflags2 &= ~XFS_DIFLAG2_REFLINK;
> > +		tip->i_diflags2 |= f & XFS_DIFLAG2_REFLINK;
> >  	}
> >  
> >  	/* Swap the cow forks. */
> > diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c
> > index 4f08793f3d6db4..193352df48f6bd 100644
> > --- a/fs/xfs/xfs_file.c
> > +++ b/fs/xfs/xfs_file.c
> > @@ -1052,9 +1052,9 @@ xfs_file_remap_range(
> >  	 */
> >  	cowextsize = 0;
> >  	if (pos_in == 0 && len == i_size_read(inode_in) &&
> > -	    (src->i_d.di_flags2 & XFS_DIFLAG2_COWEXTSIZE) &&
> > +	    (src->i_diflags2 & XFS_DIFLAG2_COWEXTSIZE) &&
> >  	    pos_out == 0 && len >= i_size_read(inode_out) &&
> > -	    !(dest->i_d.di_flags2 & XFS_DIFLAG2_COWEXTSIZE))
> > +	    !(dest->i_diflags2 & XFS_DIFLAG2_COWEXTSIZE))
> >  		cowextsize = src->i_cowextsize;
> >  
> >  	ret = xfs_reflink_update_dest(dest, pos_out + len, cowextsize,
> > diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
> > index 479342ac8851f4..593e8c5c2fd658 100644
> > --- a/fs/xfs/xfs_inode.c
> > +++ b/fs/xfs/xfs_inode.c
> > @@ -81,7 +81,7 @@ xfs_get_cowextsz_hint(
> >  	xfs_extlen_t		a, b;
> >  
> >  	a = 0;
> > -	if (ip->i_d.di_flags2 & XFS_DIFLAG2_COWEXTSIZE)
> > +	if (ip->i_diflags2 & XFS_DIFLAG2_COWEXTSIZE)
> >  		a = ip->i_cowextsize;
> >  	b = xfs_get_extsz_hint(ip);
> >  
> > @@ -671,9 +671,7 @@ uint
> >  xfs_ip2xflags(
> >  	struct xfs_inode	*ip)
> >  {
> > -	struct xfs_icdinode	*dic = &ip->i_d;
> > -
> > -	return _xfs_dic2xflags(ip->i_diflags, dic->di_flags2, XFS_IFORK_Q(ip));
> > +	return _xfs_dic2xflags(ip->i_diflags, ip->i_diflags2, XFS_IFORK_Q(ip));
> >  }
> >  
> >  /*
> > @@ -841,7 +839,7 @@ xfs_ialloc(
> >  
> >  	if (xfs_sb_version_has_v3inode(&mp->m_sb)) {
> >  		inode_set_iversion(inode, 1);
> > -		ip->i_d.di_flags2 = 0;
> > +		ip->i_diflags2 = 0;
> >  		ip->i_cowextsize = 0;
> >  		ip->i_d.di_crtime = tv;
> >  	}
> > @@ -898,13 +896,13 @@ xfs_ialloc(
> >  
> >  			ip->i_diflags |= di_flags;
> >  		}
> > -		if (pip && (pip->i_d.di_flags2 & XFS_DIFLAG2_ANY)) {
> > -			if (pip->i_d.di_flags2 & XFS_DIFLAG2_COWEXTSIZE) {
> > -				ip->i_d.di_flags2 |= XFS_DIFLAG2_COWEXTSIZE;
> > +		if (pip && (pip->i_diflags2 & XFS_DIFLAG2_ANY)) {
> > +			if (pip->i_diflags2 & XFS_DIFLAG2_COWEXTSIZE) {
> > +				ip->i_diflags2 |= XFS_DIFLAG2_COWEXTSIZE;
> >  				ip->i_cowextsize = pip->i_cowextsize;
> >  			}
> > -			if (pip->i_d.di_flags2 & XFS_DIFLAG2_DAX)
> > -				ip->i_d.di_flags2 |= XFS_DIFLAG2_DAX;
> > +			if (pip->i_diflags2 & XFS_DIFLAG2_DAX)
> > +				ip->i_diflags2 |= XFS_DIFLAG2_DAX;
> >  		}
> >  		/* FALLTHROUGH */
> >  	case S_IFLNK:
> > @@ -1456,7 +1454,7 @@ xfs_itruncate_clear_reflink_flags(
> >  	dfork = XFS_IFORK_PTR(ip, XFS_DATA_FORK);
> >  	cfork = XFS_IFORK_PTR(ip, XFS_COW_FORK);
> >  	if (dfork->if_bytes == 0 && cfork->if_bytes == 0)
> > -		ip->i_d.di_flags2 &= ~XFS_DIFLAG2_REFLINK;
> > +		ip->i_diflags2 &= ~XFS_DIFLAG2_REFLINK;
> >  	if (cfork->if_bytes == 0)
> >  		xfs_inode_clear_cowblocks_tag(ip);
> >  }
> > @@ -2756,7 +2754,7 @@ xfs_ifree(
> >  
> >  	VFS_I(ip)->i_mode = 0;		/* mark incore inode as free */
> >  	ip->i_diflags = 0;
> > -	ip->i_d.di_flags2 = 0;
> > +	ip->i_diflags2 = 0;
> >  	ip->i_d.di_dmevmask = 0;
> >  	ip->i_forkoff = 0;		/* mark the attr fork not in use */
> >  	ip->i_df.if_format = XFS_DINODE_FMT_EXTENTS;
> > diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h
> > index 7673c841d89154..709f04fadde65e 100644
> > --- a/fs/xfs/xfs_inode.h
> > +++ b/fs/xfs/xfs_inode.h
> > @@ -65,6 +65,7 @@ typedef struct xfs_inode {
> >  	};
> >  	uint8_t			i_forkoff;	/* attr fork offset >> 3 */
> >  	uint16_t		i_diflags;	/* XFS_DIFLAG_... */
> > +	uint64_t		i_diflags2;	/* XFS_DIFLAG2_... */
> >  
> >  	struct xfs_icdinode	i_d;		/* most of ondisk inode */
> >  
> > @@ -193,7 +194,7 @@ xfs_get_initial_prid(struct xfs_inode *dp)
> >  
> >  static inline bool xfs_is_reflink_inode(struct xfs_inode *ip)
> >  {
> > -	return ip->i_d.di_flags2 & XFS_DIFLAG2_REFLINK;
> > +	return ip->i_diflags2 & XFS_DIFLAG2_REFLINK;
> >  }
> >  
> >  /*
> > diff --git a/fs/xfs/xfs_inode_item.c b/fs/xfs/xfs_inode_item.c
> > index 6af8e829dd0172..04e671d2957ca2 100644
> > --- a/fs/xfs/xfs_inode_item.c
> > +++ b/fs/xfs/xfs_inode_item.c
> > @@ -342,7 +342,7 @@ xfs_inode_to_log_dinode(
> >  		to->di_changecount = inode_peek_iversion(inode);
> >  		to->di_crtime.t_sec = from->di_crtime.tv_sec;
> >  		to->di_crtime.t_nsec = from->di_crtime.tv_nsec;
> > -		to->di_flags2 = from->di_flags2;
> > +		to->di_flags2 = ip->i_diflags2;
> >  		to->di_cowextsize = ip->i_cowextsize;
> >  		to->di_ino = ip->i_ino;
> >  		to->di_lsn = lsn;
> > diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
> > index 326991f4d98096..d05b86e7930e84 100644
> > --- a/fs/xfs/xfs_ioctl.c
> > +++ b/fs/xfs/xfs_ioctl.c
> > @@ -1110,7 +1110,7 @@ xfs_fill_fsxattr(
> >  	simple_fill_fsxattr(fa, xfs_ip2xflags(ip));
> >  	fa->fsx_extsize = XFS_FSB_TO_B(mp, ip->i_extsize);
> >  	if (xfs_sb_version_has_v3inode(&mp->m_sb) &&
> > -	    (ip->i_d.di_flags2 & XFS_DIFLAG2_COWEXTSIZE))
> > +	    (ip->i_diflags2 & XFS_DIFLAG2_COWEXTSIZE))
> >  		fa->fsx_cowextsize = XFS_FSB_TO_B(mp, ip->i_cowextsize);
> >  	fa->fsx_projid = ip->i_projid;
> >  	if (ifp && (ifp->if_flags & XFS_IFEXTENTS))
> > @@ -1183,15 +1183,14 @@ xfs_flags2diflags2(
> >  	struct xfs_inode	*ip,
> >  	unsigned int		xflags)
> >  {
> > -	uint64_t		di_flags2 =
> > -		(ip->i_d.di_flags2 & XFS_DIFLAG2_REFLINK);
> > +	uint64_t		i_flags2 = (ip->i_diflags2 & XFS_DIFLAG2_REFLINK);
> >  
> >  	if (xflags & FS_XFLAG_DAX)
> > -		di_flags2 |= XFS_DIFLAG2_DAX;
> > +		i_flags2 |= XFS_DIFLAG2_DAX;
> >  	if (xflags & FS_XFLAG_COWEXTSIZE)
> > -		di_flags2 |= XFS_DIFLAG2_COWEXTSIZE;
> > +		i_flags2 |= XFS_DIFLAG2_COWEXTSIZE;
> >  
> > -	return di_flags2;
> > +	return i_flags2;
> >  }
> >  
> >  static int
> > @@ -1201,7 +1200,7 @@ xfs_ioctl_setattr_xflags(
> >  	struct fsxattr		*fa)
> >  {
> >  	struct xfs_mount	*mp = ip->i_mount;
> > -	uint64_t		di_flags2;
> > +	uint64_t		i_flags2;
> >  
> >  	/* Can't change realtime flag if any extents are allocated. */
> >  	if ((ip->i_df.if_nextents || ip->i_delayed_blks) &&
> > @@ -1217,19 +1216,19 @@ xfs_ioctl_setattr_xflags(
> >  
> >  	/* Clear reflink if we are actually able to set the rt flag. */
> >  	if ((fa->fsx_xflags & FS_XFLAG_REALTIME) && xfs_is_reflink_inode(ip))
> > -		ip->i_d.di_flags2 &= ~XFS_DIFLAG2_REFLINK;
> > +		ip->i_diflags2 &= ~XFS_DIFLAG2_REFLINK;
> >  
> >  	/* Don't allow us to set DAX mode for a reflinked file for now. */
> >  	if ((fa->fsx_xflags & FS_XFLAG_DAX) && xfs_is_reflink_inode(ip))
> >  		return -EINVAL;
> >  
> >  	/* diflags2 only valid for v3 inodes. */
> > -	di_flags2 = xfs_flags2diflags2(ip, fa->fsx_xflags);
> > -	if (di_flags2 && !xfs_sb_version_has_v3inode(&mp->m_sb))
> > +	i_flags2 = xfs_flags2diflags2(ip, fa->fsx_xflags);
> > +	if (i_flags2 && !xfs_sb_version_has_v3inode(&mp->m_sb))
> >  		return -EINVAL;
> >  
> >  	ip->i_diflags = xfs_flags2diflags(ip, fa->fsx_xflags);
> > -	ip->i_d.di_flags2 = di_flags2;
> > +	ip->i_diflags2 = i_flags2;
> >  
> >  	xfs_diflags_to_iflags(ip, false);
> >  	xfs_trans_ichgtime(tp, ip, XFS_ICHGTIME_CHG);
> > @@ -1575,7 +1574,7 @@ xfs_ioctl_setattr(
> >  	else
> >  		ip->i_extsize = 0;
> >  	if (xfs_sb_version_has_v3inode(&mp->m_sb) &&
> > -	    (ip->i_d.di_flags2 & XFS_DIFLAG2_COWEXTSIZE))
> > +	    (ip->i_diflags2 & XFS_DIFLAG2_COWEXTSIZE))
> >  		ip->i_cowextsize = fa->fsx_cowextsize >> mp->m_sb.sb_blocklog;
> >  	else
> >  		ip->i_cowextsize = 0;
> > diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
> > index f37154fc9828fd..3642f9935cae3f 100644
> > --- a/fs/xfs/xfs_iops.c
> > +++ b/fs/xfs/xfs_iops.c
> > @@ -1265,7 +1265,7 @@ xfs_inode_should_enable_dax(
> >  		return false;
> >  	if (ip->i_mount->m_flags & XFS_MOUNT_DAX_ALWAYS)
> >  		return true;
> > -	if (ip->i_d.di_flags2 & XFS_DIFLAG2_DAX)
> > +	if (ip->i_diflags2 & XFS_DIFLAG2_DAX)
> >  		return true;
> >  	return false;
> >  }
> > diff --git a/fs/xfs/xfs_itable.c b/fs/xfs/xfs_itable.c
> > index 7937af9f2ea779..4d1509437c3576 100644
> > --- a/fs/xfs/xfs_itable.c
> > +++ b/fs/xfs/xfs_itable.c
> > @@ -111,7 +111,7 @@ xfs_bulkstat_one_int(
> >  	buf->bs_version = XFS_BULKSTAT_VERSION_V5;
> >  
> >  	if (xfs_sb_version_has_v3inode(&mp->m_sb)) {
> > -		if (dic->di_flags2 & XFS_DIFLAG2_COWEXTSIZE)
> > +		if (ip->i_diflags2 & XFS_DIFLAG2_COWEXTSIZE)
> >  			buf->bs_cowextsize_blks = ip->i_cowextsize;
> >  	}
> >  
> > diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c
> > index 0e07fa7e43117e..476ba54d84a9a3 100644
> > --- a/fs/xfs/xfs_reflink.c
> > +++ b/fs/xfs/xfs_reflink.c
> > @@ -882,7 +882,7 @@ xfs_reflink_set_inode_flag(
> >  	if (!xfs_is_reflink_inode(src)) {
> >  		trace_xfs_reflink_set_inode_flag(src);
> >  		xfs_trans_ijoin(tp, src, XFS_ILOCK_EXCL);
> > -		src->i_d.di_flags2 |= XFS_DIFLAG2_REFLINK;
> > +		src->i_diflags2 |= XFS_DIFLAG2_REFLINK;
> >  		xfs_trans_log_inode(tp, src, XFS_ILOG_CORE);
> >  		xfs_ifork_init_cow(src);
> >  	} else
> > @@ -894,7 +894,7 @@ xfs_reflink_set_inode_flag(
> >  	if (!xfs_is_reflink_inode(dest)) {
> >  		trace_xfs_reflink_set_inode_flag(dest);
> >  		xfs_trans_ijoin(tp, dest, XFS_ILOCK_EXCL);
> > -		dest->i_d.di_flags2 |= XFS_DIFLAG2_REFLINK;
> > +		dest->i_diflags2 |= XFS_DIFLAG2_REFLINK;
> >  		xfs_trans_log_inode(tp, dest, XFS_ILOG_CORE);
> >  		xfs_ifork_init_cow(dest);
> >  	} else
> > @@ -943,7 +943,7 @@ xfs_reflink_update_dest(
> >  
> >  	if (cowextsize) {
> >  		dest->i_cowextsize = cowextsize;
> > -		dest->i_d.di_flags2 |= XFS_DIFLAG2_COWEXTSIZE;
> > +		dest->i_diflags2 |= XFS_DIFLAG2_COWEXTSIZE;
> >  	}
> >  
> >  	xfs_trans_log_inode(tp, dest, XFS_ILOG_CORE);
> > @@ -1463,7 +1463,7 @@ xfs_reflink_clear_inode_flag(
> >  
> >  	/* Clear the inode flag. */
> >  	trace_xfs_reflink_unset_inode_flag(ip);
> > -	ip->i_d.di_flags2 &= ~XFS_DIFLAG2_REFLINK;
> > +	ip->i_diflags2 &= ~XFS_DIFLAG2_REFLINK;
> >  	xfs_inode_clear_cowblocks_tag(ip);
> >  	xfs_trans_log_inode(*tpp, ip, XFS_ILOG_CORE);
> >  
> > 
> 
> 
> 


-- 
chandan




^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH 12/15] xfs: move the di_flags2 field to struct xfs_inode
  2020-06-22 13:23     ` Chandan Babu R
@ 2020-06-24  7:25       ` Christoph Hellwig
  2020-06-24 14:03         ` Darrick J. Wong
  0 siblings, 1 reply; 52+ messages in thread
From: Christoph Hellwig @ 2020-06-24  7:25 UTC (permalink / raw)
  To: Chandan Babu R, Darrick J. Wong; +Cc: Christoph Hellwig, linux-xfs

On Mon, Jun 22, 2020 at 06:53:23PM +0530, Chandan Babu R wrote:
> On Monday 22 June 2020 6:21:37 PM IST Chandan Babu R wrote:
> > On Saturday 20 June 2020 12:40:59 PM IST Christoph Hellwig wrote:
> > > In preparation of removing the historic icinode struct, move the flags2
> > > field into the containing xfs_inode structure.
> > >
> > 
> > The changes look good to me.
> > 
> > Reviewed-by: Chandan Babu R <chandanrlinux@gmail.com>
> 
> The commit "fs/xfs: Update xfs_ioctl_setattr_dax_invalidate()"
> (e4f9ba20d3b8c2b86ec71f326882e1a3c4e47953) adds the function
> xfs_ioctl_setattr_prepare_dax() which refers to xfs_icdinode->di_flags2. A
> rebase should solve this issue.

That doesn't exist in xfs/for-next yet.  Darrick, do you want me to
rebase on top of Linus' tree?

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH 12/15] xfs: move the di_flags2 field to struct xfs_inode
  2020-06-24  7:25       ` Christoph Hellwig
@ 2020-06-24 14:03         ` Darrick J. Wong
  2020-06-24 14:10           ` Christoph Hellwig
  0 siblings, 1 reply; 52+ messages in thread
From: Darrick J. Wong @ 2020-06-24 14:03 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: Chandan Babu R, linux-xfs

On Wed, Jun 24, 2020 at 09:25:37AM +0200, Christoph Hellwig wrote:
> On Mon, Jun 22, 2020 at 06:53:23PM +0530, Chandan Babu R wrote:
> > On Monday 22 June 2020 6:21:37 PM IST Chandan Babu R wrote:
> > > On Saturday 20 June 2020 12:40:59 PM IST Christoph Hellwig wrote:
> > > > In preparation of removing the historic icinode struct, move the flags2
> > > > field into the containing xfs_inode structure.
> > > >
> > > 
> > > The changes look good to me.
> > > 
> > > Reviewed-by: Chandan Babu R <chandanrlinux@gmail.com>
> > 
> > The commit "fs/xfs: Update xfs_ioctl_setattr_dax_invalidate()"
> > (e4f9ba20d3b8c2b86ec71f326882e1a3c4e47953) adds the function
> > xfs_ioctl_setattr_prepare_dax() which refers to xfs_icdinode->di_flags2. A
> > rebase should solve this issue.
> 
> That doesn't exist in xfs/for-next yet.  Darrick, do you want me to
> rebase on top of Linus' tree?

Sure?  I haven't really started working on 5.8 fixes branches yet,
but I'll fast-forward for-next up to 5.8-rc1.

--D

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH 12/15] xfs: move the di_flags2 field to struct xfs_inode
  2020-06-24 14:03         ` Darrick J. Wong
@ 2020-06-24 14:10           ` Christoph Hellwig
  0 siblings, 0 replies; 52+ messages in thread
From: Christoph Hellwig @ 2020-06-24 14:10 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: Christoph Hellwig, Chandan Babu R, linux-xfs

On Wed, Jun 24, 2020 at 07:03:25AM -0700, Darrick J. Wong wrote:
> On Wed, Jun 24, 2020 at 09:25:37AM +0200, Christoph Hellwig wrote:
> > On Mon, Jun 22, 2020 at 06:53:23PM +0530, Chandan Babu R wrote:
> > > On Monday 22 June 2020 6:21:37 PM IST Chandan Babu R wrote:
> > > > On Saturday 20 June 2020 12:40:59 PM IST Christoph Hellwig wrote:
> > > > > In preparation of removing the historic icinode struct, move the flags2
> > > > > field into the containing xfs_inode structure.
> > > > >
> > > > 
> > > > The changes look good to me.
> > > > 
> > > > Reviewed-by: Chandan Babu R <chandanrlinux@gmail.com>
> > > 
> > > The commit "fs/xfs: Update xfs_ioctl_setattr_dax_invalidate()"
> > > (e4f9ba20d3b8c2b86ec71f326882e1a3c4e47953) adds the function
> > > xfs_ioctl_setattr_prepare_dax() which refers to xfs_icdinode->di_flags2. A
> > > rebase should solve this issue.
> > 
> > That doesn't exist in xfs/for-next yet.  Darrick, do you want me to
> > rebase on top of Linus' tree?
> 
> Sure?  I haven't really started working on 5.8 fixes branches yet,
> but I'll fast-forward for-next up to 5.8-rc1.

I can also wait a bit.  Note that we're at -rc2 and half-way to rc3 :)


^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH 02/15] xfs: move the di_projid field to struct xfs_inode
  2020-06-20  7:10 ` [PATCH 02/15] xfs: move the di_projid field to struct xfs_inode Christoph Hellwig
  2020-06-22  7:55   ` Chandan Babu R
@ 2020-06-30 17:44   ` Darrick J. Wong
  1 sibling, 0 replies; 52+ messages in thread
From: Darrick J. Wong @ 2020-06-30 17:44 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: linux-xfs

On Sat, Jun 20, 2020 at 09:10:49AM +0200, Christoph Hellwig wrote:
> In preparation of removing the historic icinode struct, move the projid
> field into the containing xfs_inode structure.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>

Looks pretty straightforward,
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>

--D

> ---
>  fs/xfs/libxfs/xfs_inode_buf.c | 8 ++++----
>  fs/xfs/libxfs/xfs_inode_buf.h | 1 -
>  fs/xfs/xfs_bmap_util.c        | 2 +-
>  fs/xfs/xfs_dquot.c            | 2 +-
>  fs/xfs/xfs_icache.c           | 4 ++--
>  fs/xfs/xfs_inode.c            | 6 +++---
>  fs/xfs/xfs_inode.h            | 3 ++-
>  fs/xfs/xfs_inode_item.c       | 4 ++--
>  fs/xfs/xfs_ioctl.c            | 8 ++++----
>  fs/xfs/xfs_iops.c             | 2 +-
>  fs/xfs/xfs_itable.c           | 2 +-
>  fs/xfs/xfs_qm.c               | 8 ++++----
>  fs/xfs/xfs_qm_bhv.c           | 2 +-
>  13 files changed, 26 insertions(+), 26 deletions(-)
> 
> diff --git a/fs/xfs/libxfs/xfs_inode_buf.c b/fs/xfs/libxfs/xfs_inode_buf.c
> index 6f84ea85fdd837..b064cb8072c84a 100644
> --- a/fs/xfs/libxfs/xfs_inode_buf.c
> +++ b/fs/xfs/libxfs/xfs_inode_buf.c
> @@ -218,10 +218,10 @@ xfs_inode_from_disk(
>  	 */
>  	if (unlikely(from->di_version == 1)) {
>  		set_nlink(inode, be16_to_cpu(from->di_onlink));
> -		to->di_projid = 0;
> +		ip->i_projid = 0;
>  	} else {
>  		set_nlink(inode, be32_to_cpu(from->di_nlink));
> -		to->di_projid = (prid_t)be16_to_cpu(from->di_projid_hi) << 16 |
> +		ip->i_projid = (prid_t)be16_to_cpu(from->di_projid_hi) << 16 |
>  					be16_to_cpu(from->di_projid_lo);
>  	}
>  
> @@ -290,8 +290,8 @@ xfs_inode_to_disk(
>  	to->di_format = xfs_ifork_format(&ip->i_df);
>  	to->di_uid = cpu_to_be32(i_uid_read(inode));
>  	to->di_gid = cpu_to_be32(i_gid_read(inode));
> -	to->di_projid_lo = cpu_to_be16(from->di_projid & 0xffff);
> -	to->di_projid_hi = cpu_to_be16(from->di_projid >> 16);
> +	to->di_projid_lo = cpu_to_be16(ip->i_projid & 0xffff);
> +	to->di_projid_hi = cpu_to_be16(ip->i_projid >> 16);
>  
>  	memset(to->di_pad, 0, sizeof(to->di_pad));
>  	to->di_atime.t_sec = cpu_to_be32(inode->i_atime.tv_sec);
> diff --git a/fs/xfs/libxfs/xfs_inode_buf.h b/fs/xfs/libxfs/xfs_inode_buf.h
> index 865ac493c72a24..b826d81b356956 100644
> --- a/fs/xfs/libxfs/xfs_inode_buf.h
> +++ b/fs/xfs/libxfs/xfs_inode_buf.h
> @@ -17,7 +17,6 @@ struct xfs_dinode;
>   */
>  struct xfs_icdinode {
>  	uint16_t	di_flushiter;	/* incremented on flush */
> -	uint32_t	di_projid;	/* owner's project id */
>  	xfs_fsize_t	di_size;	/* number of bytes in file */
>  	xfs_rfsblock_t	di_nblocks;	/* # of direct & btree blocks used */
>  	xfs_extlen_t	di_extsize;	/* basic/minimum extent size for file */
> diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c
> index f37f5cc4b19ffe..e42553884c23cf 100644
> --- a/fs/xfs/xfs_bmap_util.c
> +++ b/fs/xfs/xfs_bmap_util.c
> @@ -1217,7 +1217,7 @@ xfs_swap_extents_check_format(
>  	if (XFS_IS_QUOTA_ON(ip->i_mount) &&
>  	    (!uid_eq(VFS_I(ip)->i_uid, VFS_I(tip)->i_uid) ||
>  	     !gid_eq(VFS_I(ip)->i_gid, VFS_I(tip)->i_gid) ||
> -	     ip->i_d.di_projid != tip->i_d.di_projid))
> +	     ip->i_projid != tip->i_projid))
>  		return -EINVAL;
>  
>  	/* Should never get a local format */
> diff --git a/fs/xfs/xfs_dquot.c b/fs/xfs/xfs_dquot.c
> index d5b7f03e93c8db..912b978a6a72d5 100644
> --- a/fs/xfs/xfs_dquot.c
> +++ b/fs/xfs/xfs_dquot.c
> @@ -868,7 +868,7 @@ xfs_qm_id_for_quotatype(
>  	case XFS_DQ_GROUP:
>  		return i_gid_read(VFS_I(ip));
>  	case XFS_DQ_PROJ:
> -		return ip->i_d.di_projid;
> +		return ip->i_projid;
>  	}
>  	ASSERT(0);
>  	return 0;
> diff --git a/fs/xfs/xfs_icache.c b/fs/xfs/xfs_icache.c
> index 660e7abd4e8b76..a3bbd6e4bb6fc8 100644
> --- a/fs/xfs/xfs_icache.c
> +++ b/fs/xfs/xfs_icache.c
> @@ -1439,7 +1439,7 @@ xfs_inode_match_id(
>  		return false;
>  
>  	if ((eofb->eof_flags & XFS_EOF_FLAGS_PRID) &&
> -	    ip->i_d.di_projid != eofb->eof_prid)
> +	    ip->i_projid != eofb->eof_prid)
>  		return false;
>  
>  	return true;
> @@ -1463,7 +1463,7 @@ xfs_inode_match_id_union(
>  		return true;
>  
>  	if ((eofb->eof_flags & XFS_EOF_FLAGS_PRID) &&
> -	    ip->i_d.di_projid == eofb->eof_prid)
> +	    ip->i_projid == eofb->eof_prid)
>  		return true;
>  
>  	return false;
> diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
> index 88a9e496480216..40e4d3ed29a798 100644
> --- a/fs/xfs/xfs_inode.c
> +++ b/fs/xfs/xfs_inode.c
> @@ -806,7 +806,7 @@ xfs_ialloc(
>  	set_nlink(inode, nlink);
>  	inode->i_uid = current_fsuid();
>  	inode->i_rdev = rdev;
> -	ip->i_d.di_projid = prid;
> +	ip->i_projid = prid;
>  
>  	if (pip && XFS_INHERIT_GID(pip)) {
>  		inode->i_gid = VFS_I(pip)->i_gid;
> @@ -1398,7 +1398,7 @@ xfs_link(
>  	 * the tree quota mechanism could be circumvented.
>  	 */
>  	if (unlikely((tdp->i_d.di_flags & XFS_DIFLAG_PROJINHERIT) &&
> -		     tdp->i_d.di_projid != sip->i_d.di_projid)) {
> +		     tdp->i_projid != sip->i_projid)) {
>  		error = -EXDEV;
>  		goto error_return;
>  	}
> @@ -3264,7 +3264,7 @@ xfs_rename(
>  	 * tree quota mechanism would be circumvented.
>  	 */
>  	if (unlikely((target_dp->i_d.di_flags & XFS_DIFLAG_PROJINHERIT) &&
> -		     target_dp->i_d.di_projid != src_ip->i_d.di_projid)) {
> +		     target_dp->i_projid != src_ip->i_projid)) {
>  		error = -EXDEV;
>  		goto out_trans_cancel;
>  	}
> diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h
> index dadcf19458960d..51ea9d53407863 100644
> --- a/fs/xfs/xfs_inode.h
> +++ b/fs/xfs/xfs_inode.h
> @@ -54,6 +54,7 @@ typedef struct xfs_inode {
>  	/* Miscellaneous state. */
>  	unsigned long		i_flags;	/* see defined flags below */
>  	uint64_t		i_delayed_blks;	/* count of delay alloc blks */
> +	uint32_t		i_projid;	/* owner's project id */
>  
>  	struct xfs_icdinode	i_d;		/* most of ondisk inode */
>  
> @@ -175,7 +176,7 @@ static inline prid_t
>  xfs_get_initial_prid(struct xfs_inode *dp)
>  {
>  	if (dp->i_d.di_flags & XFS_DIFLAG_PROJINHERIT)
> -		return dp->i_d.di_projid;
> +		return dp->i_projid;
>  
>  	return XFS_PROJID_DEFAULT;
>  }
> diff --git a/fs/xfs/xfs_inode_item.c b/fs/xfs/xfs_inode_item.c
> index ba47bf65b772be..e546b4b58ce2e0 100644
> --- a/fs/xfs/xfs_inode_item.c
> +++ b/fs/xfs/xfs_inode_item.c
> @@ -308,8 +308,8 @@ xfs_inode_to_log_dinode(
>  	to->di_format = xfs_ifork_format(&ip->i_df);
>  	to->di_uid = i_uid_read(inode);
>  	to->di_gid = i_gid_read(inode);
> -	to->di_projid_lo = from->di_projid & 0xffff;
> -	to->di_projid_hi = from->di_projid >> 16;
> +	to->di_projid_lo = ip->i_projid & 0xffff;
> +	to->di_projid_hi = ip->i_projid >> 16;
>  
>  	memset(to->di_pad, 0, sizeof(to->di_pad));
>  	memset(to->di_pad3, 0, sizeof(to->di_pad3));
> diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
> index a40f88cf3ab786..d93f4fc40fd99e 100644
> --- a/fs/xfs/xfs_ioctl.c
> +++ b/fs/xfs/xfs_ioctl.c
> @@ -1110,7 +1110,7 @@ xfs_fill_fsxattr(
>  	fa->fsx_extsize = ip->i_d.di_extsize << ip->i_mount->m_sb.sb_blocklog;
>  	fa->fsx_cowextsize = ip->i_d.di_cowextsize <<
>  			ip->i_mount->m_sb.sb_blocklog;
> -	fa->fsx_projid = ip->i_d.di_projid;
> +	fa->fsx_projid = ip->i_projid;
>  	if (ifp && (ifp->if_flags & XFS_IFEXTENTS))
>  		fa->fsx_nextents = xfs_iext_count(ifp);
>  	else
> @@ -1518,7 +1518,7 @@ xfs_ioctl_setattr(
>  	}
>  
>  	if (XFS_IS_QUOTA_RUNNING(mp) && XFS_IS_PQUOTA_ON(mp) &&
> -	    ip->i_d.di_projid != fa->fsx_projid) {
> +	    ip->i_projid != fa->fsx_projid) {
>  		code = xfs_qm_vop_chown_reserve(tp, ip, NULL, NULL, pdqp,
>  				capable(CAP_FOWNER) ?  XFS_QMOPT_FORCE_RES : 0);
>  		if (code)	/* out of quota */
> @@ -1555,12 +1555,12 @@ xfs_ioctl_setattr(
>  		VFS_I(ip)->i_mode &= ~(S_ISUID|S_ISGID);
>  
>  	/* Change the ownerships and register project quota modifications */
> -	if (ip->i_d.di_projid != fa->fsx_projid) {
> +	if (ip->i_projid != fa->fsx_projid) {
>  		if (XFS_IS_QUOTA_RUNNING(mp) && XFS_IS_PQUOTA_ON(mp)) {
>  			olddquot = xfs_qm_vop_chown(tp, ip,
>  						&ip->i_pdquot, pdqp);
>  		}
> -		ip->i_d.di_projid = fa->fsx_projid;
> +		ip->i_projid = fa->fsx_projid;
>  	}
>  
>  	/*
> diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
> index d66528fa365707..5440f555c9cc2c 100644
> --- a/fs/xfs/xfs_iops.c
> +++ b/fs/xfs/xfs_iops.c
> @@ -696,7 +696,7 @@ xfs_setattr_nonsize(
>  		 */
>  		ASSERT(udqp == NULL);
>  		ASSERT(gdqp == NULL);
> -		error = xfs_qm_vop_dqalloc(ip, uid, gid, ip->i_d.di_projid,
> +		error = xfs_qm_vop_dqalloc(ip, uid, gid, ip->i_projid,
>  					   qflags, &udqp, &gdqp, NULL);
>  		if (error)
>  			return error;
> diff --git a/fs/xfs/xfs_itable.c b/fs/xfs/xfs_itable.c
> index 16ca97a7ff00fb..97b3b794dd4ada 100644
> --- a/fs/xfs/xfs_itable.c
> +++ b/fs/xfs/xfs_itable.c
> @@ -84,7 +84,7 @@ xfs_bulkstat_one_int(
>  	/* xfs_iget returns the following without needing
>  	 * further change.
>  	 */
> -	buf->bs_projectid = ip->i_d.di_projid;
> +	buf->bs_projectid = ip->i_projid;
>  	buf->bs_ino = ino;
>  	buf->bs_uid = i_uid_read(inode);
>  	buf->bs_gid = i_gid_read(inode);
> diff --git a/fs/xfs/xfs_qm.c b/fs/xfs/xfs_qm.c
> index d6cd833173447a..ea22dcf868b474 100644
> --- a/fs/xfs/xfs_qm.c
> +++ b/fs/xfs/xfs_qm.c
> @@ -346,7 +346,7 @@ xfs_qm_dqattach_locked(
>  	}
>  
>  	if (XFS_IS_PQUOTA_ON(mp) && !ip->i_pdquot) {
> -		error = xfs_qm_dqattach_one(ip, ip->i_d.di_projid, XFS_DQ_PROJ,
> +		error = xfs_qm_dqattach_one(ip, ip->i_projid, XFS_DQ_PROJ,
>  				doalloc, &ip->i_pdquot);
>  		if (error)
>  			goto done;
> @@ -1711,7 +1711,7 @@ xfs_qm_vop_dqalloc(
>  		}
>  	}
>  	if ((flags & XFS_QMOPT_PQUOTA) && XFS_IS_PQUOTA_ON(mp)) {
> -		if (ip->i_d.di_projid != prid) {
> +		if (ip->i_projid != prid) {
>  			xfs_iunlock(ip, lockflags);
>  			error = xfs_qm_dqget(mp, (xfs_dqid_t)prid, XFS_DQ_PROJ,
>  					true, &pq);
> @@ -1844,7 +1844,7 @@ xfs_qm_vop_chown_reserve(
>  	}
>  
>  	if (XFS_IS_PQUOTA_ON(ip->i_mount) && pdqp &&
> -	    ip->i_d.di_projid != be32_to_cpu(pdqp->q_core.d_id)) {
> +	    ip->i_projid != be32_to_cpu(pdqp->q_core.d_id)) {
>  		pdq_delblks = pdqp;
>  		if (delblks) {
>  			ASSERT(ip->i_pdquot);
> @@ -1942,7 +1942,7 @@ xfs_qm_vop_create_dqattach(
>  	}
>  	if (pdqp && XFS_IS_PQUOTA_ON(mp)) {
>  		ASSERT(ip->i_pdquot == NULL);
> -		ASSERT(ip->i_d.di_projid == be32_to_cpu(pdqp->q_core.d_id));
> +		ASSERT(ip->i_projid == be32_to_cpu(pdqp->q_core.d_id));
>  
>  		ip->i_pdquot = xfs_qm_dqhold(pdqp);
>  		xfs_trans_mod_dquot(tp, pdqp, XFS_TRANS_DQ_ICOUNT, 1);
> diff --git a/fs/xfs/xfs_qm_bhv.c b/fs/xfs/xfs_qm_bhv.c
> index fc2fa418919f7f..b616ad772a6df8 100644
> --- a/fs/xfs/xfs_qm_bhv.c
> +++ b/fs/xfs/xfs_qm_bhv.c
> @@ -60,7 +60,7 @@ xfs_qm_statvfs(
>  	struct xfs_mount	*mp = ip->i_mount;
>  	struct xfs_dquot	*dqp;
>  
> -	if (!xfs_qm_dqget(mp, ip->i_d.di_projid, XFS_DQ_PROJ, false, &dqp)) {
> +	if (!xfs_qm_dqget(mp, ip->i_projid, XFS_DQ_PROJ, false, &dqp)) {
>  		xfs_fill_statvfs_from_dquot(statp, dqp);
>  		xfs_qm_dqput(dqp);
>  	}
> -- 
> 2.26.2
> 

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH 03/15] xfs: move the di_size field to struct xfs_inode
  2020-06-20  7:10 ` [PATCH 03/15] xfs: move the di_size " Christoph Hellwig
  2020-06-22  9:24   ` Chandan Babu R
@ 2020-06-30 17:45   ` Darrick J. Wong
  1 sibling, 0 replies; 52+ messages in thread
From: Darrick J. Wong @ 2020-06-30 17:45 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: linux-xfs

On Sat, Jun 20, 2020 at 07:10:50AM +0000, Christoph Hellwig wrote:
> In preparation of removing the historic icinode struct, move the on-disk
> size field into the containing xfs_inode structure.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>

Looks ok to me,
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>

--D

> ---
>  fs/xfs/libxfs/xfs_bmap.c       |  2 +-
>  fs/xfs/libxfs/xfs_dir2.c       | 14 +++++------
>  fs/xfs/libxfs/xfs_dir2_block.c | 10 ++++----
>  fs/xfs/libxfs/xfs_dir2_leaf.c  |  2 +-
>  fs/xfs/libxfs/xfs_dir2_node.c  |  2 +-
>  fs/xfs/libxfs/xfs_dir2_sf.c    | 46 +++++++++++++++++-----------------
>  fs/xfs/libxfs/xfs_inode_buf.c  |  4 +--
>  fs/xfs/libxfs/xfs_inode_buf.h  |  1 -
>  fs/xfs/libxfs/xfs_inode_fork.c |  2 +-
>  fs/xfs/scrub/dir.c             |  6 ++---
>  fs/xfs/scrub/parent.c          |  2 +-
>  fs/xfs/scrub/symlink.c         |  2 +-
>  fs/xfs/xfs_aops.c              |  4 +--
>  fs/xfs/xfs_bmap_util.c         |  6 ++---
>  fs/xfs/xfs_dir2_readdir.c      |  2 +-
>  fs/xfs/xfs_file.c              |  2 +-
>  fs/xfs/xfs_inode.c             |  8 +++---
>  fs/xfs/xfs_inode.h             |  5 ++--
>  fs/xfs/xfs_inode_item.c        |  4 +--
>  fs/xfs/xfs_iomap.c             |  2 +-
>  fs/xfs/xfs_iops.c              | 12 ++++-----
>  fs/xfs/xfs_itable.c            |  2 +-
>  fs/xfs/xfs_pnfs.c              |  2 +-
>  fs/xfs/xfs_qm_syscalls.c       |  2 +-
>  fs/xfs/xfs_reflink.c           |  4 +--
>  fs/xfs/xfs_rtalloc.c           |  8 +++---
>  fs/xfs/xfs_symlink.c           | 16 ++++++------
>  fs/xfs/xfs_trace.h             | 16 ++++++------
>  28 files changed, 94 insertions(+), 94 deletions(-)
> 
> diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
> index 667cdd0dfdf4a3..56d78f8ba55eb6 100644
> --- a/fs/xfs/libxfs/xfs_bmap.c
> +++ b/fs/xfs/libxfs/xfs_bmap.c
> @@ -1445,7 +1445,7 @@ xfs_bmap_last_offset(
>  
>  /*
>   * Returns whether the selected fork of the inode has exactly one
> - * block or not.  For the data fork we check this matches di_size,
> + * block or not.  For the data fork we check this matches i_disk_size,
>   * implying the file's range is 0..bsize-1.
>   */
>  int					/* 1=>1 block, 0=>otherwise */
> diff --git a/fs/xfs/libxfs/xfs_dir2.c b/fs/xfs/libxfs/xfs_dir2.c
> index 612a9c5e41b1c6..050bdcc4fe7376 100644
> --- a/fs/xfs/libxfs/xfs_dir2.c
> +++ b/fs/xfs/libxfs/xfs_dir2.c
> @@ -179,9 +179,9 @@ xfs_dir_isempty(
>  	xfs_dir2_sf_hdr_t	*sfp;
>  
>  	ASSERT(S_ISDIR(VFS_I(dp)->i_mode));
> -	if (dp->i_d.di_size == 0)	/* might happen during shutdown. */
> +	if (dp->i_disk_size == 0)	/* might happen during shutdown. */
>  		return 1;
> -	if (dp->i_d.di_size > XFS_IFORK_DSIZE(dp))
> +	if (dp->i_disk_size > XFS_IFORK_DSIZE(dp))
>  		return 0;
>  	sfp = (xfs_dir2_sf_hdr_t *)dp->i_df.if_u1.if_data;
>  	return !sfp->count;
> @@ -584,8 +584,8 @@ xfs_dir2_grow_inode(
>  		xfs_fsize_t	size;		/* directory file (data) size */
>  
>  		size = XFS_FSB_TO_B(mp, bno + count);
> -		if (size > dp->i_d.di_size) {
> -			dp->i_d.di_size = size;
> +		if (size > dp->i_disk_size) {
> +			dp->i_disk_size = size;
>  			xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE);
>  		}
>  	}
> @@ -608,7 +608,7 @@ xfs_dir2_isblock(
>  	rval = XFS_FSB_TO_B(args->dp->i_mount, last) == args->geo->blksize;
>  	if (XFS_IS_CORRUPT(args->dp->i_mount,
>  			   rval != 0 &&
> -			   args->dp->i_d.di_size != args->geo->blksize))
> +			   args->dp->i_disk_size != args->geo->blksize))
>  		return -EFSCORRUPTED;
>  	*vp = rval;
>  	return 0;
> @@ -687,7 +687,7 @@ xfs_dir2_shrink_inode(
>  	/*
>  	 * If the block isn't the last one in the directory, we're done.
>  	 */
> -	if (dp->i_d.di_size > xfs_dir2_db_off_to_byte(args->geo, db + 1, 0))
> +	if (dp->i_disk_size > xfs_dir2_db_off_to_byte(args->geo, db + 1, 0))
>  		return 0;
>  	bno = da;
>  	if ((error = xfs_bmap_last_before(tp, dp, &bno, XFS_DATA_FORK))) {
> @@ -703,7 +703,7 @@ xfs_dir2_shrink_inode(
>  	/*
>  	 * Set the size to the new last block.
>  	 */
> -	dp->i_d.di_size = XFS_FSB_TO_B(mp, bno);
> +	dp->i_disk_size = XFS_FSB_TO_B(mp, bno);
>  	xfs_trans_log_inode(tp, dp, XFS_ILOG_CORE);
>  	return 0;
>  }
> diff --git a/fs/xfs/libxfs/xfs_dir2_block.c b/fs/xfs/libxfs/xfs_dir2_block.c
> index 5b59d3f7746b34..7824af54637513 100644
> --- a/fs/xfs/libxfs/xfs_dir2_block.c
> +++ b/fs/xfs/libxfs/xfs_dir2_block.c
> @@ -961,7 +961,7 @@ xfs_dir2_leaf_to_block(
>  	 * been left behind during no-space-reservation operations.
>  	 * These will show up in the leaf bests table.
>  	 */
> -	while (dp->i_d.di_size > args->geo->blksize) {
> +	while (dp->i_disk_size > args->geo->blksize) {
>  		int hdrsz;
>  
>  		hdrsz = args->geo->data_entry_offset;
> @@ -1097,13 +1097,13 @@ xfs_dir2_sf_to_block(
>  	trace_xfs_dir2_sf_to_block(args);
>  
>  	ASSERT(ifp->if_flags & XFS_IFINLINE);
> -	ASSERT(dp->i_d.di_size >= offsetof(struct xfs_dir2_sf_hdr, parent));
> +	ASSERT(dp->i_disk_size >= offsetof(struct xfs_dir2_sf_hdr, parent));
>  
>  	oldsfp = (xfs_dir2_sf_hdr_t *)ifp->if_u1.if_data;
>  
> -	ASSERT(ifp->if_bytes == dp->i_d.di_size);
> +	ASSERT(ifp->if_bytes == dp->i_disk_size);
>  	ASSERT(ifp->if_u1.if_data != NULL);
> -	ASSERT(dp->i_d.di_size >= xfs_dir2_sf_hdr_size(oldsfp->i8count));
> +	ASSERT(dp->i_disk_size >= xfs_dir2_sf_hdr_size(oldsfp->i8count));
>  	ASSERT(dp->i_df.if_nextents == 0);
>  
>  	/*
> @@ -1115,7 +1115,7 @@ xfs_dir2_sf_to_block(
>  
>  	xfs_idata_realloc(dp, -ifp->if_bytes, XFS_DATA_FORK);
>  	xfs_bmap_local_to_extents_empty(tp, dp, XFS_DATA_FORK);
> -	dp->i_d.di_size = 0;
> +	dp->i_disk_size = 0;
>  
>  	/*
>  	 * Add block 0 to the inode.
> diff --git a/fs/xfs/libxfs/xfs_dir2_leaf.c b/fs/xfs/libxfs/xfs_dir2_leaf.c
> index 95d2a3f92d75de..73fb3e1152e6d7 100644
> --- a/fs/xfs/libxfs/xfs_dir2_leaf.c
> +++ b/fs/xfs/libxfs/xfs_dir2_leaf.c
> @@ -151,7 +151,7 @@ xfs_dir3_leaf_check_int(
>  	/*
>  	 * XXX (dgc): This value is not restrictive enough.
>  	 * Should factor in the size of the bests table as well.
> -	 * We can deduce a value for that from di_size.
> +	 * We can deduce a value for that from i_disk_size.
>  	 */
>  	if (hdr->count > geo->leaf_max_ents)
>  		return __this_address;
> diff --git a/fs/xfs/libxfs/xfs_dir2_node.c b/fs/xfs/libxfs/xfs_dir2_node.c
> index 6ac4aad98cd76c..3698030ca5e2f7 100644
> --- a/fs/xfs/libxfs/xfs_dir2_node.c
> +++ b/fs/xfs/libxfs/xfs_dir2_node.c
> @@ -441,7 +441,7 @@ xfs_dir2_leaf_to_node(
>  	leaf = lbp->b_addr;
>  	ltp = xfs_dir2_leaf_tail_p(args->geo, leaf);
>  	if (be32_to_cpu(ltp->bestcount) >
> -				(uint)dp->i_d.di_size / args->geo->blksize) {
> +				(uint)dp->i_disk_size / args->geo->blksize) {
>  		xfs_buf_mark_corrupt(lbp);
>  		return -EFSCORRUPTED;
>  	}
> diff --git a/fs/xfs/libxfs/xfs_dir2_sf.c b/fs/xfs/libxfs/xfs_dir2_sf.c
> index 2463b5d7344724..00fee3943a09dc 100644
> --- a/fs/xfs/libxfs/xfs_dir2_sf.c
> +++ b/fs/xfs/libxfs/xfs_dir2_sf.c
> @@ -344,7 +344,7 @@ xfs_dir2_block_to_sf(
>  	ASSERT(dp->i_df.if_bytes == 0);
>  	xfs_init_local_fork(dp, XFS_DATA_FORK, sfp, size);
>  	dp->i_df.if_format = XFS_DINODE_FMT_LOCAL;
> -	dp->i_d.di_size = size;
> +	dp->i_disk_size = size;
>  
>  	logflags |= XFS_ILOG_DDATA;
>  	xfs_dir2_sf_check(args);
> @@ -367,7 +367,7 @@ xfs_dir2_sf_addname(
>  	xfs_inode_t		*dp;		/* incore directory inode */
>  	int			error;		/* error return value */
>  	int			incr_isize;	/* total change in size */
> -	int			new_isize;	/* di_size after adding name */
> +	int			new_isize;	/* size after adding name */
>  	int			objchange;	/* changing to 8-byte inodes */
>  	xfs_dir2_data_aoff_t	offset = 0;	/* offset for new entry */
>  	int			pick;		/* which algorithm to use */
> @@ -379,11 +379,11 @@ xfs_dir2_sf_addname(
>  	ASSERT(xfs_dir2_sf_lookup(args) == -ENOENT);
>  	dp = args->dp;
>  	ASSERT(dp->i_df.if_flags & XFS_IFINLINE);
> -	ASSERT(dp->i_d.di_size >= offsetof(struct xfs_dir2_sf_hdr, parent));
> -	ASSERT(dp->i_df.if_bytes == dp->i_d.di_size);
> +	ASSERT(dp->i_disk_size >= offsetof(struct xfs_dir2_sf_hdr, parent));
> +	ASSERT(dp->i_df.if_bytes == dp->i_disk_size);
>  	ASSERT(dp->i_df.if_u1.if_data != NULL);
>  	sfp = (xfs_dir2_sf_hdr_t *)dp->i_df.if_u1.if_data;
> -	ASSERT(dp->i_d.di_size >= xfs_dir2_sf_hdr_size(sfp->i8count));
> +	ASSERT(dp->i_disk_size >= xfs_dir2_sf_hdr_size(sfp->i8count));
>  	/*
>  	 * Compute entry (and change in) size.
>  	 */
> @@ -401,7 +401,7 @@ xfs_dir2_sf_addname(
>  		objchange = 1;
>  	}
>  
> -	new_isize = (int)dp->i_d.di_size + incr_isize;
> +	new_isize = (int)dp->i_disk_size + incr_isize;
>  	/*
>  	 * Won't fit as shortform any more (due to size),
>  	 * or the pick routine says it won't (due to offset values).
> @@ -492,7 +492,7 @@ xfs_dir2_sf_addname_easy(
>  	sfp->count++;
>  	if (args->inumber > XFS_DIR2_MAX_SHORT_INUM)
>  		sfp->i8count++;
> -	dp->i_d.di_size = new_isize;
> +	dp->i_disk_size = new_isize;
>  	xfs_dir2_sf_check(args);
>  }
>  
> @@ -519,7 +519,7 @@ xfs_dir2_sf_addname_hard(
>  	int			nbytes;		/* temp for byte copies */
>  	xfs_dir2_data_aoff_t	new_offset;	/* next offset value */
>  	xfs_dir2_data_aoff_t	offset;		/* current offset value */
> -	int			old_isize;	/* previous di_size */
> +	int			old_isize;	/* previous size */
>  	xfs_dir2_sf_entry_t	*oldsfep;	/* entry in original dir */
>  	xfs_dir2_sf_hdr_t	*oldsfp;	/* original shortform dir */
>  	xfs_dir2_sf_entry_t	*sfep;		/* entry in new dir */
> @@ -529,7 +529,7 @@ xfs_dir2_sf_addname_hard(
>  	 * Copy the old directory to the stack buffer.
>  	 */
>  	sfp = (xfs_dir2_sf_hdr_t *)dp->i_df.if_u1.if_data;
> -	old_isize = (int)dp->i_d.di_size;
> +	old_isize = (int)dp->i_disk_size;
>  	buf = kmem_alloc(old_isize, 0);
>  	oldsfp = (xfs_dir2_sf_hdr_t *)buf;
>  	memcpy(oldsfp, sfp, old_isize);
> @@ -586,7 +586,7 @@ xfs_dir2_sf_addname_hard(
>  		memcpy(sfep, oldsfep, old_isize - nbytes);
>  	}
>  	kmem_free(buf);
> -	dp->i_d.di_size = new_isize;
> +	dp->i_disk_size = new_isize;
>  	xfs_dir2_sf_check(args);
>  }
>  
> @@ -697,7 +697,7 @@ xfs_dir2_sf_check(
>  		ASSERT(xfs_dir2_sf_get_ftype(mp, sfep) < XFS_DIR3_FT_MAX);
>  	}
>  	ASSERT(i8count == sfp->i8count);
> -	ASSERT((char *)sfep - (char *)sfp == dp->i_d.di_size);
> +	ASSERT((char *)sfep - (char *)sfp == dp->i_disk_size);
>  	ASSERT(offset +
>  	       (sfp->count + 2) * (uint)sizeof(xfs_dir2_leaf_entry_t) +
>  	       (uint)sizeof(xfs_dir2_block_tail_t) <= args->geo->blksize);
> @@ -821,7 +821,7 @@ xfs_dir2_sf_create(
>  	dp = args->dp;
>  
>  	ASSERT(dp != NULL);
> -	ASSERT(dp->i_d.di_size == 0);
> +	ASSERT(dp->i_disk_size == 0);
>  	/*
>  	 * If it's currently a zero-length extent file,
>  	 * convert it to local format.
> @@ -850,7 +850,7 @@ xfs_dir2_sf_create(
>  	 */
>  	xfs_dir2_sf_put_parent_ino(sfp, pino);
>  	sfp->count = 0;
> -	dp->i_d.di_size = size;
> +	dp->i_disk_size = size;
>  	xfs_dir2_sf_check(args);
>  	xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE | XFS_ILOG_DDATA);
>  	return 0;
> @@ -878,11 +878,11 @@ xfs_dir2_sf_lookup(
>  	xfs_dir2_sf_check(args);
>  
>  	ASSERT(dp->i_df.if_flags & XFS_IFINLINE);
> -	ASSERT(dp->i_d.di_size >= offsetof(struct xfs_dir2_sf_hdr, parent));
> -	ASSERT(dp->i_df.if_bytes == dp->i_d.di_size);
> +	ASSERT(dp->i_disk_size >= offsetof(struct xfs_dir2_sf_hdr, parent));
> +	ASSERT(dp->i_df.if_bytes == dp->i_disk_size);
>  	ASSERT(dp->i_df.if_u1.if_data != NULL);
>  	sfp = (xfs_dir2_sf_hdr_t *)dp->i_df.if_u1.if_data;
> -	ASSERT(dp->i_d.di_size >= xfs_dir2_sf_hdr_size(sfp->i8count));
> +	ASSERT(dp->i_disk_size >= xfs_dir2_sf_hdr_size(sfp->i8count));
>  	/*
>  	 * Special case for .
>  	 */
> @@ -955,7 +955,7 @@ xfs_dir2_sf_removename(
>  	trace_xfs_dir2_sf_removename(args);
>  
>  	ASSERT(dp->i_df.if_flags & XFS_IFINLINE);
> -	oldsize = (int)dp->i_d.di_size;
> +	oldsize = (int)dp->i_disk_size;
>  	ASSERT(oldsize >= offsetof(struct xfs_dir2_sf_hdr, parent));
>  	ASSERT(dp->i_df.if_bytes == oldsize);
>  	ASSERT(dp->i_df.if_u1.if_data != NULL);
> @@ -995,7 +995,7 @@ xfs_dir2_sf_removename(
>  	 * Fix up the header and file size.
>  	 */
>  	sfp->count--;
> -	dp->i_d.di_size = newsize;
> +	dp->i_disk_size = newsize;
>  	/*
>  	 * Reallocate, making it smaller.
>  	 */
> @@ -1054,11 +1054,11 @@ xfs_dir2_sf_replace(
>  	trace_xfs_dir2_sf_replace(args);
>  
>  	ASSERT(dp->i_df.if_flags & XFS_IFINLINE);
> -	ASSERT(dp->i_d.di_size >= offsetof(struct xfs_dir2_sf_hdr, parent));
> -	ASSERT(dp->i_df.if_bytes == dp->i_d.di_size);
> +	ASSERT(dp->i_disk_size >= offsetof(struct xfs_dir2_sf_hdr, parent));
> +	ASSERT(dp->i_df.if_bytes == dp->i_disk_size);
>  	ASSERT(dp->i_df.if_u1.if_data != NULL);
>  	sfp = (xfs_dir2_sf_hdr_t *)dp->i_df.if_u1.if_data;
> -	ASSERT(dp->i_d.di_size >= xfs_dir2_sf_hdr_size(sfp->i8count));
> +	ASSERT(dp->i_disk_size >= xfs_dir2_sf_hdr_size(sfp->i8count));
>  
>  	/*
>  	 * New inode number is large, and need to convert to 8-byte inodes.
> @@ -1219,7 +1219,7 @@ xfs_dir2_sf_toino4(
>  	 * Clean up the inode.
>  	 */
>  	kmem_free(buf);
> -	dp->i_d.di_size = newsize;
> +	dp->i_disk_size = newsize;
>  	xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE | XFS_ILOG_DDATA);
>  }
>  
> @@ -1292,6 +1292,6 @@ xfs_dir2_sf_toino8(
>  	 * Clean up the inode.
>  	 */
>  	kmem_free(buf);
> -	dp->i_d.di_size = newsize;
> +	dp->i_disk_size = newsize;
>  	xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE | XFS_ILOG_DDATA);
>  }
> diff --git a/fs/xfs/libxfs/xfs_inode_buf.c b/fs/xfs/libxfs/xfs_inode_buf.c
> index b064cb8072c84a..c202de8bbdd427 100644
> --- a/fs/xfs/libxfs/xfs_inode_buf.c
> +++ b/fs/xfs/libxfs/xfs_inode_buf.c
> @@ -241,7 +241,7 @@ xfs_inode_from_disk(
>  	inode->i_ctime.tv_sec = (int)be32_to_cpu(from->di_ctime.t_sec);
>  	inode->i_ctime.tv_nsec = (int)be32_to_cpu(from->di_ctime.t_nsec);
>  
> -	to->di_size = be64_to_cpu(from->di_size);
> +	ip->i_disk_size = be64_to_cpu(from->di_size);
>  	to->di_nblocks = be64_to_cpu(from->di_nblocks);
>  	to->di_extsize = be32_to_cpu(from->di_extsize);
>  	to->di_forkoff = from->di_forkoff;
> @@ -304,7 +304,7 @@ xfs_inode_to_disk(
>  	to->di_gen = cpu_to_be32(inode->i_generation);
>  	to->di_mode = cpu_to_be16(inode->i_mode);
>  
> -	to->di_size = cpu_to_be64(from->di_size);
> +	to->di_size = cpu_to_be64(ip->i_disk_size);
>  	to->di_nblocks = cpu_to_be64(from->di_nblocks);
>  	to->di_extsize = cpu_to_be32(from->di_extsize);
>  	to->di_nextents = cpu_to_be32(xfs_ifork_nextents(&ip->i_df));
> diff --git a/fs/xfs/libxfs/xfs_inode_buf.h b/fs/xfs/libxfs/xfs_inode_buf.h
> index b826d81b356956..f187127d50e010 100644
> --- a/fs/xfs/libxfs/xfs_inode_buf.h
> +++ b/fs/xfs/libxfs/xfs_inode_buf.h
> @@ -17,7 +17,6 @@ struct xfs_dinode;
>   */
>  struct xfs_icdinode {
>  	uint16_t	di_flushiter;	/* incremented on flush */
> -	xfs_fsize_t	di_size;	/* number of bytes in file */
>  	xfs_rfsblock_t	di_nblocks;	/* # of direct & btree blocks used */
>  	xfs_extlen_t	di_extsize;	/* basic/minimum extent size for file */
>  	uint8_t		di_forkoff;	/* attr fork offs, <<3 for 64b align */
> diff --git a/fs/xfs/libxfs/xfs_inode_fork.c b/fs/xfs/libxfs/xfs_inode_fork.c
> index 28b366275ae0ed..d2029e12bda4de 100644
> --- a/fs/xfs/libxfs/xfs_inode_fork.c
> +++ b/fs/xfs/libxfs/xfs_inode_fork.c
> @@ -240,7 +240,7 @@ xfs_iformat_data_fork(
>  	case S_IFCHR:
>  	case S_IFBLK:
>  	case S_IFSOCK:
> -		ip->i_d.di_size = 0;
> +		ip->i_disk_size = 0;
>  		inode->i_rdev = xfs_to_linux_dev_t(xfs_dinode_get_rdev(dip));
>  		return 0;
>  	case S_IFREG:
> diff --git a/fs/xfs/scrub/dir.c b/fs/xfs/scrub/dir.c
> index 7c432997edade4..d89aa8efb84545 100644
> --- a/fs/xfs/scrub/dir.c
> +++ b/fs/xfs/scrub/dir.c
> @@ -523,7 +523,7 @@ xchk_directory_leaf1_bestfree(
>  	 * There should be as many bestfree slots as there are dir data
>  	 * blocks that can fit under i_size.
>  	 */
> -	if (bestcount != xfs_dir2_byte_to_db(geo, sc->ip->i_d.di_size)) {
> +	if (bestcount != xfs_dir2_byte_to_db(geo, sc->ip->i_disk_size)) {
>  		xchk_fblock_set_corrupt(sc, XFS_DATA_FORK, lblk);
>  		goto out;
>  	}
> @@ -789,7 +789,7 @@ xchk_directory(
>  		return -ENOENT;
>  
>  	/* Plausible size? */
> -	if (sc->ip->i_d.di_size < xfs_dir2_sf_hdr_size(0)) {
> +	if (sc->ip->i_disk_size < xfs_dir2_sf_hdr_size(0)) {
>  		xchk_ino_set_corrupt(sc, sc->ip->i_ino);
>  		goto out;
>  	}
> @@ -815,7 +815,7 @@ xchk_directory(
>  	 * Userspace usually asks for a 32k buffer, so we will too.
>  	 */
>  	bufsize = (size_t)min_t(loff_t, XFS_READDIR_BUFSIZE,
> -			sc->ip->i_d.di_size);
> +			sc->ip->i_disk_size);
>  
>  	/*
>  	 * Look up every name in this directory by hash.
> diff --git a/fs/xfs/scrub/parent.c b/fs/xfs/scrub/parent.c
> index 855aa8bcab64bd..766e870999a9a8 100644
> --- a/fs/xfs/scrub/parent.c
> +++ b/fs/xfs/scrub/parent.c
> @@ -102,7 +102,7 @@ xchk_parent_count_parent_dentries(
>  	 * scanned.
>  	 */
>  	bufsize = (size_t)min_t(loff_t, XFS_READDIR_BUFSIZE,
> -			parent->i_d.di_size);
> +			parent->i_disk_size);
>  	oldpos = 0;
>  	while (true) {
>  		error = xfs_readdir(sc->tp, parent, &spc.dc, bufsize);
> diff --git a/fs/xfs/scrub/symlink.c b/fs/xfs/scrub/symlink.c
> index 5641ae512c9efc..9b751d79adf096 100644
> --- a/fs/xfs/scrub/symlink.c
> +++ b/fs/xfs/scrub/symlink.c
> @@ -43,7 +43,7 @@ xchk_symlink(
>  	if (!S_ISLNK(VFS_I(ip)->i_mode))
>  		return -ENOENT;
>  	ifp = XFS_IFORK_PTR(ip, XFS_DATA_FORK);
> -	len = ip->i_d.di_size;
> +	len = ip->i_disk_size;
>  
>  	/* Plausible size? */
>  	if (len > XFS_SYMLINK_MAXLEN || len <= 0) {
> diff --git a/fs/xfs/xfs_aops.c b/fs/xfs/xfs_aops.c
> index 2834cbf1212e5a..18a497cc817c2a 100644
> --- a/fs/xfs/xfs_aops.c
> +++ b/fs/xfs/xfs_aops.c
> @@ -36,7 +36,7 @@ XFS_WPC(struct iomap_writepage_ctx *ctx)
>  static inline bool xfs_ioend_is_append(struct iomap_ioend *ioend)
>  {
>  	return ioend->io_offset + ioend->io_size >
> -		XFS_I(ioend->io_inode)->i_d.di_size;
> +		XFS_I(ioend->io_inode)->i_disk_size;
>  }
>  
>  STATIC int
> @@ -88,7 +88,7 @@ __xfs_setfilesize(
>  
>  	trace_xfs_setfilesize(ip, offset, size);
>  
> -	ip->i_d.di_size = isize;
> +	ip->i_disk_size = isize;
>  	xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);
>  	xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
>  
> diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c
> index e42553884c23cf..d199ecddc1ab19 100644
> --- a/fs/xfs/xfs_bmap_util.c
> +++ b/fs/xfs/xfs_bmap_util.c
> @@ -423,7 +423,7 @@ xfs_getbmap(
>  		break;
>  	case XFS_DATA_FORK:
>  		if (!(iflags & BMV_IF_DELALLOC) &&
> -		    (ip->i_delayed_blks || XFS_ISIZE(ip) > ip->i_d.di_size)) {
> +		    (ip->i_delayed_blks || XFS_ISIZE(ip) > ip->i_disk_size)) {
>  			error = filemap_write_and_wait(VFS_I(ip)->i_mapping);
>  			if (error)
>  				goto out_unlock_iolock;
> @@ -1656,8 +1656,8 @@ xfs_swap_extents(
>  
>  	/* Verify all data are being swapped */
>  	if (sxp->sx_offset != 0 ||
> -	    sxp->sx_length != ip->i_d.di_size ||
> -	    sxp->sx_length != tip->i_d.di_size) {
> +	    sxp->sx_length != ip->i_disk_size ||
> +	    sxp->sx_length != tip->i_disk_size) {
>  		error = -EFAULT;
>  		goto out_trans_cancel;
>  	}
> diff --git a/fs/xfs/xfs_dir2_readdir.c b/fs/xfs/xfs_dir2_readdir.c
> index 66deddd5e29698..03e7c39a07807a 100644
> --- a/fs/xfs/xfs_dir2_readdir.c
> +++ b/fs/xfs/xfs_dir2_readdir.c
> @@ -58,7 +58,7 @@ xfs_dir2_sf_getdents(
>  	struct xfs_da_geometry	*geo = args->geo;
>  
>  	ASSERT(dp->i_df.if_flags & XFS_IFINLINE);
> -	ASSERT(dp->i_df.if_bytes == dp->i_d.di_size);
> +	ASSERT(dp->i_df.if_bytes == dp->i_disk_size);
>  	ASSERT(dp->i_df.if_u1.if_data != NULL);
>  
>  	sfp = (xfs_dir2_sf_hdr_t *)dp->i_df.if_u1.if_data;
> diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c
> index 403c90309a8ffe..14b533a8ce8e6a 100644
> --- a/fs/xfs/xfs_file.c
> +++ b/fs/xfs/xfs_file.c
> @@ -1137,7 +1137,7 @@ xfs_file_readdir(
>  	 * point we can change the ->readdir prototype to include the
>  	 * buffer size.  For now we use the current glibc buffer size.
>  	 */
> -	bufsize = (size_t)min_t(loff_t, XFS_READDIR_BUFSIZE, ip->i_d.di_size);
> +	bufsize = (size_t)min_t(loff_t, XFS_READDIR_BUFSIZE, ip->i_disk_size);
>  
>  	return xfs_readdir(NULL, ip, ctx, bufsize);
>  }
> diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
> index 40e4d3ed29a798..723a911c8b6d81 100644
> --- a/fs/xfs/xfs_inode.c
> +++ b/fs/xfs/xfs_inode.c
> @@ -825,7 +825,7 @@ xfs_ialloc(
>  	    (inode->i_mode & S_ISGID) && !in_group_p(inode->i_gid))
>  		inode->i_mode &= ~S_ISGID;
>  
> -	ip->i_d.di_size = 0;
> +	ip->i_disk_size = 0;
>  	ip->i_df.if_nextents = 0;
>  	ASSERT(ip->i_d.di_nblocks == 0);
>  
> @@ -1675,7 +1675,7 @@ xfs_inactive_truncate(
>  	 * of a system crash before the truncate completes. See the related
>  	 * comment in xfs_vn_setattr_size() for details.
>  	 */
> -	ip->i_d.di_size = 0;
> +	ip->i_disk_size = 0;
>  	xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
>  
>  	error = xfs_itruncate_extents(&tp, ip, XFS_DATA_FORK, 0);
> @@ -1831,7 +1831,7 @@ xfs_inactive(
>  	}
>  
>  	if (S_ISREG(VFS_I(ip)->i_mode) &&
> -	    (ip->i_d.di_size != 0 || XFS_ISIZE(ip) != 0 ||
> +	    (ip->i_disk_size != 0 || XFS_ISIZE(ip) != 0 ||
>  	     ip->i_df.if_nextents > 0 || ip->i_delayed_blks > 0))
>  		truncate = 1;
>  
> @@ -2729,7 +2729,7 @@ xfs_ifree(
>  	ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL));
>  	ASSERT(VFS_I(ip)->i_nlink == 0);
>  	ASSERT(ip->i_df.if_nextents == 0);
> -	ASSERT(ip->i_d.di_size == 0 || !S_ISREG(VFS_I(ip)->i_mode));
> +	ASSERT(ip->i_disk_size == 0 || !S_ISREG(VFS_I(ip)->i_mode));
>  	ASSERT(ip->i_d.di_nblocks == 0);
>  
>  	/*
> diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h
> index 51ea9d53407863..61c41395536f07 100644
> --- a/fs/xfs/xfs_inode.h
> +++ b/fs/xfs/xfs_inode.h
> @@ -54,6 +54,7 @@ typedef struct xfs_inode {
>  	/* Miscellaneous state. */
>  	unsigned long		i_flags;	/* see defined flags below */
>  	uint64_t		i_delayed_blks;	/* count of delay alloc blks */
> +	xfs_fsize_t		i_disk_size;	/* number of bytes in file */
>  	uint32_t		i_projid;	/* owner's project id */
>  
>  	struct xfs_icdinode	i_d;		/* most of ondisk inode */
> @@ -88,7 +89,7 @@ static inline xfs_fsize_t XFS_ISIZE(struct xfs_inode *ip)
>  {
>  	if (S_ISREG(VFS_I(ip)->i_mode))
>  		return i_size_read(VFS_I(ip));
> -	return ip->i_d.di_size;
> +	return ip->i_disk_size;
>  }
>  
>  /*
> @@ -102,7 +103,7 @@ xfs_new_eof(struct xfs_inode *ip, xfs_fsize_t new_size)
>  
>  	if (new_size > i_size || new_size < 0)
>  		new_size = i_size;
> -	return new_size > ip->i_d.di_size ? new_size : 0;
> +	return new_size > ip->i_disk_size ? new_size : 0;
>  }
>  
>  /*
> diff --git a/fs/xfs/xfs_inode_item.c b/fs/xfs/xfs_inode_item.c
> index e546b4b58ce2e0..179f1c2de6bd0f 100644
> --- a/fs/xfs/xfs_inode_item.c
> +++ b/fs/xfs/xfs_inode_item.c
> @@ -196,7 +196,7 @@ xfs_inode_item_format_data_fork(
>  			 */
>  			data_bytes = roundup(ip->i_df.if_bytes, 4);
>  			ASSERT(ip->i_df.if_u1.if_data != NULL);
> -			ASSERT(ip->i_d.di_size > 0);
> +			ASSERT(ip->i_disk_size > 0);
>  			xlog_copy_iovec(lv, vecp, XLOG_REG_TYPE_ILOCAL,
>  					ip->i_df.if_u1.if_data, data_bytes);
>  			ilf->ilf_dsize = (unsigned)data_bytes;
> @@ -323,7 +323,7 @@ xfs_inode_to_log_dinode(
>  	to->di_gen = inode->i_generation;
>  	to->di_mode = inode->i_mode;
>  
> -	to->di_size = from->di_size;
> +	to->di_size = ip->i_disk_size;
>  	to->di_nblocks = from->di_nblocks;
>  	to->di_extsize = from->di_extsize;
>  	to->di_nextents = xfs_ifork_nextents(&ip->i_df);
> diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c
> index b9a8c3798e08fc..6e03963b6b300e 100644
> --- a/fs/xfs/xfs_iomap.c
> +++ b/fs/xfs/xfs_iomap.c
> @@ -583,7 +583,7 @@ xfs_iomap_write_unwritten(
>  			i_size_write(inode, i_size);
>  		i_size = xfs_new_eof(ip, i_size);
>  		if (i_size) {
> -			ip->i_d.di_size = i_size;
> +			ip->i_disk_size = i_size;
>  			xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
>  		}
>  
> diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
> index 5440f555c9cc2c..1abee83d49cff9 100644
> --- a/fs/xfs/xfs_iops.c
> +++ b/fs/xfs/xfs_iops.c
> @@ -935,8 +935,8 @@ xfs_setattr_size(
>  	 * operation.
>  	 *
>  	 * And we update in-core i_size and truncate page cache beyond newsize
> -	 * before writeback the [di_size, newsize] range, so we're guaranteed
> -	 * not to write stale data past the new EOF on truncate down.
> +	 * before writeback the [i_disk_size, newsize] range, so we're
> +	 * guaranteed not to write stale data past the new EOF on truncate down.
>  	 */
>  	truncate_setsize(inode, newsize);
>  
> @@ -949,9 +949,9 @@ xfs_setattr_size(
>  	 * otherwise those blocks may not be zeroed after a crash.
>  	 */
>  	if (did_zeroing ||
> -	    (newsize > ip->i_d.di_size && oldsize != ip->i_d.di_size)) {
> +	    (newsize > ip->i_disk_size && oldsize != ip->i_disk_size)) {
>  		error = filemap_write_and_wait_range(VFS_I(ip)->i_mapping,
> -						ip->i_d.di_size, newsize - 1);
> +						ip->i_disk_size, newsize - 1);
>  		if (error)
>  			return error;
>  	}
> @@ -993,7 +993,7 @@ xfs_setattr_size(
>  	 * permanent before actually freeing any blocks it doesn't matter if
>  	 * they get written to.
>  	 */
> -	ip->i_d.di_size = newsize;
> +	ip->i_disk_size = newsize;
>  	xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
>  
>  	if (newsize <= oldsize) {
> @@ -1323,7 +1323,7 @@ xfs_setup_inode(
>  	/* make the inode look hashed for the writeback code */
>  	inode_fake_hash(inode);
>  
> -	i_size_write(inode, ip->i_d.di_size);
> +	i_size_write(inode, ip->i_disk_size);
>  	xfs_diflags_to_iflags(ip, true);
>  
>  	if (S_ISDIR(inode->i_mode)) {
> diff --git a/fs/xfs/xfs_itable.c b/fs/xfs/xfs_itable.c
> index 97b3b794dd4ada..9f92514301b334 100644
> --- a/fs/xfs/xfs_itable.c
> +++ b/fs/xfs/xfs_itable.c
> @@ -88,7 +88,7 @@ xfs_bulkstat_one_int(
>  	buf->bs_ino = ino;
>  	buf->bs_uid = i_uid_read(inode);
>  	buf->bs_gid = i_gid_read(inode);
> -	buf->bs_size = dic->di_size;
> +	buf->bs_size = ip->i_disk_size;
>  
>  	buf->bs_nlink = inode->i_nlink;
>  	buf->bs_atime = inode->i_atime.tv_sec;
> diff --git a/fs/xfs/xfs_pnfs.c b/fs/xfs/xfs_pnfs.c
> index b101feb2aab452..e6caca783764f9 100644
> --- a/fs/xfs/xfs_pnfs.c
> +++ b/fs/xfs/xfs_pnfs.c
> @@ -286,7 +286,7 @@ xfs_fs_commit_blocks(
>  	xfs_setattr_time(ip, iattr);
>  	if (update_isize) {
>  		i_size_write(inode, iattr->ia_size);
> -		ip->i_d.di_size = iattr->ia_size;
> +		ip->i_disk_size = iattr->ia_size;
>  	}
>  
>  	xfs_trans_set_sync(tp);
> diff --git a/fs/xfs/xfs_qm_syscalls.c b/fs/xfs/xfs_qm_syscalls.c
> index 7effd7a2813656..08dec36095fae2 100644
> --- a/fs/xfs/xfs_qm_syscalls.c
> +++ b/fs/xfs/xfs_qm_syscalls.c
> @@ -293,7 +293,7 @@ xfs_qm_scall_trunc_qfile(
>  	xfs_ilock(ip, XFS_ILOCK_EXCL);
>  	xfs_trans_ijoin(tp, ip, 0);
>  
> -	ip->i_d.di_size = 0;
> +	ip->i_disk_size = 0;
>  	xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
>  
>  	error = xfs_itruncate_extents(&tp, ip, XFS_DATA_FORK, 0);
> diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c
> index 107bf2a2f3448a..8598896156e29a 100644
> --- a/fs/xfs/xfs_reflink.c
> +++ b/fs/xfs/xfs_reflink.c
> @@ -938,7 +938,7 @@ xfs_reflink_update_dest(
>  	if (newlen > i_size_read(VFS_I(dest))) {
>  		trace_xfs_reflink_update_inode_size(dest, newlen);
>  		i_size_write(VFS_I(dest), newlen);
> -		dest->i_d.di_size = newlen;
> +		dest->i_disk_size = newlen;
>  	}
>  
>  	if (cowextsize) {
> @@ -1078,7 +1078,7 @@ xfs_reflink_remap_extent(
>  		if (newlen > i_size_read(VFS_I(ip))) {
>  			trace_xfs_reflink_update_inode_size(ip, newlen);
>  			i_size_write(VFS_I(ip), newlen);
> -			ip->i_d.di_size = newlen;
> +			ip->i_disk_size = newlen;
>  			xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
>  		}
>  
> diff --git a/fs/xfs/xfs_rtalloc.c b/fs/xfs/xfs_rtalloc.c
> index 6209e7b6b895b8..cc07d7d27dd7e0 100644
> --- a/fs/xfs/xfs_rtalloc.c
> +++ b/fs/xfs/xfs_rtalloc.c
> @@ -941,8 +941,8 @@ xfs_growfs_rt(
>  	 * Get the old block counts for bitmap and summary inodes.
>  	 * These can't change since other growfs callers are locked out.
>  	 */
> -	rbmblocks = XFS_B_TO_FSB(mp, mp->m_rbmip->i_d.di_size);
> -	rsumblocks = XFS_B_TO_FSB(mp, mp->m_rsumip->i_d.di_size);
> +	rbmblocks = XFS_B_TO_FSB(mp, mp->m_rbmip->i_disk_size);
> +	rsumblocks = XFS_B_TO_FSB(mp, mp->m_rsumip->i_disk_size);
>  	/*
>  	 * Allocate space to the bitmap and summary files, as necessary.
>  	 */
> @@ -1009,7 +1009,7 @@ xfs_growfs_rt(
>  		/*
>  		 * Update the bitmap inode's size.
>  		 */
> -		mp->m_rbmip->i_d.di_size =
> +		mp->m_rbmip->i_disk_size =
>  			nsbp->sb_rbmblocks * nsbp->sb_blocksize;
>  		xfs_trans_log_inode(tp, mp->m_rbmip, XFS_ILOG_CORE);
>  		/*
> @@ -1020,7 +1020,7 @@ xfs_growfs_rt(
>  		/*
>  		 * Update the summary inode's size.
>  		 */
> -		mp->m_rsumip->i_d.di_size = nmp->m_rsumsize;
> +		mp->m_rsumip->i_disk_size = nmp->m_rsumsize;
>  		xfs_trans_log_inode(tp, mp->m_rsumip, XFS_ILOG_CORE);
>  		/*
>  		 * Copy summary data from old to new sizes.
> diff --git a/fs/xfs/xfs_symlink.c b/fs/xfs/xfs_symlink.c
> index 8e88a7ca387ea9..6b8980b1497c9a 100644
> --- a/fs/xfs/xfs_symlink.c
> +++ b/fs/xfs/xfs_symlink.c
> @@ -33,7 +33,7 @@ xfs_readlink_bmap_ilocked(
>  	struct xfs_buf		*bp;
>  	xfs_daddr_t		d;
>  	char			*cur_chunk;
> -	int			pathlen = ip->i_d.di_size;
> +	int			pathlen = ip->i_disk_size;
>  	int			nmaps = XFS_SYMLINK_MAPS;
>  	int			byte_cnt;
>  	int			n;
> @@ -86,7 +86,7 @@ xfs_readlink_bmap_ilocked(
>  	}
>  	ASSERT(pathlen == 0);
>  
> -	link[ip->i_d.di_size] = '\0';
> +	link[ip->i_disk_size] = '\0';
>  	error = 0;
>  
>   out:
> @@ -111,7 +111,7 @@ xfs_readlink(
>  
>  	xfs_ilock(ip, XFS_ILOCK_SHARED);
>  
> -	pathlen = ip->i_d.di_size;
> +	pathlen = ip->i_disk_size;
>  	if (!pathlen)
>  		goto out;
>  
> @@ -250,7 +250,7 @@ xfs_symlink(
>  	if (pathlen <= XFS_IFORK_DSIZE(ip)) {
>  		xfs_init_local_fork(ip, XFS_DATA_FORK, target_path, pathlen);
>  
> -		ip->i_d.di_size = pathlen;
> +		ip->i_disk_size = pathlen;
>  		ip->i_df.if_format = XFS_DINODE_FMT_LOCAL;
>  		xfs_trans_log_inode(tp, ip, XFS_ILOG_DDATA | XFS_ILOG_CORE);
>  	} else {
> @@ -265,7 +265,7 @@ xfs_symlink(
>  			goto out_trans_cancel;
>  
>  		resblks -= fs_blocks;
> -		ip->i_d.di_size = pathlen;
> +		ip->i_disk_size = pathlen;
>  		xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
>  
>  		cur_chunk = target_path;
> @@ -399,8 +399,8 @@ xfs_inactive_symlink_rmt(
>  	 * locked for the second transaction.  In the error paths we need it
>  	 * held so the cancel won't rele it, see below.
>  	 */
> -	size = (int)ip->i_d.di_size;
> -	ip->i_d.di_size = 0;
> +	size = (int)ip->i_disk_size;
> +	ip->i_disk_size = 0;
>  	VFS_I(ip)->i_mode = (VFS_I(ip)->i_mode & ~S_IFMT) | S_IFREG;
>  	xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
>  	/*
> @@ -476,7 +476,7 @@ xfs_inactive_symlink(
>  		return -EIO;
>  
>  	xfs_ilock(ip, XFS_ILOCK_EXCL);
> -	pathlen = (int)ip->i_d.di_size;
> +	pathlen = (int)ip->i_disk_size;
>  	ASSERT(pathlen);
>  
>  	if (pathlen <= 0 || pathlen > XFS_SYMLINK_MAXLEN) {
> diff --git a/fs/xfs/xfs_trace.h b/fs/xfs/xfs_trace.h
> index 460136628a7959..5cc73db80ae0c0 100644
> --- a/fs/xfs/xfs_trace.h
> +++ b/fs/xfs/xfs_trace.h
> @@ -1140,7 +1140,7 @@ DECLARE_EVENT_CLASS(xfs_file_class,
>  	TP_fast_assign(
>  		__entry->dev = VFS_I(ip)->i_sb->s_dev;
>  		__entry->ino = ip->i_ino;
> -		__entry->size = ip->i_d.di_size;
> +		__entry->size = ip->i_disk_size;
>  		__entry->offset = offset;
>  		__entry->count = count;
>  	),
> @@ -1181,7 +1181,7 @@ DECLARE_EVENT_CLASS(xfs_imap_class,
>  	TP_fast_assign(
>  		__entry->dev = VFS_I(ip)->i_sb->s_dev;
>  		__entry->ino = ip->i_ino;
> -		__entry->size = ip->i_d.di_size;
> +		__entry->size = ip->i_disk_size;
>  		__entry->offset = offset;
>  		__entry->count = count;
>  		__entry->whichfork = whichfork;
> @@ -1227,7 +1227,7 @@ DECLARE_EVENT_CLASS(xfs_simple_io_class,
>  		__entry->dev = VFS_I(ip)->i_sb->s_dev;
>  		__entry->ino = ip->i_ino;
>  		__entry->isize = VFS_I(ip)->i_size;
> -		__entry->disize = ip->i_d.di_size;
> +		__entry->disize = ip->i_disk_size;
>  		__entry->offset = offset;
>  		__entry->count = count;
>  	),
> @@ -1265,7 +1265,7 @@ DECLARE_EVENT_CLASS(xfs_itrunc_class,
>  	TP_fast_assign(
>  		__entry->dev = VFS_I(ip)->i_sb->s_dev;
>  		__entry->ino = ip->i_ino;
> -		__entry->size = ip->i_d.di_size;
> +		__entry->size = ip->i_disk_size;
>  		__entry->new_size = new_size;
>  	),
>  	TP_printk("dev %d:%d ino 0x%llx size 0x%llx new_size 0x%llx",
> @@ -1295,7 +1295,7 @@ TRACE_EVENT(xfs_pagecache_inval,
>  	TP_fast_assign(
>  		__entry->dev = VFS_I(ip)->i_sb->s_dev;
>  		__entry->ino = ip->i_ino;
> -		__entry->size = ip->i_d.di_size;
> +		__entry->size = ip->i_disk_size;
>  		__entry->start = start;
>  		__entry->finish = finish;
>  	),
> @@ -1323,7 +1323,7 @@ TRACE_EVENT(xfs_bunmap,
>  	TP_fast_assign(
>  		__entry->dev = VFS_I(ip)->i_sb->s_dev;
>  		__entry->ino = ip->i_ino;
> -		__entry->size = ip->i_d.di_size;
> +		__entry->size = ip->i_disk_size;
>  		__entry->bno = bno;
>  		__entry->len = len;
>  		__entry->caller_ip = caller_ip;
> @@ -2984,12 +2984,12 @@ DECLARE_EVENT_CLASS(xfs_double_io_class,
>  		__entry->dev = VFS_I(src)->i_sb->s_dev;
>  		__entry->src_ino = src->i_ino;
>  		__entry->src_isize = VFS_I(src)->i_size;
> -		__entry->src_disize = src->i_d.di_size;
> +		__entry->src_disize = src->i_disk_size;
>  		__entry->src_offset = soffset;
>  		__entry->len = len;
>  		__entry->dest_ino = dest->i_ino;
>  		__entry->dest_isize = VFS_I(dest)->i_size;
> -		__entry->dest_disize = dest->i_d.di_size;
> +		__entry->dest_disize = dest->i_disk_size;
>  		__entry->dest_offset = doffset;
>  	),
>  	TP_printk("dev %d:%d count %zd "
> -- 
> 2.26.2
> 

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH 04/15] xfs: move the di_nblocks field to struct xfs_inode
  2020-06-20  7:10 ` [PATCH 04/15] xfs: move the di_nblocks " Christoph Hellwig
  2020-06-22  9:33   ` Chandan Babu R
@ 2020-06-30 17:47   ` Darrick J. Wong
  1 sibling, 0 replies; 52+ messages in thread
From: Darrick J. Wong @ 2020-06-30 17:47 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: linux-xfs

On Sat, Jun 20, 2020 at 09:10:51AM +0200, Christoph Hellwig wrote:
> In preparation of removing the historic icinode struct, move the nblocks
> field into the containing xfs_inode structure.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>

Looks pretty straightforward,
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>

--D

> ---
>  fs/xfs/libxfs/xfs_bmap.c       | 12 ++++++------
>  fs/xfs/libxfs/xfs_bmap_btree.c |  4 ++--
>  fs/xfs/libxfs/xfs_da_btree.c   |  4 ++--
>  fs/xfs/libxfs/xfs_inode_buf.c  |  4 ++--
>  fs/xfs/libxfs/xfs_inode_buf.h  |  1 -
>  fs/xfs/libxfs/xfs_inode_fork.c |  2 +-
>  fs/xfs/xfs_bmap_util.c         |  8 ++++----
>  fs/xfs/xfs_icache.c            |  4 ++--
>  fs/xfs/xfs_inode.c             |  8 ++++----
>  fs/xfs/xfs_inode.h             |  1 +
>  fs/xfs/xfs_inode_item.c        |  2 +-
>  fs/xfs/xfs_iops.c              |  3 +--
>  fs/xfs/xfs_itable.c            |  2 +-
>  fs/xfs/xfs_qm.c                | 10 +++++-----
>  fs/xfs/xfs_quotaops.c          |  2 +-
>  15 files changed, 33 insertions(+), 34 deletions(-)
> 
> diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
> index 56d78f8ba55eb6..54f3015f08285a 100644
> --- a/fs/xfs/libxfs/xfs_bmap.c
> +++ b/fs/xfs/libxfs/xfs_bmap.c
> @@ -623,7 +623,7 @@ xfs_bmap_btree_to_extents(
>  		return error;
>  	xfs_rmap_ino_bmbt_owner(&oinfo, ip->i_ino, whichfork);
>  	xfs_bmap_add_free(cur->bc_tp, cbno, 1, &oinfo);
> -	ip->i_d.di_nblocks--;
> +	ip->i_nblocks--;
>  	xfs_trans_mod_dquot_byino(tp, ip, XFS_TRANS_DQ_BCOUNT, -1L);
>  	xfs_trans_binval(tp, cbp);
>  	if (cur->bc_bufs[0] == cbp)
> @@ -725,7 +725,7 @@ xfs_bmap_extents_to_btree(
>  	       args.agno >= XFS_FSB_TO_AGNO(mp, tp->t_firstblock));
>  	tp->t_firstblock = args.fsbno;
>  	cur->bc_ino.allocated++;
> -	ip->i_d.di_nblocks++;
> +	ip->i_nblocks++;
>  	xfs_trans_mod_dquot_byino(tp, ip, XFS_TRANS_DQ_BCOUNT, 1L);
>  	error = xfs_trans_get_buf(tp, mp->m_ddev_targp,
>  			XFS_FSB_TO_DADDR(mp, args.fsbno),
> @@ -907,7 +907,7 @@ xfs_bmap_local_to_extents(
>  	xfs_iext_insert(ip, &icur, &rec, 0);
>  
>  	ifp->if_nextents = 1;
> -	ip->i_d.di_nblocks = 1;
> +	ip->i_nblocks = 1;
>  	xfs_trans_mod_dquot_byino(tp, ip,
>  		XFS_TRANS_DQ_BCOUNT, 1L);
>  	flags |= xfs_ilog_fext(whichfork);
> @@ -3448,7 +3448,7 @@ xfs_bmap_btalloc_accounting(
>  	}
>  
>  	/* data/attr fork only */
> -	ap->ip->i_d.di_nblocks += args->len;
> +	ap->ip->i_nblocks += args->len;
>  	xfs_trans_log_inode(ap->tp, ap->ip, XFS_ILOG_CORE);
>  	if (ap->wasdel) {
>  		ap->ip->i_delayed_blks -= args->len;
> @@ -4659,7 +4659,7 @@ xfs_bmapi_remap(
>  		ASSERT(got.br_startoff - bno >= len);
>  	}
>  
> -	ip->i_d.di_nblocks += len;
> +	ip->i_nblocks += len;
>  	xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
>  
>  	if (ifp->if_flags & XFS_IFBROOT) {
> @@ -5225,7 +5225,7 @@ xfs_bmap_del_extent_real(
>  	 * Adjust inode # blocks in the file.
>  	 */
>  	if (nblks)
> -		ip->i_d.di_nblocks -= nblks;
> +		ip->i_nblocks -= nblks;
>  	/*
>  	 * Adjust quota data.
>  	 */
> diff --git a/fs/xfs/libxfs/xfs_bmap_btree.c b/fs/xfs/libxfs/xfs_bmap_btree.c
> index d9c63f17d2decd..9ad4c6a1eec518 100644
> --- a/fs/xfs/libxfs/xfs_bmap_btree.c
> +++ b/fs/xfs/libxfs/xfs_bmap_btree.c
> @@ -260,7 +260,7 @@ xfs_bmbt_alloc_block(
>  	ASSERT(args.len == 1);
>  	cur->bc_tp->t_firstblock = args.fsbno;
>  	cur->bc_ino.allocated++;
> -	cur->bc_ino.ip->i_d.di_nblocks++;
> +	cur->bc_ino.ip->i_nblocks++;
>  	xfs_trans_log_inode(args.tp, cur->bc_ino.ip, XFS_ILOG_CORE);
>  	xfs_trans_mod_dquot_byino(args.tp, cur->bc_ino.ip,
>  			XFS_TRANS_DQ_BCOUNT, 1L);
> @@ -287,7 +287,7 @@ xfs_bmbt_free_block(
>  
>  	xfs_rmap_ino_bmbt_owner(&oinfo, ip->i_ino, cur->bc_ino.whichfork);
>  	xfs_bmap_add_free(cur->bc_tp, fsbno, 1, &oinfo);
> -	ip->i_d.di_nblocks--;
> +	ip->i_nblocks--;
>  
>  	xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
>  	xfs_trans_mod_dquot_byino(tp, ip, XFS_TRANS_DQ_BCOUNT, -1L);
> diff --git a/fs/xfs/libxfs/xfs_da_btree.c b/fs/xfs/libxfs/xfs_da_btree.c
> index 897749c41f36eb..55fadffb8752d3 100644
> --- a/fs/xfs/libxfs/xfs_da_btree.c
> +++ b/fs/xfs/libxfs/xfs_da_btree.c
> @@ -2139,7 +2139,7 @@ xfs_da_grow_inode_int(
>  	struct xfs_trans	*tp = args->trans;
>  	struct xfs_inode	*dp = args->dp;
>  	int			w = args->whichfork;
> -	xfs_rfsblock_t		nblks = dp->i_d.di_nblocks;
> +	xfs_rfsblock_t		nblks = dp->i_nblocks;
>  	struct xfs_bmbt_irec	map, *mapp;
>  	int			nmap, error, got, i, mapi;
>  
> @@ -2205,7 +2205,7 @@ xfs_da_grow_inode_int(
>  	}
>  
>  	/* account for newly allocated blocks in reserved blocks total */
> -	args->total -= dp->i_d.di_nblocks - nblks;
> +	args->total -= dp->i_nblocks - nblks;
>  
>  out_free_map:
>  	if (mapp != &map)
> diff --git a/fs/xfs/libxfs/xfs_inode_buf.c b/fs/xfs/libxfs/xfs_inode_buf.c
> index c202de8bbdd427..d1a15778e86a38 100644
> --- a/fs/xfs/libxfs/xfs_inode_buf.c
> +++ b/fs/xfs/libxfs/xfs_inode_buf.c
> @@ -242,7 +242,7 @@ xfs_inode_from_disk(
>  	inode->i_ctime.tv_nsec = (int)be32_to_cpu(from->di_ctime.t_nsec);
>  
>  	ip->i_disk_size = be64_to_cpu(from->di_size);
> -	to->di_nblocks = be64_to_cpu(from->di_nblocks);
> +	ip->i_nblocks = be64_to_cpu(from->di_nblocks);
>  	to->di_extsize = be32_to_cpu(from->di_extsize);
>  	to->di_forkoff = from->di_forkoff;
>  	to->di_dmevmask	= be32_to_cpu(from->di_dmevmask);
> @@ -305,7 +305,7 @@ xfs_inode_to_disk(
>  	to->di_mode = cpu_to_be16(inode->i_mode);
>  
>  	to->di_size = cpu_to_be64(ip->i_disk_size);
> -	to->di_nblocks = cpu_to_be64(from->di_nblocks);
> +	to->di_nblocks = cpu_to_be64(ip->i_nblocks);
>  	to->di_extsize = cpu_to_be32(from->di_extsize);
>  	to->di_nextents = cpu_to_be32(xfs_ifork_nextents(&ip->i_df));
>  	to->di_anextents = cpu_to_be16(xfs_ifork_nextents(ip->i_afp));
> diff --git a/fs/xfs/libxfs/xfs_inode_buf.h b/fs/xfs/libxfs/xfs_inode_buf.h
> index f187127d50e010..a322e1adf0a348 100644
> --- a/fs/xfs/libxfs/xfs_inode_buf.h
> +++ b/fs/xfs/libxfs/xfs_inode_buf.h
> @@ -17,7 +17,6 @@ struct xfs_dinode;
>   */
>  struct xfs_icdinode {
>  	uint16_t	di_flushiter;	/* incremented on flush */
> -	xfs_rfsblock_t	di_nblocks;	/* # of direct & btree blocks used */
>  	xfs_extlen_t	di_extsize;	/* basic/minimum extent size for file */
>  	uint8_t		di_forkoff;	/* attr fork offs, <<3 for 64b align */
>  	uint32_t	di_dmevmask;	/* DMIG event mask */
> diff --git a/fs/xfs/libxfs/xfs_inode_fork.c b/fs/xfs/libxfs/xfs_inode_fork.c
> index d2029e12bda4de..391836dd4814e0 100644
> --- a/fs/xfs/libxfs/xfs_inode_fork.c
> +++ b/fs/xfs/libxfs/xfs_inode_fork.c
> @@ -192,7 +192,7 @@ xfs_iformat_btree(
>  		     nrecs == 0 ||
>  		     XFS_BMDR_SPACE_CALC(nrecs) >
>  					XFS_DFORK_SIZE(dip, mp, whichfork) ||
> -		     ifp->if_nextents > ip->i_d.di_nblocks) ||
> +		     ifp->if_nextents > ip->i_nblocks) ||
>  		     level == 0 || level > XFS_BTREE_MAXLEVELS) {
>  		xfs_warn(mp, "corrupt inode %Lu (btree).",
>  					(unsigned long long) ip->i_ino);
> diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c
> index d199ecddc1ab19..5eba039d72fb83 100644
> --- a/fs/xfs/xfs_bmap_util.c
> +++ b/fs/xfs/xfs_bmap_util.c
> @@ -154,7 +154,7 @@ xfs_bmap_rtalloc(
>  		ap->blkno *= mp->m_sb.sb_rextsize;
>  		ralen *= mp->m_sb.sb_rextsize;
>  		ap->length = ralen;
> -		ap->ip->i_d.di_nblocks += ralen;
> +		ap->ip->i_nblocks += ralen;
>  		xfs_trans_log_inode(ap->tp, ap->ip, XFS_ILOG_CORE);
>  		if (ap->wasdel)
>  			ap->ip->i_delayed_blks -= ralen;
> @@ -1469,9 +1469,9 @@ xfs_swap_extent_forks(
>  	/*
>  	 * Fix the on-disk inode values
>  	 */
> -	tmp = (uint64_t)ip->i_d.di_nblocks;
> -	ip->i_d.di_nblocks = tip->i_d.di_nblocks - taforkblks + aforkblks;
> -	tip->i_d.di_nblocks = tmp + taforkblks - aforkblks;
> +	tmp = (uint64_t)ip->i_nblocks;
> +	ip->i_nblocks = tip->i_nblocks - taforkblks + aforkblks;
> +	tip->i_nblocks = tmp + taforkblks - aforkblks;
>  
>  	/*
>  	 * The extents in the source inode could still contain speculative
> diff --git a/fs/xfs/xfs_icache.c b/fs/xfs/xfs_icache.c
> index a3bbd6e4bb6fc8..ad01e694f3ab9b 100644
> --- a/fs/xfs/xfs_icache.c
> +++ b/fs/xfs/xfs_icache.c
> @@ -66,7 +66,7 @@ xfs_inode_alloc(
>  	memset(&ip->i_df, 0, sizeof(ip->i_df));
>  	ip->i_flags = 0;
>  	ip->i_delayed_blks = 0;
> -	ip->i_d.di_nblocks = 0;
> +	ip->i_nblocks = 0;
>  	ip->i_d.di_forkoff = 0;
>  	ip->i_sick = 0;
>  	ip->i_checked = 0;
> @@ -331,7 +331,7 @@ xfs_iget_check_free_state(
>  			return -EFSCORRUPTED;
>  		}
>  
> -		if (ip->i_d.di_nblocks != 0) {
> +		if (ip->i_nblocks != 0) {
>  			xfs_warn(ip->i_mount,
>  "Corruption detected! Free inode 0x%llx has blocks allocated!",
>  				ip->i_ino);
> diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
> index 723a911c8b6d81..19d132acc499cb 100644
> --- a/fs/xfs/xfs_inode.c
> +++ b/fs/xfs/xfs_inode.c
> @@ -827,7 +827,7 @@ xfs_ialloc(
>  
>  	ip->i_disk_size = 0;
>  	ip->i_df.if_nextents = 0;
> -	ASSERT(ip->i_d.di_nblocks == 0);
> +	ASSERT(ip->i_nblocks == 0);
>  
>  	tv = current_time(inode);
>  	inode->i_mtime = tv;
> @@ -2730,7 +2730,7 @@ xfs_ifree(
>  	ASSERT(VFS_I(ip)->i_nlink == 0);
>  	ASSERT(ip->i_df.if_nextents == 0);
>  	ASSERT(ip->i_disk_size == 0 || !S_ISREG(VFS_I(ip)->i_mode));
> -	ASSERT(ip->i_d.di_nblocks == 0);
> +	ASSERT(ip->i_nblocks == 0);
>  
>  	/*
>  	 * Pull the on-disk inode from the AGI unlinked list.
> @@ -3747,13 +3747,13 @@ xfs_iflush_int(
>  		}
>  	}
>  	if (XFS_TEST_ERROR(ip->i_df.if_nextents + xfs_ifork_nextents(ip->i_afp) >
> -				ip->i_d.di_nblocks, mp, XFS_ERRTAG_IFLUSH_5)) {
> +				ip->i_nblocks, mp, XFS_ERRTAG_IFLUSH_5)) {
>  		xfs_alert_tag(mp, XFS_PTAG_IFLUSH,
>  			"%s: detected corrupt incore inode %Lu, "
>  			"total extents = %d, nblocks = %Ld, ptr "PTR_FMT,
>  			__func__, ip->i_ino,
>  			ip->i_df.if_nextents + xfs_ifork_nextents(ip->i_afp),
> -			ip->i_d.di_nblocks, ip);
> +			ip->i_nblocks, ip);
>  		goto flush_out;
>  	}
>  	if (XFS_TEST_ERROR(ip->i_d.di_forkoff > mp->m_sb.sb_inodesize,
> diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h
> index 61c41395536f07..828f49f109475e 100644
> --- a/fs/xfs/xfs_inode.h
> +++ b/fs/xfs/xfs_inode.h
> @@ -55,6 +55,7 @@ typedef struct xfs_inode {
>  	unsigned long		i_flags;	/* see defined flags below */
>  	uint64_t		i_delayed_blks;	/* count of delay alloc blks */
>  	xfs_fsize_t		i_disk_size;	/* number of bytes in file */
> +	xfs_rfsblock_t		i_nblocks;	/* # of direct & btree blocks */
>  	uint32_t		i_projid;	/* owner's project id */
>  
>  	struct xfs_icdinode	i_d;		/* most of ondisk inode */
> diff --git a/fs/xfs/xfs_inode_item.c b/fs/xfs/xfs_inode_item.c
> index 179f1c2de6bd0f..0980fa43472cf8 100644
> --- a/fs/xfs/xfs_inode_item.c
> +++ b/fs/xfs/xfs_inode_item.c
> @@ -324,7 +324,7 @@ xfs_inode_to_log_dinode(
>  	to->di_mode = inode->i_mode;
>  
>  	to->di_size = ip->i_disk_size;
> -	to->di_nblocks = from->di_nblocks;
> +	to->di_nblocks = ip->i_nblocks;
>  	to->di_extsize = from->di_extsize;
>  	to->di_nextents = xfs_ifork_nextents(&ip->i_df);
>  	to->di_anextents = xfs_ifork_nextents(ip->i_afp);
> diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
> index 1abee83d49cff9..78159c57d82828 100644
> --- a/fs/xfs/xfs_iops.c
> +++ b/fs/xfs/xfs_iops.c
> @@ -554,8 +554,7 @@ xfs_vn_getattr(
>  	stat->atime = inode->i_atime;
>  	stat->mtime = inode->i_mtime;
>  	stat->ctime = inode->i_ctime;
> -	stat->blocks =
> -		XFS_FSB_TO_BB(mp, ip->i_d.di_nblocks + ip->i_delayed_blks);
> +	stat->blocks = XFS_FSB_TO_BB(mp, ip->i_nblocks + ip->i_delayed_blks);
>  
>  	if (xfs_sb_version_has_v3inode(&mp->m_sb)) {
>  		if (request_mask & STATX_BTIME) {
> diff --git a/fs/xfs/xfs_itable.c b/fs/xfs/xfs_itable.c
> index 9f92514301b334..7af144500bbfdb 100644
> --- a/fs/xfs/xfs_itable.c
> +++ b/fs/xfs/xfs_itable.c
> @@ -130,7 +130,7 @@ xfs_bulkstat_one_int(
>  	case XFS_DINODE_FMT_BTREE:
>  		buf->bs_rdev = 0;
>  		buf->bs_blksize = mp->m_sb.sb_blocksize;
> -		buf->bs_blocks = dic->di_nblocks + ip->i_delayed_blks;
> +		buf->bs_blocks = ip->i_nblocks + ip->i_delayed_blks;
>  		break;
>  	}
>  	xfs_iunlock(ip, XFS_ILOCK_SHARED);
> diff --git a/fs/xfs/xfs_qm.c b/fs/xfs/xfs_qm.c
> index ea22dcf868b474..3af3b5f5d4f2ad 100644
> --- a/fs/xfs/xfs_qm.c
> +++ b/fs/xfs/xfs_qm.c
> @@ -989,7 +989,7 @@ xfs_qm_reset_dqcounts_buf(
>  	 * trans_reserve. But, this gets called during quotacheck, and that
>  	 * happens only at mount time which is single threaded.
>  	 */
> -	if (qip->i_d.di_nblocks == 0)
> +	if (qip->i_nblocks == 0)
>  		return 0;
>  
>  	map = kmem_alloc(XFS_DQITER_MAP_SIZE * sizeof(*map), 0);
> @@ -1171,7 +1171,7 @@ xfs_qm_dqusage_adjust(
>  		xfs_bmap_count_leaves(ifp, &rtblks);
>  	}
>  
> -	nblks = (xfs_qcnt_t)ip->i_d.di_nblocks - rtblks;
> +	nblks = (xfs_qcnt_t)ip->i_nblocks - rtblks;
>  
>  	/*
>  	 * Add the (disk blocks and inode) resources occupied by this
> @@ -1774,11 +1774,11 @@ xfs_qm_vop_chown(
>  	ASSERT(prevdq);
>  	ASSERT(prevdq != newdq);
>  
> -	xfs_trans_mod_dquot(tp, prevdq, bfield, -(ip->i_d.di_nblocks));
> +	xfs_trans_mod_dquot(tp, prevdq, bfield, -(ip->i_nblocks));
>  	xfs_trans_mod_dquot(tp, prevdq, XFS_TRANS_DQ_ICOUNT, -1);
>  
>  	/* the sparkling new dquot */
> -	xfs_trans_mod_dquot(tp, newdq, bfield, ip->i_d.di_nblocks);
> +	xfs_trans_mod_dquot(tp, newdq, bfield, ip->i_nblocks);
>  	xfs_trans_mod_dquot(tp, newdq, XFS_TRANS_DQ_ICOUNT, 1);
>  
>  	/*
> @@ -1854,7 +1854,7 @@ xfs_qm_vop_chown_reserve(
>  
>  	error = xfs_trans_reserve_quota_bydquots(tp, ip->i_mount,
>  				udq_delblks, gdq_delblks, pdq_delblks,
> -				ip->i_d.di_nblocks, 1, flags | blkflags);
> +				ip->i_nblocks, 1, flags | blkflags);
>  	if (error)
>  		return error;
>  
> diff --git a/fs/xfs/xfs_quotaops.c b/fs/xfs/xfs_quotaops.c
> index bf809b77a31606..09a5290ad2bd1b 100644
> --- a/fs/xfs/xfs_quotaops.c
> +++ b/fs/xfs/xfs_quotaops.c
> @@ -35,7 +35,7 @@ xfs_qm_fill_state(
>  		tempqip = true;
>  	}
>  	tstate->flags |= QCI_SYSFILE;
> -	tstate->blocks = ip->i_d.di_nblocks;
> +	tstate->blocks = ip->i_nblocks;
>  	tstate->nextents = ip->i_df.if_nextents;
>  	tstate->spc_timelimit = (u32)defq->btimelimit;
>  	tstate->ino_timelimit = (u32)defq->itimelimit;
> -- 
> 2.26.2
> 

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH 05/15] xfs: move the di_extsize field to struct xfs_inode
  2020-06-20  7:10 ` [PATCH 05/15] xfs: move the di_extsize " Christoph Hellwig
  2020-06-22  9:36   ` Chandan Babu R
@ 2020-06-30 17:47   ` Darrick J. Wong
  1 sibling, 0 replies; 52+ messages in thread
From: Darrick J. Wong @ 2020-06-30 17:47 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: linux-xfs

On Sat, Jun 20, 2020 at 09:10:52AM +0200, Christoph Hellwig wrote:
> In preparation of removing the historic icinode struct, move the extsize
> field into the containing xfs_inode structure.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>

Looks good,
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>

--D

> ---
>  fs/xfs/libxfs/xfs_bmap.c      |  2 +-
>  fs/xfs/libxfs/xfs_inode_buf.c |  4 ++--
>  fs/xfs/libxfs/xfs_inode_buf.h |  1 -
>  fs/xfs/xfs_inode.c            | 10 +++++-----
>  fs/xfs/xfs_inode.h            |  1 +
>  fs/xfs/xfs_inode_item.c       |  2 +-
>  fs/xfs/xfs_ioctl.c            | 10 +++++-----
>  fs/xfs/xfs_itable.c           |  2 +-
>  8 files changed, 16 insertions(+), 16 deletions(-)
> 
> diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
> index 54f3015f08285a..692159357ed8e5 100644
> --- a/fs/xfs/libxfs/xfs_bmap.c
> +++ b/fs/xfs/libxfs/xfs_bmap.c
> @@ -2942,7 +2942,7 @@ xfs_bmap_add_extent_hole_real(
>   */
>  
>  /*
> - * Adjust the size of the new extent based on di_extsize and rt extsize.
> + * Adjust the size of the new extent based on i_extsize and rt extsize.
>   */
>  int
>  xfs_bmap_extsize_align(
> diff --git a/fs/xfs/libxfs/xfs_inode_buf.c b/fs/xfs/libxfs/xfs_inode_buf.c
> index d1a15778e86a38..e51b15c44bb3e1 100644
> --- a/fs/xfs/libxfs/xfs_inode_buf.c
> +++ b/fs/xfs/libxfs/xfs_inode_buf.c
> @@ -243,7 +243,7 @@ xfs_inode_from_disk(
>  
>  	ip->i_disk_size = be64_to_cpu(from->di_size);
>  	ip->i_nblocks = be64_to_cpu(from->di_nblocks);
> -	to->di_extsize = be32_to_cpu(from->di_extsize);
> +	ip->i_extsize = be32_to_cpu(from->di_extsize);
>  	to->di_forkoff = from->di_forkoff;
>  	to->di_dmevmask	= be32_to_cpu(from->di_dmevmask);
>  	to->di_dmstate	= be16_to_cpu(from->di_dmstate);
> @@ -306,7 +306,7 @@ xfs_inode_to_disk(
>  
>  	to->di_size = cpu_to_be64(ip->i_disk_size);
>  	to->di_nblocks = cpu_to_be64(ip->i_nblocks);
> -	to->di_extsize = cpu_to_be32(from->di_extsize);
> +	to->di_extsize = cpu_to_be32(ip->i_extsize);
>  	to->di_nextents = cpu_to_be32(xfs_ifork_nextents(&ip->i_df));
>  	to->di_anextents = cpu_to_be16(xfs_ifork_nextents(ip->i_afp));
>  	to->di_forkoff = from->di_forkoff;
> diff --git a/fs/xfs/libxfs/xfs_inode_buf.h b/fs/xfs/libxfs/xfs_inode_buf.h
> index a322e1adf0a348..d420ea835c8390 100644
> --- a/fs/xfs/libxfs/xfs_inode_buf.h
> +++ b/fs/xfs/libxfs/xfs_inode_buf.h
> @@ -17,7 +17,6 @@ struct xfs_dinode;
>   */
>  struct xfs_icdinode {
>  	uint16_t	di_flushiter;	/* incremented on flush */
> -	xfs_extlen_t	di_extsize;	/* basic/minimum extent size for file */
>  	uint8_t		di_forkoff;	/* attr fork offs, <<3 for 64b align */
>  	uint32_t	di_dmevmask;	/* DMIG event mask */
>  	uint16_t	di_dmstate;	/* DMIG state info */
> diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
> index 19d132acc499cb..6d1891f902aaa9 100644
> --- a/fs/xfs/xfs_inode.c
> +++ b/fs/xfs/xfs_inode.c
> @@ -61,8 +61,8 @@ xfs_get_extsz_hint(
>  	 */
>  	if (xfs_is_always_cow_inode(ip))
>  		return 0;
> -	if ((ip->i_d.di_flags & XFS_DIFLAG_EXTSIZE) && ip->i_d.di_extsize)
> -		return ip->i_d.di_extsize;
> +	if ((ip->i_d.di_flags & XFS_DIFLAG_EXTSIZE) && ip->i_extsize)
> +		return ip->i_extsize;
>  	if (XFS_IS_REALTIME_INODE(ip))
>  		return ip->i_mount->m_sb.sb_rextsize;
>  	return 0;
> @@ -834,7 +834,7 @@ xfs_ialloc(
>  	inode->i_atime = tv;
>  	inode->i_ctime = tv;
>  
> -	ip->i_d.di_extsize = 0;
> +	ip->i_extsize = 0;
>  	ip->i_d.di_dmevmask = 0;
>  	ip->i_d.di_dmstate = 0;
>  	ip->i_d.di_flags = 0;
> @@ -866,7 +866,7 @@ xfs_ialloc(
>  					di_flags |= XFS_DIFLAG_RTINHERIT;
>  				if (pip->i_d.di_flags & XFS_DIFLAG_EXTSZINHERIT) {
>  					di_flags |= XFS_DIFLAG_EXTSZINHERIT;
> -					ip->i_d.di_extsize = pip->i_d.di_extsize;
> +					ip->i_extsize = pip->i_extsize;
>  				}
>  				if (pip->i_d.di_flags & XFS_DIFLAG_PROJINHERIT)
>  					di_flags |= XFS_DIFLAG_PROJINHERIT;
> @@ -875,7 +875,7 @@ xfs_ialloc(
>  					di_flags |= XFS_DIFLAG_REALTIME;
>  				if (pip->i_d.di_flags & XFS_DIFLAG_EXTSZINHERIT) {
>  					di_flags |= XFS_DIFLAG_EXTSIZE;
> -					ip->i_d.di_extsize = pip->i_d.di_extsize;
> +					ip->i_extsize = pip->i_extsize;
>  				}
>  			}
>  			if ((pip->i_d.di_flags & XFS_DIFLAG_NOATIME) &&
> diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h
> index 828f49f109475e..af90c6f745549b 100644
> --- a/fs/xfs/xfs_inode.h
> +++ b/fs/xfs/xfs_inode.h
> @@ -57,6 +57,7 @@ typedef struct xfs_inode {
>  	xfs_fsize_t		i_disk_size;	/* number of bytes in file */
>  	xfs_rfsblock_t		i_nblocks;	/* # of direct & btree blocks */
>  	uint32_t		i_projid;	/* owner's project id */
> +	xfs_extlen_t		i_extsize;	/* basic/minimum extent size */
>  
>  	struct xfs_icdinode	i_d;		/* most of ondisk inode */
>  
> diff --git a/fs/xfs/xfs_inode_item.c b/fs/xfs/xfs_inode_item.c
> index 0980fa43472cf8..8b8c99809f273e 100644
> --- a/fs/xfs/xfs_inode_item.c
> +++ b/fs/xfs/xfs_inode_item.c
> @@ -325,7 +325,7 @@ xfs_inode_to_log_dinode(
>  
>  	to->di_size = ip->i_disk_size;
>  	to->di_nblocks = ip->i_nblocks;
> -	to->di_extsize = from->di_extsize;
> +	to->di_extsize = ip->i_extsize;
>  	to->di_nextents = xfs_ifork_nextents(&ip->i_df);
>  	to->di_anextents = xfs_ifork_nextents(ip->i_afp);
>  	to->di_forkoff = from->di_forkoff;
> diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
> index d93f4fc40fd99e..efe3b5bc1178dc 100644
> --- a/fs/xfs/xfs_ioctl.c
> +++ b/fs/xfs/xfs_ioctl.c
> @@ -1107,7 +1107,7 @@ xfs_fill_fsxattr(
>  	struct xfs_ifork	*ifp = attr ? ip->i_afp : &ip->i_df;
>  
>  	simple_fill_fsxattr(fa, xfs_ip2xflags(ip));
> -	fa->fsx_extsize = ip->i_d.di_extsize << ip->i_mount->m_sb.sb_blocklog;
> +	fa->fsx_extsize = ip->i_extsize << ip->i_mount->m_sb.sb_blocklog;
>  	fa->fsx_cowextsize = ip->i_d.di_cowextsize <<
>  			ip->i_mount->m_sb.sb_blocklog;
>  	fa->fsx_projid = ip->i_projid;
> @@ -1209,7 +1209,7 @@ xfs_ioctl_setattr_xflags(
>  	/* If realtime flag is set then must have realtime device */
>  	if (fa->fsx_xflags & FS_XFLAG_REALTIME) {
>  		if (mp->m_sb.sb_rblocks == 0 || mp->m_sb.sb_rextsize == 0 ||
> -		    (ip->i_d.di_extsize % mp->m_sb.sb_rextsize))
> +		    (ip->i_extsize % mp->m_sb.sb_rextsize))
>  			return -EINVAL;
>  	}
>  
> @@ -1381,7 +1381,7 @@ xfs_ioctl_setattr_check_extsize(
>  	xfs_fsblock_t		extsize_fsb;
>  
>  	if (S_ISREG(VFS_I(ip)->i_mode) && ip->i_df.if_nextents &&
> -	    ((ip->i_d.di_extsize << mp->m_sb.sb_blocklog) != fa->fsx_extsize))
> +	    ((ip->i_extsize << mp->m_sb.sb_blocklog) != fa->fsx_extsize))
>  		return -EINVAL;
>  
>  	if (fa->fsx_extsize == 0)
> @@ -1569,9 +1569,9 @@ xfs_ioctl_setattr(
>  	 * are set on the inode then unconditionally clear the extent size hint.
>  	 */
>  	if (ip->i_d.di_flags & (XFS_DIFLAG_EXTSIZE | XFS_DIFLAG_EXTSZINHERIT))
> -		ip->i_d.di_extsize = fa->fsx_extsize >> mp->m_sb.sb_blocklog;
> +		ip->i_extsize = fa->fsx_extsize >> mp->m_sb.sb_blocklog;
>  	else
> -		ip->i_d.di_extsize = 0;
> +		ip->i_extsize = 0;
>  	if (xfs_sb_version_has_v3inode(&mp->m_sb) &&
>  	    (ip->i_d.di_flags2 & XFS_DIFLAG2_COWEXTSIZE))
>  		ip->i_d.di_cowextsize = fa->fsx_cowextsize >>
> diff --git a/fs/xfs/xfs_itable.c b/fs/xfs/xfs_itable.c
> index 7af144500bbfdb..b0f0c19fd7822e 100644
> --- a/fs/xfs/xfs_itable.c
> +++ b/fs/xfs/xfs_itable.c
> @@ -103,7 +103,7 @@ xfs_bulkstat_one_int(
>  	buf->bs_mode = inode->i_mode;
>  
>  	buf->bs_xflags = xfs_ip2xflags(ip);
> -	buf->bs_extsize_blks = dic->di_extsize;
> +	buf->bs_extsize_blks = ip->i_extsize;
>  	buf->bs_extents = xfs_ifork_nextents(&ip->i_df);
>  	xfs_bulkstat_health(ip, buf);
>  	buf->bs_aextents = xfs_ifork_nextents(ip->i_afp);
> -- 
> 2.26.2
> 

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH 06/15] xfs: move the di_cowextsize field to struct xfs_inode
  2020-06-20  7:10 ` [PATCH 06/15] xfs: move the di_cowextsize " Christoph Hellwig
  2020-06-22  9:47   ` Chandan Babu R
@ 2020-06-30 17:48   ` Darrick J. Wong
  1 sibling, 0 replies; 52+ messages in thread
From: Darrick J. Wong @ 2020-06-30 17:48 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: linux-xfs

On Sat, Jun 20, 2020 at 09:10:53AM +0200, Christoph Hellwig wrote:
> In preparation of removing the historic icinode struct, move the
> cowextsize field into the containing xfs_inode structure.  Also
> switch to use the xfs_extlen_t instead of a uint32_t.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>

Seems like a pretty easy substitution,
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>

--D

> ---
>  fs/xfs/libxfs/xfs_inode_buf.c | 4 ++--
>  fs/xfs/libxfs/xfs_inode_buf.h | 1 -
>  fs/xfs/xfs_file.c             | 2 +-
>  fs/xfs/xfs_inode.c            | 6 +++---
>  fs/xfs/xfs_inode.h            | 1 +
>  fs/xfs/xfs_inode_item.c       | 2 +-
>  fs/xfs/xfs_ioctl.c            | 8 +++-----
>  fs/xfs/xfs_itable.c           | 2 +-
>  fs/xfs/xfs_reflink.c          | 2 +-
>  9 files changed, 13 insertions(+), 15 deletions(-)
> 
> diff --git a/fs/xfs/libxfs/xfs_inode_buf.c b/fs/xfs/libxfs/xfs_inode_buf.c
> index e51b15c44bb3e1..860e35611e001a 100644
> --- a/fs/xfs/libxfs/xfs_inode_buf.c
> +++ b/fs/xfs/libxfs/xfs_inode_buf.c
> @@ -255,7 +255,7 @@ xfs_inode_from_disk(
>  		to->di_crtime.tv_sec = be32_to_cpu(from->di_crtime.t_sec);
>  		to->di_crtime.tv_nsec = be32_to_cpu(from->di_crtime.t_nsec);
>  		to->di_flags2 = be64_to_cpu(from->di_flags2);
> -		to->di_cowextsize = be32_to_cpu(from->di_cowextsize);
> +		ip->i_cowextsize = be32_to_cpu(from->di_cowextsize);
>  	}
>  
>  	error = xfs_iformat_data_fork(ip, from);
> @@ -321,7 +321,7 @@ xfs_inode_to_disk(
>  		to->di_crtime.t_sec = cpu_to_be32(from->di_crtime.tv_sec);
>  		to->di_crtime.t_nsec = cpu_to_be32(from->di_crtime.tv_nsec);
>  		to->di_flags2 = cpu_to_be64(from->di_flags2);
> -		to->di_cowextsize = cpu_to_be32(from->di_cowextsize);
> +		to->di_cowextsize = cpu_to_be32(ip->i_cowextsize);
>  		to->di_ino = cpu_to_be64(ip->i_ino);
>  		to->di_lsn = cpu_to_be64(lsn);
>  		memset(to->di_pad2, 0, sizeof(to->di_pad2));
> diff --git a/fs/xfs/libxfs/xfs_inode_buf.h b/fs/xfs/libxfs/xfs_inode_buf.h
> index d420ea835c8390..663a97fa78f05f 100644
> --- a/fs/xfs/libxfs/xfs_inode_buf.h
> +++ b/fs/xfs/libxfs/xfs_inode_buf.h
> @@ -23,7 +23,6 @@ struct xfs_icdinode {
>  	uint16_t	di_flags;	/* random flags, XFS_DIFLAG_... */
>  
>  	uint64_t	di_flags2;	/* more random flags */
> -	uint32_t	di_cowextsize;	/* basic cow extent size for file */
>  
>  	struct timespec64 di_crtime;	/* time created */
>  };
> diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c
> index 14b533a8ce8e6a..b0384306d6622f 100644
> --- a/fs/xfs/xfs_file.c
> +++ b/fs/xfs/xfs_file.c
> @@ -1055,7 +1055,7 @@ xfs_file_remap_range(
>  	    (src->i_d.di_flags2 & XFS_DIFLAG2_COWEXTSIZE) &&
>  	    pos_out == 0 && len >= i_size_read(inode_out) &&
>  	    !(dest->i_d.di_flags2 & XFS_DIFLAG2_COWEXTSIZE))
> -		cowextsize = src->i_d.di_cowextsize;
> +		cowextsize = src->i_cowextsize;
>  
>  	ret = xfs_reflink_update_dest(dest, pos_out + len, cowextsize,
>  			remap_flags);
> diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
> index 6d1891f902aaa9..f1893824cd4e2f 100644
> --- a/fs/xfs/xfs_inode.c
> +++ b/fs/xfs/xfs_inode.c
> @@ -82,7 +82,7 @@ xfs_get_cowextsz_hint(
>  
>  	a = 0;
>  	if (ip->i_d.di_flags2 & XFS_DIFLAG2_COWEXTSIZE)
> -		a = ip->i_d.di_cowextsize;
> +		a = ip->i_cowextsize;
>  	b = xfs_get_extsz_hint(ip);
>  
>  	a = max(a, b);
> @@ -842,7 +842,7 @@ xfs_ialloc(
>  	if (xfs_sb_version_has_v3inode(&mp->m_sb)) {
>  		inode_set_iversion(inode, 1);
>  		ip->i_d.di_flags2 = 0;
> -		ip->i_d.di_cowextsize = 0;
> +		ip->i_cowextsize = 0;
>  		ip->i_d.di_crtime = tv;
>  	}
>  
> @@ -901,7 +901,7 @@ xfs_ialloc(
>  		if (pip && (pip->i_d.di_flags2 & XFS_DIFLAG2_ANY)) {
>  			if (pip->i_d.di_flags2 & XFS_DIFLAG2_COWEXTSIZE) {
>  				ip->i_d.di_flags2 |= XFS_DIFLAG2_COWEXTSIZE;
> -				ip->i_d.di_cowextsize = pip->i_d.di_cowextsize;
> +				ip->i_cowextsize = pip->i_cowextsize;
>  			}
>  			if (pip->i_d.di_flags2 & XFS_DIFLAG2_DAX)
>  				ip->i_d.di_flags2 |= XFS_DIFLAG2_DAX;
> diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h
> index af90c6f745549b..2cdb7b6b298852 100644
> --- a/fs/xfs/xfs_inode.h
> +++ b/fs/xfs/xfs_inode.h
> @@ -58,6 +58,7 @@ typedef struct xfs_inode {
>  	xfs_rfsblock_t		i_nblocks;	/* # of direct & btree blocks */
>  	uint32_t		i_projid;	/* owner's project id */
>  	xfs_extlen_t		i_extsize;	/* basic/minimum extent size */
> +	xfs_extlen_t		i_cowextsize;	/* basic cow extent size */
>  
>  	struct xfs_icdinode	i_d;		/* most of ondisk inode */
>  
> diff --git a/fs/xfs/xfs_inode_item.c b/fs/xfs/xfs_inode_item.c
> index 8b8c99809f273e..ab0d8cf8ceb6ab 100644
> --- a/fs/xfs/xfs_inode_item.c
> +++ b/fs/xfs/xfs_inode_item.c
> @@ -343,7 +343,7 @@ xfs_inode_to_log_dinode(
>  		to->di_crtime.t_sec = from->di_crtime.tv_sec;
>  		to->di_crtime.t_nsec = from->di_crtime.tv_nsec;
>  		to->di_flags2 = from->di_flags2;
> -		to->di_cowextsize = from->di_cowextsize;
> +		to->di_cowextsize = ip->i_cowextsize;
>  		to->di_ino = ip->i_ino;
>  		to->di_lsn = lsn;
>  		memset(to->di_pad2, 0, sizeof(to->di_pad2));
> diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
> index efe3b5bc1178dc..a1937900ad84be 100644
> --- a/fs/xfs/xfs_ioctl.c
> +++ b/fs/xfs/xfs_ioctl.c
> @@ -1108,8 +1108,7 @@ xfs_fill_fsxattr(
>  
>  	simple_fill_fsxattr(fa, xfs_ip2xflags(ip));
>  	fa->fsx_extsize = ip->i_extsize << ip->i_mount->m_sb.sb_blocklog;
> -	fa->fsx_cowextsize = ip->i_d.di_cowextsize <<
> -			ip->i_mount->m_sb.sb_blocklog;
> +	fa->fsx_cowextsize = ip->i_cowextsize << ip->i_mount->m_sb.sb_blocklog;
>  	fa->fsx_projid = ip->i_projid;
>  	if (ifp && (ifp->if_flags & XFS_IFEXTENTS))
>  		fa->fsx_nextents = xfs_iext_count(ifp);
> @@ -1574,10 +1573,9 @@ xfs_ioctl_setattr(
>  		ip->i_extsize = 0;
>  	if (xfs_sb_version_has_v3inode(&mp->m_sb) &&
>  	    (ip->i_d.di_flags2 & XFS_DIFLAG2_COWEXTSIZE))
> -		ip->i_d.di_cowextsize = fa->fsx_cowextsize >>
> -				mp->m_sb.sb_blocklog;
> +		ip->i_cowextsize = fa->fsx_cowextsize >> mp->m_sb.sb_blocklog;
>  	else
> -		ip->i_d.di_cowextsize = 0;
> +		ip->i_cowextsize = 0;
>  
>  	code = xfs_trans_commit(tp);
>  
> diff --git a/fs/xfs/xfs_itable.c b/fs/xfs/xfs_itable.c
> index b0f0c19fd7822e..7937af9f2ea779 100644
> --- a/fs/xfs/xfs_itable.c
> +++ b/fs/xfs/xfs_itable.c
> @@ -112,7 +112,7 @@ xfs_bulkstat_one_int(
>  
>  	if (xfs_sb_version_has_v3inode(&mp->m_sb)) {
>  		if (dic->di_flags2 & XFS_DIFLAG2_COWEXTSIZE)
> -			buf->bs_cowextsize_blks = dic->di_cowextsize;
> +			buf->bs_cowextsize_blks = ip->i_cowextsize;
>  	}
>  
>  	switch (ip->i_df.if_format) {
> diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c
> index 8598896156e29a..0e07fa7e43117e 100644
> --- a/fs/xfs/xfs_reflink.c
> +++ b/fs/xfs/xfs_reflink.c
> @@ -942,7 +942,7 @@ xfs_reflink_update_dest(
>  	}
>  
>  	if (cowextsize) {
> -		dest->i_d.di_cowextsize = cowextsize;
> +		dest->i_cowextsize = cowextsize;
>  		dest->i_d.di_flags2 |= XFS_DIFLAG2_COWEXTSIZE;
>  	}
>  
> -- 
> 2.26.2
> 

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH 07/15] xfs: move the di_flushiter field to struct xfs_inode
  2020-06-20  7:10 ` [PATCH 07/15] xfs: move the di_flushiter " Christoph Hellwig
  2020-06-22  9:49   ` Chandan Babu R
@ 2020-06-30 17:48   ` Darrick J. Wong
  1 sibling, 0 replies; 52+ messages in thread
From: Darrick J. Wong @ 2020-06-30 17:48 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: linux-xfs

On Sat, Jun 20, 2020 at 09:10:54AM +0200, Christoph Hellwig wrote:
> In preparation of removing the historic icinode struct, move the
> flushiter field into the containing xfs_inode structure.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>

Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>

--D

> ---
>  fs/xfs/libxfs/xfs_inode_buf.c |  4 ++--
>  fs/xfs/libxfs/xfs_inode_buf.h |  1 -
>  fs/xfs/xfs_icache.c           |  2 +-
>  fs/xfs/xfs_inode.c            | 19 +++++++++----------
>  fs/xfs/xfs_inode.h            |  1 +
>  fs/xfs/xfs_inode_item.c       |  2 +-
>  6 files changed, 14 insertions(+), 15 deletions(-)
> 
> diff --git a/fs/xfs/libxfs/xfs_inode_buf.c b/fs/xfs/libxfs/xfs_inode_buf.c
> index 860e35611e001a..03bd7cdd0ddc81 100644
> --- a/fs/xfs/libxfs/xfs_inode_buf.c
> +++ b/fs/xfs/libxfs/xfs_inode_buf.c
> @@ -205,7 +205,7 @@ xfs_inode_from_disk(
>  	 * inode. If the inode is unused, mode is zero and we shouldn't mess
>  	 * with the unitialized part of it.
>  	 */
> -	to->di_flushiter = be16_to_cpu(from->di_flushiter);
> +	ip->i_flushiter = be16_to_cpu(from->di_flushiter);
>  	inode->i_generation = be32_to_cpu(from->di_gen);
>  	inode->i_mode = be16_to_cpu(from->di_mode);
>  	if (!inode->i_mode)
> @@ -329,7 +329,7 @@ xfs_inode_to_disk(
>  		to->di_flushiter = 0;
>  	} else {
>  		to->di_version = 2;
> -		to->di_flushiter = cpu_to_be16(from->di_flushiter);
> +		to->di_flushiter = cpu_to_be16(ip->i_flushiter);
>  	}
>  }
>  
> diff --git a/fs/xfs/libxfs/xfs_inode_buf.h b/fs/xfs/libxfs/xfs_inode_buf.h
> index 663a97fa78f05f..8cc96f2766ff4f 100644
> --- a/fs/xfs/libxfs/xfs_inode_buf.h
> +++ b/fs/xfs/libxfs/xfs_inode_buf.h
> @@ -16,7 +16,6 @@ struct xfs_dinode;
>   * format specific structures at the appropriate time.
>   */
>  struct xfs_icdinode {
> -	uint16_t	di_flushiter;	/* incremented on flush */
>  	uint8_t		di_forkoff;	/* attr fork offs, <<3 for 64b align */
>  	uint32_t	di_dmevmask;	/* DMIG event mask */
>  	uint16_t	di_dmstate;	/* DMIG state info */
> diff --git a/fs/xfs/xfs_icache.c b/fs/xfs/xfs_icache.c
> index ad01e694f3ab9b..e6b40f7035aa5a 100644
> --- a/fs/xfs/xfs_icache.c
> +++ b/fs/xfs/xfs_icache.c
> @@ -521,7 +521,7 @@ xfs_iget_cache_miss(
>  	 * simply build the new inode core with a random generation number.
>  	 *
>  	 * For version 4 (and older) superblocks, log recovery is dependent on
> -	 * the di_flushiter field being initialised from the current on-disk
> +	 * the i_flushiter field being initialised from the current on-disk
>  	 * value and hence we must also read the inode off disk even when
>  	 * initializing new inodes.
>  	 */
> diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
> index f1893824cd4e2f..5e0336e0dbae44 100644
> --- a/fs/xfs/xfs_inode.c
> +++ b/fs/xfs/xfs_inode.c
> @@ -3765,16 +3765,15 @@ xfs_iflush_int(
>  	}
>  
>  	/*
> -	 * Inode item log recovery for v2 inodes are dependent on the
> -	 * di_flushiter count for correct sequencing. We bump the flush
> -	 * iteration count so we can detect flushes which postdate a log record
> -	 * during recovery. This is redundant as we now log every change and
> -	 * hence this can't happen but we need to still do it to ensure
> -	 * backwards compatibility with old kernels that predate logging all
> -	 * inode changes.
> +	 * Inode item log recovery for v2 inodes are dependent on the flushiter
> +	 * count for correct sequencing.  We bump the flush iteration count so
> +	 * we can detect flushes which postdate a log record during recovery.
> +	 * This is redundant as we now log every change and hence this can't
> +	 * happen but we need to still do it to ensure backwards compatibility
> +	 * with old kernels that predate logging all inode changes.
>  	 */
>  	if (!xfs_sb_version_has_v3inode(&mp->m_sb))
> -		ip->i_d.di_flushiter++;
> +		ip->i_flushiter++;
>  
>  	/*
>  	 * If there are inline format data / attr forks attached to this inode,
> @@ -3795,8 +3794,8 @@ xfs_iflush_int(
>  	xfs_inode_to_disk(ip, dip, iip->ili_item.li_lsn);
>  
>  	/* Wrap, we never let the log put out DI_MAX_FLUSH */
> -	if (ip->i_d.di_flushiter == DI_MAX_FLUSH)
> -		ip->i_d.di_flushiter = 0;
> +	if (ip->i_flushiter == DI_MAX_FLUSH)
> +		ip->i_flushiter = 0;
>  
>  	xfs_iflush_fork(ip, dip, iip, XFS_DATA_FORK);
>  	if (XFS_IFORK_Q(ip))
> diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h
> index 2cdb7b6b298852..581618ea1156da 100644
> --- a/fs/xfs/xfs_inode.h
> +++ b/fs/xfs/xfs_inode.h
> @@ -59,6 +59,7 @@ typedef struct xfs_inode {
>  	uint32_t		i_projid;	/* owner's project id */
>  	xfs_extlen_t		i_extsize;	/* basic/minimum extent size */
>  	xfs_extlen_t		i_cowextsize;	/* basic cow extent size */
> +	uint16_t		i_flushiter;	/* incremented on flush */
>  
>  	struct xfs_icdinode	i_d;		/* most of ondisk inode */
>  
> diff --git a/fs/xfs/xfs_inode_item.c b/fs/xfs/xfs_inode_item.c
> index ab0d8cf8ceb6ab..8357fe37d3eb8a 100644
> --- a/fs/xfs/xfs_inode_item.c
> +++ b/fs/xfs/xfs_inode_item.c
> @@ -351,7 +351,7 @@ xfs_inode_to_log_dinode(
>  		to->di_flushiter = 0;
>  	} else {
>  		to->di_version = 2;
> -		to->di_flushiter = from->di_flushiter;
> +		to->di_flushiter = ip->i_flushiter;
>  	}
>  }
>  
> -- 
> 2.26.2
> 

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH 08/15] xfs: use a union for i_cowextsize and i_flushiter
  2020-06-20  7:10 ` [PATCH 08/15] xfs: use a union for i_cowextsize and i_flushiter Christoph Hellwig
  2020-06-22 10:53   ` Chandan Babu R
@ 2020-06-30 17:51   ` Darrick J. Wong
  1 sibling, 0 replies; 52+ messages in thread
From: Darrick J. Wong @ 2020-06-30 17:51 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: linux-xfs

On Sat, Jun 20, 2020 at 07:10:55AM +0000, Christoph Hellwig wrote:
> The i_cowextsize field is only used for v3 inodes, and the i_flushiter
> field is only used for v1/v2 inodes.  Use a union to pack the inode a
> littler better after adding a few missing guards around their usage.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>

/me had previously wondered why it was that _from_disk didn't set the
fields conditionally, but it all looks all right now, so,

Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>

--D

> ---
>  fs/xfs/libxfs/xfs_inode_buf.c | 3 ++-
>  fs/xfs/xfs_inode.c            | 6 ++++--
>  fs/xfs/xfs_inode.h            | 7 +++++--
>  fs/xfs/xfs_ioctl.c            | 6 +++++-
>  4 files changed, 16 insertions(+), 6 deletions(-)
> 
> diff --git a/fs/xfs/libxfs/xfs_inode_buf.c b/fs/xfs/libxfs/xfs_inode_buf.c
> index 03bd7cdd0ddc81..8c4b7bd69285fa 100644
> --- a/fs/xfs/libxfs/xfs_inode_buf.c
> +++ b/fs/xfs/libxfs/xfs_inode_buf.c
> @@ -205,7 +205,8 @@ xfs_inode_from_disk(
>  	 * inode. If the inode is unused, mode is zero and we shouldn't mess
>  	 * with the unitialized part of it.
>  	 */
> -	ip->i_flushiter = be16_to_cpu(from->di_flushiter);
> +	if (!xfs_sb_version_has_v3inode(&ip->i_mount->m_sb))
> +		ip->i_flushiter = be16_to_cpu(from->di_flushiter);
>  	inode->i_generation = be32_to_cpu(from->di_gen);
>  	inode->i_mode = be16_to_cpu(from->di_mode);
>  	if (!inode->i_mode)
> diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
> index 5e0336e0dbae44..fd111e05c0bb2e 100644
> --- a/fs/xfs/xfs_inode.c
> +++ b/fs/xfs/xfs_inode.c
> @@ -3794,8 +3794,10 @@ xfs_iflush_int(
>  	xfs_inode_to_disk(ip, dip, iip->ili_item.li_lsn);
>  
>  	/* Wrap, we never let the log put out DI_MAX_FLUSH */
> -	if (ip->i_flushiter == DI_MAX_FLUSH)
> -		ip->i_flushiter = 0;
> +	if (!xfs_sb_version_has_v3inode(&mp->m_sb)) {
> +		if (ip->i_flushiter == DI_MAX_FLUSH)
> +			ip->i_flushiter = 0;
> +	}
>  
>  	xfs_iflush_fork(ip, dip, iip, XFS_DATA_FORK);
>  	if (XFS_IFORK_Q(ip))
> diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h
> index 581618ea1156da..a0444b9ce3f792 100644
> --- a/fs/xfs/xfs_inode.h
> +++ b/fs/xfs/xfs_inode.h
> @@ -58,8 +58,11 @@ typedef struct xfs_inode {
>  	xfs_rfsblock_t		i_nblocks;	/* # of direct & btree blocks */
>  	uint32_t		i_projid;	/* owner's project id */
>  	xfs_extlen_t		i_extsize;	/* basic/minimum extent size */
> -	xfs_extlen_t		i_cowextsize;	/* basic cow extent size */
> -	uint16_t		i_flushiter;	/* incremented on flush */
> +	/* cowextsize is only used for v3 inodes, flushiter for v1/2 */
> +	union {
> +		xfs_extlen_t	i_cowextsize;	/* basic cow extent size */
> +		uint16_t	i_flushiter;	/* incremented on flush */
> +	};
>  
>  	struct xfs_icdinode	i_d;		/* most of ondisk inode */
>  
> diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
> index a1937900ad84be..60544dd0f875b8 100644
> --- a/fs/xfs/xfs_ioctl.c
> +++ b/fs/xfs/xfs_ioctl.c
> @@ -1108,7 +1108,11 @@ xfs_fill_fsxattr(
>  
>  	simple_fill_fsxattr(fa, xfs_ip2xflags(ip));
>  	fa->fsx_extsize = ip->i_extsize << ip->i_mount->m_sb.sb_blocklog;
> -	fa->fsx_cowextsize = ip->i_cowextsize << ip->i_mount->m_sb.sb_blocklog;
> +	if (xfs_sb_version_has_v3inode(&ip->i_mount->m_sb) &&
> +	    (ip->i_d.di_flags2 & XFS_DIFLAG2_COWEXTSIZE)) {
> +		fa->fsx_cowextsize =
> +			ip->i_cowextsize << ip->i_mount->m_sb.sb_blocklog;
> +	}
>  	fa->fsx_projid = ip->i_projid;
>  	if (ifp && (ifp->if_flags & XFS_IFEXTENTS))
>  		fa->fsx_nextents = xfs_iext_count(ifp);
> -- 
> 2.26.2
> 

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH 09/15] xfs: cleanup xfs_fill_fsxattr
  2020-06-20  7:10 ` [PATCH 09/15] xfs: cleanup xfs_fill_fsxattr Christoph Hellwig
  2020-06-22 11:01   ` Chandan Babu R
@ 2020-06-30 17:52   ` Darrick J. Wong
  1 sibling, 0 replies; 52+ messages in thread
From: Darrick J. Wong @ 2020-06-30 17:52 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: linux-xfs

On Sat, Jun 20, 2020 at 09:10:56AM +0200, Christoph Hellwig wrote:
> Add a local xfs_mount variable, and use the XFS_FSB_TO_B helper.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>

Yes thank you!

Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>

--D

> ---
>  fs/xfs/xfs_ioctl.c | 11 +++++------
>  1 file changed, 5 insertions(+), 6 deletions(-)
> 
> diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
> index 60544dd0f875b8..cabc86ed6756bc 100644
> --- a/fs/xfs/xfs_ioctl.c
> +++ b/fs/xfs/xfs_ioctl.c
> @@ -1104,15 +1104,14 @@ xfs_fill_fsxattr(
>  	bool			attr,
>  	struct fsxattr		*fa)
>  {
> +	struct xfs_mount	*mp = ip->i_mount;
>  	struct xfs_ifork	*ifp = attr ? ip->i_afp : &ip->i_df;
>  
>  	simple_fill_fsxattr(fa, xfs_ip2xflags(ip));
> -	fa->fsx_extsize = ip->i_extsize << ip->i_mount->m_sb.sb_blocklog;
> -	if (xfs_sb_version_has_v3inode(&ip->i_mount->m_sb) &&
> -	    (ip->i_d.di_flags2 & XFS_DIFLAG2_COWEXTSIZE)) {
> -		fa->fsx_cowextsize =
> -			ip->i_cowextsize << ip->i_mount->m_sb.sb_blocklog;
> -	}
> +	fa->fsx_extsize = XFS_FSB_TO_B(mp, ip->i_extsize);
> +	if (xfs_sb_version_has_v3inode(&mp->m_sb) &&
> +	    (ip->i_d.di_flags2 & XFS_DIFLAG2_COWEXTSIZE))
> +		fa->fsx_cowextsize = XFS_FSB_TO_B(mp, ip->i_cowextsize);
>  	fa->fsx_projid = ip->i_projid;
>  	if (ifp && (ifp->if_flags & XFS_IFEXTENTS))
>  		fa->fsx_nextents = xfs_iext_count(ifp);
> -- 
> 2.26.2
> 

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH 10/15] xfs: move the di_forkoff field to struct xfs_inode
  2020-06-20  7:10 ` [PATCH 10/15] xfs: move the di_forkoff field to struct xfs_inode Christoph Hellwig
  2020-06-22 12:15   ` Chandan Babu R
@ 2020-06-30 17:52   ` Darrick J. Wong
  1 sibling, 0 replies; 52+ messages in thread
From: Darrick J. Wong @ 2020-06-30 17:52 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: linux-xfs

On Sat, Jun 20, 2020 at 09:10:57AM +0200, Christoph Hellwig wrote:
> In preparation of removing the historic icinode struct, move the
> forkoff field into the containing xfs_inode structure.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>

Nice conversion,
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>

--D

> ---
>  fs/xfs/libxfs/xfs_attr_leaf.c  | 22 +++++++++++-----------
>  fs/xfs/libxfs/xfs_bmap.c       | 32 ++++++++++++++++----------------
>  fs/xfs/libxfs/xfs_inode_buf.c  |  4 ++--
>  fs/xfs/libxfs/xfs_inode_buf.h  |  1 -
>  fs/xfs/libxfs/xfs_inode_fork.h |  4 ++--
>  fs/xfs/xfs_icache.c            |  2 +-
>  fs/xfs/xfs_inode.c             |  8 ++++----
>  fs/xfs/xfs_inode.h             |  1 +
>  fs/xfs/xfs_inode_item.c        |  2 +-
>  9 files changed, 38 insertions(+), 38 deletions(-)
> 
> diff --git a/fs/xfs/libxfs/xfs_attr_leaf.c b/fs/xfs/libxfs/xfs_attr_leaf.c
> index 2f7e89e4be3e3f..3dca59de331fdf 100644
> --- a/fs/xfs/libxfs/xfs_attr_leaf.c
> +++ b/fs/xfs/libxfs/xfs_attr_leaf.c
> @@ -518,10 +518,10 @@ xfs_attr_copy_value(
>   * Query whether the requested number of additional bytes of extended
>   * attribute space will be able to fit inline.
>   *
> - * Returns zero if not, else the di_forkoff fork offset to be used in the
> + * Returns zero if not, else the i_forkoff fork offset to be used in the
>   * literal area for attribute data once the new bytes have been added.
>   *
> - * di_forkoff must be 8 byte aligned, hence is stored as a >>3 value;
> + * i_forkoff must be 8 byte aligned, hence is stored as a >>3 value;
>   * special case for dev/uuid inodes, they have fixed size data forks.
>   */
>  int
> @@ -554,7 +554,7 @@ xfs_attr_shortform_bytesfit(
>  	 * literal area rebalancing.
>  	 */
>  	if (bytes <= XFS_IFORK_ASIZE(dp))
> -		return dp->i_d.di_forkoff;
> +		return dp->i_forkoff;
>  
>  	/*
>  	 * For attr2 we can try to move the forkoff if there is space in the
> @@ -575,7 +575,7 @@ xfs_attr_shortform_bytesfit(
>  		 * minimum offset only needs to be the space required for
>  		 * the btree root.
>  		 */
> -		if (!dp->i_d.di_forkoff && dp->i_df.if_bytes >
> +		if (!dp->i_forkoff && dp->i_df.if_bytes >
>  		    xfs_default_attroffset(dp))
>  			dsize = XFS_BMDR_SPACE_CALC(MINDBTPTRS);
>  		break;
> @@ -586,10 +586,10 @@ xfs_attr_shortform_bytesfit(
>  		 * minforkoff to where the btree root can finish so we have
>  		 * plenty of room for attrs
>  		 */
> -		if (dp->i_d.di_forkoff) {
> -			if (offset < dp->i_d.di_forkoff)
> +		if (dp->i_forkoff) {
> +			if (offset < dp->i_forkoff)
>  				return 0;
> -			return dp->i_d.di_forkoff;
> +			return dp->i_forkoff;
>  		}
>  		dsize = XFS_BMAP_BROOT_SPACE(mp, dp->i_df.if_broot);
>  		break;
> @@ -677,7 +677,7 @@ xfs_attr_shortform_add(xfs_da_args_t *args, int forkoff)
>  
>  	dp = args->dp;
>  	mp = dp->i_mount;
> -	dp->i_d.di_forkoff = forkoff;
> +	dp->i_forkoff = forkoff;
>  
>  	ifp = dp->i_afp;
>  	ASSERT(ifp->if_flags & XFS_IFINLINE);
> @@ -720,7 +720,7 @@ xfs_attr_fork_remove(
>  	xfs_idestroy_fork(ip->i_afp);
>  	kmem_cache_free(xfs_ifork_zone, ip->i_afp);
>  	ip->i_afp = NULL;
> -	ip->i_d.di_forkoff = 0;
> +	ip->i_forkoff = 0;
>  	xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
>  }
>  
> @@ -775,8 +775,8 @@ xfs_attr_shortform_remove(xfs_da_args_t *args)
>  		xfs_attr_fork_remove(dp, args->trans);
>  	} else {
>  		xfs_idata_realloc(dp, -size, XFS_ATTR_FORK);
> -		dp->i_d.di_forkoff = xfs_attr_shortform_bytesfit(dp, totsize);
> -		ASSERT(dp->i_d.di_forkoff);
> +		dp->i_forkoff = xfs_attr_shortform_bytesfit(dp, totsize);
> +		ASSERT(dp->i_forkoff);
>  		ASSERT(totsize > sizeof(xfs_attr_sf_hdr_t) ||
>  				(args->op_flags & XFS_DA_OP_ADDNAME) ||
>  				!(mp->m_flags & XFS_MOUNT_ATTR2) ||
> diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
> index 692159357ed8e5..7e7e4459a606f1 100644
> --- a/fs/xfs/libxfs/xfs_bmap.c
> +++ b/fs/xfs/libxfs/xfs_bmap.c
> @@ -66,13 +66,13 @@ xfs_bmap_compute_maxlevels(
>  	 * either a signed 32-bit number for the data fork, or a signed 16-bit
>  	 * number for the attr fork.
>  	 *
> -	 * Note that we can no longer assume that if we are in ATTR1 that
> -	 * the fork offset of all the inodes will be
> -	 * (xfs_default_attroffset(ip) >> 3) because we could have mounted
> -	 * with ATTR2 and then mounted back with ATTR1, keeping the
> -	 * di_forkoff's fixed but probably at various positions. Therefore,
> -	 * for both ATTR1 and ATTR2 we have to assume the worst case scenario
> -	 * of a minimum size available.
> +	 * Note that we can no longer assume that if we are in ATTR1 that the
> +	 * fork offset of all the inodes will be
> +	 * (xfs_default_attroffset(ip) >> 3) because we could have mounted with
> +	 * ATTR2 and then mounted back with ATTR1, keeping the i_forkoff's fixed
> +	 * but probably at various positions. Therefore, for both ATTR1 and
> +	 * ATTR2 we have to assume the worst case scenario of a minimum size
> +	 * available.
>  	 */
>  	if (whichfork == XFS_DATA_FORK) {
>  		maxleafents = MAXEXTNUM;
> @@ -205,9 +205,9 @@ xfs_default_attroffset(
>  }
>  
>  /*
> - * Helper routine to reset inode di_forkoff field when switching
> - * attribute fork from local to extent format - we reset it where
> - * possible to make space available for inline data fork extents.
> + * Helper routine to reset inode i_forkoff field when switching attribute fork
> + * from local to extent format - we reset it where possible to make space
> + * available for inline data fork extents.
>   */
>  STATIC void
>  xfs_bmap_forkoff_reset(
> @@ -219,8 +219,8 @@ xfs_bmap_forkoff_reset(
>  	    ip->i_df.if_format != XFS_DINODE_FMT_BTREE) {
>  		uint	dfl_forkoff = xfs_default_attroffset(ip) >> 3;
>  
> -		if (dfl_forkoff > ip->i_d.di_forkoff)
> -			ip->i_d.di_forkoff = dfl_forkoff;
> +		if (dfl_forkoff > ip->i_forkoff)
> +			ip->i_forkoff = dfl_forkoff;
>  	}
>  }
>  
> @@ -1035,14 +1035,14 @@ xfs_bmap_set_attrforkoff(
>  {
>  	switch (ip->i_df.if_format) {
>  	case XFS_DINODE_FMT_DEV:
> -		ip->i_d.di_forkoff = roundup(sizeof(xfs_dev_t), 8) >> 3;
> +		ip->i_forkoff = roundup(sizeof(xfs_dev_t), 8) >> 3;
>  		break;
>  	case XFS_DINODE_FMT_LOCAL:
>  	case XFS_DINODE_FMT_EXTENTS:
>  	case XFS_DINODE_FMT_BTREE:
> -		ip->i_d.di_forkoff = xfs_attr_shortform_bytesfit(ip, size);
> -		if (!ip->i_d.di_forkoff)
> -			ip->i_d.di_forkoff = xfs_default_attroffset(ip) >> 3;
> +		ip->i_forkoff = xfs_attr_shortform_bytesfit(ip, size);
> +		if (!ip->i_forkoff)
> +			ip->i_forkoff = xfs_default_attroffset(ip) >> 3;
>  		else if ((ip->i_mount->m_flags & XFS_MOUNT_ATTR2) && version)
>  			*version = 2;
>  		break;
> diff --git a/fs/xfs/libxfs/xfs_inode_buf.c b/fs/xfs/libxfs/xfs_inode_buf.c
> index 8c4b7bd69285fa..69a6844b1698d0 100644
> --- a/fs/xfs/libxfs/xfs_inode_buf.c
> +++ b/fs/xfs/libxfs/xfs_inode_buf.c
> @@ -245,7 +245,7 @@ xfs_inode_from_disk(
>  	ip->i_disk_size = be64_to_cpu(from->di_size);
>  	ip->i_nblocks = be64_to_cpu(from->di_nblocks);
>  	ip->i_extsize = be32_to_cpu(from->di_extsize);
> -	to->di_forkoff = from->di_forkoff;
> +	ip->i_forkoff = from->di_forkoff;
>  	to->di_dmevmask	= be32_to_cpu(from->di_dmevmask);
>  	to->di_dmstate	= be16_to_cpu(from->di_dmstate);
>  	to->di_flags	= be16_to_cpu(from->di_flags);
> @@ -310,7 +310,7 @@ xfs_inode_to_disk(
>  	to->di_extsize = cpu_to_be32(ip->i_extsize);
>  	to->di_nextents = cpu_to_be32(xfs_ifork_nextents(&ip->i_df));
>  	to->di_anextents = cpu_to_be16(xfs_ifork_nextents(ip->i_afp));
> -	to->di_forkoff = from->di_forkoff;
> +	to->di_forkoff = ip->i_forkoff;
>  	to->di_aformat = xfs_ifork_format(ip->i_afp);
>  	to->di_dmevmask = cpu_to_be32(from->di_dmevmask);
>  	to->di_dmstate = cpu_to_be16(from->di_dmstate);
> diff --git a/fs/xfs/libxfs/xfs_inode_buf.h b/fs/xfs/libxfs/xfs_inode_buf.h
> index 8cc96f2766ff4f..032486dbf82757 100644
> --- a/fs/xfs/libxfs/xfs_inode_buf.h
> +++ b/fs/xfs/libxfs/xfs_inode_buf.h
> @@ -16,7 +16,6 @@ struct xfs_dinode;
>   * format specific structures at the appropriate time.
>   */
>  struct xfs_icdinode {
> -	uint8_t		di_forkoff;	/* attr fork offs, <<3 for 64b align */
>  	uint32_t	di_dmevmask;	/* DMIG event mask */
>  	uint16_t	di_dmstate;	/* DMIG state info */
>  	uint16_t	di_flags;	/* random flags, XFS_DIFLAG_... */
> diff --git a/fs/xfs/libxfs/xfs_inode_fork.h b/fs/xfs/libxfs/xfs_inode_fork.h
> index a4953e95c4f3f6..7d6982b23446c2 100644
> --- a/fs/xfs/libxfs/xfs_inode_fork.h
> +++ b/fs/xfs/libxfs/xfs_inode_fork.h
> @@ -38,8 +38,8 @@ struct xfs_ifork {
>   * Fork handling.
>   */
>  
> -#define XFS_IFORK_Q(ip)			((ip)->i_d.di_forkoff != 0)
> -#define XFS_IFORK_BOFF(ip)		((int)((ip)->i_d.di_forkoff << 3))
> +#define XFS_IFORK_Q(ip)			((ip)->i_forkoff != 0)
> +#define XFS_IFORK_BOFF(ip)		((int)((ip)->i_forkoff << 3))
>  
>  #define XFS_IFORK_PTR(ip,w)		\
>  	((w) == XFS_DATA_FORK ? \
> diff --git a/fs/xfs/xfs_icache.c b/fs/xfs/xfs_icache.c
> index e6b40f7035aa5a..ccd437432aa963 100644
> --- a/fs/xfs/xfs_icache.c
> +++ b/fs/xfs/xfs_icache.c
> @@ -67,7 +67,7 @@ xfs_inode_alloc(
>  	ip->i_flags = 0;
>  	ip->i_delayed_blks = 0;
>  	ip->i_nblocks = 0;
> -	ip->i_d.di_forkoff = 0;
> +	ip->i_forkoff = 0;
>  	ip->i_sick = 0;
>  	ip->i_checked = 0;
>  	INIT_WORK(&ip->i_ioend_work, xfs_end_io);
> diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
> index fd111e05c0bb2e..764f91610d1496 100644
> --- a/fs/xfs/xfs_inode.c
> +++ b/fs/xfs/xfs_inode.c
> @@ -1858,7 +1858,7 @@ xfs_inactive(
>  	}
>  
>  	ASSERT(!ip->i_afp);
> -	ASSERT(ip->i_d.di_forkoff == 0);
> +	ASSERT(ip->i_forkoff == 0);
>  
>  	/*
>  	 * Free the inode.
> @@ -2758,7 +2758,7 @@ xfs_ifree(
>  	ip->i_d.di_flags = 0;
>  	ip->i_d.di_flags2 = 0;
>  	ip->i_d.di_dmevmask = 0;
> -	ip->i_d.di_forkoff = 0;		/* mark the attr fork not in use */
> +	ip->i_forkoff = 0;		/* mark the attr fork not in use */
>  	ip->i_df.if_format = XFS_DINODE_FMT_EXTENTS;
>  
>  	/* Don't attempt to replay owner changes for a deleted inode */
> @@ -3756,11 +3756,11 @@ xfs_iflush_int(
>  			ip->i_nblocks, ip);
>  		goto flush_out;
>  	}
> -	if (XFS_TEST_ERROR(ip->i_d.di_forkoff > mp->m_sb.sb_inodesize,
> +	if (XFS_TEST_ERROR(ip->i_forkoff > mp->m_sb.sb_inodesize,
>  				mp, XFS_ERRTAG_IFLUSH_6)) {
>  		xfs_alert_tag(mp, XFS_PTAG_IFLUSH,
>  			"%s: bad inode %Lu, forkoff 0x%x, ptr "PTR_FMT,
> -			__func__, ip->i_ino, ip->i_d.di_forkoff, ip);
> +			__func__, ip->i_ino, ip->i_forkoff, ip);
>  		goto flush_out;
>  	}
>  
> diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h
> index a0444b9ce3f792..31440ab88cf141 100644
> --- a/fs/xfs/xfs_inode.h
> +++ b/fs/xfs/xfs_inode.h
> @@ -63,6 +63,7 @@ typedef struct xfs_inode {
>  		xfs_extlen_t	i_cowextsize;	/* basic cow extent size */
>  		uint16_t	i_flushiter;	/* incremented on flush */
>  	};
> +	uint8_t			i_forkoff;	/* attr fork offset >> 3 */
>  
>  	struct xfs_icdinode	i_d;		/* most of ondisk inode */
>  
> diff --git a/fs/xfs/xfs_inode_item.c b/fs/xfs/xfs_inode_item.c
> index 8357fe37d3eb8a..a83ddc4e029f0f 100644
> --- a/fs/xfs/xfs_inode_item.c
> +++ b/fs/xfs/xfs_inode_item.c
> @@ -328,7 +328,7 @@ xfs_inode_to_log_dinode(
>  	to->di_extsize = ip->i_extsize;
>  	to->di_nextents = xfs_ifork_nextents(&ip->i_df);
>  	to->di_anextents = xfs_ifork_nextents(ip->i_afp);
> -	to->di_forkoff = from->di_forkoff;
> +	to->di_forkoff = ip->i_forkoff;
>  	to->di_aformat = xfs_ifork_format(ip->i_afp);
>  	to->di_dmevmask = from->di_dmevmask;
>  	to->di_dmstate = from->di_dmstate;
> -- 
> 2.26.2
> 

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH 11/15] xfs: move the di_flags field to struct xfs_inode
  2020-06-20  7:10 ` [PATCH 11/15] xfs: move the di_flags " Christoph Hellwig
  2020-06-22 12:41   ` Chandan Babu R
@ 2020-06-30 17:53   ` Darrick J. Wong
  1 sibling, 0 replies; 52+ messages in thread
From: Darrick J. Wong @ 2020-06-30 17:53 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: linux-xfs

On Sat, Jun 20, 2020 at 09:10:58AM +0200, Christoph Hellwig wrote:
> In preparation of removing the historic icinode struct, move the flags
> field into the containing xfs_inode structure.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>

Looks ok,
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>

--D

> ---
>  fs/xfs/libxfs/xfs_bmap_btree.c |  2 +-
>  fs/xfs/libxfs/xfs_inode_buf.c  |  4 ++--
>  fs/xfs/libxfs/xfs_inode_buf.h  |  1 -
>  fs/xfs/libxfs/xfs_rtbitmap.c   |  4 ++--
>  fs/xfs/scrub/common.c          |  2 +-
>  fs/xfs/xfs_bmap_util.c         |  4 ++--
>  fs/xfs/xfs_file.c              |  4 ++--
>  fs/xfs/xfs_filestream.h        |  2 +-
>  fs/xfs/xfs_inode.c             | 38 +++++++++++++++++-----------------
>  fs/xfs/xfs_inode.h             |  3 ++-
>  fs/xfs/xfs_inode_item.c        |  2 +-
>  fs/xfs/xfs_ioctl.c             |  9 ++++----
>  fs/xfs/xfs_iops.c              |  6 +++---
>  fs/xfs/xfs_linux.h             |  2 +-
>  fs/xfs/xfs_rtalloc.c           |  4 ++--
>  fs/xfs/xfs_super.c             |  4 ++--
>  fs/xfs/xfs_symlink.c           |  2 +-
>  17 files changed, 46 insertions(+), 47 deletions(-)
> 
> diff --git a/fs/xfs/libxfs/xfs_bmap_btree.c b/fs/xfs/libxfs/xfs_bmap_btree.c
> index 9ad4c6a1eec518..d32f3a94c936e6 100644
> --- a/fs/xfs/libxfs/xfs_bmap_btree.c
> +++ b/fs/xfs/libxfs/xfs_bmap_btree.c
> @@ -183,7 +183,7 @@ xfs_bmbt_update_cursor(
>  	struct xfs_btree_cur	*dst)
>  {
>  	ASSERT((dst->bc_tp->t_firstblock != NULLFSBLOCK) ||
> -	       (dst->bc_ino.ip->i_d.di_flags & XFS_DIFLAG_REALTIME));
> +	       (dst->bc_ino.ip->i_diflags & XFS_DIFLAG_REALTIME));
>  
>  	dst->bc_ino.allocated += src->bc_ino.allocated;
>  	dst->bc_tp->t_firstblock = src->bc_tp->t_firstblock;
> diff --git a/fs/xfs/libxfs/xfs_inode_buf.c b/fs/xfs/libxfs/xfs_inode_buf.c
> index 69a6844b1698d0..bb9c4775ecaa5c 100644
> --- a/fs/xfs/libxfs/xfs_inode_buf.c
> +++ b/fs/xfs/libxfs/xfs_inode_buf.c
> @@ -248,7 +248,7 @@ xfs_inode_from_disk(
>  	ip->i_forkoff = from->di_forkoff;
>  	to->di_dmevmask	= be32_to_cpu(from->di_dmevmask);
>  	to->di_dmstate	= be16_to_cpu(from->di_dmstate);
> -	to->di_flags	= be16_to_cpu(from->di_flags);
> +	ip->i_diflags	= be16_to_cpu(from->di_flags);
>  
>  	if (xfs_sb_version_has_v3inode(&ip->i_mount->m_sb)) {
>  		inode_set_iversion_queried(inode,
> @@ -314,7 +314,7 @@ xfs_inode_to_disk(
>  	to->di_aformat = xfs_ifork_format(ip->i_afp);
>  	to->di_dmevmask = cpu_to_be32(from->di_dmevmask);
>  	to->di_dmstate = cpu_to_be16(from->di_dmstate);
> -	to->di_flags = cpu_to_be16(from->di_flags);
> +	to->di_flags = cpu_to_be16(ip->i_diflags);
>  
>  	if (xfs_sb_version_has_v3inode(&ip->i_mount->m_sb)) {
>  		to->di_version = 3;
> diff --git a/fs/xfs/libxfs/xfs_inode_buf.h b/fs/xfs/libxfs/xfs_inode_buf.h
> index 032486dbf82757..5c6a6ac521b11d 100644
> --- a/fs/xfs/libxfs/xfs_inode_buf.h
> +++ b/fs/xfs/libxfs/xfs_inode_buf.h
> @@ -18,7 +18,6 @@ struct xfs_dinode;
>  struct xfs_icdinode {
>  	uint32_t	di_dmevmask;	/* DMIG event mask */
>  	uint16_t	di_dmstate;	/* DMIG state info */
> -	uint16_t	di_flags;	/* random flags, XFS_DIFLAG_... */
>  
>  	uint64_t	di_flags2;	/* more random flags */
>  
> diff --git a/fs/xfs/libxfs/xfs_rtbitmap.c b/fs/xfs/libxfs/xfs_rtbitmap.c
> index 9498ced947be9e..57381b9aca00ac 100644
> --- a/fs/xfs/libxfs/xfs_rtbitmap.c
> +++ b/fs/xfs/libxfs/xfs_rtbitmap.c
> @@ -997,8 +997,8 @@ xfs_rtfree_extent(
>  	 */
>  	if (tp->t_frextents_delta + mp->m_sb.sb_frextents ==
>  	    mp->m_sb.sb_rextents) {
> -		if (!(mp->m_rbmip->i_d.di_flags & XFS_DIFLAG_NEWRTBM))
> -			mp->m_rbmip->i_d.di_flags |= XFS_DIFLAG_NEWRTBM;
> +		if (!(mp->m_rbmip->i_diflags & XFS_DIFLAG_NEWRTBM))
> +			mp->m_rbmip->i_diflags |= XFS_DIFLAG_NEWRTBM;
>  		*(uint64_t *)&VFS_I(mp->m_rbmip)->i_atime = 0;
>  		xfs_trans_log_inode(tp, mp->m_rbmip, XFS_ILOG_CORE);
>  	}
> diff --git a/fs/xfs/scrub/common.c b/fs/xfs/scrub/common.c
> index 18876056e5e02a..254dc813696de4 100644
> --- a/fs/xfs/scrub/common.c
> +++ b/fs/xfs/scrub/common.c
> @@ -835,7 +835,7 @@ xchk_metadata_inode_forks(
>  		return 0;
>  
>  	/* Metadata inodes don't live on the rt device. */
> -	if (sc->ip->i_d.di_flags & XFS_DIFLAG_REALTIME) {
> +	if (sc->ip->i_diflags & XFS_DIFLAG_REALTIME) {
>  		xchk_ino_set_corrupt(sc, sc->ip->i_ino);
>  		return 0;
>  	}
> diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c
> index 5eba039d72fb83..0b944aad75e618 100644
> --- a/fs/xfs/xfs_bmap_util.c
> +++ b/fs/xfs/xfs_bmap_util.c
> @@ -439,7 +439,7 @@ xfs_getbmap(
>  		}
>  
>  		if (xfs_get_extsz_hint(ip) ||
> -		    (ip->i_d.di_flags &
> +		    (ip->i_diflags &
>  		     (XFS_DIFLAG_PREALLOC | XFS_DIFLAG_APPEND)))
>  			max_len = mp->m_super->s_maxbytes;
>  		else
> @@ -620,7 +620,7 @@ xfs_can_free_eofblocks(struct xfs_inode *ip, bool force)
>  	 * Do not free real preallocated or append-only files unless the file
>  	 * has delalloc blocks and we are forced to remove them.
>  	 */
> -	if (ip->i_d.di_flags & (XFS_DIFLAG_PREALLOC | XFS_DIFLAG_APPEND))
> +	if (ip->i_diflags & (XFS_DIFLAG_PREALLOC | XFS_DIFLAG_APPEND))
>  		if (!force || ip->i_delayed_blks == 0)
>  			return false;
>  
> diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c
> index b0384306d6622f..4f08793f3d6db4 100644
> --- a/fs/xfs/xfs_file.c
> +++ b/fs/xfs/xfs_file.c
> @@ -56,9 +56,9 @@ xfs_update_prealloc_flags(
>  	}
>  
>  	if (flags & XFS_PREALLOC_SET)
> -		ip->i_d.di_flags |= XFS_DIFLAG_PREALLOC;
> +		ip->i_diflags |= XFS_DIFLAG_PREALLOC;
>  	if (flags & XFS_PREALLOC_CLEAR)
> -		ip->i_d.di_flags &= ~XFS_DIFLAG_PREALLOC;
> +		ip->i_diflags &= ~XFS_DIFLAG_PREALLOC;
>  
>  	xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
>  	if (flags & XFS_PREALLOC_SYNC)
> diff --git a/fs/xfs/xfs_filestream.h b/fs/xfs/xfs_filestream.h
> index 5cc7665e93c92b..3af963743e4d0b 100644
> --- a/fs/xfs/xfs_filestream.h
> +++ b/fs/xfs/xfs_filestream.h
> @@ -22,7 +22,7 @@ xfs_inode_is_filestream(
>  	struct xfs_inode	*ip)
>  {
>  	return (ip->i_mount->m_flags & XFS_MOUNT_FILESTREAMS) ||
> -		(ip->i_d.di_flags & XFS_DIFLAG_FILESTREAM);
> +		(ip->i_diflags & XFS_DIFLAG_FILESTREAM);
>  }
>  
>  #endif /* __XFS_FILESTREAM_H__ */
> diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
> index 764f91610d1496..479342ac8851f4 100644
> --- a/fs/xfs/xfs_inode.c
> +++ b/fs/xfs/xfs_inode.c
> @@ -61,7 +61,7 @@ xfs_get_extsz_hint(
>  	 */
>  	if (xfs_is_always_cow_inode(ip))
>  		return 0;
> -	if ((ip->i_d.di_flags & XFS_DIFLAG_EXTSIZE) && ip->i_extsize)
> +	if ((ip->i_diflags & XFS_DIFLAG_EXTSIZE) && ip->i_extsize)
>  		return ip->i_extsize;
>  	if (XFS_IS_REALTIME_INODE(ip))
>  		return ip->i_mount->m_sb.sb_rextsize;
> @@ -673,7 +673,7 @@ xfs_ip2xflags(
>  {
>  	struct xfs_icdinode	*dic = &ip->i_d;
>  
> -	return _xfs_dic2xflags(dic->di_flags, dic->di_flags2, XFS_IFORK_Q(ip));
> +	return _xfs_dic2xflags(ip->i_diflags, dic->di_flags2, XFS_IFORK_Q(ip));
>  }
>  
>  /*
> @@ -837,7 +837,7 @@ xfs_ialloc(
>  	ip->i_extsize = 0;
>  	ip->i_d.di_dmevmask = 0;
>  	ip->i_d.di_dmstate = 0;
> -	ip->i_d.di_flags = 0;
> +	ip->i_diflags = 0;
>  
>  	if (xfs_sb_version_has_v3inode(&mp->m_sb)) {
>  		inode_set_iversion(inode, 1);
> @@ -858,45 +858,45 @@ xfs_ialloc(
>  		break;
>  	case S_IFREG:
>  	case S_IFDIR:
> -		if (pip && (pip->i_d.di_flags & XFS_DIFLAG_ANY)) {
> +		if (pip && (pip->i_diflags & XFS_DIFLAG_ANY)) {
>  			uint		di_flags = 0;
>  
>  			if (S_ISDIR(mode)) {
> -				if (pip->i_d.di_flags & XFS_DIFLAG_RTINHERIT)
> +				if (pip->i_diflags & XFS_DIFLAG_RTINHERIT)
>  					di_flags |= XFS_DIFLAG_RTINHERIT;
> -				if (pip->i_d.di_flags & XFS_DIFLAG_EXTSZINHERIT) {
> +				if (pip->i_diflags & XFS_DIFLAG_EXTSZINHERIT) {
>  					di_flags |= XFS_DIFLAG_EXTSZINHERIT;
>  					ip->i_extsize = pip->i_extsize;
>  				}
> -				if (pip->i_d.di_flags & XFS_DIFLAG_PROJINHERIT)
> +				if (pip->i_diflags & XFS_DIFLAG_PROJINHERIT)
>  					di_flags |= XFS_DIFLAG_PROJINHERIT;
>  			} else if (S_ISREG(mode)) {
> -				if (pip->i_d.di_flags & XFS_DIFLAG_RTINHERIT)
> +				if (pip->i_diflags & XFS_DIFLAG_RTINHERIT)
>  					di_flags |= XFS_DIFLAG_REALTIME;
> -				if (pip->i_d.di_flags & XFS_DIFLAG_EXTSZINHERIT) {
> +				if (pip->i_diflags & XFS_DIFLAG_EXTSZINHERIT) {
>  					di_flags |= XFS_DIFLAG_EXTSIZE;
>  					ip->i_extsize = pip->i_extsize;
>  				}
>  			}
> -			if ((pip->i_d.di_flags & XFS_DIFLAG_NOATIME) &&
> +			if ((pip->i_diflags & XFS_DIFLAG_NOATIME) &&
>  			    xfs_inherit_noatime)
>  				di_flags |= XFS_DIFLAG_NOATIME;
> -			if ((pip->i_d.di_flags & XFS_DIFLAG_NODUMP) &&
> +			if ((pip->i_diflags & XFS_DIFLAG_NODUMP) &&
>  			    xfs_inherit_nodump)
>  				di_flags |= XFS_DIFLAG_NODUMP;
> -			if ((pip->i_d.di_flags & XFS_DIFLAG_SYNC) &&
> +			if ((pip->i_diflags & XFS_DIFLAG_SYNC) &&
>  			    xfs_inherit_sync)
>  				di_flags |= XFS_DIFLAG_SYNC;
> -			if ((pip->i_d.di_flags & XFS_DIFLAG_NOSYMLINKS) &&
> +			if ((pip->i_diflags & XFS_DIFLAG_NOSYMLINKS) &&
>  			    xfs_inherit_nosymlinks)
>  				di_flags |= XFS_DIFLAG_NOSYMLINKS;
> -			if ((pip->i_d.di_flags & XFS_DIFLAG_NODEFRAG) &&
> +			if ((pip->i_diflags & XFS_DIFLAG_NODEFRAG) &&
>  			    xfs_inherit_nodefrag)
>  				di_flags |= XFS_DIFLAG_NODEFRAG;
> -			if (pip->i_d.di_flags & XFS_DIFLAG_FILESTREAM)
> +			if (pip->i_diflags & XFS_DIFLAG_FILESTREAM)
>  				di_flags |= XFS_DIFLAG_FILESTREAM;
>  
> -			ip->i_d.di_flags |= di_flags;
> +			ip->i_diflags |= di_flags;
>  		}
>  		if (pip && (pip->i_d.di_flags2 & XFS_DIFLAG2_ANY)) {
>  			if (pip->i_d.di_flags2 & XFS_DIFLAG2_COWEXTSIZE) {
> @@ -1397,7 +1397,7 @@ xfs_link(
>  	 * creation in our tree when the project IDs are the same; else
>  	 * the tree quota mechanism could be circumvented.
>  	 */
> -	if (unlikely((tdp->i_d.di_flags & XFS_DIFLAG_PROJINHERIT) &&
> +	if (unlikely((tdp->i_diflags & XFS_DIFLAG_PROJINHERIT) &&
>  		     tdp->i_projid != sip->i_projid)) {
>  		error = -EXDEV;
>  		goto error_return;
> @@ -2755,7 +2755,7 @@ xfs_ifree(
>  	}
>  
>  	VFS_I(ip)->i_mode = 0;		/* mark incore inode as free */
> -	ip->i_d.di_flags = 0;
> +	ip->i_diflags = 0;
>  	ip->i_d.di_flags2 = 0;
>  	ip->i_d.di_dmevmask = 0;
>  	ip->i_forkoff = 0;		/* mark the attr fork not in use */
> @@ -3263,7 +3263,7 @@ xfs_rename(
>  	 * into our tree when the project IDs are the same; else the
>  	 * tree quota mechanism would be circumvented.
>  	 */
> -	if (unlikely((target_dp->i_d.di_flags & XFS_DIFLAG_PROJINHERIT) &&
> +	if (unlikely((target_dp->i_diflags & XFS_DIFLAG_PROJINHERIT) &&
>  		     target_dp->i_projid != src_ip->i_projid)) {
>  		error = -EXDEV;
>  		goto out_trans_cancel;
> diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h
> index 31440ab88cf141..7673c841d89154 100644
> --- a/fs/xfs/xfs_inode.h
> +++ b/fs/xfs/xfs_inode.h
> @@ -64,6 +64,7 @@ typedef struct xfs_inode {
>  		uint16_t	i_flushiter;	/* incremented on flush */
>  	};
>  	uint8_t			i_forkoff;	/* attr fork offset >> 3 */
> +	uint16_t		i_diflags;	/* XFS_DIFLAG_... */
>  
>  	struct xfs_icdinode	i_d;		/* most of ondisk inode */
>  
> @@ -184,7 +185,7 @@ xfs_iflags_test_and_set(xfs_inode_t *ip, unsigned short flags)
>  static inline prid_t
>  xfs_get_initial_prid(struct xfs_inode *dp)
>  {
> -	if (dp->i_d.di_flags & XFS_DIFLAG_PROJINHERIT)
> +	if (dp->i_diflags & XFS_DIFLAG_PROJINHERIT)
>  		return dp->i_projid;
>  
>  	return XFS_PROJID_DEFAULT;
> diff --git a/fs/xfs/xfs_inode_item.c b/fs/xfs/xfs_inode_item.c
> index a83ddc4e029f0f..6af8e829dd0172 100644
> --- a/fs/xfs/xfs_inode_item.c
> +++ b/fs/xfs/xfs_inode_item.c
> @@ -332,7 +332,7 @@ xfs_inode_to_log_dinode(
>  	to->di_aformat = xfs_ifork_format(ip->i_afp);
>  	to->di_dmevmask = from->di_dmevmask;
>  	to->di_dmstate = from->di_dmstate;
> -	to->di_flags = from->di_flags;
> +	to->di_flags = ip->i_diflags;
>  
>  	/* log a dummy value to ensure log structure is fully initialised */
>  	to->di_next_unlinked = NULLAGINO;
> diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
> index cabc86ed6756bc..326991f4d98096 100644
> --- a/fs/xfs/xfs_ioctl.c
> +++ b/fs/xfs/xfs_ioctl.c
> @@ -1143,7 +1143,7 @@ xfs_flags2diflags(
>  {
>  	/* can't set PREALLOC this way, just preserve it */
>  	uint16_t		di_flags =
> -		(ip->i_d.di_flags & XFS_DIFLAG_PREALLOC);
> +		(ip->i_diflags & XFS_DIFLAG_PREALLOC);
>  
>  	if (xflags & FS_XFLAG_IMMUTABLE)
>  		di_flags |= XFS_DIFLAG_IMMUTABLE;
> @@ -1228,7 +1228,7 @@ xfs_ioctl_setattr_xflags(
>  	if (di_flags2 && !xfs_sb_version_has_v3inode(&mp->m_sb))
>  		return -EINVAL;
>  
> -	ip->i_d.di_flags = xfs_flags2diflags(ip, fa->fsx_xflags);
> +	ip->i_diflags = xfs_flags2diflags(ip, fa->fsx_xflags);
>  	ip->i_d.di_flags2 = di_flags2;
>  
>  	xfs_diflags_to_iflags(ip, false);
> @@ -1570,7 +1570,7 @@ xfs_ioctl_setattr(
>  	 * extent size hint should be set on the inode. If no extent size flags
>  	 * are set on the inode then unconditionally clear the extent size hint.
>  	 */
> -	if (ip->i_d.di_flags & (XFS_DIFLAG_EXTSIZE | XFS_DIFLAG_EXTSZINHERIT))
> +	if (ip->i_diflags & (XFS_DIFLAG_EXTSIZE | XFS_DIFLAG_EXTSZINHERIT))
>  		ip->i_extsize = fa->fsx_extsize >> mp->m_sb.sb_blocklog;
>  	else
>  		ip->i_extsize = 0;
> @@ -1622,9 +1622,8 @@ xfs_ioc_getxflags(
>  	xfs_inode_t		*ip,
>  	void			__user *arg)
>  {
> -	unsigned int		flags;
> +	unsigned int		flags = xfs_di2lxflags(ip->i_diflags);
>  
> -	flags = xfs_di2lxflags(ip->i_d.di_flags);
>  	if (copy_to_user(arg, &flags, sizeof(flags)))
>  		return -EFAULT;
>  	return 0;
> diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
> index 78159c57d82828..f37154fc9828fd 100644
> --- a/fs/xfs/xfs_iops.c
> +++ b/fs/xfs/xfs_iops.c
> @@ -567,11 +567,11 @@ xfs_vn_getattr(
>  	 * Note: If you add another clause to set an attribute flag, please
>  	 * update attributes_mask below.
>  	 */
> -	if (ip->i_d.di_flags & XFS_DIFLAG_IMMUTABLE)
> +	if (ip->i_diflags & XFS_DIFLAG_IMMUTABLE)
>  		stat->attributes |= STATX_ATTR_IMMUTABLE;
> -	if (ip->i_d.di_flags & XFS_DIFLAG_APPEND)
> +	if (ip->i_diflags & XFS_DIFLAG_APPEND)
>  		stat->attributes |= STATX_ATTR_APPEND;
> -	if (ip->i_d.di_flags & XFS_DIFLAG_NODUMP)
> +	if (ip->i_diflags & XFS_DIFLAG_NODUMP)
>  		stat->attributes |= STATX_ATTR_NODUMP;
>  
>  	stat->attributes_mask |= (STATX_ATTR_IMMUTABLE |
> diff --git a/fs/xfs/xfs_linux.h b/fs/xfs/xfs_linux.h
> index 9f70d2f68e059b..95cc3386ac3b4f 100644
> --- a/fs/xfs/xfs_linux.h
> +++ b/fs/xfs/xfs_linux.h
> @@ -233,7 +233,7 @@ int xfs_rw_bdev(struct block_device *bdev, sector_t sector, unsigned int count,
>   * configured realtime device.
>   */
>  #define XFS_IS_REALTIME_INODE(ip)			\
> -	(((ip)->i_d.di_flags & XFS_DIFLAG_REALTIME) &&	\
> +	(((ip)->i_diflags & XFS_DIFLAG_REALTIME) &&	\
>  	 (ip)->i_mount->m_rtdev_targp)
>  #define XFS_IS_REALTIME_MOUNT(mp) ((mp)->m_rtdev_targp ? 1 : 0)
>  #else
> diff --git a/fs/xfs/xfs_rtalloc.c b/fs/xfs/xfs_rtalloc.c
> index cc07d7d27dd7e0..592a1160200f5e 100644
> --- a/fs/xfs/xfs_rtalloc.c
> +++ b/fs/xfs/xfs_rtalloc.c
> @@ -1281,8 +1281,8 @@ xfs_rtpick_extent(
>  	ASSERT(xfs_isilocked(mp->m_rbmip, XFS_ILOCK_EXCL));
>  
>  	seqp = (uint64_t *)&VFS_I(mp->m_rbmip)->i_atime;
> -	if (!(mp->m_rbmip->i_d.di_flags & XFS_DIFLAG_NEWRTBM)) {
> -		mp->m_rbmip->i_d.di_flags |= XFS_DIFLAG_NEWRTBM;
> +	if (!(mp->m_rbmip->i_diflags & XFS_DIFLAG_NEWRTBM)) {
> +		mp->m_rbmip->i_diflags |= XFS_DIFLAG_NEWRTBM;
>  		*seqp = 0;
>  	}
>  	seq = *seqp;
> diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
> index fa58cb07c8fdfe..06a01528543aef 100644
> --- a/fs/xfs/xfs_super.c
> +++ b/fs/xfs/xfs_super.c
> @@ -828,13 +828,13 @@ xfs_fs_statfs(
>  	statp->f_ffree = max_t(int64_t, ffree, 0);
>  
>  
> -	if ((ip->i_d.di_flags & XFS_DIFLAG_PROJINHERIT) &&
> +	if ((ip->i_diflags & XFS_DIFLAG_PROJINHERIT) &&
>  	    ((mp->m_qflags & (XFS_PQUOTA_ACCT|XFS_PQUOTA_ENFD))) ==
>  			      (XFS_PQUOTA_ACCT|XFS_PQUOTA_ENFD))
>  		xfs_qm_statvfs(ip, statp);
>  
>  	if (XFS_IS_REALTIME_MOUNT(mp) &&
> -	    (ip->i_d.di_flags & (XFS_DIFLAG_RTINHERIT | XFS_DIFLAG_REALTIME))) {
> +	    (ip->i_diflags & (XFS_DIFLAG_RTINHERIT | XFS_DIFLAG_REALTIME))) {
>  		statp->f_blocks = sbp->sb_rblocks;
>  		statp->f_bavail = statp->f_bfree =
>  			sbp->sb_frextents * sbp->sb_rextsize;
> diff --git a/fs/xfs/xfs_symlink.c b/fs/xfs/xfs_symlink.c
> index 6b8980b1497c9a..dc86e3117f73f0 100644
> --- a/fs/xfs/xfs_symlink.c
> +++ b/fs/xfs/xfs_symlink.c
> @@ -207,7 +207,7 @@ xfs_symlink(
>  	/*
>  	 * Check whether the directory allows new symlinks or not.
>  	 */
> -	if (dp->i_d.di_flags & XFS_DIFLAG_NOSYMLINKS) {
> +	if (dp->i_diflags & XFS_DIFLAG_NOSYMLINKS) {
>  		error = -EPERM;
>  		goto out_trans_cancel;
>  	}
> -- 
> 2.26.2
> 

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH 12/15] xfs: move the di_flags2 field to struct xfs_inode
  2020-06-20  7:10 ` [PATCH 12/15] xfs: move the di_flags2 " Christoph Hellwig
  2020-06-22 12:51   ` Chandan Babu R
@ 2020-06-30 17:54   ` Darrick J. Wong
  1 sibling, 0 replies; 52+ messages in thread
From: Darrick J. Wong @ 2020-06-30 17:54 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: linux-xfs

On Sat, Jun 20, 2020 at 09:10:59AM +0200, Christoph Hellwig wrote:
> In preparation of removing the historic icinode struct, move the flags2

"icdinode" (hmm I guess I hadn't noticed that until now...)

> field into the containing xfs_inode structure.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>

With that fixed up (in this patch and the others),
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>

--D

> ---
>  fs/xfs/libxfs/xfs_inode_buf.c |  4 ++--
>  fs/xfs/libxfs/xfs_inode_buf.h |  2 --
>  fs/xfs/xfs_bmap_util.c        | 24 ++++++++++++------------
>  fs/xfs/xfs_file.c             |  4 ++--
>  fs/xfs/xfs_inode.c            | 22 ++++++++++------------
>  fs/xfs/xfs_inode.h            |  3 ++-
>  fs/xfs/xfs_inode_item.c       |  2 +-
>  fs/xfs/xfs_ioctl.c            | 23 +++++++++++------------
>  fs/xfs/xfs_iops.c             |  2 +-
>  fs/xfs/xfs_itable.c           |  2 +-
>  fs/xfs/xfs_reflink.c          |  8 ++++----
>  11 files changed, 46 insertions(+), 50 deletions(-)
> 
> diff --git a/fs/xfs/libxfs/xfs_inode_buf.c b/fs/xfs/libxfs/xfs_inode_buf.c
> index bb9c4775ecaa5c..79e470933abfa8 100644
> --- a/fs/xfs/libxfs/xfs_inode_buf.c
> +++ b/fs/xfs/libxfs/xfs_inode_buf.c
> @@ -255,7 +255,7 @@ xfs_inode_from_disk(
>  					   be64_to_cpu(from->di_changecount));
>  		to->di_crtime.tv_sec = be32_to_cpu(from->di_crtime.t_sec);
>  		to->di_crtime.tv_nsec = be32_to_cpu(from->di_crtime.t_nsec);
> -		to->di_flags2 = be64_to_cpu(from->di_flags2);
> +		ip->i_diflags2 = be64_to_cpu(from->di_flags2);
>  		ip->i_cowextsize = be32_to_cpu(from->di_cowextsize);
>  	}
>  
> @@ -321,7 +321,7 @@ xfs_inode_to_disk(
>  		to->di_changecount = cpu_to_be64(inode_peek_iversion(inode));
>  		to->di_crtime.t_sec = cpu_to_be32(from->di_crtime.tv_sec);
>  		to->di_crtime.t_nsec = cpu_to_be32(from->di_crtime.tv_nsec);
> -		to->di_flags2 = cpu_to_be64(from->di_flags2);
> +		to->di_flags2 = cpu_to_be64(ip->i_diflags2);
>  		to->di_cowextsize = cpu_to_be32(ip->i_cowextsize);
>  		to->di_ino = cpu_to_be64(ip->i_ino);
>  		to->di_lsn = cpu_to_be64(lsn);
> diff --git a/fs/xfs/libxfs/xfs_inode_buf.h b/fs/xfs/libxfs/xfs_inode_buf.h
> index 5c6a6ac521b11d..4bfad6d6d5710a 100644
> --- a/fs/xfs/libxfs/xfs_inode_buf.h
> +++ b/fs/xfs/libxfs/xfs_inode_buf.h
> @@ -19,8 +19,6 @@ struct xfs_icdinode {
>  	uint32_t	di_dmevmask;	/* DMIG event mask */
>  	uint16_t	di_dmstate;	/* DMIG state info */
>  
> -	uint64_t	di_flags2;	/* more random flags */
> -
>  	struct timespec64 di_crtime;	/* time created */
>  };
>  
> diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c
> index 0b944aad75e618..8f85a4131983a6 100644
> --- a/fs/xfs/xfs_bmap_util.c
> +++ b/fs/xfs/xfs_bmap_util.c
> @@ -1332,9 +1332,9 @@ xfs_swap_extent_rmap(
>  	 * rmap functions when we go to fix up the rmaps.  The flags
>  	 * will be switch for reals later.
>  	 */
> -	tip_flags2 = tip->i_d.di_flags2;
> -	if (ip->i_d.di_flags2 & XFS_DIFLAG2_REFLINK)
> -		tip->i_d.di_flags2 |= XFS_DIFLAG2_REFLINK;
> +	tip_flags2 = tip->i_diflags2;
> +	if (ip->i_diflags2 & XFS_DIFLAG2_REFLINK)
> +		tip->i_diflags2 |= XFS_DIFLAG2_REFLINK;
>  
>  	offset_fsb = 0;
>  	end_fsb = XFS_B_TO_FSB(ip->i_mount, i_size_read(VFS_I(ip)));
> @@ -1405,12 +1405,12 @@ xfs_swap_extent_rmap(
>  		offset_fsb += ilen;
>  	}
>  
> -	tip->i_d.di_flags2 = tip_flags2;
> +	tip->i_diflags2 = tip_flags2;
>  	return 0;
>  
>  out:
>  	trace_xfs_swap_extent_rmap_error(ip, error, _RET_IP_);
> -	tip->i_d.di_flags2 = tip_flags2;
> +	tip->i_diflags2 = tip_flags2;
>  	return error;
>  }
>  
> @@ -1708,13 +1708,13 @@ xfs_swap_extents(
>  		goto out_trans_cancel;
>  
>  	/* Do we have to swap reflink flags? */
> -	if ((ip->i_d.di_flags2 & XFS_DIFLAG2_REFLINK) ^
> -	    (tip->i_d.di_flags2 & XFS_DIFLAG2_REFLINK)) {
> -		f = ip->i_d.di_flags2 & XFS_DIFLAG2_REFLINK;
> -		ip->i_d.di_flags2 &= ~XFS_DIFLAG2_REFLINK;
> -		ip->i_d.di_flags2 |= tip->i_d.di_flags2 & XFS_DIFLAG2_REFLINK;
> -		tip->i_d.di_flags2 &= ~XFS_DIFLAG2_REFLINK;
> -		tip->i_d.di_flags2 |= f & XFS_DIFLAG2_REFLINK;
> +	if ((ip->i_diflags2 & XFS_DIFLAG2_REFLINK) ^
> +	    (tip->i_diflags2 & XFS_DIFLAG2_REFLINK)) {
> +		f = ip->i_diflags2 & XFS_DIFLAG2_REFLINK;
> +		ip->i_diflags2 &= ~XFS_DIFLAG2_REFLINK;
> +		ip->i_diflags2 |= tip->i_diflags2 & XFS_DIFLAG2_REFLINK;
> +		tip->i_diflags2 &= ~XFS_DIFLAG2_REFLINK;
> +		tip->i_diflags2 |= f & XFS_DIFLAG2_REFLINK;
>  	}
>  
>  	/* Swap the cow forks. */
> diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c
> index 4f08793f3d6db4..193352df48f6bd 100644
> --- a/fs/xfs/xfs_file.c
> +++ b/fs/xfs/xfs_file.c
> @@ -1052,9 +1052,9 @@ xfs_file_remap_range(
>  	 */
>  	cowextsize = 0;
>  	if (pos_in == 0 && len == i_size_read(inode_in) &&
> -	    (src->i_d.di_flags2 & XFS_DIFLAG2_COWEXTSIZE) &&
> +	    (src->i_diflags2 & XFS_DIFLAG2_COWEXTSIZE) &&
>  	    pos_out == 0 && len >= i_size_read(inode_out) &&
> -	    !(dest->i_d.di_flags2 & XFS_DIFLAG2_COWEXTSIZE))
> +	    !(dest->i_diflags2 & XFS_DIFLAG2_COWEXTSIZE))
>  		cowextsize = src->i_cowextsize;
>  
>  	ret = xfs_reflink_update_dest(dest, pos_out + len, cowextsize,
> diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
> index 479342ac8851f4..593e8c5c2fd658 100644
> --- a/fs/xfs/xfs_inode.c
> +++ b/fs/xfs/xfs_inode.c
> @@ -81,7 +81,7 @@ xfs_get_cowextsz_hint(
>  	xfs_extlen_t		a, b;
>  
>  	a = 0;
> -	if (ip->i_d.di_flags2 & XFS_DIFLAG2_COWEXTSIZE)
> +	if (ip->i_diflags2 & XFS_DIFLAG2_COWEXTSIZE)
>  		a = ip->i_cowextsize;
>  	b = xfs_get_extsz_hint(ip);
>  
> @@ -671,9 +671,7 @@ uint
>  xfs_ip2xflags(
>  	struct xfs_inode	*ip)
>  {
> -	struct xfs_icdinode	*dic = &ip->i_d;
> -
> -	return _xfs_dic2xflags(ip->i_diflags, dic->di_flags2, XFS_IFORK_Q(ip));
> +	return _xfs_dic2xflags(ip->i_diflags, ip->i_diflags2, XFS_IFORK_Q(ip));
>  }
>  
>  /*
> @@ -841,7 +839,7 @@ xfs_ialloc(
>  
>  	if (xfs_sb_version_has_v3inode(&mp->m_sb)) {
>  		inode_set_iversion(inode, 1);
> -		ip->i_d.di_flags2 = 0;
> +		ip->i_diflags2 = 0;
>  		ip->i_cowextsize = 0;
>  		ip->i_d.di_crtime = tv;
>  	}
> @@ -898,13 +896,13 @@ xfs_ialloc(
>  
>  			ip->i_diflags |= di_flags;
>  		}
> -		if (pip && (pip->i_d.di_flags2 & XFS_DIFLAG2_ANY)) {
> -			if (pip->i_d.di_flags2 & XFS_DIFLAG2_COWEXTSIZE) {
> -				ip->i_d.di_flags2 |= XFS_DIFLAG2_COWEXTSIZE;
> +		if (pip && (pip->i_diflags2 & XFS_DIFLAG2_ANY)) {
> +			if (pip->i_diflags2 & XFS_DIFLAG2_COWEXTSIZE) {
> +				ip->i_diflags2 |= XFS_DIFLAG2_COWEXTSIZE;
>  				ip->i_cowextsize = pip->i_cowextsize;
>  			}
> -			if (pip->i_d.di_flags2 & XFS_DIFLAG2_DAX)
> -				ip->i_d.di_flags2 |= XFS_DIFLAG2_DAX;
> +			if (pip->i_diflags2 & XFS_DIFLAG2_DAX)
> +				ip->i_diflags2 |= XFS_DIFLAG2_DAX;
>  		}
>  		/* FALLTHROUGH */
>  	case S_IFLNK:
> @@ -1456,7 +1454,7 @@ xfs_itruncate_clear_reflink_flags(
>  	dfork = XFS_IFORK_PTR(ip, XFS_DATA_FORK);
>  	cfork = XFS_IFORK_PTR(ip, XFS_COW_FORK);
>  	if (dfork->if_bytes == 0 && cfork->if_bytes == 0)
> -		ip->i_d.di_flags2 &= ~XFS_DIFLAG2_REFLINK;
> +		ip->i_diflags2 &= ~XFS_DIFLAG2_REFLINK;
>  	if (cfork->if_bytes == 0)
>  		xfs_inode_clear_cowblocks_tag(ip);
>  }
> @@ -2756,7 +2754,7 @@ xfs_ifree(
>  
>  	VFS_I(ip)->i_mode = 0;		/* mark incore inode as free */
>  	ip->i_diflags = 0;
> -	ip->i_d.di_flags2 = 0;
> +	ip->i_diflags2 = 0;
>  	ip->i_d.di_dmevmask = 0;
>  	ip->i_forkoff = 0;		/* mark the attr fork not in use */
>  	ip->i_df.if_format = XFS_DINODE_FMT_EXTENTS;
> diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h
> index 7673c841d89154..709f04fadde65e 100644
> --- a/fs/xfs/xfs_inode.h
> +++ b/fs/xfs/xfs_inode.h
> @@ -65,6 +65,7 @@ typedef struct xfs_inode {
>  	};
>  	uint8_t			i_forkoff;	/* attr fork offset >> 3 */
>  	uint16_t		i_diflags;	/* XFS_DIFLAG_... */
> +	uint64_t		i_diflags2;	/* XFS_DIFLAG2_... */
>  
>  	struct xfs_icdinode	i_d;		/* most of ondisk inode */
>  
> @@ -193,7 +194,7 @@ xfs_get_initial_prid(struct xfs_inode *dp)
>  
>  static inline bool xfs_is_reflink_inode(struct xfs_inode *ip)
>  {
> -	return ip->i_d.di_flags2 & XFS_DIFLAG2_REFLINK;
> +	return ip->i_diflags2 & XFS_DIFLAG2_REFLINK;
>  }
>  
>  /*
> diff --git a/fs/xfs/xfs_inode_item.c b/fs/xfs/xfs_inode_item.c
> index 6af8e829dd0172..04e671d2957ca2 100644
> --- a/fs/xfs/xfs_inode_item.c
> +++ b/fs/xfs/xfs_inode_item.c
> @@ -342,7 +342,7 @@ xfs_inode_to_log_dinode(
>  		to->di_changecount = inode_peek_iversion(inode);
>  		to->di_crtime.t_sec = from->di_crtime.tv_sec;
>  		to->di_crtime.t_nsec = from->di_crtime.tv_nsec;
> -		to->di_flags2 = from->di_flags2;
> +		to->di_flags2 = ip->i_diflags2;
>  		to->di_cowextsize = ip->i_cowextsize;
>  		to->di_ino = ip->i_ino;
>  		to->di_lsn = lsn;
> diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
> index 326991f4d98096..d05b86e7930e84 100644
> --- a/fs/xfs/xfs_ioctl.c
> +++ b/fs/xfs/xfs_ioctl.c
> @@ -1110,7 +1110,7 @@ xfs_fill_fsxattr(
>  	simple_fill_fsxattr(fa, xfs_ip2xflags(ip));
>  	fa->fsx_extsize = XFS_FSB_TO_B(mp, ip->i_extsize);
>  	if (xfs_sb_version_has_v3inode(&mp->m_sb) &&
> -	    (ip->i_d.di_flags2 & XFS_DIFLAG2_COWEXTSIZE))
> +	    (ip->i_diflags2 & XFS_DIFLAG2_COWEXTSIZE))
>  		fa->fsx_cowextsize = XFS_FSB_TO_B(mp, ip->i_cowextsize);
>  	fa->fsx_projid = ip->i_projid;
>  	if (ifp && (ifp->if_flags & XFS_IFEXTENTS))
> @@ -1183,15 +1183,14 @@ xfs_flags2diflags2(
>  	struct xfs_inode	*ip,
>  	unsigned int		xflags)
>  {
> -	uint64_t		di_flags2 =
> -		(ip->i_d.di_flags2 & XFS_DIFLAG2_REFLINK);
> +	uint64_t		i_flags2 = (ip->i_diflags2 & XFS_DIFLAG2_REFLINK);
>  
>  	if (xflags & FS_XFLAG_DAX)
> -		di_flags2 |= XFS_DIFLAG2_DAX;
> +		i_flags2 |= XFS_DIFLAG2_DAX;
>  	if (xflags & FS_XFLAG_COWEXTSIZE)
> -		di_flags2 |= XFS_DIFLAG2_COWEXTSIZE;
> +		i_flags2 |= XFS_DIFLAG2_COWEXTSIZE;
>  
> -	return di_flags2;
> +	return i_flags2;
>  }
>  
>  static int
> @@ -1201,7 +1200,7 @@ xfs_ioctl_setattr_xflags(
>  	struct fsxattr		*fa)
>  {
>  	struct xfs_mount	*mp = ip->i_mount;
> -	uint64_t		di_flags2;
> +	uint64_t		i_flags2;
>  
>  	/* Can't change realtime flag if any extents are allocated. */
>  	if ((ip->i_df.if_nextents || ip->i_delayed_blks) &&
> @@ -1217,19 +1216,19 @@ xfs_ioctl_setattr_xflags(
>  
>  	/* Clear reflink if we are actually able to set the rt flag. */
>  	if ((fa->fsx_xflags & FS_XFLAG_REALTIME) && xfs_is_reflink_inode(ip))
> -		ip->i_d.di_flags2 &= ~XFS_DIFLAG2_REFLINK;
> +		ip->i_diflags2 &= ~XFS_DIFLAG2_REFLINK;
>  
>  	/* Don't allow us to set DAX mode for a reflinked file for now. */
>  	if ((fa->fsx_xflags & FS_XFLAG_DAX) && xfs_is_reflink_inode(ip))
>  		return -EINVAL;
>  
>  	/* diflags2 only valid for v3 inodes. */
> -	di_flags2 = xfs_flags2diflags2(ip, fa->fsx_xflags);
> -	if (di_flags2 && !xfs_sb_version_has_v3inode(&mp->m_sb))
> +	i_flags2 = xfs_flags2diflags2(ip, fa->fsx_xflags);
> +	if (i_flags2 && !xfs_sb_version_has_v3inode(&mp->m_sb))
>  		return -EINVAL;
>  
>  	ip->i_diflags = xfs_flags2diflags(ip, fa->fsx_xflags);
> -	ip->i_d.di_flags2 = di_flags2;
> +	ip->i_diflags2 = i_flags2;
>  
>  	xfs_diflags_to_iflags(ip, false);
>  	xfs_trans_ichgtime(tp, ip, XFS_ICHGTIME_CHG);
> @@ -1575,7 +1574,7 @@ xfs_ioctl_setattr(
>  	else
>  		ip->i_extsize = 0;
>  	if (xfs_sb_version_has_v3inode(&mp->m_sb) &&
> -	    (ip->i_d.di_flags2 & XFS_DIFLAG2_COWEXTSIZE))
> +	    (ip->i_diflags2 & XFS_DIFLAG2_COWEXTSIZE))
>  		ip->i_cowextsize = fa->fsx_cowextsize >> mp->m_sb.sb_blocklog;
>  	else
>  		ip->i_cowextsize = 0;
> diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
> index f37154fc9828fd..3642f9935cae3f 100644
> --- a/fs/xfs/xfs_iops.c
> +++ b/fs/xfs/xfs_iops.c
> @@ -1265,7 +1265,7 @@ xfs_inode_should_enable_dax(
>  		return false;
>  	if (ip->i_mount->m_flags & XFS_MOUNT_DAX_ALWAYS)
>  		return true;
> -	if (ip->i_d.di_flags2 & XFS_DIFLAG2_DAX)
> +	if (ip->i_diflags2 & XFS_DIFLAG2_DAX)
>  		return true;
>  	return false;
>  }
> diff --git a/fs/xfs/xfs_itable.c b/fs/xfs/xfs_itable.c
> index 7937af9f2ea779..4d1509437c3576 100644
> --- a/fs/xfs/xfs_itable.c
> +++ b/fs/xfs/xfs_itable.c
> @@ -111,7 +111,7 @@ xfs_bulkstat_one_int(
>  	buf->bs_version = XFS_BULKSTAT_VERSION_V5;
>  
>  	if (xfs_sb_version_has_v3inode(&mp->m_sb)) {
> -		if (dic->di_flags2 & XFS_DIFLAG2_COWEXTSIZE)
> +		if (ip->i_diflags2 & XFS_DIFLAG2_COWEXTSIZE)
>  			buf->bs_cowextsize_blks = ip->i_cowextsize;
>  	}
>  
> diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c
> index 0e07fa7e43117e..476ba54d84a9a3 100644
> --- a/fs/xfs/xfs_reflink.c
> +++ b/fs/xfs/xfs_reflink.c
> @@ -882,7 +882,7 @@ xfs_reflink_set_inode_flag(
>  	if (!xfs_is_reflink_inode(src)) {
>  		trace_xfs_reflink_set_inode_flag(src);
>  		xfs_trans_ijoin(tp, src, XFS_ILOCK_EXCL);
> -		src->i_d.di_flags2 |= XFS_DIFLAG2_REFLINK;
> +		src->i_diflags2 |= XFS_DIFLAG2_REFLINK;
>  		xfs_trans_log_inode(tp, src, XFS_ILOG_CORE);
>  		xfs_ifork_init_cow(src);
>  	} else
> @@ -894,7 +894,7 @@ xfs_reflink_set_inode_flag(
>  	if (!xfs_is_reflink_inode(dest)) {
>  		trace_xfs_reflink_set_inode_flag(dest);
>  		xfs_trans_ijoin(tp, dest, XFS_ILOCK_EXCL);
> -		dest->i_d.di_flags2 |= XFS_DIFLAG2_REFLINK;
> +		dest->i_diflags2 |= XFS_DIFLAG2_REFLINK;
>  		xfs_trans_log_inode(tp, dest, XFS_ILOG_CORE);
>  		xfs_ifork_init_cow(dest);
>  	} else
> @@ -943,7 +943,7 @@ xfs_reflink_update_dest(
>  
>  	if (cowextsize) {
>  		dest->i_cowextsize = cowextsize;
> -		dest->i_d.di_flags2 |= XFS_DIFLAG2_COWEXTSIZE;
> +		dest->i_diflags2 |= XFS_DIFLAG2_COWEXTSIZE;
>  	}
>  
>  	xfs_trans_log_inode(tp, dest, XFS_ILOG_CORE);
> @@ -1463,7 +1463,7 @@ xfs_reflink_clear_inode_flag(
>  
>  	/* Clear the inode flag. */
>  	trace_xfs_reflink_unset_inode_flag(ip);
> -	ip->i_d.di_flags2 &= ~XFS_DIFLAG2_REFLINK;
> +	ip->i_diflags2 &= ~XFS_DIFLAG2_REFLINK;
>  	xfs_inode_clear_cowblocks_tag(ip);
>  	xfs_trans_log_inode(*tpp, ip, XFS_ILOG_CORE);
>  
> -- 
> 2.26.2
> 

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH 13/15] xfs: move the di_crtime field to struct xfs_inode
  2020-06-20  7:11 ` [PATCH 13/15] xfs: move the di_crtime " Christoph Hellwig
  2020-06-22 12:54   ` Chandan Babu R
@ 2020-06-30 17:55   ` Darrick J. Wong
  1 sibling, 0 replies; 52+ messages in thread
From: Darrick J. Wong @ 2020-06-30 17:55 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: linux-xfs

On Sat, Jun 20, 2020 at 09:11:00AM +0200, Christoph Hellwig wrote:
> In preparation of removing the historic icinode struct, move the crtime
> field into the containing xfs_inode structure.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>

Looks good to me,
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>

--D

> ---
>  fs/xfs/libxfs/xfs_inode_buf.c   | 8 ++++----
>  fs/xfs/libxfs/xfs_inode_buf.h   | 2 --
>  fs/xfs/libxfs/xfs_trans_inode.c | 2 +-
>  fs/xfs/xfs_inode.c              | 2 +-
>  fs/xfs/xfs_inode.h              | 1 +
>  fs/xfs/xfs_inode_item.c         | 4 ++--
>  fs/xfs/xfs_iops.c               | 2 +-
>  fs/xfs/xfs_itable.c             | 4 ++--
>  8 files changed, 12 insertions(+), 13 deletions(-)
> 
> diff --git a/fs/xfs/libxfs/xfs_inode_buf.c b/fs/xfs/libxfs/xfs_inode_buf.c
> index 79e470933abfa8..af595ee23635aa 100644
> --- a/fs/xfs/libxfs/xfs_inode_buf.c
> +++ b/fs/xfs/libxfs/xfs_inode_buf.c
> @@ -253,8 +253,8 @@ xfs_inode_from_disk(
>  	if (xfs_sb_version_has_v3inode(&ip->i_mount->m_sb)) {
>  		inode_set_iversion_queried(inode,
>  					   be64_to_cpu(from->di_changecount));
> -		to->di_crtime.tv_sec = be32_to_cpu(from->di_crtime.t_sec);
> -		to->di_crtime.tv_nsec = be32_to_cpu(from->di_crtime.t_nsec);
> +		ip->i_crtime.tv_sec = be32_to_cpu(from->di_crtime.t_sec);
> +		ip->i_crtime.tv_nsec = be32_to_cpu(from->di_crtime.t_nsec);
>  		ip->i_diflags2 = be64_to_cpu(from->di_flags2);
>  		ip->i_cowextsize = be32_to_cpu(from->di_cowextsize);
>  	}
> @@ -319,8 +319,8 @@ xfs_inode_to_disk(
>  	if (xfs_sb_version_has_v3inode(&ip->i_mount->m_sb)) {
>  		to->di_version = 3;
>  		to->di_changecount = cpu_to_be64(inode_peek_iversion(inode));
> -		to->di_crtime.t_sec = cpu_to_be32(from->di_crtime.tv_sec);
> -		to->di_crtime.t_nsec = cpu_to_be32(from->di_crtime.tv_nsec);
> +		to->di_crtime.t_sec = cpu_to_be32(ip->i_crtime.tv_sec);
> +		to->di_crtime.t_nsec = cpu_to_be32(ip->i_crtime.tv_nsec);
>  		to->di_flags2 = cpu_to_be64(ip->i_diflags2);
>  		to->di_cowextsize = cpu_to_be32(ip->i_cowextsize);
>  		to->di_ino = cpu_to_be64(ip->i_ino);
> diff --git a/fs/xfs/libxfs/xfs_inode_buf.h b/fs/xfs/libxfs/xfs_inode_buf.h
> index 4bfad6d6d5710a..2a8e7a7ed8d18d 100644
> --- a/fs/xfs/libxfs/xfs_inode_buf.h
> +++ b/fs/xfs/libxfs/xfs_inode_buf.h
> @@ -18,8 +18,6 @@ struct xfs_dinode;
>  struct xfs_icdinode {
>  	uint32_t	di_dmevmask;	/* DMIG event mask */
>  	uint16_t	di_dmstate;	/* DMIG state info */
> -
> -	struct timespec64 di_crtime;	/* time created */
>  };
>  
>  /*
> diff --git a/fs/xfs/libxfs/xfs_trans_inode.c b/fs/xfs/libxfs/xfs_trans_inode.c
> index b5dfb665484223..3c690829634cdc 100644
> --- a/fs/xfs/libxfs/xfs_trans_inode.c
> +++ b/fs/xfs/libxfs/xfs_trans_inode.c
> @@ -67,7 +67,7 @@ xfs_trans_ichgtime(
>  	if (flags & XFS_ICHGTIME_CHG)
>  		inode->i_ctime = tv;
>  	if (flags & XFS_ICHGTIME_CREATE)
> -		ip->i_d.di_crtime = tv;
> +		ip->i_crtime = tv;
>  }
>  
>  /*
> diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
> index 593e8c5c2fd658..59f11314750a46 100644
> --- a/fs/xfs/xfs_inode.c
> +++ b/fs/xfs/xfs_inode.c
> @@ -841,7 +841,7 @@ xfs_ialloc(
>  		inode_set_iversion(inode, 1);
>  		ip->i_diflags2 = 0;
>  		ip->i_cowextsize = 0;
> -		ip->i_d.di_crtime = tv;
> +		ip->i_crtime = tv;
>  	}
>  
>  	flags = XFS_ILOG_CORE;
> diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h
> index 709f04fadde65e..106a8d6cc010cb 100644
> --- a/fs/xfs/xfs_inode.h
> +++ b/fs/xfs/xfs_inode.h
> @@ -66,6 +66,7 @@ typedef struct xfs_inode {
>  	uint8_t			i_forkoff;	/* attr fork offset >> 3 */
>  	uint16_t		i_diflags;	/* XFS_DIFLAG_... */
>  	uint64_t		i_diflags2;	/* XFS_DIFLAG2_... */
> +	struct timespec64	i_crtime;	/* time created */
>  
>  	struct xfs_icdinode	i_d;		/* most of ondisk inode */
>  
> diff --git a/fs/xfs/xfs_inode_item.c b/fs/xfs/xfs_inode_item.c
> index 04e671d2957ca2..dff3bc6a33720a 100644
> --- a/fs/xfs/xfs_inode_item.c
> +++ b/fs/xfs/xfs_inode_item.c
> @@ -340,8 +340,8 @@ xfs_inode_to_log_dinode(
>  	if (xfs_sb_version_has_v3inode(&ip->i_mount->m_sb)) {
>  		to->di_version = 3;
>  		to->di_changecount = inode_peek_iversion(inode);
> -		to->di_crtime.t_sec = from->di_crtime.tv_sec;
> -		to->di_crtime.t_nsec = from->di_crtime.tv_nsec;
> +		to->di_crtime.t_sec = ip->i_crtime.tv_sec;
> +		to->di_crtime.t_nsec = ip->i_crtime.tv_nsec;
>  		to->di_flags2 = ip->i_diflags2;
>  		to->di_cowextsize = ip->i_cowextsize;
>  		to->di_ino = ip->i_ino;
> diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
> index 3642f9935cae3f..6aace9c6586ca5 100644
> --- a/fs/xfs/xfs_iops.c
> +++ b/fs/xfs/xfs_iops.c
> @@ -559,7 +559,7 @@ xfs_vn_getattr(
>  	if (xfs_sb_version_has_v3inode(&mp->m_sb)) {
>  		if (request_mask & STATX_BTIME) {
>  			stat->result_mask |= STATX_BTIME;
> -			stat->btime = ip->i_d.di_crtime;
> +			stat->btime = ip->i_crtime;
>  		}
>  	}
>  
> diff --git a/fs/xfs/xfs_itable.c b/fs/xfs/xfs_itable.c
> index 4d1509437c3576..7945c6c4844940 100644
> --- a/fs/xfs/xfs_itable.c
> +++ b/fs/xfs/xfs_itable.c
> @@ -97,8 +97,8 @@ xfs_bulkstat_one_int(
>  	buf->bs_mtime_nsec = inode->i_mtime.tv_nsec;
>  	buf->bs_ctime = inode->i_ctime.tv_sec;
>  	buf->bs_ctime_nsec = inode->i_ctime.tv_nsec;
> -	buf->bs_btime = dic->di_crtime.tv_sec;
> -	buf->bs_btime_nsec = dic->di_crtime.tv_nsec;
> +	buf->bs_btime = ip->i_crtime.tv_sec;
> +	buf->bs_btime_nsec = ip->i_crtime.tv_nsec;
>  	buf->bs_gen = inode->i_generation;
>  	buf->bs_mode = inode->i_mode;
>  
> -- 
> 2.26.2
> 

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH 14/15] xfs: move the di_dmevmask field to struct xfs_inode
  2020-06-20  7:11 ` [PATCH 14/15] xfs: move the di_dmevmask " Christoph Hellwig
  2020-06-22 12:58   ` Chandan Babu R
@ 2020-06-30 17:55   ` Darrick J. Wong
  1 sibling, 0 replies; 52+ messages in thread
From: Darrick J. Wong @ 2020-06-30 17:55 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: linux-xfs

On Sat, Jun 20, 2020 at 09:11:01AM +0200, Christoph Hellwig wrote:
> In preparation of removing the historic icinode struct, move the
> dmevmask field into the containing xfs_inode structure.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>

Easy conversion,
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>

--D

> ---
>  fs/xfs/libxfs/xfs_inode_buf.c | 4 ++--
>  fs/xfs/libxfs/xfs_inode_buf.h | 1 -
>  fs/xfs/xfs_inode.c            | 4 ++--
>  fs/xfs/xfs_inode.h            | 1 +
>  fs/xfs/xfs_inode_item.c       | 2 +-
>  fs/xfs/xfs_log_recover.c      | 2 +-
>  6 files changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/fs/xfs/libxfs/xfs_inode_buf.c b/fs/xfs/libxfs/xfs_inode_buf.c
> index af595ee23635aa..d361803102d0e1 100644
> --- a/fs/xfs/libxfs/xfs_inode_buf.c
> +++ b/fs/xfs/libxfs/xfs_inode_buf.c
> @@ -246,7 +246,7 @@ xfs_inode_from_disk(
>  	ip->i_nblocks = be64_to_cpu(from->di_nblocks);
>  	ip->i_extsize = be32_to_cpu(from->di_extsize);
>  	ip->i_forkoff = from->di_forkoff;
> -	to->di_dmevmask	= be32_to_cpu(from->di_dmevmask);
> +	ip->i_dmevmask	= be32_to_cpu(from->di_dmevmask);
>  	to->di_dmstate	= be16_to_cpu(from->di_dmstate);
>  	ip->i_diflags	= be16_to_cpu(from->di_flags);
>  
> @@ -312,7 +312,7 @@ xfs_inode_to_disk(
>  	to->di_anextents = cpu_to_be16(xfs_ifork_nextents(ip->i_afp));
>  	to->di_forkoff = ip->i_forkoff;
>  	to->di_aformat = xfs_ifork_format(ip->i_afp);
> -	to->di_dmevmask = cpu_to_be32(from->di_dmevmask);
> +	to->di_dmevmask = cpu_to_be32(ip->i_dmevmask);
>  	to->di_dmstate = cpu_to_be16(from->di_dmstate);
>  	to->di_flags = cpu_to_be16(ip->i_diflags);
>  
> diff --git a/fs/xfs/libxfs/xfs_inode_buf.h b/fs/xfs/libxfs/xfs_inode_buf.h
> index 2a8e7a7ed8d18d..0cfc1aaff6c6f3 100644
> --- a/fs/xfs/libxfs/xfs_inode_buf.h
> +++ b/fs/xfs/libxfs/xfs_inode_buf.h
> @@ -16,7 +16,6 @@ struct xfs_dinode;
>   * format specific structures at the appropriate time.
>   */
>  struct xfs_icdinode {
> -	uint32_t	di_dmevmask;	/* DMIG event mask */
>  	uint16_t	di_dmstate;	/* DMIG state info */
>  };
>  
> diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
> index 59f11314750a46..db48c910c8d7b0 100644
> --- a/fs/xfs/xfs_inode.c
> +++ b/fs/xfs/xfs_inode.c
> @@ -833,7 +833,7 @@ xfs_ialloc(
>  	inode->i_ctime = tv;
>  
>  	ip->i_extsize = 0;
> -	ip->i_d.di_dmevmask = 0;
> +	ip->i_dmevmask = 0;
>  	ip->i_d.di_dmstate = 0;
>  	ip->i_diflags = 0;
>  
> @@ -2755,7 +2755,7 @@ xfs_ifree(
>  	VFS_I(ip)->i_mode = 0;		/* mark incore inode as free */
>  	ip->i_diflags = 0;
>  	ip->i_diflags2 = 0;
> -	ip->i_d.di_dmevmask = 0;
> +	ip->i_dmevmask = 0;
>  	ip->i_forkoff = 0;		/* mark the attr fork not in use */
>  	ip->i_df.if_format = XFS_DINODE_FMT_EXTENTS;
>  
> diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h
> index 106a8d6cc010cb..e64df2e7438aa0 100644
> --- a/fs/xfs/xfs_inode.h
> +++ b/fs/xfs/xfs_inode.h
> @@ -67,6 +67,7 @@ typedef struct xfs_inode {
>  	uint16_t		i_diflags;	/* XFS_DIFLAG_... */
>  	uint64_t		i_diflags2;	/* XFS_DIFLAG2_... */
>  	struct timespec64	i_crtime;	/* time created */
> +	uint32_t		i_dmevmask;	/* DMIG event mask */
>  
>  	struct xfs_icdinode	i_d;		/* most of ondisk inode */
>  
> diff --git a/fs/xfs/xfs_inode_item.c b/fs/xfs/xfs_inode_item.c
> index dff3bc6a33720a..9b7860025c497d 100644
> --- a/fs/xfs/xfs_inode_item.c
> +++ b/fs/xfs/xfs_inode_item.c
> @@ -330,7 +330,7 @@ xfs_inode_to_log_dinode(
>  	to->di_anextents = xfs_ifork_nextents(ip->i_afp);
>  	to->di_forkoff = ip->i_forkoff;
>  	to->di_aformat = xfs_ifork_format(ip->i_afp);
> -	to->di_dmevmask = from->di_dmevmask;
> +	to->di_dmevmask = ip->i_dmevmask;
>  	to->di_dmstate = from->di_dmstate;
>  	to->di_flags = ip->i_diflags;
>  
> diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c
> index ec015df55b77a9..d096b8c4013814 100644
> --- a/fs/xfs/xfs_log_recover.c
> +++ b/fs/xfs/xfs_log_recover.c
> @@ -2720,7 +2720,7 @@ xlog_recover_process_one_iunlink(
>  	 * Prevent any DMAPI event from being sent when the reference on
>  	 * the inode is dropped.
>  	 */
> -	ip->i_d.di_dmevmask = 0;
> +	ip->i_dmevmask = 0;
>  
>  	xfs_irele(ip);
>  	return agino;
> -- 
> 2.26.2
> 

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH 15/15] xfs: move the di_dmstate field to struct xfs_inode
  2020-06-20  7:11 ` [PATCH 15/15] xfs: move the di_dmstate " Christoph Hellwig
  2020-06-22 13:18   ` Chandan Babu R
@ 2020-06-30 17:56   ` Darrick J. Wong
  1 sibling, 0 replies; 52+ messages in thread
From: Darrick J. Wong @ 2020-06-30 17:56 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: linux-xfs

On Sat, Jun 20, 2020 at 09:11:02AM +0200, Christoph Hellwig wrote:
> Move the di_dmstate into struct xfs_inode, and thus finally kill of
> the xfs_icdinode structure.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>

Hooray, it's gone finally...

Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>

--D

> ---
>  fs/xfs/libxfs/xfs_inode_buf.c |  6 ++----
>  fs/xfs/libxfs/xfs_inode_buf.h | 10 ----------
>  fs/xfs/xfs_inode.c            |  2 +-
>  fs/xfs/xfs_inode.h            |  3 +--
>  fs/xfs/xfs_inode_item.c       |  3 +--
>  fs/xfs/xfs_itable.c           |  3 ---
>  6 files changed, 5 insertions(+), 22 deletions(-)
> 
> diff --git a/fs/xfs/libxfs/xfs_inode_buf.c b/fs/xfs/libxfs/xfs_inode_buf.c
> index d361803102d0e1..e4e96a47e0bab6 100644
> --- a/fs/xfs/libxfs/xfs_inode_buf.c
> +++ b/fs/xfs/libxfs/xfs_inode_buf.c
> @@ -185,7 +185,6 @@ xfs_inode_from_disk(
>  	struct xfs_inode	*ip,
>  	struct xfs_dinode	*from)
>  {
> -	struct xfs_icdinode	*to = &ip->i_d;
>  	struct inode		*inode = VFS_I(ip);
>  	int			error;
>  	xfs_failaddr_t		fa;
> @@ -247,7 +246,7 @@ xfs_inode_from_disk(
>  	ip->i_extsize = be32_to_cpu(from->di_extsize);
>  	ip->i_forkoff = from->di_forkoff;
>  	ip->i_dmevmask	= be32_to_cpu(from->di_dmevmask);
> -	to->di_dmstate	= be16_to_cpu(from->di_dmstate);
> +	ip->i_dmstate	= be16_to_cpu(from->di_dmstate);
>  	ip->i_diflags	= be16_to_cpu(from->di_flags);
>  
>  	if (xfs_sb_version_has_v3inode(&ip->i_mount->m_sb)) {
> @@ -282,7 +281,6 @@ xfs_inode_to_disk(
>  	struct xfs_dinode	*to,
>  	xfs_lsn_t		lsn)
>  {
> -	struct xfs_icdinode	*from = &ip->i_d;
>  	struct inode		*inode = VFS_I(ip);
>  
>  	to->di_magic = cpu_to_be16(XFS_DINODE_MAGIC);
> @@ -313,7 +311,7 @@ xfs_inode_to_disk(
>  	to->di_forkoff = ip->i_forkoff;
>  	to->di_aformat = xfs_ifork_format(ip->i_afp);
>  	to->di_dmevmask = cpu_to_be32(ip->i_dmevmask);
> -	to->di_dmstate = cpu_to_be16(from->di_dmstate);
> +	to->di_dmstate = cpu_to_be16(ip->i_dmstate);
>  	to->di_flags = cpu_to_be16(ip->i_diflags);
>  
>  	if (xfs_sb_version_has_v3inode(&ip->i_mount->m_sb)) {
> diff --git a/fs/xfs/libxfs/xfs_inode_buf.h b/fs/xfs/libxfs/xfs_inode_buf.h
> index 0cfc1aaff6c6f3..834c8b3e917370 100644
> --- a/fs/xfs/libxfs/xfs_inode_buf.h
> +++ b/fs/xfs/libxfs/xfs_inode_buf.h
> @@ -9,16 +9,6 @@
>  struct xfs_inode;
>  struct xfs_dinode;
>  
> -/*
> - * In memory representation of the XFS inode. This is held in the in-core struct
> - * xfs_inode and represents the current on disk values but the structure is not
> - * in on-disk format.  That is, this structure is always translated to on-disk
> - * format specific structures at the appropriate time.
> - */
> -struct xfs_icdinode {
> -	uint16_t	di_dmstate;	/* DMIG state info */
> -};
> -
>  /*
>   * Inode location information.  Stored in the inode and passed to
>   * xfs_imap_to_bp() to get a buffer and dinode for a given inode.
> diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
> index db48c910c8d7b0..79436ed0b14e89 100644
> --- a/fs/xfs/xfs_inode.c
> +++ b/fs/xfs/xfs_inode.c
> @@ -834,7 +834,7 @@ xfs_ialloc(
>  
>  	ip->i_extsize = 0;
>  	ip->i_dmevmask = 0;
> -	ip->i_d.di_dmstate = 0;
> +	ip->i_dmstate = 0;
>  	ip->i_diflags = 0;
>  
>  	if (xfs_sb_version_has_v3inode(&mp->m_sb)) {
> diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h
> index e64df2e7438aa0..f0537ead8bad90 100644
> --- a/fs/xfs/xfs_inode.h
> +++ b/fs/xfs/xfs_inode.h
> @@ -68,8 +68,7 @@ typedef struct xfs_inode {
>  	uint64_t		i_diflags2;	/* XFS_DIFLAG2_... */
>  	struct timespec64	i_crtime;	/* time created */
>  	uint32_t		i_dmevmask;	/* DMIG event mask */
> -
> -	struct xfs_icdinode	i_d;		/* most of ondisk inode */
> +	uint16_t		i_dmstate;	/* DMIG state info */
>  
>  	/* VFS inode */
>  	struct inode		i_vnode;	/* embedded VFS inode */
> diff --git a/fs/xfs/xfs_inode_item.c b/fs/xfs/xfs_inode_item.c
> index 9b7860025c497d..628f8190abddca 100644
> --- a/fs/xfs/xfs_inode_item.c
> +++ b/fs/xfs/xfs_inode_item.c
> @@ -301,7 +301,6 @@ xfs_inode_to_log_dinode(
>  	struct xfs_log_dinode	*to,
>  	xfs_lsn_t		lsn)
>  {
> -	struct xfs_icdinode	*from = &ip->i_d;
>  	struct inode		*inode = VFS_I(ip);
>  
>  	to->di_magic = XFS_DINODE_MAGIC;
> @@ -331,7 +330,7 @@ xfs_inode_to_log_dinode(
>  	to->di_forkoff = ip->i_forkoff;
>  	to->di_aformat = xfs_ifork_format(ip->i_afp);
>  	to->di_dmevmask = ip->i_dmevmask;
> -	to->di_dmstate = from->di_dmstate;
> +	to->di_dmstate = ip->i_dmstate;
>  	to->di_flags = ip->i_diflags;
>  
>  	/* log a dummy value to ensure log structure is fully initialised */
> diff --git a/fs/xfs/xfs_itable.c b/fs/xfs/xfs_itable.c
> index 7945c6c4844940..cd1f09e57b9483 100644
> --- a/fs/xfs/xfs_itable.c
> +++ b/fs/xfs/xfs_itable.c
> @@ -58,7 +58,6 @@ xfs_bulkstat_one_int(
>  	xfs_ino_t		ino,
>  	struct xfs_bstat_chunk	*bc)
>  {
> -	struct xfs_icdinode	*dic;		/* dinode core info pointer */
>  	struct xfs_inode	*ip;		/* incore inode pointer */
>  	struct inode		*inode;
>  	struct xfs_bulkstat	*buf = bc->buf;
> @@ -79,8 +78,6 @@ xfs_bulkstat_one_int(
>  	ASSERT(ip->i_imap.im_blkno != 0);
>  	inode = VFS_I(ip);
>  
> -	dic = &ip->i_d;
> -
>  	/* xfs_iget returns the following without needing
>  	 * further change.
>  	 */
> -- 
> 2.26.2
> 

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH 01/15] xfs: don't clear the "dinode core" in xfs_inode_alloc
  2020-06-20  7:10 ` [PATCH 01/15] xfs: don't clear the "dinode core" in xfs_inode_alloc Christoph Hellwig
  2020-06-22  7:11   ` Chandan Babu R
@ 2020-06-30 17:58   ` Darrick J. Wong
  2020-07-02 18:34     ` Darrick J. Wong
  1 sibling, 1 reply; 52+ messages in thread
From: Darrick J. Wong @ 2020-06-30 17:58 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: linux-xfs

On Sat, Jun 20, 2020 at 09:10:48AM +0200, Christoph Hellwig wrote:
> The xfs_icdinode structure just contains a random mix of inode field,
> which are all read from the on-disk inode and mostly not looked at
> before reading the inode or initializing a new inode cluster.  The
> only exceptions are the forkoff and blocks field, which are used
> in sanity checks for freshly allocated inodes.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>

/me thinks this looks ok, though I'm leaning on Chandan probably having
done a more thorough examination than I did...

Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>

--D

> ---
>  fs/xfs/xfs_icache.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/xfs/xfs_icache.c b/fs/xfs/xfs_icache.c
> index 0a5ac6f9a58349..660e7abd4e8b76 100644
> --- a/fs/xfs/xfs_icache.c
> +++ b/fs/xfs/xfs_icache.c
> @@ -66,7 +66,8 @@ xfs_inode_alloc(
>  	memset(&ip->i_df, 0, sizeof(ip->i_df));
>  	ip->i_flags = 0;
>  	ip->i_delayed_blks = 0;
> -	memset(&ip->i_d, 0, sizeof(ip->i_d));
> +	ip->i_d.di_nblocks = 0;
> +	ip->i_d.di_forkoff = 0;
>  	ip->i_sick = 0;
>  	ip->i_checked = 0;
>  	INIT_WORK(&ip->i_ioend_work, xfs_end_io);
> -- 
> 2.26.2
> 

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: xfs inode structure cleanups v2
  2020-06-20  7:10 xfs inode structure cleanups v2 Christoph Hellwig
                   ` (14 preceding siblings ...)
  2020-06-20  7:11 ` [PATCH 15/15] xfs: move the di_dmstate " Christoph Hellwig
@ 2020-06-30 18:01 ` Darrick J. Wong
  15 siblings, 0 replies; 52+ messages in thread
From: Darrick J. Wong @ 2020-06-30 18:01 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: linux-xfs

On Sat, Jun 20, 2020 at 09:10:47AM +0200, Christoph Hellwig wrote:
> Hi all,
> 
> This series cleans up how we define struct xfs_inode.  Most importantly
> it removes the pointles xfs_icdinode sub-structure.
> 
> Changes since v1:
>  - rebased to 5.8-rc
>  - use xfs_extlen_t fo i_cowextsize
>  - cleanup xfs_fill_fsxattr

Hm, ok, so this all looks reasonable.  Two questions about the series:

1) What do the xfsprogs changes look like?

2) Does Dave's inode flushing patchset(s) clash with this?  I think this
(and the quota cleanups I just posted) will go in after those iflush
changes, assuming we get the bugs worked out...

--D

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH 01/15] xfs: don't clear the "dinode core" in xfs_inode_alloc
  2020-06-30 17:58   ` Darrick J. Wong
@ 2020-07-02 18:34     ` Darrick J. Wong
  0 siblings, 0 replies; 52+ messages in thread
From: Darrick J. Wong @ 2020-07-02 18:34 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: linux-xfs

On Tue, Jun 30, 2020 at 10:58:49AM -0700, Darrick J. Wong wrote:
> On Sat, Jun 20, 2020 at 09:10:48AM +0200, Christoph Hellwig wrote:
> > The xfs_icdinode structure just contains a random mix of inode field,
> > which are all read from the on-disk inode and mostly not looked at
> > before reading the inode or initializing a new inode cluster.  The
> > only exceptions are the forkoff and blocks field, which are used
> > in sanity checks for freshly allocated inodes.
> > 
> > Signed-off-by: Christoph Hellwig <hch@lst.de>
> 
> /me thinks this looks ok, though I'm leaning on Chandan probably having
> done a more thorough examination than I did...

...which I should not have done, because this is not correct.

Prior to this patch, xfs_inode_alloc would always zero ip->i_d before
loading the inode in from disk.  xfs_inode_from_disk, in turn, didn't
have to worry about zeroing fields if it was reading in a v2 inode.
Hence it does nothing about i_diflags2 or i_crtime.

Unfortunately, this opens a crash vector.  Let's say you mount a V5 fs,
create some reflinked files, and unmount the V5 fs.  Next, you mount a
V4 fs, and if the slab reuses the incore inodes, the next
xfs_inode_alloc won't clear the v3inode fields, and neither will
xfs_inode_from_disk.  The xfs_is_reflink_inode helper will see the
REFLINK flag set in i_diflags2 (remember, nobody cleared it) and try to
do CoW things, and kaboom.

We could (should?) probably fix the helper, but we definitely cannot be
leaving nuggets like this around in memory from the previous occupants.

I suspect the (v3inode && IGET_CREATE && !MOUNT_IKEEP) case could also
be a (theoretical) future landmine.

FWIW I found this by running fstests with 'MKFS_OPTIONS="-m crc=0"' and
then running xfs/096 and then generic/456 in that order, though I think
reproducibility here depends on the luck of the draw wrt slab caches.

> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>

Withdrawn, for now...

--D

> 
> --D
> 
> > ---
> >  fs/xfs/xfs_icache.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> > 
> > diff --git a/fs/xfs/xfs_icache.c b/fs/xfs/xfs_icache.c
> > index 0a5ac6f9a58349..660e7abd4e8b76 100644
> > --- a/fs/xfs/xfs_icache.c
> > +++ b/fs/xfs/xfs_icache.c
> > @@ -66,7 +66,8 @@ xfs_inode_alloc(
> >  	memset(&ip->i_df, 0, sizeof(ip->i_df));
> >  	ip->i_flags = 0;
> >  	ip->i_delayed_blks = 0;
> > -	memset(&ip->i_d, 0, sizeof(ip->i_d));
> > +	ip->i_d.di_nblocks = 0;
> > +	ip->i_d.di_forkoff = 0;
> >  	ip->i_sick = 0;
> >  	ip->i_checked = 0;
> >  	INIT_WORK(&ip->i_ioend_work, xfs_end_io);
> > -- 
> > 2.26.2
> > 

^ permalink raw reply	[flat|nested] 52+ messages in thread

end of thread, other threads:[~2020-07-02 18:34 UTC | newest]

Thread overview: 52+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-20  7:10 xfs inode structure cleanups v2 Christoph Hellwig
2020-06-20  7:10 ` [PATCH 01/15] xfs: don't clear the "dinode core" in xfs_inode_alloc Christoph Hellwig
2020-06-22  7:11   ` Chandan Babu R
2020-06-30 17:58   ` Darrick J. Wong
2020-07-02 18:34     ` Darrick J. Wong
2020-06-20  7:10 ` [PATCH 02/15] xfs: move the di_projid field to struct xfs_inode Christoph Hellwig
2020-06-22  7:55   ` Chandan Babu R
2020-06-30 17:44   ` Darrick J. Wong
2020-06-20  7:10 ` [PATCH 03/15] xfs: move the di_size " Christoph Hellwig
2020-06-22  9:24   ` Chandan Babu R
2020-06-30 17:45   ` Darrick J. Wong
2020-06-20  7:10 ` [PATCH 04/15] xfs: move the di_nblocks " Christoph Hellwig
2020-06-22  9:33   ` Chandan Babu R
2020-06-30 17:47   ` Darrick J. Wong
2020-06-20  7:10 ` [PATCH 05/15] xfs: move the di_extsize " Christoph Hellwig
2020-06-22  9:36   ` Chandan Babu R
2020-06-30 17:47   ` Darrick J. Wong
2020-06-20  7:10 ` [PATCH 06/15] xfs: move the di_cowextsize " Christoph Hellwig
2020-06-22  9:47   ` Chandan Babu R
2020-06-30 17:48   ` Darrick J. Wong
2020-06-20  7:10 ` [PATCH 07/15] xfs: move the di_flushiter " Christoph Hellwig
2020-06-22  9:49   ` Chandan Babu R
2020-06-30 17:48   ` Darrick J. Wong
2020-06-20  7:10 ` [PATCH 08/15] xfs: use a union for i_cowextsize and i_flushiter Christoph Hellwig
2020-06-22 10:53   ` Chandan Babu R
2020-06-30 17:51   ` Darrick J. Wong
2020-06-20  7:10 ` [PATCH 09/15] xfs: cleanup xfs_fill_fsxattr Christoph Hellwig
2020-06-22 11:01   ` Chandan Babu R
2020-06-30 17:52   ` Darrick J. Wong
2020-06-20  7:10 ` [PATCH 10/15] xfs: move the di_forkoff field to struct xfs_inode Christoph Hellwig
2020-06-22 12:15   ` Chandan Babu R
2020-06-30 17:52   ` Darrick J. Wong
2020-06-20  7:10 ` [PATCH 11/15] xfs: move the di_flags " Christoph Hellwig
2020-06-22 12:41   ` Chandan Babu R
2020-06-30 17:53   ` Darrick J. Wong
2020-06-20  7:10 ` [PATCH 12/15] xfs: move the di_flags2 " Christoph Hellwig
2020-06-22 12:51   ` Chandan Babu R
2020-06-22 13:23     ` Chandan Babu R
2020-06-24  7:25       ` Christoph Hellwig
2020-06-24 14:03         ` Darrick J. Wong
2020-06-24 14:10           ` Christoph Hellwig
2020-06-30 17:54   ` Darrick J. Wong
2020-06-20  7:11 ` [PATCH 13/15] xfs: move the di_crtime " Christoph Hellwig
2020-06-22 12:54   ` Chandan Babu R
2020-06-30 17:55   ` Darrick J. Wong
2020-06-20  7:11 ` [PATCH 14/15] xfs: move the di_dmevmask " Christoph Hellwig
2020-06-22 12:58   ` Chandan Babu R
2020-06-30 17:55   ` Darrick J. Wong
2020-06-20  7:11 ` [PATCH 15/15] xfs: move the di_dmstate " Christoph Hellwig
2020-06-22 13:18   ` Chandan Babu R
2020-06-30 17:56   ` Darrick J. Wong
2020-06-30 18:01 ` xfs inode structure cleanups v2 Darrick J. Wong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).