All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/15] xfsprogs: libxfs kernel sync to 4.6-for-next
@ 2016-02-17  7:20 Dave Chinner
  2016-02-17  7:20 ` [PATCH 01/15] xfs: wire up Q_XGETNEXTQUOTA / get_nextdqblk Dave Chinner
                   ` (15 more replies)
  0 siblings, 16 replies; 28+ messages in thread
From: Dave Chinner @ 2016-02-17  7:20 UTC (permalink / raw)
  To: xfs

Hi folks,

This series brings the xfsprogs libxfs code in sync with what is
currently in the kernel for-next branch. This is aimed at the
xfsprogs for-next branch so that Darrick can use this as the base
for his rmap/reflink xfsprogs tree.

The only "interesting" thing in this series is the xfs_icdinode
modifications. I've made the structures similar to the kernel
so the same macros can be used, and jumped one step ahead of the
kernel by adding XFS_ISREG/XFS_ISDIR wrappers to keep the userspace
conversions simple.

Overall, it turned out ot be a lot simpler than I though it would
be, and points to the general direction that needs to be taken here:
use the xfs_dinode for anythign futzing directly with on disk
inodes, use the xfs_inode for everything else. I also noticed a
coupl eof good opportunites for factoring, such as the repeated
copy/paste of inode allocation and initialisation code.

Comments welcome!

-Dave.

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

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

* [PATCH 01/15] xfs: wire up Q_XGETNEXTQUOTA / get_nextdqblk
  2016-02-17  7:20 [PATCH 00/15] xfsprogs: libxfs kernel sync to 4.6-for-next Dave Chinner
@ 2016-02-17  7:20 ` Dave Chinner
  2016-02-17  7:25   ` Christoph Hellwig
  2016-02-17  7:20 ` [PATCH 02/15] xfs: handle errors from ->free_blocks in xfs_btree_kill_iroot Dave Chinner
                   ` (14 subsequent siblings)
  15 siblings, 1 reply; 28+ messages in thread
From: Dave Chinner @ 2016-02-17  7:20 UTC (permalink / raw)
  To: xfs

From: Eric Sandeen <sandeen@sandeen.net>

Source kernel commit 296c24e26ee3af2dbfecb482e6bc9560bd34c455

Add code to allow the Q_XGETNEXTQUOTA quotactl to quickly find
all active quotas by examining the quota inode, and skipping
over unallocated or uninitialized regions.

Userspace can then use this interface rather than i.e. a
getpwent() loop when asked to report all active quotas.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
---
 libxfs/xfs_quota_defs.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libxfs/xfs_quota_defs.h b/libxfs/xfs_quota_defs.h
index f51078f..8eed512 100644
--- a/libxfs/xfs_quota_defs.h
+++ b/libxfs/xfs_quota_defs.h
@@ -37,7 +37,7 @@ typedef __uint16_t	xfs_qwarncnt_t;
 #define XFS_DQ_PROJ		0x0002		/* project quota */
 #define XFS_DQ_GROUP		0x0004		/* a group quota */
 #define XFS_DQ_DIRTY		0x0008		/* dquot is dirty */
-#define XFS_DQ_FREEING		0x0010		/* dquot is beeing torn down */
+#define XFS_DQ_FREEING		0x0010		/* dquot is being torn down */
 
 #define XFS_DQ_ALLTYPES		(XFS_DQ_USER|XFS_DQ_PROJ|XFS_DQ_GROUP)
 
@@ -116,6 +116,7 @@ typedef __uint16_t	xfs_qwarncnt_t;
 #define XFS_QMOPT_DQREPAIR	0x0001000 /* repair dquot if damaged */
 #define XFS_QMOPT_GQUOTA	0x0002000 /* group dquot requested */
 #define XFS_QMOPT_ENOSPC	0x0004000 /* enospc instead of edquot (prj) */
+#define XFS_QMOPT_DQNEXT	0x0008000 /* return next dquot >= this ID */
 
 /*
  * flags to xfs_trans_mod_dquot to indicate which field needs to be
-- 
2.7.0

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

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

* [PATCH 02/15] xfs: handle errors from ->free_blocks in xfs_btree_kill_iroot
  2016-02-17  7:20 [PATCH 00/15] xfsprogs: libxfs kernel sync to 4.6-for-next Dave Chinner
  2016-02-17  7:20 ` [PATCH 01/15] xfs: wire up Q_XGETNEXTQUOTA / get_nextdqblk Dave Chinner
@ 2016-02-17  7:20 ` Dave Chinner
  2016-02-17  7:20 ` [PATCH 03/15] xfs: factor btree block freeing into a helper Dave Chinner
                   ` (13 subsequent siblings)
  15 siblings, 0 replies; 28+ messages in thread
From: Dave Chinner @ 2016-02-17  7:20 UTC (permalink / raw)
  To: xfs

From: Christoph Hellwig <hch@lst.de>

Source kernel commit 196328ec973a74ee52cc282824e72c3824dc1cf5

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
---
 libxfs/xfs_btree.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/libxfs/xfs_btree.c b/libxfs/xfs_btree.c
index efcad26..14d8bf3 100644
--- a/libxfs/xfs_btree.c
+++ b/libxfs/xfs_btree.c
@@ -3209,6 +3209,7 @@ xfs_btree_kill_iroot(
 	int			level;
 	int			index;
 	int			numrecs;
+	int			error;
 #ifdef DEBUG
 	union xfs_btree_ptr	ptr;
 	int			i;
@@ -3272,8 +3273,6 @@ xfs_btree_kill_iroot(
 	cpp = xfs_btree_ptr_addr(cur, 1, cblock);
 #ifdef DEBUG
 	for (i = 0; i < numrecs; i++) {
-		int		error;
-
 		error = xfs_btree_check_ptr(cur, cpp, i, level - 1);
 		if (error) {
 			XFS_BTREE_TRACE_CURSOR(cur, XBT_ERROR);
@@ -3283,7 +3282,11 @@ xfs_btree_kill_iroot(
 #endif
 	xfs_btree_copy_ptrs(cur, pp, cpp, numrecs);
 
-	cur->bc_ops->free_block(cur, cbp);
+	error = cur->bc_ops->free_block(cur, cbp);
+	if (error) {
+		XFS_BTREE_TRACE_CURSOR(cur, XBT_ERROR);
+		return error;
+	}
 	XFS_BTREE_STATS_INC(cur, free);
 
 	cur->bc_bufs[level - 1] = NULL;
-- 
2.7.0

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

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

* [PATCH 03/15] xfs: factor btree block freeing into a helper
  2016-02-17  7:20 [PATCH 00/15] xfsprogs: libxfs kernel sync to 4.6-for-next Dave Chinner
  2016-02-17  7:20 ` [PATCH 01/15] xfs: wire up Q_XGETNEXTQUOTA / get_nextdqblk Dave Chinner
  2016-02-17  7:20 ` [PATCH 02/15] xfs: handle errors from ->free_blocks in xfs_btree_kill_iroot Dave Chinner
@ 2016-02-17  7:20 ` Dave Chinner
  2016-02-17  7:20 ` [PATCH 04/15] xfs: move buffer invalidation to xfs_btree_free_block Dave Chinner
                   ` (12 subsequent siblings)
  15 siblings, 0 replies; 28+ messages in thread
From: Dave Chinner @ 2016-02-17  7:20 UTC (permalink / raw)
  To: xfs

From: Christoph Hellwig <hch@lst.de>

Source kernel commit c46ee8ad7856b58eeb383c30ce847897f85c4103

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
---
 libxfs/xfs_btree.c | 23 ++++++++++++++++-------
 1 file changed, 16 insertions(+), 7 deletions(-)

diff --git a/libxfs/xfs_btree.c b/libxfs/xfs_btree.c
index 14d8bf3..f4a1c67 100644
--- a/libxfs/xfs_btree.c
+++ b/libxfs/xfs_btree.c
@@ -290,6 +290,19 @@ xfs_btree_sblock_verify_crc(
 	return true;
 }
 
+static int
+xfs_btree_free_block(
+	struct xfs_btree_cur	*cur,
+	struct xfs_buf		*bp)
+{
+	int			error;
+
+	error = cur->bc_ops->free_block(cur, bp);
+	if (!error)
+		XFS_BTREE_STATS_INC(cur, free);
+	return error;
+}
+
 /*
  * Delete the btree cursor.
  */
@@ -3282,12 +3295,11 @@ xfs_btree_kill_iroot(
 #endif
 	xfs_btree_copy_ptrs(cur, pp, cpp, numrecs);
 
-	error = cur->bc_ops->free_block(cur, cbp);
+	error = xfs_btree_free_block(cur, cbp);
 	if (error) {
 		XFS_BTREE_TRACE_CURSOR(cur, XBT_ERROR);
 		return error;
 	}
-	XFS_BTREE_STATS_INC(cur, free);
 
 	cur->bc_bufs[level - 1] = NULL;
 	be16_add_cpu(&block->bb_level, -1);
@@ -3320,14 +3332,12 @@ xfs_btree_kill_root(
 	 */
 	cur->bc_ops->set_root(cur, newroot, -1);
 
-	error = cur->bc_ops->free_block(cur, bp);
+	error = xfs_btree_free_block(cur, bp);
 	if (error) {
 		XFS_BTREE_TRACE_CURSOR(cur, XBT_ERROR);
 		return error;
 	}
 
-	XFS_BTREE_STATS_INC(cur, free);
-
 	cur->bc_bufs[level] = NULL;
 	cur->bc_ra[level] = 0;
 	cur->bc_nlevels--;
@@ -3833,10 +3843,9 @@ xfs_btree_delrec(
 	}
 
 	/* Free the deleted block. */
-	error = cur->bc_ops->free_block(cur, rbp);
+	error = xfs_btree_free_block(cur, rbp);
 	if (error)
 		goto error0;
-	XFS_BTREE_STATS_INC(cur, free);
 
 	/*
 	 * If we joined with the left neighbor, set the buffer in the
-- 
2.7.0

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

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

* [PATCH 04/15] xfs: move buffer invalidation to xfs_btree_free_block
  2016-02-17  7:20 [PATCH 00/15] xfsprogs: libxfs kernel sync to 4.6-for-next Dave Chinner
                   ` (2 preceding siblings ...)
  2016-02-17  7:20 ` [PATCH 03/15] xfs: factor btree block freeing into a helper Dave Chinner
@ 2016-02-17  7:20 ` Dave Chinner
  2016-02-17  7:20 ` [PATCH 05/15] xfs: remove unused function definitions Dave Chinner
                   ` (11 subsequent siblings)
  15 siblings, 0 replies; 28+ messages in thread
From: Dave Chinner @ 2016-02-17  7:20 UTC (permalink / raw)
  To: xfs

From: Christoph Hellwig <hch@lst.de>

Source kernel commit edfd9dd549212a0923c9b5b142275dc88912abfa

... instead of leaving it in the methods.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
---
 libxfs/xfs_alloc_btree.c  |  2 --
 libxfs/xfs_bmap_btree.c   |  1 -
 libxfs/xfs_btree.c        |  4 +++-
 libxfs/xfs_ialloc_btree.c | 12 ++----------
 4 files changed, 5 insertions(+), 14 deletions(-)

diff --git a/libxfs/xfs_alloc_btree.c b/libxfs/xfs_alloc_btree.c
index 6f13572..79d0fb9 100644
--- a/libxfs/xfs_alloc_btree.c
+++ b/libxfs/xfs_alloc_btree.c
@@ -116,8 +116,6 @@ xfs_allocbt_free_block(
 	xfs_extent_busy_insert(cur->bc_tp, be32_to_cpu(agf->agf_seqno), bno, 1,
 			      XFS_EXTENT_BUSY_SKIP_DISCARD);
 	xfs_trans_agbtree_delta(cur->bc_tp, -1);
-
-	xfs_trans_binval(cur->bc_tp, bp);
 	return 0;
 }
 
diff --git a/libxfs/xfs_bmap_btree.c b/libxfs/xfs_bmap_btree.c
index 2ef1836..a63379b 100644
--- a/libxfs/xfs_bmap_btree.c
+++ b/libxfs/xfs_bmap_btree.c
@@ -528,7 +528,6 @@ xfs_bmbt_free_block(
 
 	xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
 	xfs_trans_mod_dquot_byino(tp, ip, XFS_TRANS_DQ_BCOUNT, -1L);
-	xfs_trans_binval(tp, bp);
 	return 0;
 }
 
diff --git a/libxfs/xfs_btree.c b/libxfs/xfs_btree.c
index f4a1c67..a736cb5 100644
--- a/libxfs/xfs_btree.c
+++ b/libxfs/xfs_btree.c
@@ -298,8 +298,10 @@ xfs_btree_free_block(
 	int			error;
 
 	error = cur->bc_ops->free_block(cur, bp);
-	if (!error)
+	if (!error) {
+		xfs_trans_binval(cur->bc_tp, bp);
 		XFS_BTREE_STATS_INC(cur, free);
+	}
 	return error;
 }
 
diff --git a/libxfs/xfs_ialloc_btree.c b/libxfs/xfs_ialloc_btree.c
index 52939c3..a077635 100644
--- a/libxfs/xfs_ialloc_btree.c
+++ b/libxfs/xfs_ialloc_btree.c
@@ -124,16 +124,8 @@ xfs_inobt_free_block(
 	struct xfs_btree_cur	*cur,
 	struct xfs_buf		*bp)
 {
-	xfs_fsblock_t		fsbno;
-	int			error;
-
-	fsbno = XFS_DADDR_TO_FSB(cur->bc_mp, XFS_BUF_ADDR(bp));
-	error = xfs_free_extent(cur->bc_tp, fsbno, 1);
-	if (error)
-		return error;
-
-	xfs_trans_binval(cur->bc_tp, bp);
-	return error;
+	return xfs_free_extent(cur->bc_tp,
+			XFS_DADDR_TO_FSB(cur->bc_mp, XFS_BUF_ADDR(bp)), 1);
 }
 
 STATIC int
-- 
2.7.0

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

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

* [PATCH 05/15] xfs: remove unused function definitions
  2016-02-17  7:20 [PATCH 00/15] xfsprogs: libxfs kernel sync to 4.6-for-next Dave Chinner
                   ` (3 preceding siblings ...)
  2016-02-17  7:20 ` [PATCH 04/15] xfs: move buffer invalidation to xfs_btree_free_block Dave Chinner
@ 2016-02-17  7:20 ` Dave Chinner
  2016-02-17  7:20 ` [PATCH 06/15] xfs: RT bitmap and summary buffers are not typed Dave Chinner
                   ` (10 subsequent siblings)
  15 siblings, 0 replies; 28+ messages in thread
From: Dave Chinner @ 2016-02-17  7:20 UTC (permalink / raw)
  To: xfs

From: Eric Sandeen <sandeen@redhat.com>

Source kernel commit de0b85a8cf24f8c535b7f719c454e3951298d17a

Old leftovers.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
---
 libxfs/xfs_sb.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/libxfs/xfs_sb.h b/libxfs/xfs_sb.h
index b25bb9a..961e647 100644
--- a/libxfs/xfs_sb.h
+++ b/libxfs/xfs_sb.h
@@ -27,7 +27,6 @@ extern struct xfs_perag *xfs_perag_get_tag(struct xfs_mount *, xfs_agnumber_t,
 extern void	xfs_perag_put(struct xfs_perag *pag);
 extern int	xfs_initialize_perag_data(struct xfs_mount *, xfs_agnumber_t);
 
-extern void	xfs_sb_calc_crc(struct xfs_buf *bp);
 extern void	xfs_log_sb(struct xfs_trans *tp);
 extern int	xfs_sync_sb(struct xfs_mount *mp, bool wait);
 extern void	xfs_sb_mount_common(struct xfs_mount *mp, struct xfs_sb *sbp);
-- 
2.7.0

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

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

* [PATCH 06/15] xfs: RT bitmap and summary buffers are not typed
  2016-02-17  7:20 [PATCH 00/15] xfsprogs: libxfs kernel sync to 4.6-for-next Dave Chinner
                   ` (4 preceding siblings ...)
  2016-02-17  7:20 ` [PATCH 05/15] xfs: remove unused function definitions Dave Chinner
@ 2016-02-17  7:20 ` Dave Chinner
  2016-02-17  7:20 ` [PATCH 07/15] xfs: RT bitmap and summary buffers need verifiers Dave Chinner
                   ` (9 subsequent siblings)
  15 siblings, 0 replies; 28+ messages in thread
From: Dave Chinner @ 2016-02-17  7:20 UTC (permalink / raw)
  To: xfs

From: Dave Chinner <dchinner@redhat.com>

Source kernel commit f67ca6eca89cddd355c83639a90109e245f9d5a7

When logging buffers, we attach a type to them that follows the
buffer all the way into the log and is used to identify the buffer
contents in log recovery. Both the realtime summary buffers and the
bitmap buffers do not have types defined or set, so when we try to
log them we see assert failure:

XFS: Assertion failed: (bip->bli_flags & XFS_BLI_STALE) || (xfs_blft_from_flags(&bip->__bli_format) > XFS_BLFT_UNKNOWN_BUF && xfs_blft_from_flags(&bip->__bli_format) < XFS_BLFT_MAX_BUF), file: fs/xfs/xfs_buf_item.c, line: 294

Fix this by adding buffer log format types for these buffers, and
add identification support into log recovery for them. Only build the log
recovery support if CONFIG_XFS_RT=y - we can't get into log recovery for real
time filesystems if support is not built into the kernel, and this avoids
potential build problems.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Tested-by: Ross Zwisler <ross.zwisler@linux.intel.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
---
 libxfs/xfs_log_format.h | 2 ++
 libxfs/xfs_rtbitmap.c   | 3 +++
 2 files changed, 5 insertions(+)

diff --git a/libxfs/xfs_log_format.h b/libxfs/xfs_log_format.h
index db8ceeb..c860345 100644
--- a/libxfs/xfs_log_format.h
+++ b/libxfs/xfs_log_format.h
@@ -495,6 +495,8 @@ enum xfs_blft {
 	XFS_BLFT_ATTR_LEAF_BUF,
 	XFS_BLFT_ATTR_RMT_BUF,
 	XFS_BLFT_SB_BUF,
+	XFS_BLFT_RTBITMAP_BUF,
+	XFS_BLFT_RTSUMMARY_BUF,
 	XFS_BLFT_MAX_BUF = (1 << XFS_BLFT_BITS),
 };
 
diff --git a/libxfs/xfs_rtbitmap.c b/libxfs/xfs_rtbitmap.c
index 5648ea5..3e61eb2 100644
--- a/libxfs/xfs_rtbitmap.c
+++ b/libxfs/xfs_rtbitmap.c
@@ -66,6 +66,9 @@ xfs_rtbuf_get(
 				   mp->m_bsize, 0, &bp, NULL);
 	if (error)
 		return error;
+
+	xfs_trans_buf_set_type(tp, bp, issum ? XFS_BLFT_RTSUMMARY_BUF
+					     : XFS_BLFT_RTBITMAP_BUF);
 	*bpp = bp;
 	return 0;
 }
-- 
2.7.0

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

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

* [PATCH 07/15] xfs: RT bitmap and summary buffers need verifiers
  2016-02-17  7:20 [PATCH 00/15] xfsprogs: libxfs kernel sync to 4.6-for-next Dave Chinner
                   ` (5 preceding siblings ...)
  2016-02-17  7:20 ` [PATCH 06/15] xfs: RT bitmap and summary buffers are not typed Dave Chinner
@ 2016-02-17  7:20 ` Dave Chinner
  2016-02-17  7:20 ` [PATCH 08/15] xfs: introduce inode log format object Dave Chinner
                   ` (8 subsequent siblings)
  15 siblings, 0 replies; 28+ messages in thread
From: Dave Chinner @ 2016-02-17  7:20 UTC (permalink / raw)
  To: xfs

From: Dave Chinner <dchinner@redhat.com>

Source kernel commit bf85e0998ae8bafc1e0863d914df3be2b1bc372a

Buffers without verifiers issue runtime warnings on XFS. We don't
have anything we can actually verify in the RT buffers (no CRCs, not
magic numbers, etc), but we still need verifiers to avoid the
warnings.

Add a set of dummy verifier operations for the realtime buffers and
apply them in the appropriate places.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Tested-by: Ross Zwisler <ross.zwisler@linux.intel.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
---
 libxfs/xfs_rtbitmap.c | 27 ++++++++++++++++++++++++++-
 libxfs/xfs_shared.h   |  1 +
 2 files changed, 27 insertions(+), 1 deletion(-)

diff --git a/libxfs/xfs_rtbitmap.c b/libxfs/xfs_rtbitmap.c
index 3e61eb2..684a18b 100644
--- a/libxfs/xfs_rtbitmap.c
+++ b/libxfs/xfs_rtbitmap.c
@@ -37,6 +37,31 @@
  */
 
 /*
+ * Real time buffers need verifiers to avoid runtime warnings during IO.
+ * We don't have anything to verify, however, so these are just dummy
+ * operations.
+ */
+static void
+xfs_rtbuf_verify_read(
+	struct xfs_buf	*bp)
+{
+	return;
+}
+
+static void
+xfs_rtbuf_verify_write(
+	struct xfs_buf	*bp)
+{
+	return;
+}
+
+const struct xfs_buf_ops xfs_rtbuf_ops = {
+	.name = "rtbuf",
+	.verify_read = xfs_rtbuf_verify_read,
+	.verify_write = xfs_rtbuf_verify_write,
+};
+
+/*
  * Get a buffer for the bitmap or summary file block specified.
  * The buffer is returned read and locked.
  */
@@ -63,7 +88,7 @@ xfs_rtbuf_get(
 	ASSERT(map.br_startblock != NULLFSBLOCK);
 	error = xfs_trans_read_buf(mp, tp, mp->m_ddev_targp,
 				   XFS_FSB_TO_DADDR(mp, map.br_startblock),
-				   mp->m_bsize, 0, &bp, NULL);
+				   mp->m_bsize, 0, &bp, &xfs_rtbuf_ops);
 	if (error)
 		return error;
 
diff --git a/libxfs/xfs_shared.h b/libxfs/xfs_shared.h
index 15c3ceb..81ac870 100644
--- a/libxfs/xfs_shared.h
+++ b/libxfs/xfs_shared.h
@@ -53,6 +53,7 @@ extern const struct xfs_buf_ops xfs_dquot_buf_ra_ops;
 extern const struct xfs_buf_ops xfs_sb_buf_ops;
 extern const struct xfs_buf_ops xfs_sb_quiet_buf_ops;
 extern const struct xfs_buf_ops xfs_symlink_buf_ops;
+extern const struct xfs_buf_ops xfs_rtbuf_ops;
 
 /*
  * Transaction types.  Used to distinguish types of buffers. These never reach
-- 
2.7.0

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

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

* [PATCH 08/15] xfs: introduce inode log format object
  2016-02-17  7:20 [PATCH 00/15] xfsprogs: libxfs kernel sync to 4.6-for-next Dave Chinner
                   ` (6 preceding siblings ...)
  2016-02-17  7:20 ` [PATCH 07/15] xfs: RT bitmap and summary buffers need verifiers Dave Chinner
@ 2016-02-17  7:20 ` Dave Chinner
  2016-02-17  7:20 ` [PATCH 09/15] xfs: remove timestamps from incore inode Dave Chinner
                   ` (7 subsequent siblings)
  15 siblings, 0 replies; 28+ messages in thread
From: Dave Chinner @ 2016-02-17  7:20 UTC (permalink / raw)
  To: xfs

From: Dave Chinner <dchinner@redhat.com>

Source kernel commit f8d55aa0523ad0f78979c222ed18b78ea7be793a

We currently carry around and log an entire inode core in the
struct xfs_inode. A lot of the information in the inode core is
duplicated in the VFS inode, but we cannot remove this duplication
of infomration because the inode core is logged directly in
xfs_inode_item_format().

Add a new function xfs_inode_item_format_core() that copies the
inode core data into a struct xfs_icdinode that is pulled directly
from the log vector buffer. This means we no longer directly
copy the inode core, but copy the structures one member at a time.
This will be slightly less efficient than copying, but will allow us
to remove duplicate and unnecessary items from the struct xfs_inode.

To enable us to do this, call the new structure a xfs_log_dinode,
so that we know it's different to the physical xfs_dinode and the
in-core xfs_icdinode.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dave Chinner <david@fromorbit.com>
---
 db/check.c               |  2 +-
 libxfs/util.c            |  2 +-
 libxfs/xfs_inode_buf.c   |  8 ++++----
 libxfs/xfs_inode_buf.h   | 53 +++++++++++++++++++++++++++++++++++++++++++++++-
 libxfs/xfs_log_format.h  | 15 +++++++-------
 logprint/log_misc.c      |  7 ++++---
 logprint/log_print_all.c | 13 ++++++------
 repair/phase6.c          |  8 ++++----
 repair/phase7.c          |  2 +-
 9 files changed, 82 insertions(+), 28 deletions(-)

diff --git a/db/check.c b/db/check.c
index 838db53..d6d1d57 100644
--- a/db/check.c
+++ b/db/check.c
@@ -2619,7 +2619,7 @@ process_inode(
 {
 	blkmap_t		*blkmap;
 	xfs_fsblock_t		bno = 0;
-	xfs_icdinode_t		idic;
+	struct xfs_icdinode	idic;
 	inodata_t		*id = NULL;
 	xfs_ino_t		ino;
 	xfs_extnum_t		nextents = 0;
diff --git a/libxfs/util.c b/libxfs/util.c
index 4a72e89..787fd5d 100644
--- a/libxfs/util.c
+++ b/libxfs/util.c
@@ -345,7 +345,7 @@ void
 libxfs_iprint(
 	xfs_inode_t		*ip)
 {
-	xfs_icdinode_t		*dip;
+	struct xfs_icdinode	*dip;
 	xfs_bmbt_rec_host_t	*ep;
 	xfs_extnum_t		i;
 	xfs_extnum_t		nextents;
diff --git a/libxfs/xfs_inode_buf.c b/libxfs/xfs_inode_buf.c
index 89c05ad..dbea592 100644
--- a/libxfs/xfs_inode_buf.c
+++ b/libxfs/xfs_inode_buf.c
@@ -205,8 +205,8 @@ xfs_imap_to_bp(
 
 void
 xfs_dinode_from_disk(
-	xfs_icdinode_t		*to,
-	xfs_dinode_t		*from)
+	struct xfs_icdinode	*to,
+	struct xfs_dinode	*from)
 {
 	to->di_magic = be16_to_cpu(from->di_magic);
 	to->di_mode = be16_to_cpu(from->di_mode);
@@ -252,8 +252,8 @@ xfs_dinode_from_disk(
 
 void
 xfs_dinode_to_disk(
-	xfs_dinode_t		*to,
-	xfs_icdinode_t		*from)
+	struct xfs_dinode	*to,
+	struct xfs_icdinode	*from)
 {
 	to->di_magic = cpu_to_be16(from->di_magic);
 	to->di_mode = cpu_to_be16(from->di_mode);
diff --git a/libxfs/xfs_inode_buf.h b/libxfs/xfs_inode_buf.h
index 03f2a90..da66458 100644
--- a/libxfs/xfs_inode_buf.h
+++ b/libxfs/xfs_inode_buf.h
@@ -20,7 +20,58 @@
 
 struct xfs_inode;
 struct xfs_dinode;
-struct xfs_icdinode;
+
+/*
+ * In memory representation of the XFS inode. This is held in the in-core
+ * struct xfs_inode to represent the on disk values, but no longer needs to be
+ * identical to the on-disk structure as it is always translated to on-disk
+ * format specific structures at the appropriate time.
+ */
+struct xfs_icdinode {
+	__uint16_t	di_magic;	/* inode magic # = XFS_DINODE_MAGIC */
+	__uint16_t	di_mode;	/* mode and type of file */
+	__int8_t	di_version;	/* inode version */
+	__int8_t	di_format;	/* format of di_c data */
+	__uint16_t	di_onlink;	/* old number of links to file */
+	__uint32_t	di_uid;		/* owner's user id */
+	__uint32_t	di_gid;		/* owner's group id */
+	__uint32_t	di_nlink;	/* number of links to file */
+	__uint16_t	di_projid_lo;	/* lower part of owner's project id */
+	__uint16_t	di_projid_hi;	/* higher part of owner's project id */
+	__uint8_t	di_pad[6];	/* unused, zeroed space */
+	__uint16_t	di_flushiter;	/* incremented on flush */
+	xfs_ictimestamp_t di_atime;	/* time last accessed */
+	xfs_ictimestamp_t di_mtime;	/* time last modified */
+	xfs_ictimestamp_t di_ctime;	/* time created/inode modified */
+	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 */
+	xfs_extnum_t	di_nextents;	/* number of extents in data fork */
+	xfs_aextnum_t	di_anextents;	/* number of extents in attribute fork*/
+	__uint8_t	di_forkoff;	/* attr fork offs, <<3 for 64b align */
+	__int8_t	di_aformat;	/* format of attr fork's data */
+	__uint32_t	di_dmevmask;	/* DMIG event mask */
+	__uint16_t	di_dmstate;	/* DMIG state info */
+	__uint16_t	di_flags;	/* random flags, XFS_DIFLAG_... */
+	__uint32_t	di_gen;		/* generation number */
+
+	/* di_next_unlinked is the only non-core field in the old dinode */
+	xfs_agino_t	di_next_unlinked;/* agi unlinked list ptr */
+
+	/* start of the extended dinode, writable fields */
+	__uint32_t	di_crc;		/* CRC of the inode */
+	__uint64_t	di_changecount;	/* number of attribute changes */
+	xfs_lsn_t	di_lsn;		/* flush sequence */
+	__uint64_t	di_flags2;	/* more random flags */
+	__uint8_t	di_pad2[16];	/* more padding for future expansion */
+
+	/* fields only written to during inode creation */
+	xfs_ictimestamp_t di_crtime;	/* time created */
+	xfs_ino_t	di_ino;		/* inode number */
+	uuid_t		di_uuid;	/* UUID of the filesystem */
+
+	/* structure must be padded to 64 bit alignment */
+};
 
 /*
  * Inode location information.  Stored in the inode and passed to
diff --git a/libxfs/xfs_log_format.h b/libxfs/xfs_log_format.h
index c860345..85d4732 100644
--- a/libxfs/xfs_log_format.h
+++ b/libxfs/xfs_log_format.h
@@ -290,6 +290,7 @@ typedef struct xfs_inode_log_format_64 {
 	__int32_t		ilf_boffset;	/* off of inode in buffer */
 } xfs_inode_log_format_64_t;
 
+
 /*
  * Flags for xfs_trans_log_inode flags field.
  */
@@ -360,10 +361,10 @@ typedef struct xfs_ictimestamp {
 } xfs_ictimestamp_t;
 
 /*
- * NOTE:  This structure must be kept identical to struct xfs_dinode
- *	  except for the endianness annotations.
+ * Define the format of the inode core that is logged. This structure must be
+ * kept identical to struct xfs_dinode except for the endianness annotations.
  */
-typedef struct xfs_icdinode {
+struct xfs_log_dinode {
 	__uint16_t	di_magic;	/* inode magic # = XFS_DINODE_MAGIC */
 	__uint16_t	di_mode;	/* mode and type of file */
 	__int8_t	di_version;	/* inode version */
@@ -407,13 +408,13 @@ typedef struct xfs_icdinode {
 	uuid_t		di_uuid;	/* UUID of the filesystem */
 
 	/* structure must be padded to 64 bit alignment */
-} xfs_icdinode_t;
+};
 
-static inline uint xfs_icdinode_size(int version)
+static inline uint xfs_log_dinode_size(int version)
 {
 	if (version == 3)
-		return sizeof(struct xfs_icdinode);
-	return offsetof(struct xfs_icdinode, di_next_unlinked);
+		return sizeof(struct xfs_log_dinode);
+	return offsetof(struct xfs_log_dinode, di_next_unlinked);
 }
 
 /*
diff --git a/logprint/log_misc.c b/logprint/log_misc.c
index 7378fe1..e6ee832 100644
--- a/logprint/log_misc.c
+++ b/logprint/log_misc.c
@@ -588,7 +588,8 @@ xlog_print_trans_qoff(char **ptr, uint len)
 
 
 void
-xlog_print_trans_inode_core(xfs_icdinode_t *ip)
+xlog_print_trans_inode_core(
+	struct xfs_log_dinode	*ip)
 {
     printf(_("INODE CORE\n"));
     printf(_("magic 0x%hx mode 0%ho version %d format %d\n"),
@@ -652,7 +653,7 @@ xlog_print_trans_inode(
 	int		num_ops,
 	int		continued)
 {
-    xfs_icdinode_t	   dino;
+    struct xfs_log_dinode dino;
     xlog_op_header_t	   *op_head;
     xfs_inode_log_format_t dst_lbuf;
     xfs_inode_log_format_64_t src_lbuf; /* buffer of biggest one */
@@ -705,7 +706,7 @@ xlog_print_trans_inode(
     mode = dino.di_mode & S_IFMT;
     size = (int)dino.di_size;
     xlog_print_trans_inode_core(&dino);
-    *ptr += xfs_icdinode_size(dino.di_version);
+    *ptr += xfs_log_dinode_size(dino.di_version);
 
     if (*i == num_ops-1 && f->ilf_size == 3)  {
 	return 1;
diff --git a/logprint/log_print_all.c b/logprint/log_print_all.c
index ba26408..1bc18af 100644
--- a/logprint/log_print_all.c
+++ b/logprint/log_print_all.c
@@ -250,7 +250,7 @@ xlog_recover_print_dquot(
 
 STATIC void
 xlog_recover_print_inode_core(
-	xfs_icdinode_t		*di)
+	struct xfs_log_dinode	*di)
 {
 	printf(_("	CORE inode:\n"));
 	if (!print_inode)
@@ -259,8 +259,9 @@ xlog_recover_print_inode_core(
 	     "onlink:%d\n"),
 	       (di->di_magic>>8) & 0xff, di->di_magic & 0xff,
 	       di->di_mode, di->di_version, di->di_format, di->di_onlink);
-	printf(_("		uid:%d  gid:%d  nlink:%d projid:%u\n"),
-	       di->di_uid, di->di_gid, di->di_nlink, xfs_get_projid(di));
+	printf(_("		uid:%d  gid:%d  nlink:%d projid:0x%04x%04x\n"),
+	       di->di_uid, di->di_gid, di->di_nlink,
+	       di->di_projid_hi, di->di_projid_lo);
 	printf(_("		atime:%d  mtime:%d  ctime:%d\n"),
 	       di->di_atime.t_sec, di->di_mtime.t_sec, di->di_ctime.t_sec);
 	printf(_("		flushiter:%d\n"), di->di_flushiter);
@@ -293,9 +294,9 @@ xlog_recover_print_inode(
 	       f->ilf_dsize);
 
 	/* core inode comes 2nd */
-	ASSERT(item->ri_buf[1].i_len == xfs_icdinode_size(1) ||
-		item->ri_buf[1].i_len == xfs_icdinode_size(3));
-	xlog_recover_print_inode_core((xfs_icdinode_t *)
+	ASSERT(item->ri_buf[1].i_len == xfs_log_dinode_size(2) ||
+		item->ri_buf[1].i_len == xfs_log_dinode_size(3));
+	xlog_recover_print_inode_core((struct xfs_log_dinode *)
 				      item->ri_buf[1].i_addr);
 
 	hasdata = (f->ilf_fields & XFS_ILOG_DFORK) != 0;
diff --git a/repair/phase6.c b/repair/phase6.c
index eb36520..3aa109d 100644
--- a/repair/phase6.c
+++ b/repair/phase6.c
@@ -507,8 +507,8 @@ mk_rbmino(xfs_mount_t *mp)
 			error);
 	}
 
-	vers = xfs_sb_version_hascrc(&mp->m_sb) ? 3 : 1;
-	memset(&ip->i_d, 0, xfs_icdinode_size(vers));
+	vers = xfs_sb_version_hascrc(&mp->m_sb) ? 3 : 2;
+	memset(&ip->i_d, 0, sizeof(ip->i_d));
 
 	ip->i_d.di_magic = XFS_DINODE_MAGIC;
 	ip->i_d.di_mode = S_IFREG;
@@ -767,7 +767,7 @@ mk_rsumino(xfs_mount_t *mp)
 	}
 
 	vers = xfs_sb_version_hascrc(&mp->m_sb) ? 3 : 1;
-	memset(&ip->i_d, 0, xfs_icdinode_size(vers));
+	memset(&ip->i_d, 0, sizeof(ip->i_d));
 
 	ip->i_d.di_magic = XFS_DINODE_MAGIC;
 	ip->i_d.di_mode = S_IFREG;
@@ -882,7 +882,7 @@ mk_root_dir(xfs_mount_t *mp)
 	 * take care of the core -- initialization from xfs_ialloc()
 	 */
 	vers = xfs_sb_version_hascrc(&mp->m_sb) ? 3 : 2;
-	memset(&ip->i_d, 0, xfs_icdinode_size(vers));
+	memset(&ip->i_d, 0, sizeof(ip->i_d));
 
 	ip->i_d.di_magic = XFS_DINODE_MAGIC;
 	ip->i_d.di_mode = (__uint16_t) mode|S_IFDIR;
diff --git a/repair/phase7.c b/repair/phase7.c
index 640eaec..72a8ade 100644
--- a/repair/phase7.c
+++ b/repair/phase7.c
@@ -31,7 +31,7 @@
 /* dinoc is a pointer to the IN-CORE dinode core */
 static void
 set_nlinks(
-	xfs_icdinode_t		*dinoc,
+	struct xfs_icdinode	*dinoc,
 	xfs_ino_t		ino,
 	__uint32_t		nrefs,
 	int			*dirty)
-- 
2.7.0

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

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

* [PATCH 09/15] xfs: remove timestamps from incore inode
  2016-02-17  7:20 [PATCH 00/15] xfsprogs: libxfs kernel sync to 4.6-for-next Dave Chinner
                   ` (7 preceding siblings ...)
  2016-02-17  7:20 ` [PATCH 08/15] xfs: introduce inode log format object Dave Chinner
@ 2016-02-17  7:20 ` Dave Chinner
  2016-02-26 18:02   ` Brian Foster
  2016-02-17  7:20 ` [PATCH 10/15] xfs: cull unnecessary icdinode fields Dave Chinner
                   ` (6 subsequent siblings)
  15 siblings, 1 reply; 28+ messages in thread
From: Dave Chinner @ 2016-02-17  7:20 UTC (permalink / raw)
  To: xfs

From: Dave Chinner <dchinner@redhat.com>

Source kernel commit 3987848c7c2be112e03c82d03821b044f1c0edec

The struct xfs_inode has two copies of the current timestamps in it,
one in the vfs inode and one in the struct xfs_icdinode. Now that we
no longer log the struct xfs_icdinode directly, we don't need to
keep the timestamps in this structure. instead we can copy them
straight out of the VFS inode when formatting the inode log item or
the on-disk inode.

This reduces the struct xfs_inode in size by 24 bytes.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dave Chinner <david@fromorbit.com>
---
 db/check.c               | 106 +++++++++++++++++++++++------------------------
 include/xfs_inode.h      |  16 ++++++-
 libxfs/libxfs_api_defs.h |   4 +-
 libxfs/util.c            |  17 ++++----
 libxfs/xfs_inode_buf.c   |  91 ++++++++++++++++++++++++++++++++++------
 libxfs/xfs_inode_buf.h   |   9 ++--
 libxfs/xfs_rtbitmap.c    |   2 +-
 mkfs/proto.c             |   2 +-
 8 files changed, 162 insertions(+), 85 deletions(-)

diff --git a/db/check.c b/db/check.c
index d6d1d57..2203f41 100644
--- a/db/check.c
+++ b/db/check.c
@@ -2619,7 +2619,7 @@ process_inode(
 {
 	blkmap_t		*blkmap;
 	xfs_fsblock_t		bno = 0;
-	struct xfs_icdinode	idic;
+	struct xfs_inode	xino;
 	inodata_t		*id = NULL;
 	xfs_ino_t		ino;
 	xfs_extnum_t		nextents = 0;
@@ -2663,7 +2663,7 @@ process_inode(
 		"dev", "local", "extents", "btree", "uuid"
 	};
 
-	libxfs_dinode_from_disk(&idic, dip);
+	libxfs_inode_from_disk(&xino, dip);
 
 	ino = XFS_AGINO_TO_INO(mp, be32_to_cpu(agf->agf_seqno), agino);
 	if (!isfree) {
@@ -2672,42 +2672,42 @@ process_inode(
 		blkmap = NULL;
 	}
 	v = (!sflag || (id && id->ilist) || CHECK_BLIST(bno));
-	if (idic.di_magic != XFS_DINODE_MAGIC) {
+	if (xino.i_d.di_magic != XFS_DINODE_MAGIC) {
 		if (isfree || v)
 			dbprintf(_("bad magic number %#x for inode %lld\n"),
-				idic.di_magic, ino);
+				xino.i_d.di_magic, ino);
 		error++;
 		return;
 	}
-	if (!xfs_dinode_good_version(mp, idic.di_version)) {
+	if (!xfs_dinode_good_version(mp, xino.i_d.di_version)) {
 		if (isfree || v)
 			dbprintf(_("bad version number %#x for inode %lld\n"),
-				idic.di_version, ino);
+				xino.i_d.di_version, ino);
 		error++;
 		return;
 	}
 	if (isfree) {
-		if (idic.di_nblocks != 0) {
+		if (xino.i_d.di_nblocks != 0) {
 			if (v)
 				dbprintf(_("bad nblocks %lld for free inode "
 					 "%lld\n"),
-					idic.di_nblocks, ino);
+					xino.i_d.di_nblocks, ino);
 			error++;
 		}
-		if (idic.di_version == 1)
-			nlink = idic.di_onlink;
+		if (xino.i_d.di_version == 1)
+			nlink = xino.i_d.di_onlink;
 		else
-			nlink = idic.di_nlink;
+			nlink = xino.i_d.di_nlink;
 		if (nlink != 0) {
 			if (v)
 				dbprintf(_("bad nlink %d for free inode %lld\n"),
 					nlink, ino);
 			error++;
 		}
-		if (idic.di_mode != 0) {
+		if (xino.i_d.di_mode != 0) {
 			if (v)
 				dbprintf(_("bad mode %#o for free inode %lld\n"),
-					idic.di_mode, ino);
+					xino.i_d.di_mode, ino);
 			error++;
 		}
 		return;
@@ -2722,26 +2722,26 @@ process_inode(
 	/*
 	 * di_mode is a 16-bit uint so no need to check the < 0 case
 	 */
-	if ((((idic.di_mode & S_IFMT) >> 12) > 15) ||
-	    (!(okfmts[(idic.di_mode & S_IFMT) >> 12] & (1 << idic.di_format)))) {
+	if ((((xino.i_d.di_mode & S_IFMT) >> 12) > 15) ||
+	    (!(okfmts[(xino.i_d.di_mode & S_IFMT) >> 12] & (1 << xino.i_d.di_format)))) {
 		if (v)
 			dbprintf(_("bad format %d for inode %lld type %#o\n"),
-				idic.di_format, id->ino, idic.di_mode & S_IFMT);
+				xino.i_d.di_format, id->ino, xino.i_d.di_mode & S_IFMT);
 		error++;
 		return;
 	}
 	if ((unsigned int)XFS_DFORK_ASIZE(dip, mp) >=
-					XFS_LITINO(mp, idic.di_version))  {
+					XFS_LITINO(mp, xino.i_d.di_version))  {
 		if (v)
 			dbprintf(_("bad fork offset %d for inode %lld\n"),
-				idic.di_forkoff, id->ino);
+				xino.i_d.di_forkoff, id->ino);
 		error++;
 		return;
 	}
-	if ((unsigned int)idic.di_aformat > XFS_DINODE_FMT_BTREE)  {
+	if ((unsigned int)xino.i_d.di_aformat > XFS_DINODE_FMT_BTREE)  {
 		if (v)
 			dbprintf(_("bad attribute format %d for inode %lld\n"),
-				idic.di_aformat, id->ino);
+				xino.i_d.di_aformat, id->ino);
 		error++;
 		return;
 	}
@@ -2749,48 +2749,48 @@ process_inode(
 		dbprintf(_("inode %lld mode %#o fmt %s "
 			 "afmt %s "
 			 "nex %d anex %d nblk %lld sz %lld%s%s%s%s%s%s%s\n"),
-			id->ino, idic.di_mode, fmtnames[(int)idic.di_format],
-			fmtnames[(int)idic.di_aformat],
-			idic.di_nextents,
-			idic.di_anextents,
-			idic.di_nblocks, idic.di_size,
-			idic.di_flags & XFS_DIFLAG_REALTIME ? " rt" : "",
-			idic.di_flags & XFS_DIFLAG_PREALLOC ? " pre" : "",
-			idic.di_flags & XFS_DIFLAG_IMMUTABLE? " imm" : "",
-			idic.di_flags & XFS_DIFLAG_APPEND   ? " app" : "",
-			idic.di_flags & XFS_DIFLAG_SYNC     ? " syn" : "",
-			idic.di_flags & XFS_DIFLAG_NOATIME  ? " noa" : "",
-			idic.di_flags & XFS_DIFLAG_NODUMP   ? " nod" : "");
+			id->ino, xino.i_d.di_mode, fmtnames[(int)xino.i_d.di_format],
+			fmtnames[(int)xino.i_d.di_aformat],
+			xino.i_d.di_nextents,
+			xino.i_d.di_anextents,
+			xino.i_d.di_nblocks, xino.i_d.di_size,
+			xino.i_d.di_flags & XFS_DIFLAG_REALTIME ? " rt" : "",
+			xino.i_d.di_flags & XFS_DIFLAG_PREALLOC ? " pre" : "",
+			xino.i_d.di_flags & XFS_DIFLAG_IMMUTABLE? " imm" : "",
+			xino.i_d.di_flags & XFS_DIFLAG_APPEND   ? " app" : "",
+			xino.i_d.di_flags & XFS_DIFLAG_SYNC     ? " syn" : "",
+			xino.i_d.di_flags & XFS_DIFLAG_NOATIME  ? " noa" : "",
+			xino.i_d.di_flags & XFS_DIFLAG_NODUMP   ? " nod" : "");
 	security = 0;
-	switch (idic.di_mode & S_IFMT) {
+	switch (xino.i_d.di_mode & S_IFMT) {
 	case S_IFDIR:
 		type = DBM_DIR;
-		if (idic.di_format == XFS_DINODE_FMT_LOCAL)
+		if (xino.i_d.di_format == XFS_DINODE_FMT_LOCAL)
 			break;
-		blkmap = blkmap_alloc(idic.di_nextents);
+		blkmap = blkmap_alloc(xino.i_d.di_nextents);
 		break;
 	case S_IFREG:
-		if (idic.di_flags & XFS_DIFLAG_REALTIME)
+		if (xino.i_d.di_flags & XFS_DIFLAG_REALTIME)
 			type = DBM_RTDATA;
 		else if (id->ino == mp->m_sb.sb_rbmino) {
 			type = DBM_RTBITMAP;
-			blkmap = blkmap_alloc(idic.di_nextents);
+			blkmap = blkmap_alloc(xino.i_d.di_nextents);
 			addlink_inode(id);
 		} else if (id->ino == mp->m_sb.sb_rsumino) {
 			type = DBM_RTSUM;
-			blkmap = blkmap_alloc(idic.di_nextents);
+			blkmap = blkmap_alloc(xino.i_d.di_nextents);
 			addlink_inode(id);
 		}
 		else if (id->ino == mp->m_sb.sb_uquotino ||
 			 id->ino == mp->m_sb.sb_gquotino ||
 			 id->ino == mp->m_sb.sb_pquotino) {
 			type = DBM_QUOTA;
-			blkmap = blkmap_alloc(idic.di_nextents);
+			blkmap = blkmap_alloc(xino.i_d.di_nextents);
 			addlink_inode(id);
 		}
 		else
 			type = DBM_DATA;
-		if (idic.di_mode & (S_ISUID | S_ISGID))
+		if (xino.i_d.di_mode & (S_ISUID | S_ISGID))
 			security = 1;
 		break;
 	case S_IFLNK:
@@ -2801,13 +2801,13 @@ process_inode(
 		type = DBM_UNKNOWN;
 		break;
 	}
-	if (idic.di_version == 1)
-		setlink_inode(id, idic.di_onlink, type == DBM_DIR, security);
+	if (xino.i_d.di_version == 1)
+		setlink_inode(id, xino.i_d.di_onlink, type == DBM_DIR, security);
 	else {
 		sbversion |= XFS_SB_VERSION_NLINKBIT;
-		setlink_inode(id, idic.di_nlink, type == DBM_DIR, security);
+		setlink_inode(id, xino.i_d.di_nlink, type == DBM_DIR, security);
 	}
-	switch (idic.di_format) {
+	switch (xino.i_d.di_format) {
 	case XFS_DINODE_FMT_LOCAL:
 		process_lclinode(id, dip, type, &totdblocks, &totiblocks,
 			&nextents, &blkmap, XFS_DATA_FORK);
@@ -2823,7 +2823,7 @@ process_inode(
 	}
 	if (XFS_DFORK_Q(dip)) {
 		sbversion |= XFS_SB_VERSION_ATTRBIT;
-		switch (idic.di_aformat) {
+		switch (xino.i_d.di_aformat) {
 		case XFS_DINODE_FMT_LOCAL:
 			process_lclinode(id, dip, DBM_ATTR, &atotdblocks,
 				&atotiblocks, &anextents, NULL, XFS_ATTR_FORK);
@@ -2859,30 +2859,30 @@ process_inode(
 			break;
 		}
 		if (ic) {
-			dqprid = xfs_get_projid(&idic);	/* dquot ID is u32 */
-			quota_add(&dqprid, &idic.di_gid, &idic.di_uid,
+			dqprid = xfs_get_projid(&xino.i_d);	/* dquot ID is u32 */
+			quota_add(&dqprid, &xino.i_d.di_gid, &xino.i_d.di_uid,
 				  0, bc, ic, rc);
 		}
 	}
 	totblocks = totdblocks + totiblocks + atotdblocks + atotiblocks;
-	if (totblocks != idic.di_nblocks) {
+	if (totblocks != xino.i_d.di_nblocks) {
 		if (v)
 			dbprintf(_("bad nblocks %lld for inode %lld, counted "
 				 "%lld\n"),
-				idic.di_nblocks, id->ino, totblocks);
+				xino.i_d.di_nblocks, id->ino, totblocks);
 		error++;
 	}
-	if (nextents != idic.di_nextents) {
+	if (nextents != xino.i_d.di_nextents) {
 		if (v)
 			dbprintf(_("bad nextents %d for inode %lld, counted %d\n"),
-				idic.di_nextents, id->ino, nextents);
+				xino.i_d.di_nextents, id->ino, nextents);
 		error++;
 	}
-	if (anextents != idic.di_anextents) {
+	if (anextents != xino.i_d.di_anextents) {
 		if (v)
 			dbprintf(_("bad anextents %d for inode %lld, counted "
 				 "%d\n"),
-				idic.di_anextents, id->ino, anextents);
+				xino.i_d.di_anextents, id->ino, anextents);
 		error++;
 	}
 	if (type == DBM_DIR)
diff --git a/include/xfs_inode.h b/include/xfs_inode.h
index 71c0fb4..1efff0f 100644
--- a/include/xfs_inode.h
+++ b/include/xfs_inode.h
@@ -29,8 +29,16 @@ struct xfs_inode_log_item;
 struct xfs_dir_ops;
 
 /*
- * Inode interface
+ * Inode interface. This fakes up a "VFS inode" to make the xfs_inode appear
+ * similar to the kernel which now is used tohold certain parts of the on-disk
+ * metadata.
  */
+struct inode {
+	struct timespec	i_atime;
+	struct timespec	i_mtime;
+	struct timespec	i_ctime;
+};
+
 typedef struct xfs_inode {
 	struct cache_node	i_node;
 	struct xfs_mount	*i_mount;	/* fs mount struct ptr */
@@ -45,8 +53,14 @@ typedef struct xfs_inode {
 	struct xfs_icdinode	i_d;		/* most of ondisk inode */
 	xfs_fsize_t		i_size;		/* in-memory size */
 	const struct xfs_dir_ops *d_ops;	/* directory ops vector */
+	struct inode		i_vnode;
 } xfs_inode_t;
 
+static inline struct inode *VFS_I(struct xfs_inode *ip)
+{
+	return &ip->i_vnode;
+}
+
 /*
  * For regular files we only update the on-disk filesize when actually
  * writing data back to disk.  Until then only the copy in the VFS inode
diff --git a/libxfs/libxfs_api_defs.h b/libxfs/libxfs_api_defs.h
index 3a649e3..685c7a7 100644
--- a/libxfs/libxfs_api_defs.h
+++ b/libxfs/libxfs_api_defs.h
@@ -92,8 +92,8 @@
 #define xfs_dir2_data_use_free		libxfs_dir2_data_use_free
 #define xfs_dir2_shrink_inode		libxfs_dir2_shrink_inode
 
-#define xfs_dinode_from_disk		libxfs_dinode_from_disk
-#define xfs_dinode_to_disk		libxfs_dinode_to_disk
+#define xfs_inode_from_disk		libxfs_inode_from_disk
+#define xfs_inode_to_disk		libxfs_inode_to_disk
 #define xfs_dinode_calc_crc		libxfs_dinode_calc_crc
 #define xfs_idata_realloc		libxfs_idata_realloc
 #define xfs_idestroy_fork		libxfs_idestroy_fork
diff --git a/libxfs/util.c b/libxfs/util.c
index 787fd5d..86fadc3 100644
--- a/libxfs/util.c
+++ b/libxfs/util.c
@@ -161,14 +161,10 @@ libxfs_trans_ichgtime(
 	gettimeofday(&stv, (struct timezone *)0);
 	tv.tv_sec = stv.tv_sec;
 	tv.tv_nsec = stv.tv_usec * 1000;
-	if (flags & XFS_ICHGTIME_MOD) {
-		ip->i_d.di_mtime.t_sec = (__int32_t)tv.tv_sec;
-		ip->i_d.di_mtime.t_nsec = (__int32_t)tv.tv_nsec;
-	}
-	if (flags & XFS_ICHGTIME_CHG) {
-		ip->i_d.di_ctime.t_sec = (__int32_t)tv.tv_sec;
-		ip->i_d.di_ctime.t_nsec = (__int32_t)tv.tv_nsec;
-	}
+	if (flags & XFS_ICHGTIME_MOD)
+		VFS_I(ip)->i_mtime = tv;
+	if (flags & XFS_ICHGTIME_CHG)
+		VFS_I(ip)->i_ctime = tv;
 	if (flags & XFS_ICHGTIME_CREATE) {
 		ip->i_d.di_crtime.t_sec = (__int32_t)tv.tv_sec;
 		ip->i_d.di_crtime.t_nsec = (__int32_t)tv.tv_nsec;
@@ -270,7 +266,8 @@ libxfs_ialloc(
 		ip->i_d.di_lsn = 0;
 		ip->i_d.di_flags2 = 0;
 		memset(&(ip->i_d.di_pad2[0]), 0, sizeof(ip->i_d.di_pad2));
-		ip->i_d.di_crtime = ip->i_d.di_mtime;
+		ip->i_d.di_crtime.t_sec = (__int32_t)VFS_I(ip)->i_mtime.tv_sec;
+		ip->i_d.di_crtime.t_nsec = (__int32_t)VFS_I(ip)->i_mtime.tv_nsec;
 	}
 
 	flags = XFS_ILOG_CORE;
@@ -452,7 +449,7 @@ libxfs_iflush_int(xfs_inode_t *ip, xfs_buf_t *bp)
 	 * because if the inode is dirty at all the core must
 	 * be.
 	 */
-	xfs_dinode_to_disk(dip, &ip->i_d);
+	xfs_inode_to_disk(ip, dip);
 
 	xfs_iflush_fork(ip, dip, iip, XFS_DATA_FORK);
 	if (XFS_IFORK_Q(ip))
diff --git a/libxfs/xfs_inode_buf.c b/libxfs/xfs_inode_buf.c
index dbea592..f546b41 100644
--- a/libxfs/xfs_inode_buf.c
+++ b/libxfs/xfs_inode_buf.c
@@ -204,10 +204,13 @@ xfs_imap_to_bp(
 }
 
 void
-xfs_dinode_from_disk(
-	struct xfs_icdinode	*to,
+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);
+
 	to->di_magic = be16_to_cpu(from->di_magic);
 	to->di_mode = be16_to_cpu(from->di_mode);
 	to->di_version = from ->di_version;
@@ -220,12 +223,20 @@ xfs_dinode_from_disk(
 	to->di_projid_hi = be16_to_cpu(from->di_projid_hi);
 	memcpy(to->di_pad, from->di_pad, sizeof(to->di_pad));
 	to->di_flushiter = be16_to_cpu(from->di_flushiter);
-	to->di_atime.t_sec = be32_to_cpu(from->di_atime.t_sec);
-	to->di_atime.t_nsec = be32_to_cpu(from->di_atime.t_nsec);
-	to->di_mtime.t_sec = be32_to_cpu(from->di_mtime.t_sec);
-	to->di_mtime.t_nsec = be32_to_cpu(from->di_mtime.t_nsec);
-	to->di_ctime.t_sec = be32_to_cpu(from->di_ctime.t_sec);
-	to->di_ctime.t_nsec = be32_to_cpu(from->di_ctime.t_nsec);
+
+	/*
+	 * Time is signed, so need to convert to signed 32 bit before
+	 * storing in inode timestamp which may be 64 bit. Otherwise
+	 * a time before epoch is converted to a time long after epoch
+	 * on 64 bit systems.
+	 */
+	inode->i_atime.tv_sec = (int)be32_to_cpu(from->di_atime.t_sec);
+	inode->i_atime.tv_nsec = (int)be32_to_cpu(from->di_atime.t_nsec);
+	inode->i_mtime.tv_sec = (int)be32_to_cpu(from->di_mtime.t_sec);
+	inode->i_mtime.tv_nsec = (int)be32_to_cpu(from->di_mtime.t_nsec);
+	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);
 	to->di_nblocks = be64_to_cpu(from->di_nblocks);
 	to->di_extsize = be32_to_cpu(from->di_extsize);
@@ -251,9 +262,63 @@ xfs_dinode_from_disk(
 }
 
 void
-xfs_dinode_to_disk(
-	struct xfs_dinode	*to,
-	struct xfs_icdinode	*from)
+xfs_inode_to_disk(
+	struct xfs_inode	*ip,
+	struct xfs_dinode	*to)
+{
+	struct xfs_icdinode	*from = &ip->i_d;
+	struct inode		*inode = VFS_I(ip);
+
+	to->di_magic = cpu_to_be16(from->di_magic);
+	to->di_mode = cpu_to_be16(from->di_mode);
+	to->di_version = from ->di_version;
+	to->di_format = from->di_format;
+	to->di_onlink = cpu_to_be16(from->di_onlink);
+	to->di_uid = cpu_to_be32(from->di_uid);
+	to->di_gid = cpu_to_be32(from->di_gid);
+	to->di_nlink = cpu_to_be32(from->di_nlink);
+	to->di_projid_lo = cpu_to_be16(from->di_projid_lo);
+	to->di_projid_hi = cpu_to_be16(from->di_projid_hi);
+	memcpy(to->di_pad, from->di_pad, sizeof(to->di_pad));
+
+	to->di_atime.t_sec = cpu_to_be32(inode->i_atime.tv_sec);
+	to->di_atime.t_nsec = cpu_to_be32(inode->i_atime.tv_nsec);
+	to->di_mtime.t_sec = cpu_to_be32(inode->i_mtime.tv_sec);
+	to->di_mtime.t_nsec = cpu_to_be32(inode->i_mtime.tv_nsec);
+	to->di_ctime.t_sec = cpu_to_be32(inode->i_ctime.tv_sec);
+	to->di_ctime.t_nsec = cpu_to_be32(inode->i_ctime.tv_nsec);
+
+	to->di_size = cpu_to_be64(from->di_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(from->di_nextents);
+	to->di_anextents = cpu_to_be16(from->di_anextents);
+	to->di_forkoff = from->di_forkoff;
+	to->di_aformat = from->di_aformat;
+	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_gen = cpu_to_be32(from->di_gen);
+
+	if (from->di_version == 3) {
+		to->di_changecount = cpu_to_be64(from->di_changecount);
+		to->di_crtime.t_sec = cpu_to_be32(from->di_crtime.t_sec);
+		to->di_crtime.t_nsec = cpu_to_be32(from->di_crtime.t_nsec);
+		to->di_flags2 = cpu_to_be64(from->di_flags2);
+		to->di_ino = cpu_to_be64(from->di_ino);
+		to->di_lsn = cpu_to_be64(from->di_lsn);
+		memcpy(to->di_pad2, from->di_pad2, sizeof(to->di_pad2));
+		uuid_copy(&to->di_uuid, &from->di_uuid);
+		to->di_flushiter = 0;
+	} else {
+		to->di_flushiter = cpu_to_be16(from->di_flushiter);
+	}
+}
+
+void
+xfs_log_dinode_to_disk(
+	struct xfs_log_dinode	*from,
+	struct xfs_dinode	*to)
 {
 	to->di_magic = cpu_to_be16(from->di_magic);
 	to->di_mode = cpu_to_be16(from->di_mode);
@@ -266,12 +331,14 @@ xfs_dinode_to_disk(
 	to->di_projid_lo = cpu_to_be16(from->di_projid_lo);
 	to->di_projid_hi = cpu_to_be16(from->di_projid_hi);
 	memcpy(to->di_pad, from->di_pad, sizeof(to->di_pad));
+
 	to->di_atime.t_sec = cpu_to_be32(from->di_atime.t_sec);
 	to->di_atime.t_nsec = cpu_to_be32(from->di_atime.t_nsec);
 	to->di_mtime.t_sec = cpu_to_be32(from->di_mtime.t_sec);
 	to->di_mtime.t_nsec = cpu_to_be32(from->di_mtime.t_nsec);
 	to->di_ctime.t_sec = cpu_to_be32(from->di_ctime.t_sec);
 	to->di_ctime.t_nsec = cpu_to_be32(from->di_ctime.t_nsec);
+
 	to->di_size = cpu_to_be64(from->di_size);
 	to->di_nblocks = cpu_to_be64(from->di_nblocks);
 	to->di_extsize = cpu_to_be32(from->di_extsize);
@@ -412,7 +479,7 @@ xfs_iread(
 	 * Otherwise, just get the truly permanent information.
 	 */
 	if (dip->di_mode) {
-		xfs_dinode_from_disk(&ip->i_d, dip);
+		xfs_inode_from_disk(ip, dip);
 		error = xfs_iformat_fork(ip, dip);
 		if (error)  {
 #ifdef DEBUG
diff --git a/libxfs/xfs_inode_buf.h b/libxfs/xfs_inode_buf.h
index da66458..6242974 100644
--- a/libxfs/xfs_inode_buf.h
+++ b/libxfs/xfs_inode_buf.h
@@ -40,9 +40,6 @@ struct xfs_icdinode {
 	__uint16_t	di_projid_hi;	/* higher part of owner's project id */
 	__uint8_t	di_pad[6];	/* unused, zeroed space */
 	__uint16_t	di_flushiter;	/* incremented on flush */
-	xfs_ictimestamp_t di_atime;	/* time last accessed */
-	xfs_ictimestamp_t di_mtime;	/* time last modified */
-	xfs_ictimestamp_t di_ctime;	/* time created/inode modified */
 	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 */
@@ -89,8 +86,10 @@ int	xfs_imap_to_bp(struct xfs_mount *, struct xfs_trans *,
 int	xfs_iread(struct xfs_mount *, struct xfs_trans *,
 		  struct xfs_inode *, uint);
 void	xfs_dinode_calc_crc(struct xfs_mount *, struct xfs_dinode *);
-void	xfs_dinode_to_disk(struct xfs_dinode *to, struct xfs_icdinode *from);
-void	xfs_dinode_from_disk(struct xfs_icdinode *to, struct xfs_dinode *from);
+void	xfs_inode_to_disk(struct xfs_inode *ip, struct xfs_dinode *to);
+void	xfs_inode_from_disk(struct xfs_inode *ip, struct xfs_dinode *from);
+void	xfs_log_dinode_to_disk(struct xfs_log_dinode *from,
+			       struct xfs_dinode *to);
 bool	xfs_dinode_verify(struct xfs_mount *mp, xfs_ino_t ino,
 			  struct xfs_dinode *dip);
 
diff --git a/libxfs/xfs_rtbitmap.c b/libxfs/xfs_rtbitmap.c
index 684a18b..70ea975 100644
--- a/libxfs/xfs_rtbitmap.c
+++ b/libxfs/xfs_rtbitmap.c
@@ -1006,7 +1006,7 @@ xfs_rtfree_extent(
 	    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;
-		*(__uint64_t *)&mp->m_rbmip->i_d.di_atime = 0;
+		*(__uint64_t *)&VFS_I(mp->m_rbmip)->i_atime = 0;
 		xfs_trans_log_inode(tp, mp->m_rbmip, XFS_ILOG_CORE);
 	}
 	return 0;
diff --git a/mkfs/proto.c b/mkfs/proto.c
index 21960d5..72a1576 100644
--- a/mkfs/proto.c
+++ b/mkfs/proto.c
@@ -653,7 +653,7 @@ rtinit(
 	mp->m_sb.sb_rbmino = rbmip->i_ino;
 	rbmip->i_d.di_size = mp->m_sb.sb_rbmblocks * mp->m_sb.sb_blocksize;
 	rbmip->i_d.di_flags = XFS_DIFLAG_NEWRTBM;
-	*(__uint64_t *)&rbmip->i_d.di_atime = 0;
+	*(__uint64_t *)&VFS_I(mp->m_rbmip)->i_atime = 0;
 	libxfs_trans_log_inode(tp, rbmip, XFS_ILOG_CORE);
 	libxfs_log_sb(tp);
 	mp->m_rbmip = rbmip;
-- 
2.7.0

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

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

* [PATCH 10/15] xfs: cull unnecessary icdinode fields
  2016-02-17  7:20 [PATCH 00/15] xfsprogs: libxfs kernel sync to 4.6-for-next Dave Chinner
                   ` (8 preceding siblings ...)
  2016-02-17  7:20 ` [PATCH 09/15] xfs: remove timestamps from incore inode Dave Chinner
@ 2016-02-17  7:20 ` Dave Chinner
  2016-02-17  7:20 ` [PATCH 11/15] xfs: move v1 inode conversion to xfs_inode_from_disk Dave Chinner
                   ` (5 subsequent siblings)
  15 siblings, 0 replies; 28+ messages in thread
From: Dave Chinner @ 2016-02-17  7:20 UTC (permalink / raw)
  To: xfs

From: Dave Chinner <dchinner@redhat.com>

Source kernel commit 93f958f9c41f0bfd10627a2279457df64004d957

Now that the struct xfs_icdinode is not directly related to the
on-disk format, we can cull things in it we really don't need to
store:

- magic number never changes
- padding is not necessary
- next_unlinked is never used
- inode number is redundant
- uuid is redundant
- lsn is accessed directly from dinode
- inode CRC is only accessed directly from dinode

Hence we can remove these from the struct xfs_icdinode and redirect
the code that uses them to the xfs_dinode appripriately.  This
reduces the size of the struct icdinode from 152 bytes to 88 bytes,
and removes a fair chunk of unnecessary code, too.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dave Chinner <david@fromorbit.com>
---
 db/check.c             |  4 ++--
 libxfs/util.c          | 11 +----------
 libxfs/xfs_inode_buf.c | 39 +++++++++++++--------------------------
 libxfs/xfs_inode_buf.h | 25 ++++++-------------------
 repair/phase6.c        | 18 ------------------
 5 files changed, 22 insertions(+), 75 deletions(-)

diff --git a/db/check.c b/db/check.c
index 2203f41..95a68d4 100644
--- a/db/check.c
+++ b/db/check.c
@@ -2672,10 +2672,10 @@ process_inode(
 		blkmap = NULL;
 	}
 	v = (!sflag || (id && id->ilist) || CHECK_BLIST(bno));
-	if (xino.i_d.di_magic != XFS_DINODE_MAGIC) {
+	if (dip->di_magic != cpu_to_be16(XFS_DINODE_MAGIC)) {
 		if (isfree || v)
 			dbprintf(_("bad magic number %#x for inode %lld\n"),
-				xino.i_d.di_magic, ino);
+				be16_to_cpu(dip->di_magic), ino);
 		error++;
 		return;
 	}
diff --git a/libxfs/util.c b/libxfs/util.c
index 86fadc3..a893c3a 100644
--- a/libxfs/util.c
+++ b/libxfs/util.c
@@ -224,7 +224,6 @@ libxfs_ialloc(
 	ip->i_d.di_uid = cr->cr_uid;
 	ip->i_d.di_gid = cr->cr_gid;
 	xfs_set_projid(&ip->i_d, pip ? 0 : fsx->fsx_projid);
-	memset(&(ip->i_d.di_pad[0]), 0, sizeof(ip->i_d.di_pad));
 	xfs_trans_ichgtime(tp, ip, XFS_ICHGTIME_CHG | XFS_ICHGTIME_MOD);
 
 	/*
@@ -261,11 +260,8 @@ libxfs_ialloc(
 	if (ip->i_d.di_version == 3) {
 		ASSERT(ip->i_d.di_ino == ino);
 		ASSERT(uuid_equal(&ip->i_d.di_uuid, &mp->m_sb.sb_meta_uuid));
-		ip->i_d.di_crc = 0;
 		ip->i_d.di_changecount = 1;
-		ip->i_d.di_lsn = 0;
 		ip->i_d.di_flags2 = 0;
-		memset(&(ip->i_d.di_pad2[0]), 0, sizeof(ip->i_d.di_pad2));
 		ip->i_d.di_crtime.t_sec = (__int32_t)VFS_I(ip)->i_mtime.tv_sec;
 		ip->i_d.di_crtime.t_nsec = (__int32_t)VFS_I(ip)->i_mtime.tv_nsec;
 	}
@@ -376,7 +372,6 @@ libxfs_iprint(
 
 	dip = &ip->i_d;
 	printf("\nOn disk portion\n");
-	printf("    di_magic %x\n", dip->di_magic);
 	printf("    di_mode %o\n", dip->di_mode);
 	printf("    di_version %x\n", (uint)dip->di_version);
 	switch (ip->i_d.di_format) {
@@ -449,16 +444,12 @@ libxfs_iflush_int(xfs_inode_t *ip, xfs_buf_t *bp)
 	 * because if the inode is dirty at all the core must
 	 * be.
 	 */
-	xfs_inode_to_disk(ip, dip);
+	xfs_inode_to_disk(ip, dip, iip->ili_item.li_lsn);
 
 	xfs_iflush_fork(ip, dip, iip, XFS_DATA_FORK);
 	if (XFS_IFORK_Q(ip))
 		xfs_iflush_fork(ip, dip, iip, XFS_ATTR_FORK);
 
-	/* update the lsn in the on disk inode if required */
-	if (ip->i_d.di_version == 3)
-		dip->di_lsn = cpu_to_be64(iip->ili_item.li_lsn);
-
 	/* generate the checksum. */
 	xfs_dinode_calc_crc(mp, dip);
 
diff --git a/libxfs/xfs_inode_buf.c b/libxfs/xfs_inode_buf.c
index f546b41..5a7a118 100644
--- a/libxfs/xfs_inode_buf.c
+++ b/libxfs/xfs_inode_buf.c
@@ -211,7 +211,6 @@ xfs_inode_from_disk(
 	struct xfs_icdinode	*to = &ip->i_d;
 	struct inode		*inode = VFS_I(ip);
 
-	to->di_magic = be16_to_cpu(from->di_magic);
 	to->di_mode = be16_to_cpu(from->di_mode);
 	to->di_version = from ->di_version;
 	to->di_format = from->di_format;
@@ -221,7 +220,6 @@ xfs_inode_from_disk(
 	to->di_nlink = be32_to_cpu(from->di_nlink);
 	to->di_projid_lo = be16_to_cpu(from->di_projid_lo);
 	to->di_projid_hi = be16_to_cpu(from->di_projid_hi);
-	memcpy(to->di_pad, from->di_pad, sizeof(to->di_pad));
 	to->di_flushiter = be16_to_cpu(from->di_flushiter);
 
 	/*
@@ -254,24 +252,22 @@ xfs_inode_from_disk(
 		to->di_crtime.t_sec = be32_to_cpu(from->di_crtime.t_sec);
 		to->di_crtime.t_nsec = be32_to_cpu(from->di_crtime.t_nsec);
 		to->di_flags2 = be64_to_cpu(from->di_flags2);
-		to->di_ino = be64_to_cpu(from->di_ino);
-		to->di_lsn = be64_to_cpu(from->di_lsn);
-		memcpy(to->di_pad2, from->di_pad2, sizeof(to->di_pad2));
-		uuid_copy(&to->di_uuid, &from->di_uuid);
 	}
 }
 
 void
 xfs_inode_to_disk(
 	struct xfs_inode	*ip,
-	struct xfs_dinode	*to)
+	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(from->di_magic);
+	to->di_magic = cpu_to_be16(XFS_DINODE_MAGIC);
+
 	to->di_mode = cpu_to_be16(from->di_mode);
-	to->di_version = from ->di_version;
+	to->di_version = from->di_version;
 	to->di_format = from->di_format;
 	to->di_onlink = cpu_to_be16(from->di_onlink);
 	to->di_uid = cpu_to_be32(from->di_uid);
@@ -279,8 +275,8 @@ xfs_inode_to_disk(
 	to->di_nlink = cpu_to_be32(from->di_nlink);
 	to->di_projid_lo = cpu_to_be16(from->di_projid_lo);
 	to->di_projid_hi = cpu_to_be16(from->di_projid_hi);
-	memcpy(to->di_pad, from->di_pad, sizeof(to->di_pad));
 
+	memset(to->di_pad, 0, sizeof(to->di_pad));
 	to->di_atime.t_sec = cpu_to_be32(inode->i_atime.tv_sec);
 	to->di_atime.t_nsec = cpu_to_be32(inode->i_atime.tv_nsec);
 	to->di_mtime.t_sec = cpu_to_be32(inode->i_mtime.tv_sec);
@@ -305,10 +301,11 @@ xfs_inode_to_disk(
 		to->di_crtime.t_sec = cpu_to_be32(from->di_crtime.t_sec);
 		to->di_crtime.t_nsec = cpu_to_be32(from->di_crtime.t_nsec);
 		to->di_flags2 = cpu_to_be64(from->di_flags2);
-		to->di_ino = cpu_to_be64(from->di_ino);
-		to->di_lsn = cpu_to_be64(from->di_lsn);
-		memcpy(to->di_pad2, from->di_pad2, sizeof(to->di_pad2));
-		uuid_copy(&to->di_uuid, &from->di_uuid);
+
+		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));
+		uuid_copy(&to->di_uuid, &ip->i_mount->m_sb.sb_meta_uuid);
 		to->di_flushiter = 0;
 	} else {
 		to->di_flushiter = cpu_to_be16(from->di_flushiter);
@@ -443,13 +440,10 @@ xfs_iread(
 	    !(mp->m_flags & XFS_MOUNT_IKEEP)) {
 		/* initialise the on-disk inode core */
 		memset(&ip->i_d, 0, sizeof(ip->i_d));
-		ip->i_d.di_magic = XFS_DINODE_MAGIC;
 		ip->i_d.di_gen = prandom_u32();
-		if (xfs_sb_version_hascrc(&mp->m_sb)) {
+		if (xfs_sb_version_hascrc(&mp->m_sb))
 			ip->i_d.di_version = 3;
-			ip->i_d.di_ino = ip->i_ino;
-			uuid_copy(&ip->i_d.di_uuid, &mp->m_sb.sb_meta_uuid);
-		} else
+		else
 			ip->i_d.di_version = 2;
 		return 0;
 	}
@@ -493,16 +487,10 @@ xfs_iread(
 		 * Partial initialisation of the in-core inode. Just the bits
 		 * that xfs_ialloc won't overwrite or relies on being correct.
 		 */
-		ip->i_d.di_magic = be16_to_cpu(dip->di_magic);
 		ip->i_d.di_version = dip->di_version;
 		ip->i_d.di_gen = be32_to_cpu(dip->di_gen);
 		ip->i_d.di_flushiter = be16_to_cpu(dip->di_flushiter);
 
-		if (dip->di_version == 3) {
-			ip->i_d.di_ino = be64_to_cpu(dip->di_ino);
-			uuid_copy(&ip->i_d.di_uuid, &dip->di_uuid);
-		}
-
 		/*
 		 * Make sure to pull in the mode here as well in
 		 * case the inode is released without being used.
@@ -523,7 +511,6 @@ xfs_iread(
 	 */
 	if (ip->i_d.di_version == 1) {
 		ip->i_d.di_version = 2;
-		memset(&(ip->i_d.di_pad[0]), 0, sizeof(ip->i_d.di_pad));
 		ip->i_d.di_nlink = ip->i_d.di_onlink;
 		ip->i_d.di_onlink = 0;
 		xfs_set_projid(&ip->i_d, 0);
diff --git a/libxfs/xfs_inode_buf.h b/libxfs/xfs_inode_buf.h
index 6242974..974d060 100644
--- a/libxfs/xfs_inode_buf.h
+++ b/libxfs/xfs_inode_buf.h
@@ -22,24 +22,22 @@ struct xfs_inode;
 struct xfs_dinode;
 
 /*
- * In memory representation of the XFS inode. This is held in the in-core
- * struct xfs_inode to represent the on disk values, but no longer needs to be
- * identical to the on-disk structure as it is always translated to on-disk
+ * 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_magic;	/* inode magic # = XFS_DINODE_MAGIC */
 	__uint16_t	di_mode;	/* mode and type of file */
 	__int8_t	di_version;	/* inode version */
 	__int8_t	di_format;	/* format of di_c data */
 	__uint16_t	di_onlink;	/* old number of links to file */
+	__uint16_t	di_flushiter;	/* incremented on flush */
 	__uint32_t	di_uid;		/* owner's user id */
 	__uint32_t	di_gid;		/* owner's group id */
 	__uint32_t	di_nlink;	/* number of links to file */
 	__uint16_t	di_projid_lo;	/* lower part of owner's project id */
 	__uint16_t	di_projid_hi;	/* higher part of owner's project id */
-	__uint8_t	di_pad[6];	/* unused, zeroed space */
-	__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 */
@@ -52,22 +50,10 @@ struct xfs_icdinode {
 	__uint16_t	di_flags;	/* random flags, XFS_DIFLAG_... */
 	__uint32_t	di_gen;		/* generation number */
 
-	/* di_next_unlinked is the only non-core field in the old dinode */
-	xfs_agino_t	di_next_unlinked;/* agi unlinked list ptr */
-
-	/* start of the extended dinode, writable fields */
-	__uint32_t	di_crc;		/* CRC of the inode */
 	__uint64_t	di_changecount;	/* number of attribute changes */
-	xfs_lsn_t	di_lsn;		/* flush sequence */
 	__uint64_t	di_flags2;	/* more random flags */
-	__uint8_t	di_pad2[16];	/* more padding for future expansion */
 
-	/* fields only written to during inode creation */
 	xfs_ictimestamp_t di_crtime;	/* time created */
-	xfs_ino_t	di_ino;		/* inode number */
-	uuid_t		di_uuid;	/* UUID of the filesystem */
-
-	/* structure must be padded to 64 bit alignment */
 };
 
 /*
@@ -86,7 +72,8 @@ int	xfs_imap_to_bp(struct xfs_mount *, struct xfs_trans *,
 int	xfs_iread(struct xfs_mount *, struct xfs_trans *,
 		  struct xfs_inode *, uint);
 void	xfs_dinode_calc_crc(struct xfs_mount *, struct xfs_dinode *);
-void	xfs_inode_to_disk(struct xfs_inode *ip, struct xfs_dinode *to);
+void	xfs_inode_to_disk(struct xfs_inode *ip, struct xfs_dinode *to,
+			  xfs_lsn_t lsn);
 void	xfs_inode_from_disk(struct xfs_inode *ip, struct xfs_dinode *from);
 void	xfs_log_dinode_to_disk(struct xfs_log_dinode *from,
 			       struct xfs_dinode *to);
diff --git a/repair/phase6.c b/repair/phase6.c
index 3aa109d..00142e2 100644
--- a/repair/phase6.c
+++ b/repair/phase6.c
@@ -510,7 +510,6 @@ mk_rbmino(xfs_mount_t *mp)
 	vers = xfs_sb_version_hascrc(&mp->m_sb) ? 3 : 2;
 	memset(&ip->i_d, 0, sizeof(ip->i_d));
 
-	ip->i_d.di_magic = XFS_DINODE_MAGIC;
 	ip->i_d.di_mode = S_IFREG;
 	ip->i_d.di_version = vers;
 	ip->i_d.di_format = XFS_DINODE_FMT_EXTENTS;
@@ -520,13 +519,8 @@ mk_rbmino(xfs_mount_t *mp)
 
 	times = XFS_ICHGTIME_CHG | XFS_ICHGTIME_MOD;
 	if (ip->i_d.di_version == 3) {
-		ip->i_d.di_crc = 0;
 		ip->i_d.di_changecount = 1;
-		ip->i_d.di_lsn = 0;
 		ip->i_d.di_flags2 = 0;
-		ip->i_d.di_ino = mp->m_sb.sb_rbmino;
-		memset(&(ip->i_d.di_pad2[0]), 0, sizeof(ip->i_d.di_pad2));
-		platform_uuid_copy(&ip->i_d.di_uuid, &mp->m_sb.sb_meta_uuid);
 		times |= XFS_ICHGTIME_CREATE;
 	}
 	libxfs_trans_ichgtime(tp, ip, times);
@@ -769,7 +763,6 @@ mk_rsumino(xfs_mount_t *mp)
 	vers = xfs_sb_version_hascrc(&mp->m_sb) ? 3 : 1;
 	memset(&ip->i_d, 0, sizeof(ip->i_d));
 
-	ip->i_d.di_magic = XFS_DINODE_MAGIC;
 	ip->i_d.di_mode = S_IFREG;
 	ip->i_d.di_version = vers;
 	ip->i_d.di_format = XFS_DINODE_FMT_EXTENTS;
@@ -779,13 +772,8 @@ mk_rsumino(xfs_mount_t *mp)
 
 	times = XFS_ICHGTIME_CHG | XFS_ICHGTIME_MOD;
 	if (ip->i_d.di_version == 3) {
-		ip->i_d.di_crc = 0;
 		ip->i_d.di_changecount = 1;
-		ip->i_d.di_lsn = 0;
 		ip->i_d.di_flags2 = 0;
-		ip->i_d.di_ino = mp->m_sb.sb_rsumino;
-		memset(&(ip->i_d.di_pad2[0]), 0, sizeof(ip->i_d.di_pad2));
-		platform_uuid_copy(&ip->i_d.di_uuid, &mp->m_sb.sb_meta_uuid);
 		times |= XFS_ICHGTIME_CREATE;
 	}
 	libxfs_trans_ichgtime(tp, ip, times);
@@ -884,7 +872,6 @@ mk_root_dir(xfs_mount_t *mp)
 	vers = xfs_sb_version_hascrc(&mp->m_sb) ? 3 : 2;
 	memset(&ip->i_d, 0, sizeof(ip->i_d));
 
-	ip->i_d.di_magic = XFS_DINODE_MAGIC;
 	ip->i_d.di_mode = (__uint16_t) mode|S_IFDIR;
 	ip->i_d.di_version = vers;
 	ip->i_d.di_format = XFS_DINODE_FMT_EXTENTS;
@@ -894,13 +881,8 @@ mk_root_dir(xfs_mount_t *mp)
 
 	times = XFS_ICHGTIME_CHG | XFS_ICHGTIME_MOD;
 	if (ip->i_d.di_version == 3) {
-		ip->i_d.di_crc = 0;
 		ip->i_d.di_changecount = 1;
-		ip->i_d.di_lsn = 0;
 		ip->i_d.di_flags2 = 0;
-		ip->i_d.di_ino = mp->m_sb.sb_rootino;
-		memset(&(ip->i_d.di_pad2[0]), 0, sizeof(ip->i_d.di_pad2));
-		platform_uuid_copy(&ip->i_d.di_uuid, &mp->m_sb.sb_meta_uuid);
 		times |= XFS_ICHGTIME_CREATE;
 	}
 	libxfs_trans_ichgtime(tp, ip, times);
-- 
2.7.0

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

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

* [PATCH 11/15] xfs: move v1 inode conversion to xfs_inode_from_disk
  2016-02-17  7:20 [PATCH 00/15] xfsprogs: libxfs kernel sync to 4.6-for-next Dave Chinner
                   ` (9 preceding siblings ...)
  2016-02-17  7:20 ` [PATCH 10/15] xfs: cull unnecessary icdinode fields Dave Chinner
@ 2016-02-17  7:20 ` Dave Chinner
  2016-02-17  7:32   ` Christoph Hellwig
  2016-02-17  7:20 ` [PATCH 12/15] xfs: use vfs inode nlink field everywhere Dave Chinner
                   ` (4 subsequent siblings)
  15 siblings, 1 reply; 28+ messages in thread
From: Dave Chinner @ 2016-02-17  7:20 UTC (permalink / raw)
  To: xfs

From: Dave Chinner <dchinner@redhat.com>

Source kernel commit faeb4e4715be017e88e630bda84477afc1dff38b

So we don't have to carry an di_onlink variable around anymore, move
the inode conversion from v1 inode format to v2 inode format into
xfs_inode_from_disk(). This means we can remove the di_onlink fields
from the struct xfs_icdinode.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dave Chinner <david@fromorbit.com>
---
 db/check.c               | 19 ++++++-------------
 libxfs/util.c            |  1 -
 libxfs/xfs_inode_buf.c   | 41 ++++++++++++++++++++---------------------
 libxfs/xfs_inode_buf.h   |  1 -
 libxfs/xfs_log_format.h  |  2 +-
 logprint/log_print_all.c |  5 ++---
 6 files changed, 29 insertions(+), 40 deletions(-)

diff --git a/db/check.c b/db/check.c
index 95a68d4..412ab3d 100644
--- a/db/check.c
+++ b/db/check.c
@@ -2623,7 +2623,6 @@ process_inode(
 	inodata_t		*id = NULL;
 	xfs_ino_t		ino;
 	xfs_extnum_t		nextents = 0;
-	int			nlink;
 	int			security;
 	xfs_rfsblock_t		totblocks;
 	xfs_rfsblock_t		totdblocks = 0;
@@ -2694,14 +2693,10 @@ process_inode(
 					xino.i_d.di_nblocks, ino);
 			error++;
 		}
-		if (xino.i_d.di_version == 1)
-			nlink = xino.i_d.di_onlink;
-		else
-			nlink = xino.i_d.di_nlink;
-		if (nlink != 0) {
+		if (dip->di_nlink != 0) {
 			if (v)
 				dbprintf(_("bad nlink %d for free inode %lld\n"),
-					nlink, ino);
+					be32_to_cpu(dip->di_nlink), ino);
 			error++;
 		}
 		if (xino.i_d.di_mode != 0) {
@@ -2801,12 +2796,10 @@ process_inode(
 		type = DBM_UNKNOWN;
 		break;
 	}
-	if (xino.i_d.di_version == 1)
-		setlink_inode(id, xino.i_d.di_onlink, type == DBM_DIR, security);
-	else {
-		sbversion |= XFS_SB_VERSION_NLINKBIT;
-		setlink_inode(id, xino.i_d.di_nlink, type == DBM_DIR, security);
-	}
+
+	sbversion |= XFS_SB_VERSION_NLINKBIT;
+	setlink_inode(id, be32_to_cpu(dip->di_nlink), type == DBM_DIR, security);
+
 	switch (xino.i_d.di_format) {
 	case XFS_DINODE_FMT_LOCAL:
 		process_lclinode(id, dip, type, &totdblocks, &totiblocks,
diff --git a/libxfs/util.c b/libxfs/util.c
index a893c3a..bbaf790 100644
--- a/libxfs/util.c
+++ b/libxfs/util.c
@@ -218,7 +218,6 @@ libxfs_ialloc(
 	ASSERT(ip != NULL);
 
 	ip->i_d.di_mode = (__uint16_t)mode;
-	ip->i_d.di_onlink = 0;
 	ip->i_d.di_nlink = nlink;
 	ASSERT(ip->i_d.di_nlink == nlink);
 	ip->i_d.di_uid = cr->cr_uid;
diff --git a/libxfs/xfs_inode_buf.c b/libxfs/xfs_inode_buf.c
index 5a7a118..66a827a 100644
--- a/libxfs/xfs_inode_buf.c
+++ b/libxfs/xfs_inode_buf.c
@@ -213,13 +213,25 @@ xfs_inode_from_disk(
 
 	to->di_mode = be16_to_cpu(from->di_mode);
 	to->di_version = from ->di_version;
+
+	/*
+	 * Convert v1 inodes immediately to v2 inode format as this is the
+	 * minimum inode version format we support in the rest of the code.
+	 */
+	if (to->di_version == 1) {
+		to->di_nlink = be16_to_cpu(from->di_onlink);
+		to->di_projid_lo = 0;
+		to->di_projid_hi = 0;
+		to->di_version = 2;
+	} else {
+		to->di_nlink = be32_to_cpu(from->di_nlink);
+		to->di_projid_lo = be16_to_cpu(from->di_projid_lo);
+		to->di_projid_hi = be16_to_cpu(from->di_projid_hi);
+	}
+
 	to->di_format = from->di_format;
-	to->di_onlink = be16_to_cpu(from->di_onlink);
 	to->di_uid = be32_to_cpu(from->di_uid);
 	to->di_gid = be32_to_cpu(from->di_gid);
-	to->di_nlink = be32_to_cpu(from->di_nlink);
-	to->di_projid_lo = be16_to_cpu(from->di_projid_lo);
-	to->di_projid_hi = be16_to_cpu(from->di_projid_hi);
 	to->di_flushiter = be16_to_cpu(from->di_flushiter);
 
 	/*
@@ -265,11 +277,11 @@ xfs_inode_to_disk(
 	struct inode		*inode = VFS_I(ip);
 
 	to->di_magic = cpu_to_be16(XFS_DINODE_MAGIC);
+	to->di_onlink = 0;
 
 	to->di_mode = cpu_to_be16(from->di_mode);
 	to->di_version = from->di_version;
 	to->di_format = from->di_format;
-	to->di_onlink = cpu_to_be16(from->di_onlink);
 	to->di_uid = cpu_to_be32(from->di_uid);
 	to->di_gid = cpu_to_be32(from->di_gid);
 	to->di_nlink = cpu_to_be32(from->di_nlink);
@@ -319,9 +331,9 @@ xfs_log_dinode_to_disk(
 {
 	to->di_magic = cpu_to_be16(from->di_magic);
 	to->di_mode = cpu_to_be16(from->di_mode);
-	to->di_version = from ->di_version;
+	to->di_version = from->di_version;
 	to->di_format = from->di_format;
-	to->di_onlink = cpu_to_be16(from->di_onlink);
+	to->di_onlink = 0;
 	to->di_uid = cpu_to_be32(from->di_uid);
 	to->di_gid = cpu_to_be32(from->di_gid);
 	to->di_nlink = cpu_to_be32(from->di_nlink);
@@ -501,20 +513,7 @@ xfs_iread(
 		ip->i_d.di_mode = 0;
 	}
 
-	/*
-	 * Automatically convert version 1 inode formats in memory to version 2
-	 * inode format. If the inode is modified, it will get logged and
-	 * rewritten as a version 2 inode. We can do this because we set the
-	 * superblock feature bit for v2 inodes unconditionally during mount
-	 * and it means the reast of the code can assume the inode version is 2
-	 * or higher.
-	 */
-	if (ip->i_d.di_version == 1) {
-		ip->i_d.di_version = 2;
-		ip->i_d.di_nlink = ip->i_d.di_onlink;
-		ip->i_d.di_onlink = 0;
-		xfs_set_projid(&ip->i_d, 0);
-	}
+	ASSERT(ip->i_d.di_version >= 2);
 
 	ip->i_delayed_blks = 0;
 
diff --git a/libxfs/xfs_inode_buf.h b/libxfs/xfs_inode_buf.h
index 974d060..489b96e 100644
--- a/libxfs/xfs_inode_buf.h
+++ b/libxfs/xfs_inode_buf.h
@@ -31,7 +31,6 @@ struct xfs_icdinode {
 	__uint16_t	di_mode;	/* mode and type of file */
 	__int8_t	di_version;	/* inode version */
 	__int8_t	di_format;	/* format of di_c data */
-	__uint16_t	di_onlink;	/* old number of links to file */
 	__uint16_t	di_flushiter;	/* incremented on flush */
 	__uint32_t	di_uid;		/* owner's user id */
 	__uint32_t	di_gid;		/* owner's group id */
diff --git a/libxfs/xfs_log_format.h b/libxfs/xfs_log_format.h
index 85d4732..40005bf 100644
--- a/libxfs/xfs_log_format.h
+++ b/libxfs/xfs_log_format.h
@@ -369,7 +369,7 @@ struct xfs_log_dinode {
 	__uint16_t	di_mode;	/* mode and type of file */
 	__int8_t	di_version;	/* inode version */
 	__int8_t	di_format;	/* format of di_c data */
-	__uint16_t	di_onlink;	/* old number of links to file */
+	__uint8_t	di_pad3[2];	/* unused in v2/3 inodes */
 	__uint32_t	di_uid;		/* owner's user id */
 	__uint32_t	di_gid;		/* owner's group id */
 	__uint32_t	di_nlink;	/* number of links to file */
diff --git a/logprint/log_print_all.c b/logprint/log_print_all.c
index 1bc18af..f95f4aa 100644
--- a/logprint/log_print_all.c
+++ b/logprint/log_print_all.c
@@ -255,10 +255,9 @@ xlog_recover_print_inode_core(
 	printf(_("	CORE inode:\n"));
 	if (!print_inode)
 		return;
-	printf(_("		magic:%c%c  mode:0x%x  ver:%d  format:%d  "
-	     "onlink:%d\n"),
+	printf(_("		magic:%c%c  mode:0x%x  ver:%d  format:%d\n"),
 	       (di->di_magic>>8) & 0xff, di->di_magic & 0xff,
-	       di->di_mode, di->di_version, di->di_format, di->di_onlink);
+	       di->di_mode, di->di_version, di->di_format);
 	printf(_("		uid:%d  gid:%d  nlink:%d projid:0x%04x%04x\n"),
 	       di->di_uid, di->di_gid, di->di_nlink,
 	       di->di_projid_hi, di->di_projid_lo);
-- 
2.7.0

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

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

* [PATCH 12/15] xfs: use vfs inode nlink field everywhere
  2016-02-17  7:20 [PATCH 00/15] xfsprogs: libxfs kernel sync to 4.6-for-next Dave Chinner
                   ` (10 preceding siblings ...)
  2016-02-17  7:20 ` [PATCH 11/15] xfs: move v1 inode conversion to xfs_inode_from_disk Dave Chinner
@ 2016-02-17  7:20 ` Dave Chinner
  2016-02-17  7:35   ` Christoph Hellwig
  2016-02-17  7:20 ` [PATCH 13/15] xfs: move inode generation count to VFS inode Dave Chinner
                   ` (3 subsequent siblings)
  15 siblings, 1 reply; 28+ messages in thread
From: Dave Chinner @ 2016-02-17  7:20 UTC (permalink / raw)
  To: xfs

From: Dave Chinner <dchinner@redhat.com>

Source kernel commit 54d7b5c1d03e9711cce2d72237d5b3f5c87431f4

The VFS tracks the inode nlink just like the xfs_icdinode. We can
remove the variable from the icdinode and use the VFS inode variable
everywhere, reducing the size of the xfs_icdinode by a further 4
bytes.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dave Chinner <david@fromorbit.com>
---
 include/xfs_inode.h      |  1 +
 libxfs/libxfs_api_defs.h |  4 ++++
 libxfs/util.c            |  5 ++---
 libxfs/xfs_inode_buf.c   |  6 +++---
 libxfs/xfs_inode_buf.h   |  1 -
 mkfs/proto.c             |  4 ++--
 repair/phase6.c          | 18 +++++++++---------
 repair/phase7.c          | 43 ++++++++++++++-----------------------------
 8 files changed, 35 insertions(+), 47 deletions(-)

diff --git a/include/xfs_inode.h b/include/xfs_inode.h
index 1efff0f..e7aa9e9 100644
--- a/include/xfs_inode.h
+++ b/include/xfs_inode.h
@@ -34,6 +34,7 @@ struct xfs_dir_ops;
  * metadata.
  */
 struct inode {
+	uint32_t	i_nlink;
 	struct timespec	i_atime;
 	struct timespec	i_mtime;
 	struct timespec	i_ctime;
diff --git a/libxfs/libxfs_api_defs.h b/libxfs/libxfs_api_defs.h
index 685c7a7..1408be3 100644
--- a/libxfs/libxfs_api_defs.h
+++ b/libxfs/libxfs_api_defs.h
@@ -108,4 +108,8 @@
 
 #define xfs_verify_cksum		libxfs_verify_cksum
 
+/* inode link counts */
+#define set_nlink(inode, nlink)	({ (inode)->i_nlink = (nlink); })
+#define inc_nlink(inode)	(inode)->i_nlink++
+
 #endif /* __LIBXFS_API_DEFS_H__ */
diff --git a/libxfs/util.c b/libxfs/util.c
index bbaf790..9327a62 100644
--- a/libxfs/util.c
+++ b/libxfs/util.c
@@ -218,8 +218,7 @@ libxfs_ialloc(
 	ASSERT(ip != NULL);
 
 	ip->i_d.di_mode = (__uint16_t)mode;
-	ip->i_d.di_nlink = nlink;
-	ASSERT(ip->i_d.di_nlink == nlink);
+	set_nlink(VFS_I(ip), nlink);
 	ip->i_d.di_uid = cr->cr_uid;
 	ip->i_d.di_gid = cr->cr_gid;
 	xfs_set_projid(&ip->i_d, pip ? 0 : fsx->fsx_projid);
@@ -387,7 +386,7 @@ libxfs_iprint(
 		printf("    Other inode\n");
 		break;
 	}
-	printf("   di_nlink %x\n", dip->di_nlink);
+	printf("   di_nlink %x\n", VFS_I(ip)->i_nlink);
 	printf("   di_uid %d\n", dip->di_uid);
 	printf("   di_gid %d\n", dip->di_gid);
 	printf("   di_nextents %d\n", dip->di_nextents);
diff --git a/libxfs/xfs_inode_buf.c b/libxfs/xfs_inode_buf.c
index 66a827a..dba8a4b 100644
--- a/libxfs/xfs_inode_buf.c
+++ b/libxfs/xfs_inode_buf.c
@@ -219,12 +219,12 @@ xfs_inode_from_disk(
 	 * minimum inode version format we support in the rest of the code.
 	 */
 	if (to->di_version == 1) {
-		to->di_nlink = be16_to_cpu(from->di_onlink);
+		set_nlink(inode, be16_to_cpu(from->di_onlink));
 		to->di_projid_lo = 0;
 		to->di_projid_hi = 0;
 		to->di_version = 2;
 	} else {
-		to->di_nlink = be32_to_cpu(from->di_nlink);
+		set_nlink(inode, be32_to_cpu(from->di_nlink));
 		to->di_projid_lo = be16_to_cpu(from->di_projid_lo);
 		to->di_projid_hi = be16_to_cpu(from->di_projid_hi);
 	}
@@ -284,7 +284,6 @@ xfs_inode_to_disk(
 	to->di_format = from->di_format;
 	to->di_uid = cpu_to_be32(from->di_uid);
 	to->di_gid = cpu_to_be32(from->di_gid);
-	to->di_nlink = cpu_to_be32(from->di_nlink);
 	to->di_projid_lo = cpu_to_be16(from->di_projid_lo);
 	to->di_projid_hi = cpu_to_be16(from->di_projid_hi);
 
@@ -295,6 +294,7 @@ xfs_inode_to_disk(
 	to->di_mtime.t_nsec = cpu_to_be32(inode->i_mtime.tv_nsec);
 	to->di_ctime.t_sec = cpu_to_be32(inode->i_ctime.tv_sec);
 	to->di_ctime.t_nsec = cpu_to_be32(inode->i_ctime.tv_nsec);
+	to->di_nlink = cpu_to_be32(inode->i_nlink);
 
 	to->di_size = cpu_to_be64(from->di_size);
 	to->di_nblocks = cpu_to_be64(from->di_nblocks);
diff --git a/libxfs/xfs_inode_buf.h b/libxfs/xfs_inode_buf.h
index 489b96e..ccc4052 100644
--- a/libxfs/xfs_inode_buf.h
+++ b/libxfs/xfs_inode_buf.h
@@ -34,7 +34,6 @@ struct xfs_icdinode {
 	__uint16_t	di_flushiter;	/* incremented on flush */
 	__uint32_t	di_uid;		/* owner's user id */
 	__uint32_t	di_gid;		/* owner's group id */
-	__uint32_t	di_nlink;	/* number of links to file */
 	__uint16_t	di_projid_lo;	/* lower part of owner's project id */
 	__uint16_t	di_projid_hi;	/* higher part of owner's project id */
 	xfs_fsize_t	di_size;	/* number of bytes in file */
diff --git a/mkfs/proto.c b/mkfs/proto.c
index 72a1576..9550859 100644
--- a/mkfs/proto.c
+++ b/mkfs/proto.c
@@ -546,7 +546,7 @@ parseproto(
 				&creds, fsxp, &ip);
 		if (error)
 			fail(_("Inode allocation failed"), error);
-		ip->i_d.di_nlink++;		/* account for . */
+		ip->i_vnode.i_nlink++;		/* account for . */
 		if (!pip) {
 			pip = ip;
 			mp->m_sb.sb_rootino = ip->i_ino;
@@ -557,7 +557,7 @@ parseproto(
 			xname.type = XFS_DIR3_FT_DIR;
 			newdirent(mp, tp, pip, &xname, ip->i_ino,
 				  &first, &flist);
-			pip->i_d.di_nlink++;
+			pip->i_vnode.i_nlink++;
 			libxfs_trans_log_inode(tp, pip, XFS_ILOG_CORE);
 		}
 		newdirectory(mp, tp, ip, pip);
diff --git a/repair/phase6.c b/repair/phase6.c
index 00142e2..7e14346 100644
--- a/repair/phase6.c
+++ b/repair/phase6.c
@@ -515,7 +515,7 @@ mk_rbmino(xfs_mount_t *mp)
 	ip->i_d.di_format = XFS_DINODE_FMT_EXTENTS;
 	ip->i_d.di_aformat = XFS_DINODE_FMT_EXTENTS;
 
-	ip->i_d.di_nlink = 1;		/* account for sb ptr */
+	set_nlink(VFS_I(ip), 1);	/* account for sb ptr */
 
 	times = XFS_ICHGTIME_CHG | XFS_ICHGTIME_MOD;
 	if (ip->i_d.di_version == 3) {
@@ -768,7 +768,7 @@ mk_rsumino(xfs_mount_t *mp)
 	ip->i_d.di_format = XFS_DINODE_FMT_EXTENTS;
 	ip->i_d.di_aformat = XFS_DINODE_FMT_EXTENTS;
 
-	ip->i_d.di_nlink = 1;		/* account for sb ptr */
+	set_nlink(VFS_I(ip), 1);	/* account for sb ptr */
 
 	times = XFS_ICHGTIME_CHG | XFS_ICHGTIME_MOD;
 	if (ip->i_d.di_version == 3) {
@@ -877,7 +877,7 @@ mk_root_dir(xfs_mount_t *mp)
 	ip->i_d.di_format = XFS_DINODE_FMT_EXTENTS;
 	ip->i_d.di_aformat = XFS_DINODE_FMT_EXTENTS;
 
-	ip->i_d.di_nlink = 1;		/* account for . */
+	set_nlink(VFS_I(ip), 1);	/* account for . */
 
 	times = XFS_ICHGTIME_CHG | XFS_ICHGTIME_MOD;
 	if (ip->i_d.di_version == 3) {
@@ -976,7 +976,7 @@ mk_orphanage(xfs_mount_t *mp)
 		do_error(_("%s inode allocation failed %d\n"),
 			ORPHANAGE, error);
 	}
-	ip->i_d.di_nlink++;		/* account for . */
+	inc_nlink(VFS_I(ip));		/* account for . */
 	ino = ip->i_ino;
 
 	irec = find_inode_rec(mp,
@@ -1027,7 +1027,7 @@ mk_orphanage(xfs_mount_t *mp)
 	 * bump up the link count in the root directory to account
 	 * for .. in the new directory
 	 */
-	pip->i_d.di_nlink++;
+	inc_nlink(VFS_I(pip));
 	add_inode_ref(find_inode_rec(mp,
 				XFS_INO_TO_AGNO(mp, mp->m_sb.sb_rootino),
 				XFS_INO_TO_AGINO(mp, mp->m_sb.sb_rootino)), 0);
@@ -1133,7 +1133,7 @@ mv_orphanage(
 			if (irec)
 				add_inode_ref(irec, ino_offset);
 			else
-				orphanage_ip->i_d.di_nlink++;
+				inc_nlink(VFS_I(orphanage_ip));
 			libxfs_trans_log_inode(tp, orphanage_ip, XFS_ILOG_CORE);
 
 			err = -libxfs_dir_createname(tp, ino_p, &xfs_name_dotdot,
@@ -1143,7 +1143,7 @@ mv_orphanage(
 	_("creation of .. entry failed (%d), filesystem may be out of space\n"),
 					err);
 
-			ino_p->i_d.di_nlink++;
+			inc_nlink(VFS_I(ino_p));
 			libxfs_trans_log_inode(tp, ino_p, XFS_ILOG_CORE);
 
 			err = -libxfs_bmap_finish(&tp, &flist, ino_p);
@@ -1176,7 +1176,7 @@ mv_orphanage(
 			if (irec)
 				add_inode_ref(irec, ino_offset);
 			else
-				orphanage_ip->i_d.di_nlink++;
+				inc_nlink(VFS_I(orphanage_ip));
 			libxfs_trans_log_inode(tp, orphanage_ip, XFS_ILOG_CORE);
 
 			/*
@@ -1229,7 +1229,7 @@ mv_orphanage(
 				ORPHANAGE, err);
 		ASSERT(err == 0);
 
-		ino_p->i_d.di_nlink = 1;
+		set_nlink(VFS_I(ino_p), 1);
 		libxfs_trans_log_inode(tp, ino_p, XFS_ILOG_CORE);
 
 		err = -libxfs_bmap_finish(&tp, &flist, ino_p);
diff --git a/repair/phase7.c b/repair/phase7.c
index 72a8ade..3e234b9 100644
--- a/repair/phase7.c
+++ b/repair/phase7.c
@@ -28,31 +28,6 @@
 #include "progress.h"
 #include "threads.h"
 
-/* dinoc is a pointer to the IN-CORE dinode core */
-static void
-set_nlinks(
-	struct xfs_icdinode	*dinoc,
-	xfs_ino_t		ino,
-	__uint32_t		nrefs,
-	int			*dirty)
-{
-	if (dinoc->di_nlink == nrefs)
-		return;
-
-	if (!no_modify) {
-		*dirty = 1;
-		do_warn(_("resetting inode %" PRIu64 " nlinks from %u to %u\n"),
-			ino, dinoc->di_nlink, nrefs);
-
-		ASSERT(dinoc->di_version > 1);
-		dinoc->di_nlink = nrefs;
-	} else  {
-		do_warn(
-_("would have reset inode %" PRIu64 " nlinks from %u to %u\n"),
-			ino, dinoc->di_nlink, nrefs);
-	}
-}
-
 static void
 update_inode_nlinks(
 	xfs_mount_t 		*mp,
@@ -88,10 +63,20 @@ update_inode_nlinks(
 
 	dirty = 0;
 
-	/*
-	 * compare and set links for all inodes
-	 */
-	set_nlinks(&ip->i_d, ino, nlinks, &dirty);
+	/* compare and set links if they differ.  */
+	if (VFS_I(ip)->i_nlink != nlinks) {
+		if (!no_modify) {
+			do_warn(
+	_("resetting inode %" PRIu64 " nlinks from %u to %u\n"),
+				ino, VFS_I(ip)->i_nlink, nlinks);
+			set_nlink(VFS_I(ip), nlinks);
+			dirty = 1;
+		} else {
+			do_warn(
+	_("would have reset inode %" PRIu64 " nlinks from %u to %u\n"),
+				ino, VFS_I(ip)->i_nlink, nlinks);
+		}
+	}
 
 	if (!dirty)  {
 		libxfs_trans_cancel(tp);
-- 
2.7.0

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

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

* [PATCH 13/15] xfs: move inode generation count to VFS inode
  2016-02-17  7:20 [PATCH 00/15] xfsprogs: libxfs kernel sync to 4.6-for-next Dave Chinner
                   ` (11 preceding siblings ...)
  2016-02-17  7:20 ` [PATCH 12/15] xfs: use vfs inode nlink field everywhere Dave Chinner
@ 2016-02-17  7:20 ` Dave Chinner
  2016-02-17  7:20 ` [PATCH 14/15] xfs: move di_changecount " Dave Chinner
                   ` (2 subsequent siblings)
  15 siblings, 0 replies; 28+ messages in thread
From: Dave Chinner @ 2016-02-17  7:20 UTC (permalink / raw)
  To: xfs

From: Dave Chinner <dchinner@redhat.com>

Source kernel commit 9e9a2674e43353f650ecd19a54eba028eafff82e

Pull another 4 bytes out of the xfs_icdinode.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dave Chinner <david@fromorbit.com>
---
 include/xfs_inode.h    | 1 +
 libxfs/util.c          | 5 +----
 libxfs/xfs_inode_buf.c | 8 ++++----
 libxfs/xfs_inode_buf.h | 1 -
 4 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/include/xfs_inode.h b/include/xfs_inode.h
index e7aa9e9..f7ad924 100644
--- a/include/xfs_inode.h
+++ b/include/xfs_inode.h
@@ -35,6 +35,7 @@ struct xfs_dir_ops;
  */
 struct inode {
 	uint32_t	i_nlink;
+	uint32_t	i_generation;
 	struct timespec	i_atime;
 	struct timespec	i_mtime;
 	struct timespec	i_ctime;
diff --git a/libxfs/util.c b/libxfs/util.c
index 9327a62..3263ae7 100644
--- a/libxfs/util.c
+++ b/libxfs/util.c
@@ -247,9 +247,6 @@ libxfs_ialloc(
 	ip->i_d.di_size = 0;
 	ip->i_d.di_nextents = 0;
 	ASSERT(ip->i_d.di_nblocks == 0);
-	/*
-	 * di_gen will have been taken care of in xfs_iread.
-	 */
 	ip->i_d.di_extsize = pip ? 0 : fsx->fsx_extsize;
 	ip->i_d.di_dmevmask = 0;
 	ip->i_d.di_dmstate = 0;
@@ -391,7 +388,7 @@ libxfs_iprint(
 	printf("   di_gid %d\n", dip->di_gid);
 	printf("   di_nextents %d\n", dip->di_nextents);
 	printf("   di_size %llu\n", (unsigned long long)dip->di_size);
-	printf("   di_gen %x\n", dip->di_gen);
+	printf("   di_gen %x\n", VFS_I(ip)->i_generation);
 	printf("   di_extsize %d\n", dip->di_extsize);
 	printf("   di_flags %x\n", dip->di_flags);
 	printf("   di_nblocks %llu\n", (unsigned long long)dip->di_nblocks);
diff --git a/libxfs/xfs_inode_buf.c b/libxfs/xfs_inode_buf.c
index dba8a4b..224edd3 100644
--- a/libxfs/xfs_inode_buf.c
+++ b/libxfs/xfs_inode_buf.c
@@ -246,6 +246,7 @@ xfs_inode_from_disk(
 	inode->i_mtime.tv_nsec = (int)be32_to_cpu(from->di_mtime.t_nsec);
 	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);
+	inode->i_generation = be32_to_cpu(from->di_gen);
 
 	to->di_size = be64_to_cpu(from->di_size);
 	to->di_nblocks = be64_to_cpu(from->di_nblocks);
@@ -257,7 +258,6 @@ xfs_inode_from_disk(
 	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);
-	to->di_gen	= be32_to_cpu(from->di_gen);
 
 	if (to->di_version == 3) {
 		to->di_changecount = be64_to_cpu(from->di_changecount);
@@ -295,6 +295,7 @@ xfs_inode_to_disk(
 	to->di_ctime.t_sec = cpu_to_be32(inode->i_ctime.tv_sec);
 	to->di_ctime.t_nsec = cpu_to_be32(inode->i_ctime.tv_nsec);
 	to->di_nlink = cpu_to_be32(inode->i_nlink);
+	to->di_gen = cpu_to_be32(inode->i_generation);
 
 	to->di_size = cpu_to_be64(from->di_size);
 	to->di_nblocks = cpu_to_be64(from->di_nblocks);
@@ -306,7 +307,6 @@ xfs_inode_to_disk(
 	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_gen = cpu_to_be32(from->di_gen);
 
 	if (from->di_version == 3) {
 		to->di_changecount = cpu_to_be64(from->di_changecount);
@@ -452,7 +452,7 @@ xfs_iread(
 	    !(mp->m_flags & XFS_MOUNT_IKEEP)) {
 		/* initialise the on-disk inode core */
 		memset(&ip->i_d, 0, sizeof(ip->i_d));
-		ip->i_d.di_gen = prandom_u32();
+		VFS_I(ip)->i_generation = prandom_u32();
 		if (xfs_sb_version_hascrc(&mp->m_sb))
 			ip->i_d.di_version = 3;
 		else
@@ -500,7 +500,7 @@ xfs_iread(
 		 * that xfs_ialloc won't overwrite or relies on being correct.
 		 */
 		ip->i_d.di_version = dip->di_version;
-		ip->i_d.di_gen = be32_to_cpu(dip->di_gen);
+		VFS_I(ip)->i_generation = be32_to_cpu(dip->di_gen);
 		ip->i_d.di_flushiter = be16_to_cpu(dip->di_flushiter);
 
 		/*
diff --git a/libxfs/xfs_inode_buf.h b/libxfs/xfs_inode_buf.h
index ccc4052..83ae8ed 100644
--- a/libxfs/xfs_inode_buf.h
+++ b/libxfs/xfs_inode_buf.h
@@ -46,7 +46,6 @@ 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_... */
-	__uint32_t	di_gen;		/* generation number */
 
 	__uint64_t	di_changecount;	/* number of attribute changes */
 	__uint64_t	di_flags2;	/* more random flags */
-- 
2.7.0

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

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

* [PATCH 14/15] xfs: move di_changecount to VFS inode
  2016-02-17  7:20 [PATCH 00/15] xfsprogs: libxfs kernel sync to 4.6-for-next Dave Chinner
                   ` (12 preceding siblings ...)
  2016-02-17  7:20 ` [PATCH 13/15] xfs: move inode generation count to VFS inode Dave Chinner
@ 2016-02-17  7:20 ` Dave Chinner
  2016-02-17  7:20 ` [PATCH 15/15] xfs: mode di_mode to vfs inode Dave Chinner
  2016-02-17  7:56 ` [PATCH 00/15] xfsprogs: libxfs kernel sync to 4.6-for-next Christoph Hellwig
  15 siblings, 0 replies; 28+ messages in thread
From: Dave Chinner @ 2016-02-17  7:20 UTC (permalink / raw)
  To: xfs

From: Dave Chinner <dchinner@redhat.com>

Source kernel commit 83e06f21b439b7b308eda06332a4feef35739e94

We can store the di_changecount in the i_version field of the VFS
inode and remove another 8 bytes from the xfs_icdinode.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dave Chinner <david@fromorbit.com>
---
 include/xfs_inode.h    | 1 +
 libxfs/util.c          | 4 ++--
 libxfs/xfs_inode_buf.c | 4 ++--
 libxfs/xfs_inode_buf.h | 1 -
 repair/phase6.c        | 6 +++---
 5 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/include/xfs_inode.h b/include/xfs_inode.h
index f7ad924..0290f97 100644
--- a/include/xfs_inode.h
+++ b/include/xfs_inode.h
@@ -36,6 +36,7 @@ struct xfs_dir_ops;
 struct inode {
 	uint32_t	i_nlink;
 	uint32_t	i_generation;
+	uint64_t	i_version;
 	struct timespec	i_atime;
 	struct timespec	i_mtime;
 	struct timespec	i_ctime;
diff --git a/libxfs/util.c b/libxfs/util.c
index 3263ae7..9c2f1d2 100644
--- a/libxfs/util.c
+++ b/libxfs/util.c
@@ -255,7 +255,7 @@ libxfs_ialloc(
 	if (ip->i_d.di_version == 3) {
 		ASSERT(ip->i_d.di_ino == ino);
 		ASSERT(uuid_equal(&ip->i_d.di_uuid, &mp->m_sb.sb_meta_uuid));
-		ip->i_d.di_changecount = 1;
+		VFS_I(ip)->i_version = 1;
 		ip->i_d.di_flags2 = 0;
 		ip->i_d.di_crtime.t_sec = (__int32_t)VFS_I(ip)->i_mtime.tv_sec;
 		ip->i_d.di_crtime.t_nsec = (__int32_t)VFS_I(ip)->i_mtime.tv_nsec;
@@ -431,7 +431,7 @@ libxfs_iflush_int(xfs_inode_t *ip, xfs_buf_t *bp)
 
 	/* bump the change count on v3 inodes */
 	if (ip->i_d.di_version == 3)
-		ip->i_d.di_changecount++;
+		VFS_I(ip)->i_version++;
 
 	/*
 	 * Copy the dirty parts of the inode into the on-disk
diff --git a/libxfs/xfs_inode_buf.c b/libxfs/xfs_inode_buf.c
index 224edd3..da9edcd 100644
--- a/libxfs/xfs_inode_buf.c
+++ b/libxfs/xfs_inode_buf.c
@@ -260,7 +260,7 @@ xfs_inode_from_disk(
 	to->di_flags	= be16_to_cpu(from->di_flags);
 
 	if (to->di_version == 3) {
-		to->di_changecount = be64_to_cpu(from->di_changecount);
+		inode->i_version = be64_to_cpu(from->di_changecount);
 		to->di_crtime.t_sec = be32_to_cpu(from->di_crtime.t_sec);
 		to->di_crtime.t_nsec = be32_to_cpu(from->di_crtime.t_nsec);
 		to->di_flags2 = be64_to_cpu(from->di_flags2);
@@ -309,7 +309,7 @@ xfs_inode_to_disk(
 	to->di_flags = cpu_to_be16(from->di_flags);
 
 	if (from->di_version == 3) {
-		to->di_changecount = cpu_to_be64(from->di_changecount);
+		to->di_changecount = cpu_to_be64(inode->i_version);
 		to->di_crtime.t_sec = cpu_to_be32(from->di_crtime.t_sec);
 		to->di_crtime.t_nsec = cpu_to_be32(from->di_crtime.t_nsec);
 		to->di_flags2 = cpu_to_be64(from->di_flags2);
diff --git a/libxfs/xfs_inode_buf.h b/libxfs/xfs_inode_buf.h
index 83ae8ed..ad98fdd 100644
--- a/libxfs/xfs_inode_buf.h
+++ b/libxfs/xfs_inode_buf.h
@@ -47,7 +47,6 @@ struct xfs_icdinode {
 	__uint16_t	di_dmstate;	/* DMIG state info */
 	__uint16_t	di_flags;	/* random flags, XFS_DIFLAG_... */
 
-	__uint64_t	di_changecount;	/* number of attribute changes */
 	__uint64_t	di_flags2;	/* more random flags */
 
 	xfs_ictimestamp_t di_crtime;	/* time created */
diff --git a/repair/phase6.c b/repair/phase6.c
index 7e14346..7415199 100644
--- a/repair/phase6.c
+++ b/repair/phase6.c
@@ -519,7 +519,7 @@ mk_rbmino(xfs_mount_t *mp)
 
 	times = XFS_ICHGTIME_CHG | XFS_ICHGTIME_MOD;
 	if (ip->i_d.di_version == 3) {
-		ip->i_d.di_changecount = 1;
+		VFS_I(ip)->i_version = 1;
 		ip->i_d.di_flags2 = 0;
 		times |= XFS_ICHGTIME_CREATE;
 	}
@@ -772,7 +772,7 @@ mk_rsumino(xfs_mount_t *mp)
 
 	times = XFS_ICHGTIME_CHG | XFS_ICHGTIME_MOD;
 	if (ip->i_d.di_version == 3) {
-		ip->i_d.di_changecount = 1;
+		VFS_I(ip)->i_version = 1;
 		ip->i_d.di_flags2 = 0;
 		times |= XFS_ICHGTIME_CREATE;
 	}
@@ -881,7 +881,7 @@ mk_root_dir(xfs_mount_t *mp)
 
 	times = XFS_ICHGTIME_CHG | XFS_ICHGTIME_MOD;
 	if (ip->i_d.di_version == 3) {
-		ip->i_d.di_changecount = 1;
+		VFS_I(ip)->i_version = 1;
 		ip->i_d.di_flags2 = 0;
 		times |= XFS_ICHGTIME_CREATE;
 	}
-- 
2.7.0

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

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

* [PATCH 15/15] xfs: mode di_mode to vfs inode
  2016-02-17  7:20 [PATCH 00/15] xfsprogs: libxfs kernel sync to 4.6-for-next Dave Chinner
                   ` (13 preceding siblings ...)
  2016-02-17  7:20 ` [PATCH 14/15] xfs: move di_changecount " Dave Chinner
@ 2016-02-17  7:20 ` Dave Chinner
  2016-02-17  7:56 ` [PATCH 00/15] xfsprogs: libxfs kernel sync to 4.6-for-next Christoph Hellwig
  15 siblings, 0 replies; 28+ messages in thread
From: Dave Chinner @ 2016-02-17  7:20 UTC (permalink / raw)
  To: xfs

From: Dave Chinner <dchinner@redhat.com>

Source kernel commit c19b3b05ae440de50fffe2ac2a9b27392a7448e9

Move the di_mode value from the xfs_icdinode to the VFS inode, reducing
the xfs_icdinode byte another 2 bytes and collapsing another 2 byte hole
in the structure.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dave Chinner <david@fromorbit.com>
---
 db/check.c              | 18 ++++++++++--------
 include/xfs_inode.h     | 16 +++++++++++++++-
 libxfs/rdwr.c           |  4 ++--
 libxfs/util.c           | 17 ++++++++---------
 libxfs/xfs_bmap.c       |  6 +++---
 libxfs/xfs_dir2.c       | 12 ++++++------
 libxfs/xfs_inode_buf.c  |  8 ++++----
 libxfs/xfs_inode_buf.h  |  1 -
 libxfs/xfs_inode_fork.c |  2 +-
 mkfs/proto.c            |  6 +++---
 repair/phase6.c         |  8 ++++----
 11 files changed, 56 insertions(+), 42 deletions(-)

diff --git a/db/check.c b/db/check.c
index 412ab3d..36a0f64 100644
--- a/db/check.c
+++ b/db/check.c
@@ -2636,6 +2636,7 @@ process_inode(
 	xfs_qcnt_t		rc = 0;
 	xfs_dqid_t		dqprid;
 	int			v = 0;
+	mode_t			mode;
 	static char		okfmts[] = {
 		0,				/* type 0 unused */
 		1 << XFS_DINODE_FMT_DEV,	/* FIFO */
@@ -2699,10 +2700,10 @@ process_inode(
 					be32_to_cpu(dip->di_nlink), ino);
 			error++;
 		}
-		if (xino.i_d.di_mode != 0) {
+		if (dip->di_mode != 0) {
 			if (v)
 				dbprintf(_("bad mode %#o for free inode %lld\n"),
-					xino.i_d.di_mode, ino);
+					be16_to_cpu(dip->di_mode), ino);
 			error++;
 		}
 		return;
@@ -2717,11 +2718,12 @@ process_inode(
 	/*
 	 * di_mode is a 16-bit uint so no need to check the < 0 case
 	 */
-	if ((((xino.i_d.di_mode & S_IFMT) >> 12) > 15) ||
-	    (!(okfmts[(xino.i_d.di_mode & S_IFMT) >> 12] & (1 << xino.i_d.di_format)))) {
+	mode = be16_to_cpu(dip->di_mode);
+	if ((((mode & S_IFMT) >> 12) > 15) ||
+	    (!(okfmts[(mode & S_IFMT) >> 12] & (1 << xino.i_d.di_format)))) {
 		if (v)
 			dbprintf(_("bad format %d for inode %lld type %#o\n"),
-				xino.i_d.di_format, id->ino, xino.i_d.di_mode & S_IFMT);
+				xino.i_d.di_format, id->ino, mode & S_IFMT);
 		error++;
 		return;
 	}
@@ -2744,7 +2746,7 @@ process_inode(
 		dbprintf(_("inode %lld mode %#o fmt %s "
 			 "afmt %s "
 			 "nex %d anex %d nblk %lld sz %lld%s%s%s%s%s%s%s\n"),
-			id->ino, xino.i_d.di_mode, fmtnames[(int)xino.i_d.di_format],
+			id->ino, mode, fmtnames[(int)xino.i_d.di_format],
 			fmtnames[(int)xino.i_d.di_aformat],
 			xino.i_d.di_nextents,
 			xino.i_d.di_anextents,
@@ -2757,7 +2759,7 @@ process_inode(
 			xino.i_d.di_flags & XFS_DIFLAG_NOATIME  ? " noa" : "",
 			xino.i_d.di_flags & XFS_DIFLAG_NODUMP   ? " nod" : "");
 	security = 0;
-	switch (xino.i_d.di_mode & S_IFMT) {
+	switch (mode & S_IFMT) {
 	case S_IFDIR:
 		type = DBM_DIR;
 		if (xino.i_d.di_format == XFS_DINODE_FMT_LOCAL)
@@ -2785,7 +2787,7 @@ process_inode(
 		}
 		else
 			type = DBM_DATA;
-		if (xino.i_d.di_mode & (S_ISUID | S_ISGID))
+		if (mode & (S_ISUID | S_ISGID))
 			security = 1;
 		break;
 	case S_IFLNK:
diff --git a/include/xfs_inode.h b/include/xfs_inode.h
index 0290f97..d6990e5 100644
--- a/include/xfs_inode.h
+++ b/include/xfs_inode.h
@@ -34,6 +34,7 @@ struct xfs_dir_ops;
  * metadata.
  */
 struct inode {
+	mode_t		i_mode;
 	uint32_t	i_nlink;
 	uint32_t	i_generation;
 	uint64_t	i_version;
@@ -65,13 +66,26 @@ static inline struct inode *VFS_I(struct xfs_inode *ip)
 }
 
 /*
+ * wrappers around the mode checks to simplify code
+ */
+static inline bool XFS_ISREG(struct xfs_inode *ip)
+{
+	return S_ISREG(VFS_I(ip)->i_mode);
+}
+
+static inline bool XFS_ISDIR(struct xfs_inode *ip)
+{
+	return S_ISDIR(VFS_I(ip)->i_mode);
+}
+
+/*
  * For regular files we only update the on-disk filesize when actually
  * writing data back to disk.  Until then only the copy in the VFS inode
  * is uptodate.
  */
 static inline xfs_fsize_t XFS_ISIZE(struct xfs_inode *ip)
 {
-	if (S_ISREG(ip->i_d.di_mode))
+	if (XFS_ISREG(ip))
 		return ip->i_size;
 	return ip->i_d.di_size;
 }
diff --git a/libxfs/rdwr.c b/libxfs/rdwr.c
index 3522c26..0ec38c5 100644
--- a/libxfs/rdwr.c
+++ b/libxfs/rdwr.c
@@ -1351,7 +1351,7 @@ libxfs_iget(xfs_mount_t *mp, xfs_trans_t *tp, xfs_ino_t ino, uint lock_flags,
 	/*
 	 * set up the inode ops structure that the libxfs code relies on
 	 */
-	if (S_ISDIR(ip->i_d.di_mode))
+	if (XFS_ISDIR(ip))
 		ip->d_ops = mp->m_dir_inode_ops;
 	else
 		ip->d_ops = mp->m_nondir_inode_ops;
@@ -1363,7 +1363,7 @@ libxfs_iget(xfs_mount_t *mp, xfs_trans_t *tp, xfs_ino_t ino, uint lock_flags,
 static void
 libxfs_idestroy(xfs_inode_t *ip)
 {
-	switch (ip->i_d.di_mode & S_IFMT) {
+	switch (VFS_I(ip)->i_mode & S_IFMT) {
 		case S_IFREG:
 		case S_IFDIR:
 		case S_IFLNK:
diff --git a/libxfs/util.c b/libxfs/util.c
index 9c2f1d2..576f954 100644
--- a/libxfs/util.c
+++ b/libxfs/util.c
@@ -217,7 +217,7 @@ libxfs_ialloc(
 		return error;
 	ASSERT(ip != NULL);
 
-	ip->i_d.di_mode = (__uint16_t)mode;
+	VFS_I(ip)->i_mode = mode;
 	set_nlink(VFS_I(ip), nlink);
 	ip->i_d.di_uid = cr->cr_uid;
 	ip->i_d.di_gid = cr->cr_gid;
@@ -238,10 +238,10 @@ libxfs_ialloc(
 		 */
 	}
 
-	if (pip && (pip->i_d.di_mode & S_ISGID)) {
+	if (pip && (VFS_I(pip)->i_mode & S_ISGID)) {
 		ip->i_d.di_gid = pip->i_d.di_gid;
-		if ((pip->i_d.di_mode & S_ISGID) && (mode & S_IFMT) == S_IFDIR)
-			ip->i_d.di_mode |= S_ISGID;
+		if ((VFS_I(pip)->i_mode & S_ISGID) && (mode & S_IFMT) == S_IFDIR)
+			VFS_I(ip)->i_mode |= S_ISGID;
 	}
 
 	ip->i_d.di_size = 0;
@@ -316,7 +316,7 @@ libxfs_ialloc(
 	/*
 	 * set up the inode ops structure that the libxfs code relies on
 	 */
-	if (S_ISDIR(ip->i_d.di_mode))
+	if (XFS_ISDIR(ip))
 		ip->d_ops = ip->i_mount->m_dir_inode_ops;
 	else
 		ip->d_ops = ip->i_mount->m_nondir_inode_ops;
@@ -367,7 +367,7 @@ libxfs_iprint(
 
 	dip = &ip->i_d;
 	printf("\nOn disk portion\n");
-	printf("    di_mode %o\n", dip->di_mode);
+	printf("    di_mode %o\n", VFS_I(ip)->i_mode);
 	printf("    di_version %x\n", (uint)dip->di_version);
 	switch (ip->i_d.di_format) {
 	case XFS_DINODE_FMT_LOCAL:
@@ -417,11 +417,10 @@ libxfs_iflush_int(xfs_inode_t *ip, xfs_buf_t *bp)
 	dip = xfs_buf_offset(bp, ip->i_imap.im_boffset);
 
 	ASSERT(ip->i_d.di_magic == XFS_DINODE_MAGIC);
-	if ((ip->i_d.di_mode & S_IFMT) == S_IFREG) {
+	if (XFS_ISREG(ip)) {
 		ASSERT( (ip->i_d.di_format == XFS_DINODE_FMT_EXTENTS) ||
 			(ip->i_d.di_format == XFS_DINODE_FMT_BTREE) );
-	}
-	else if ((ip->i_d.di_mode & S_IFMT) == S_IFDIR) {
+	} else if (XFS_ISDIR(ip) == S_IFDIR) {
 		ASSERT( (ip->i_d.di_format == XFS_DINODE_FMT_EXTENTS) ||
 			(ip->i_d.di_format == XFS_DINODE_FMT_BTREE)   ||
 			(ip->i_d.di_format == XFS_DINODE_FMT_LOCAL) );
diff --git a/libxfs/xfs_bmap.c b/libxfs/xfs_bmap.c
index 8cb89bc..40286e4 100644
--- a/libxfs/xfs_bmap.c
+++ b/libxfs/xfs_bmap.c
@@ -904,7 +904,7 @@ xfs_bmap_local_to_extents(
 	 * We don't want to deal with the case of keeping inode data inline yet.
 	 * So sending the data fork of a regular inode is invalid.
 	 */
-	ASSERT(!(S_ISREG(ip->i_d.di_mode) && whichfork == XFS_DATA_FORK));
+	ASSERT(!(S_ISREG(VFS_I(ip)->i_mode) && whichfork == XFS_DATA_FORK));
 	ifp = XFS_IFORK_PTR(ip, whichfork);
 	ASSERT(XFS_IFORK_FORMAT(ip, whichfork) == XFS_DINODE_FMT_LOCAL);
 
@@ -1071,7 +1071,7 @@ xfs_bmap_add_attrfork_local(
 	if (ip->i_df.if_bytes <= XFS_IFORK_DSIZE(ip))
 		return 0;
 
-	if (S_ISDIR(ip->i_d.di_mode)) {
+	if (S_ISDIR(VFS_I(ip)->i_mode)) {
 		memset(&dargs, 0, sizeof(dargs));
 		dargs.geo = ip->i_mount->m_dir_geo;
 		dargs.dp = ip;
@@ -1083,7 +1083,7 @@ xfs_bmap_add_attrfork_local(
 		return xfs_dir2_sf_to_block(&dargs);
 	}
 
-	if (S_ISLNK(ip->i_d.di_mode))
+	if (S_ISLNK(VFS_I(ip)->i_mode))
 		return xfs_bmap_local_to_extents(tp, ip, firstblock, 1,
 						 flags, XFS_DATA_FORK,
 						 xfs_symlink_local_to_remote);
diff --git a/libxfs/xfs_dir2.c b/libxfs/xfs_dir2.c
index 89b4781..723b267 100644
--- a/libxfs/xfs_dir2.c
+++ b/libxfs/xfs_dir2.c
@@ -174,7 +174,7 @@ xfs_dir_isempty(
 {
 	xfs_dir2_sf_hdr_t	*sfp;
 
-	ASSERT(S_ISDIR(dp->i_d.di_mode));
+	ASSERT(S_ISDIR(VFS_I(dp)->i_mode));
 	if (dp->i_d.di_size == 0)	/* might happen during shutdown. */
 		return 1;
 	if (dp->i_d.di_size > XFS_IFORK_DSIZE(dp))
@@ -229,7 +229,7 @@ xfs_dir_init(
 	struct xfs_da_args *args;
 	int		error;
 
-	ASSERT(S_ISDIR(dp->i_d.di_mode));
+	ASSERT(S_ISDIR(VFS_I(dp)->i_mode));
 	error = xfs_dir_ino_validate(tp->t_mountp, pdp->i_ino);
 	if (error)
 		return error;
@@ -264,7 +264,7 @@ xfs_dir_createname(
 	int			rval;
 	int			v;		/* type-checking value */
 
-	ASSERT(S_ISDIR(dp->i_d.di_mode));
+	ASSERT(S_ISDIR(VFS_I(dp)->i_mode));
 	if (inum) {
 		rval = xfs_dir_ino_validate(tp->t_mountp, inum);
 		if (rval)
@@ -362,7 +362,7 @@ xfs_dir_lookup(
 	int		v;		/* type-checking value */
 	int		lock_mode;
 
-	ASSERT(S_ISDIR(dp->i_d.di_mode));
+	ASSERT(S_ISDIR(VFS_I(dp)->i_mode));
 	XFS_STATS_INC(dp->i_mount, xs_dir_lookup);
 
 	/*
@@ -441,7 +441,7 @@ xfs_dir_removename(
 	int		rval;
 	int		v;		/* type-checking value */
 
-	ASSERT(S_ISDIR(dp->i_d.di_mode));
+	ASSERT(S_ISDIR(VFS_I(dp)->i_mode));
 	XFS_STATS_INC(dp->i_mount, xs_dir_remove);
 
 	args = kmem_zalloc(sizeof(*args), KM_SLEEP | KM_NOFS);
@@ -503,7 +503,7 @@ xfs_dir_replace(
 	int		rval;
 	int		v;		/* type-checking value */
 
-	ASSERT(S_ISDIR(dp->i_d.di_mode));
+	ASSERT(S_ISDIR(VFS_I(dp)->i_mode));
 
 	rval = xfs_dir_ino_validate(tp->t_mountp, inum);
 	if (rval)
diff --git a/libxfs/xfs_inode_buf.c b/libxfs/xfs_inode_buf.c
index da9edcd..e3d674d 100644
--- a/libxfs/xfs_inode_buf.c
+++ b/libxfs/xfs_inode_buf.c
@@ -211,13 +211,12 @@ xfs_inode_from_disk(
 	struct xfs_icdinode	*to = &ip->i_d;
 	struct inode		*inode = VFS_I(ip);
 
-	to->di_mode = be16_to_cpu(from->di_mode);
-	to->di_version = from ->di_version;
 
 	/*
 	 * Convert v1 inodes immediately to v2 inode format as this is the
 	 * minimum inode version format we support in the rest of the code.
 	 */
+	to->di_version = from->di_version;
 	if (to->di_version == 1) {
 		set_nlink(inode, be16_to_cpu(from->di_onlink));
 		to->di_projid_lo = 0;
@@ -247,6 +246,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);
 	inode->i_generation = be32_to_cpu(from->di_gen);
+	inode->i_mode = be16_to_cpu(from->di_mode);
 
 	to->di_size = be64_to_cpu(from->di_size);
 	to->di_nblocks = be64_to_cpu(from->di_nblocks);
@@ -279,7 +279,6 @@ xfs_inode_to_disk(
 	to->di_magic = cpu_to_be16(XFS_DINODE_MAGIC);
 	to->di_onlink = 0;
 
-	to->di_mode = cpu_to_be16(from->di_mode);
 	to->di_version = from->di_version;
 	to->di_format = from->di_format;
 	to->di_uid = cpu_to_be32(from->di_uid);
@@ -296,6 +295,7 @@ xfs_inode_to_disk(
 	to->di_ctime.t_nsec = cpu_to_be32(inode->i_ctime.tv_nsec);
 	to->di_nlink = cpu_to_be32(inode->i_nlink);
 	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_nblocks = cpu_to_be64(from->di_nblocks);
@@ -510,7 +510,7 @@ xfs_iread(
 		 * the inode is already free and not try to mess
 		 * with the uninitialized part of it.
 		 */
-		ip->i_d.di_mode = 0;
+		VFS_I(ip)->i_mode = 0;
 	}
 
 	ASSERT(ip->i_d.di_version >= 2);
diff --git a/libxfs/xfs_inode_buf.h b/libxfs/xfs_inode_buf.h
index ad98fdd..4ece9bf 100644
--- a/libxfs/xfs_inode_buf.h
+++ b/libxfs/xfs_inode_buf.h
@@ -28,7 +28,6 @@ struct xfs_dinode;
  * format specific structures at the appropriate time.
  */
 struct xfs_icdinode {
-	__uint16_t	di_mode;	/* mode and type of file */
 	__int8_t	di_version;	/* inode version */
 	__int8_t	di_format;	/* format of di_c data */
 	__uint16_t	di_flushiter;	/* incremented on flush */
diff --git a/libxfs/xfs_inode_fork.c b/libxfs/xfs_inode_fork.c
index f40649e..2af1dba 100644
--- a/libxfs/xfs_inode_fork.c
+++ b/libxfs/xfs_inode_fork.c
@@ -117,7 +117,7 @@ xfs_iformat_fork(
 		return -EFSCORRUPTED;
 	}
 
-	switch (ip->i_d.di_mode & S_IFMT) {
+	switch (VFS_I(ip)->i_mode & S_IFMT) {
 	case S_IFIFO:
 	case S_IFCHR:
 	case S_IFBLK:
diff --git a/mkfs/proto.c b/mkfs/proto.c
index 9550859..4fc1f3c 100644
--- a/mkfs/proto.c
+++ b/mkfs/proto.c
@@ -198,7 +198,7 @@ rsvfile(
 
 	libxfs_trans_ijoin(tp, ip, 0);
 
-	ip->i_d.di_mode &= ~S_ISUID;
+	VFS_I(ip)->i_mode &= ~S_ISUID;
 
 	/*
 	 * Note that we don't have to worry about mandatory
@@ -207,8 +207,8 @@ rsvfile(
 	 * on, but if it was on then mandatory locking wouldn't
 	 * have been enabled.
 	 */
-	if (ip->i_d.di_mode & S_IXGRP)
-		ip->i_d.di_mode &= ~S_ISGID;
+	if (VFS_I(ip)->i_mode & S_IXGRP)
+		VFS_I(ip)->i_mode &= ~S_ISGID;
 
 	libxfs_trans_ichgtime(tp, ip, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG);
 
diff --git a/repair/phase6.c b/repair/phase6.c
index 7415199..0a71164 100644
--- a/repair/phase6.c
+++ b/repair/phase6.c
@@ -510,7 +510,7 @@ mk_rbmino(xfs_mount_t *mp)
 	vers = xfs_sb_version_hascrc(&mp->m_sb) ? 3 : 2;
 	memset(&ip->i_d, 0, sizeof(ip->i_d));
 
-	ip->i_d.di_mode = S_IFREG;
+	VFS_I(ip)->i_mode = S_IFREG;
 	ip->i_d.di_version = vers;
 	ip->i_d.di_format = XFS_DINODE_FMT_EXTENTS;
 	ip->i_d.di_aformat = XFS_DINODE_FMT_EXTENTS;
@@ -763,7 +763,7 @@ mk_rsumino(xfs_mount_t *mp)
 	vers = xfs_sb_version_hascrc(&mp->m_sb) ? 3 : 1;
 	memset(&ip->i_d, 0, sizeof(ip->i_d));
 
-	ip->i_d.di_mode = S_IFREG;
+	VFS_I(ip)->i_mode = S_IFREG;
 	ip->i_d.di_version = vers;
 	ip->i_d.di_format = XFS_DINODE_FMT_EXTENTS;
 	ip->i_d.di_aformat = XFS_DINODE_FMT_EXTENTS;
@@ -872,7 +872,7 @@ mk_root_dir(xfs_mount_t *mp)
 	vers = xfs_sb_version_hascrc(&mp->m_sb) ? 3 : 2;
 	memset(&ip->i_d, 0, sizeof(ip->i_d));
 
-	ip->i_d.di_mode = (__uint16_t) mode|S_IFDIR;
+	VFS_I(ip)->i_mode = mode|S_IFDIR;
 	ip->i_d.di_version = vers;
 	ip->i_d.di_format = XFS_DINODE_FMT_EXTENTS;
 	ip->i_d.di_aformat = XFS_DINODE_FMT_EXTENTS;
@@ -1097,7 +1097,7 @@ mv_orphanage(
 	if ((err = -libxfs_iget(mp, NULL, ino, 0, &ino_p, 0)))
 		do_error(_("%d - couldn't iget disconnected inode\n"), err);
 
-	xname.type = xfs_mode_to_ftype[(ino_p->i_d.di_mode & S_IFMT)>>S_SHIFT];
+	xname.type = xfs_mode_to_ftype[(VFS_I(ino_p)->i_mode & S_IFMT)>>S_SHIFT];
 
 	if (isa_dir)  {
 		irec = find_inode_rec(mp, XFS_INO_TO_AGNO(mp, orphanage_ino),
-- 
2.7.0

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

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

* Re: [PATCH 01/15] xfs: wire up Q_XGETNEXTQUOTA / get_nextdqblk
  2016-02-17  7:20 ` [PATCH 01/15] xfs: wire up Q_XGETNEXTQUOTA / get_nextdqblk Dave Chinner
@ 2016-02-17  7:25   ` Christoph Hellwig
  0 siblings, 0 replies; 28+ messages in thread
From: Christoph Hellwig @ 2016-02-17  7:25 UTC (permalink / raw)
  To: Dave Chinner; +Cc: xfs

Looks fine,

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

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

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

* Re: [PATCH 11/15] xfs: move v1 inode conversion to xfs_inode_from_disk
  2016-02-17  7:20 ` [PATCH 11/15] xfs: move v1 inode conversion to xfs_inode_from_disk Dave Chinner
@ 2016-02-17  7:32   ` Christoph Hellwig
  2016-02-17  7:48     ` Dave Chinner
  0 siblings, 1 reply; 28+ messages in thread
From: Christoph Hellwig @ 2016-02-17  7:32 UTC (permalink / raw)
  To: Dave Chinner; +Cc: xfs

On Wed, Feb 17, 2016 at 06:20:48PM +1100, Dave Chinner wrote:
> +
> +	sbversion |= XFS_SB_VERSION_NLINKBIT;
> +	setlink_inode(id, be32_to_cpu(dip->di_nlink), type == DBM_DIR, security);
> +

So we always convert to v2 inodes here.  Given that's it's xfs_check
it's only in-core so harmless, but a comment here might be useful.

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

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

* Re: [PATCH 12/15] xfs: use vfs inode nlink field everywhere
  2016-02-17  7:20 ` [PATCH 12/15] xfs: use vfs inode nlink field everywhere Dave Chinner
@ 2016-02-17  7:35   ` Christoph Hellwig
  2016-02-17  7:49     ` Dave Chinner
  0 siblings, 1 reply; 28+ messages in thread
From: Christoph Hellwig @ 2016-02-17  7:35 UTC (permalink / raw)
  To: Dave Chinner; +Cc: xfs

> index 685c7a7..1408be3 100644
> --- a/libxfs/libxfs_api_defs.h
> +++ b/libxfs/libxfs_api_defs.h
> @@ -108,4 +108,8 @@
>  
>  #define xfs_verify_cksum		libxfs_verify_cksum
>  
> +/* inode link counts */
> +#define set_nlink(inode, nlink)	({ (inode)->i_nlink = (nlink); })
> +#define inc_nlink(inode)	(inode)->i_nlink++

Can we defines these as inlines?

> +		ip->i_vnode.i_nlink++;		/* account for . */

Shouldn't we use VFS_I() like everywhere else?

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

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

* Re: [PATCH 11/15] xfs: move v1 inode conversion to xfs_inode_from_disk
  2016-02-17  7:32   ` Christoph Hellwig
@ 2016-02-17  7:48     ` Dave Chinner
  2016-02-17  8:30       ` Dave Chinner
  0 siblings, 1 reply; 28+ messages in thread
From: Dave Chinner @ 2016-02-17  7:48 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: xfs

On Tue, Feb 16, 2016 at 11:32:04PM -0800, Christoph Hellwig wrote:
> On Wed, Feb 17, 2016 at 06:20:48PM +1100, Dave Chinner wrote:
> > +
> > +	sbversion |= XFS_SB_VERSION_NLINKBIT;
> > +	setlink_inode(id, be32_to_cpu(dip->di_nlink), type == DBM_DIR, security);
> > +
> 
> So we always convert to v2 inodes here.  Given that's it's xfs_check
> it's only in-core so harmless, but a comment here might be useful.

Yeah, probably. I'll have to look at this a bit closer - I think I
assumed that we're always going to have v2 inode format here (like
we do in the kernel), but that may not be true. I'll have a closer
look.

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

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

* Re: [PATCH 12/15] xfs: use vfs inode nlink field everywhere
  2016-02-17  7:35   ` Christoph Hellwig
@ 2016-02-17  7:49     ` Dave Chinner
  0 siblings, 0 replies; 28+ messages in thread
From: Dave Chinner @ 2016-02-17  7:49 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: xfs

On Tue, Feb 16, 2016 at 11:35:06PM -0800, Christoph Hellwig wrote:
> > index 685c7a7..1408be3 100644
> > --- a/libxfs/libxfs_api_defs.h
> > +++ b/libxfs/libxfs_api_defs.h
> > @@ -108,4 +108,8 @@
> >  
> >  #define xfs_verify_cksum		libxfs_verify_cksum
> >  
> > +/* inode link counts */
> > +#define set_nlink(inode, nlink)	({ (inode)->i_nlink = (nlink); })
> > +#define inc_nlink(inode)	(inode)->i_nlink++
> 
> Can we defines these as inlines?

I'll probably have to move them somewhere else for that.
include/xfs_inode.h will probably work.

> 
> > +		ip->i_vnode.i_nlink++;		/* account for . */
> 
> Shouldn't we use VFS_I() like everywhere else?

inc_nlink(), too. I forgot to go back and change it when I decided
on adding the wrapper.

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

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

* Re: [PATCH 00/15] xfsprogs: libxfs kernel sync to 4.6-for-next
  2016-02-17  7:20 [PATCH 00/15] xfsprogs: libxfs kernel sync to 4.6-for-next Dave Chinner
                   ` (14 preceding siblings ...)
  2016-02-17  7:20 ` [PATCH 15/15] xfs: mode di_mode to vfs inode Dave Chinner
@ 2016-02-17  7:56 ` Christoph Hellwig
  2016-02-17  8:16   ` Dave Chinner
  15 siblings, 1 reply; 28+ messages in thread
From: Christoph Hellwig @ 2016-02-17  7:56 UTC (permalink / raw)
  To: Dave Chinner; +Cc: xfs

The series looks fine modulo the nitpicks I posted.

But shouldn't the rtinode fixes go into 4.5 as clear bugfixes?

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

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

* Re: [PATCH 00/15] xfsprogs: libxfs kernel sync to 4.6-for-next
  2016-02-17  7:56 ` [PATCH 00/15] xfsprogs: libxfs kernel sync to 4.6-for-next Christoph Hellwig
@ 2016-02-17  8:16   ` Dave Chinner
  0 siblings, 0 replies; 28+ messages in thread
From: Dave Chinner @ 2016-02-17  8:16 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: xfs

On Tue, Feb 16, 2016 at 11:56:14PM -0800, Christoph Hellwig wrote:
> The series looks fine modulo the nitpicks I posted.
> 
> But shouldn't the rtinode fixes go into 4.5 as clear bugfixes?

None of the changes in those two patches actually affect userspace.
These first is a log recovery fix, and the second was to silence a
warning in kernel IO submission which doesn't exist in userspace.

So apart from syncing up the code, AFAICT there isn't a compelling
reason to pull them back into 4.5.

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

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

* Re: [PATCH 11/15] xfs: move v1 inode conversion to xfs_inode_from_disk
  2016-02-17  7:48     ` Dave Chinner
@ 2016-02-17  8:30       ` Dave Chinner
  2016-02-17  8:33         ` Christoph Hellwig
  0 siblings, 1 reply; 28+ messages in thread
From: Dave Chinner @ 2016-02-17  8:30 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: xfs

On Wed, Feb 17, 2016 at 06:48:21PM +1100, Dave Chinner wrote:
> On Tue, Feb 16, 2016 at 11:32:04PM -0800, Christoph Hellwig wrote:
> > On Wed, Feb 17, 2016 at 06:20:48PM +1100, Dave Chinner wrote:
> > > +
> > > +	sbversion |= XFS_SB_VERSION_NLINKBIT;
> > > +	setlink_inode(id, be32_to_cpu(dip->di_nlink), type == DBM_DIR, security);
> > > +
> > 
> > So we always convert to v2 inodes here.  Given that's it's xfs_check
> > it's only in-core so harmless, but a comment here might be useful.
> 
> Yeah, probably. I'll have to look at this a bit closer - I think I
> assumed that we're always going to have v2 inode format here (like
> we do in the kernel), but that may not be true. I'll have a closer
> look.

having a closer look, the XFS_SB_VERSION_NLINKBIT that is set here
in sbversion is never used, so I just removed it. I also changed it
back to using the converted in-memory link count so it's always
going to be correct now. Now it is just:

+       setlink_inode(id, xino.i_d.di_nlink, type == DBM_DIR, security);

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

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

* Re: [PATCH 11/15] xfs: move v1 inode conversion to xfs_inode_from_disk
  2016-02-17  8:30       ` Dave Chinner
@ 2016-02-17  8:33         ` Christoph Hellwig
  2016-02-17  9:30           ` Dave Chinner
  0 siblings, 1 reply; 28+ messages in thread
From: Christoph Hellwig @ 2016-02-17  8:33 UTC (permalink / raw)
  To: Dave Chinner; +Cc: Christoph Hellwig, xfs

On Wed, Feb 17, 2016 at 07:30:00PM +1100, Dave Chinner wrote:
> > Yeah, probably. I'll have to look at this a bit closer - I think I
> > assumed that we're always going to have v2 inode format here (like
> > we do in the kernel), but that may not be true. I'll have a closer
> > look.
> 
> having a closer look, the XFS_SB_VERSION_NLINKBIT that is set here
> in sbversion is never used, so I just removed it. I also changed it
> back to using the converted in-memory link count so it's always
> going to be correct now. Now it is just:
> 
> +       setlink_inode(id, xino.i_d.di_nlink, type == DBM_DIR, security);

Great.  With that and the other nitpicks address:

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

for the whole series.

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

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

* Re: [PATCH 11/15] xfs: move v1 inode conversion to xfs_inode_from_disk
  2016-02-17  8:33         ` Christoph Hellwig
@ 2016-02-17  9:30           ` Dave Chinner
  0 siblings, 0 replies; 28+ messages in thread
From: Dave Chinner @ 2016-02-17  9:30 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: xfs

On Wed, Feb 17, 2016 at 12:33:08AM -0800, Christoph Hellwig wrote:
> On Wed, Feb 17, 2016 at 07:30:00PM +1100, Dave Chinner wrote:
> > > Yeah, probably. I'll have to look at this a bit closer - I think I
> > > assumed that we're always going to have v2 inode format here (like
> > > we do in the kernel), but that may not be true. I'll have a closer
> > > look.
> > 
> > having a closer look, the XFS_SB_VERSION_NLINKBIT that is set here
> > in sbversion is never used, so I just removed it. I also changed it
> > back to using the converted in-memory link count so it's always
> > going to be correct now. Now it is just:
> > 
> > +       setlink_inode(id, xino.i_d.di_nlink, type == DBM_DIR, security);
> 
> Great.  With that and the other nitpicks address:
> 
> Reviewed-by: Christoph Hellwig <hch@lst.de>
> 
> for the whole series.

Thanks for the fast turnaround, Christoph! I'll get this
pushed out in the morning....

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

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

* Re: [PATCH 09/15] xfs: remove timestamps from incore inode
  2016-02-17  7:20 ` [PATCH 09/15] xfs: remove timestamps from incore inode Dave Chinner
@ 2016-02-26 18:02   ` Brian Foster
  2016-02-26 19:35     ` Darrick J. Wong
  0 siblings, 1 reply; 28+ messages in thread
From: Brian Foster @ 2016-02-26 18:02 UTC (permalink / raw)
  To: Dave Chinner; +Cc: xfs

On Wed, Feb 17, 2016 at 06:20:46PM +1100, Dave Chinner wrote:
> From: Dave Chinner <dchinner@redhat.com>
> 
> Source kernel commit 3987848c7c2be112e03c82d03821b044f1c0edec
> 
> The struct xfs_inode has two copies of the current timestamps in it,
> one in the vfs inode and one in the struct xfs_icdinode. Now that we
> no longer log the struct xfs_icdinode directly, we don't need to
> keep the timestamps in this structure. instead we can copy them
> straight out of the VFS inode when formatting the inode log item or
> the on-disk inode.
> 
> This reduces the struct xfs_inode in size by 24 bytes.
> 
> Signed-off-by: Dave Chinner <dchinner@redhat.com>
> Reviewed-by: Brian Foster <bfoster@redhat.com>
> Reviewed-by: Christoph Hellwig <hch@lst.de>
> Signed-off-by: Dave Chinner <david@fromorbit.com>
> ---
>  db/check.c               | 106 +++++++++++++++++++++++------------------------
>  include/xfs_inode.h      |  16 ++++++-
>  libxfs/libxfs_api_defs.h |   4 +-
>  libxfs/util.c            |  17 ++++----
>  libxfs/xfs_inode_buf.c   |  91 ++++++++++++++++++++++++++++++++++------
>  libxfs/xfs_inode_buf.h   |   9 ++--
>  libxfs/xfs_rtbitmap.c    |   2 +-
>  mkfs/proto.c             |   2 +-
>  8 files changed, 162 insertions(+), 85 deletions(-)
> 
...
> diff --git a/mkfs/proto.c b/mkfs/proto.c
> index 21960d5..72a1576 100644
> --- a/mkfs/proto.c
> +++ b/mkfs/proto.c
> @@ -653,7 +653,7 @@ rtinit(
>  	mp->m_sb.sb_rbmino = rbmip->i_ino;
>  	rbmip->i_d.di_size = mp->m_sb.sb_rbmblocks * mp->m_sb.sb_blocksize;
>  	rbmip->i_d.di_flags = XFS_DIFLAG_NEWRTBM;
> -	*(__uint64_t *)&rbmip->i_d.di_atime = 0;
> +	*(__uint64_t *)&VFS_I(mp->m_rbmip)->i_atime = 0;

FYI, this bit causes a NULL dereference because we've switched to using
mp->m_rbmip instead of rbmip, and mp->m_rbmip is not initialized until
just below. I assume this can be fixed in-tree...

Brian

>  	libxfs_trans_log_inode(tp, rbmip, XFS_ILOG_CORE);
>  	libxfs_log_sb(tp);
>  	mp->m_rbmip = rbmip;
> -- 
> 2.7.0
> 
> _______________________________________________
> xfs mailing list
> xfs@oss.sgi.com
> http://oss.sgi.com/mailman/listinfo/xfs

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

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

* Re: [PATCH 09/15] xfs: remove timestamps from incore inode
  2016-02-26 18:02   ` Brian Foster
@ 2016-02-26 19:35     ` Darrick J. Wong
  0 siblings, 0 replies; 28+ messages in thread
From: Darrick J. Wong @ 2016-02-26 19:35 UTC (permalink / raw)
  To: Brian Foster; +Cc: xfs

On Fri, Feb 26, 2016 at 01:02:28PM -0500, Brian Foster wrote:
> On Wed, Feb 17, 2016 at 06:20:46PM +1100, Dave Chinner wrote:
> > From: Dave Chinner <dchinner@redhat.com>
> > 
> > Source kernel commit 3987848c7c2be112e03c82d03821b044f1c0edec
> > 
> > The struct xfs_inode has two copies of the current timestamps in it,
> > one in the vfs inode and one in the struct xfs_icdinode. Now that we
> > no longer log the struct xfs_icdinode directly, we don't need to
> > keep the timestamps in this structure. instead we can copy them
> > straight out of the VFS inode when formatting the inode log item or
> > the on-disk inode.
> > 
> > This reduces the struct xfs_inode in size by 24 bytes.
> > 
> > Signed-off-by: Dave Chinner <dchinner@redhat.com>
> > Reviewed-by: Brian Foster <bfoster@redhat.com>
> > Reviewed-by: Christoph Hellwig <hch@lst.de>
> > Signed-off-by: Dave Chinner <david@fromorbit.com>
> > ---
> >  db/check.c               | 106 +++++++++++++++++++++++------------------------
> >  include/xfs_inode.h      |  16 ++++++-
> >  libxfs/libxfs_api_defs.h |   4 +-
> >  libxfs/util.c            |  17 ++++----
> >  libxfs/xfs_inode_buf.c   |  91 ++++++++++++++++++++++++++++++++++------
> >  libxfs/xfs_inode_buf.h   |   9 ++--
> >  libxfs/xfs_rtbitmap.c    |   2 +-
> >  mkfs/proto.c             |   2 +-
> >  8 files changed, 162 insertions(+), 85 deletions(-)
> > 
> ...
> > diff --git a/mkfs/proto.c b/mkfs/proto.c
> > index 21960d5..72a1576 100644
> > --- a/mkfs/proto.c
> > +++ b/mkfs/proto.c
> > @@ -653,7 +653,7 @@ rtinit(
> >  	mp->m_sb.sb_rbmino = rbmip->i_ino;
> >  	rbmip->i_d.di_size = mp->m_sb.sb_rbmblocks * mp->m_sb.sb_blocksize;
> >  	rbmip->i_d.di_flags = XFS_DIFLAG_NEWRTBM;
> > -	*(__uint64_t *)&rbmip->i_d.di_atime = 0;
> > +	*(__uint64_t *)&VFS_I(mp->m_rbmip)->i_atime = 0;
> 
> FYI, this bit causes a NULL dereference because we've switched to using
> mp->m_rbmip instead of rbmip, and mp->m_rbmip is not initialized until
> just below. I assume this can be fixed in-tree...

I fixed it in the xfsprogs reflink tree that Dave is poking with, so
I'll send the patch to the mailing list.

--D

> 
> Brian
> 
> >  	libxfs_trans_log_inode(tp, rbmip, XFS_ILOG_CORE);
> >  	libxfs_log_sb(tp);
> >  	mp->m_rbmip = rbmip;
> > -- 
> > 2.7.0
> > 
> > _______________________________________________
> > xfs mailing list
> > xfs@oss.sgi.com
> > http://oss.sgi.com/mailman/listinfo/xfs
> 
> _______________________________________________
> xfs mailing list
> xfs@oss.sgi.com
> http://oss.sgi.com/mailman/listinfo/xfs

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

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

end of thread, other threads:[~2016-02-26 19:36 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-17  7:20 [PATCH 00/15] xfsprogs: libxfs kernel sync to 4.6-for-next Dave Chinner
2016-02-17  7:20 ` [PATCH 01/15] xfs: wire up Q_XGETNEXTQUOTA / get_nextdqblk Dave Chinner
2016-02-17  7:25   ` Christoph Hellwig
2016-02-17  7:20 ` [PATCH 02/15] xfs: handle errors from ->free_blocks in xfs_btree_kill_iroot Dave Chinner
2016-02-17  7:20 ` [PATCH 03/15] xfs: factor btree block freeing into a helper Dave Chinner
2016-02-17  7:20 ` [PATCH 04/15] xfs: move buffer invalidation to xfs_btree_free_block Dave Chinner
2016-02-17  7:20 ` [PATCH 05/15] xfs: remove unused function definitions Dave Chinner
2016-02-17  7:20 ` [PATCH 06/15] xfs: RT bitmap and summary buffers are not typed Dave Chinner
2016-02-17  7:20 ` [PATCH 07/15] xfs: RT bitmap and summary buffers need verifiers Dave Chinner
2016-02-17  7:20 ` [PATCH 08/15] xfs: introduce inode log format object Dave Chinner
2016-02-17  7:20 ` [PATCH 09/15] xfs: remove timestamps from incore inode Dave Chinner
2016-02-26 18:02   ` Brian Foster
2016-02-26 19:35     ` Darrick J. Wong
2016-02-17  7:20 ` [PATCH 10/15] xfs: cull unnecessary icdinode fields Dave Chinner
2016-02-17  7:20 ` [PATCH 11/15] xfs: move v1 inode conversion to xfs_inode_from_disk Dave Chinner
2016-02-17  7:32   ` Christoph Hellwig
2016-02-17  7:48     ` Dave Chinner
2016-02-17  8:30       ` Dave Chinner
2016-02-17  8:33         ` Christoph Hellwig
2016-02-17  9:30           ` Dave Chinner
2016-02-17  7:20 ` [PATCH 12/15] xfs: use vfs inode nlink field everywhere Dave Chinner
2016-02-17  7:35   ` Christoph Hellwig
2016-02-17  7:49     ` Dave Chinner
2016-02-17  7:20 ` [PATCH 13/15] xfs: move inode generation count to VFS inode Dave Chinner
2016-02-17  7:20 ` [PATCH 14/15] xfs: move di_changecount " Dave Chinner
2016-02-17  7:20 ` [PATCH 15/15] xfs: mode di_mode to vfs inode Dave Chinner
2016-02-17  7:56 ` [PATCH 00/15] xfsprogs: libxfs kernel sync to 4.6-for-next Christoph Hellwig
2016-02-17  8:16   ` Dave Chinner

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.