public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Dave Chinner <david@fromorbit.com>
To: xfs@oss.sgi.com
Subject: [PATCH 11/15] xfs: move v1 inode conversion to xfs_inode_from_disk
Date: Wed, 17 Feb 2016 18:20:48 +1100	[thread overview]
Message-ID: <1455693652-3899-12-git-send-email-david@fromorbit.com> (raw)
In-Reply-To: <1455693652-3899-1-git-send-email-david@fromorbit.com>

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

  parent reply	other threads:[~2016-02-17  7:21 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 ` Dave Chinner [this message]
2016-02-17  7:32   ` [PATCH 11/15] xfs: move v1 inode conversion to xfs_inode_from_disk 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1455693652-3899-12-git-send-email-david@fromorbit.com \
    --to=david@fromorbit.com \
    --cc=xfs@oss.sgi.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox