All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mark Tinguely <tinguely@sgi.com>
To: xfs@oss.sgi.com
Subject: [RFC 13/17] xfsprogs: add parent pointer support into Linux 3.10 inode 3
Date: Wed, 15 Jan 2014 16:00:25 -0600	[thread overview]
Message-ID: <20140116000852.319706063@sgi.com> (raw)
In-Reply-To: 20140115220012.624438534@sgi.com

[-- Attachment #1: 01-xfsprogs-add-parent-pointers.patch --]
[-- Type: text/plain, Size: 7508 bytes --]

Add parent pointer support into the inode version 3 (CRC inode).
Make changes to mkfs.xfs to enable parent pointers using the
"-i parent=1" option.

---
 include/xfs_dinode.h     |    4 +++-
 include/xfs_log_format.h |    4 +++-
 include/xfs_sb.h         |   14 ++++++++++++--
 libxfs/xfs_ialloc.c      |   12 ++++++++++++
 man/man8/mkfs.xfs.8      |    6 ++++++
 mkfs/xfs_mkfs.c          |   24 +++++++++++++++++++-----
 6 files changed, 55 insertions(+), 9 deletions(-)

Index: b/include/xfs_dinode.h
===================================================================
--- a/include/xfs_dinode.h
+++ b/include/xfs_dinode.h
@@ -79,7 +79,9 @@ typedef struct xfs_dinode {
 	__be64		di_changecount;	/* number of attribute changes */
 	__be64		di_lsn;		/* flush sequence */
 	__be64		di_flags2;	/* more random flags */
-	__u8		di_pad2[16];	/* more padding for future expansion */
+	__be64		di_parent;	/* parent directory inode */
+	__be32		di_poffset;	/* offset into parent directory */
+	__u8		di_pad2[4];	/* more padding for future expansion */
 
 	/* fields only written to during inode creation */
 	xfs_timestamp_t	di_crtime;	/* time created */
Index: b/include/xfs_log_format.h
===================================================================
--- a/include/xfs_log_format.h
+++ b/include/xfs_log_format.h
@@ -567,7 +567,9 @@ typedef struct xfs_icdinode {
 	__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 */
+	__uint64_t	di_parent;	/* parent directory inode */
+	__uint32_t	di_poffset;	/* offset into parent directory */
+	__uint8_t	di_pad2[4];	/* more padding for future expansion */
 
 	/* fields only written to during inode creation */
 	xfs_ictimestamp_t di_crtime;	/* time created */
Index: b/include/xfs_sb.h
===================================================================
--- a/include/xfs_sb.h
+++ b/include/xfs_sb.h
@@ -90,6 +90,7 @@ struct xfs_trans;
 	(XFS_SB_VERSION2_LAZYSBCOUNTBIT	| \
 	 XFS_SB_VERSION2_ATTR2BIT	| \
 	 XFS_SB_VERSION2_PROJID32BIT	| \
+	 XFS_SB_VERSION2_PARENTBIT	| \
 	 XFS_SB_VERSION2_FTYPE)
 #define	XFS_SB_VERSION2_OKSASHFBITS	\
 	(0)
@@ -328,7 +329,6 @@ typedef enum {
 	 XFS_SB_FEATURES_RO_COMPAT | XFS_SB_FEATURES_INCOMPAT | \
 	 XFS_SB_FEATURES_LOG_INCOMPAT | XFS_SB_PQUOTINO)
 
-
 /*
  * Misc. Flags - warning - these will be cleared by xfs_repair unless
  * a feature bit is set when the flag is used.
@@ -596,8 +596,10 @@ xfs_sb_has_ro_compat_feature(
 }
 
 #define XFS_SB_FEAT_INCOMPAT_FTYPE	(1 << 0)	/* filetype in dirent */
+#define XFS_SB_FEAT_INCOMPAT_PARENT	(2 << 0)	/* parent inode ptrs */
 #define XFS_SB_FEAT_INCOMPAT_ALL \
-		(XFS_SB_FEAT_INCOMPAT_FTYPE)
+		(XFS_SB_FEAT_INCOMPAT_FTYPE | \
+		 XFS_SB_FEAT_INCOMPAT_PARENT)
 
 #define XFS_SB_FEAT_INCOMPAT_UNKNOWN	~XFS_SB_FEAT_INCOMPAT_ALL
 static inline bool
@@ -639,6 +641,14 @@ static inline int xfs_sb_version_hasftyp
 		 (sbp->sb_features2 & XFS_SB_VERSION2_FTYPE));
 }
 
+static inline int xfs_sb_version_hasparent(struct xfs_sb *sbp)
+{
+	return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5 &&
+		xfs_sb_has_incompat_feature(sbp, XFS_SB_FEAT_INCOMPAT_PARENT)) ||
+		(xfs_sb_version_hasmorebits(sbp) &&
+		(sbp->sb_features2 & XFS_SB_VERSION2_PARENTBIT));
+}
+
 /*
  * end of superblock version macros
  */
Index: b/libxfs/xfs_ialloc.c
===================================================================
--- a/libxfs/xfs_ialloc.c
+++ b/libxfs/xfs_ialloc.c
@@ -233,6 +233,18 @@ xfs_ialloc_inode_init(
 			free->di_next_unlinked = cpu_to_be32(NULLAGINO);
 
 			if (version == 3) {
+				if (xfs_sb_version_hasparent(&mp->m_sb) &&
+					   (mp->m_sb.sb_rootino == NULLFSINO ||
+					    mp->m_sb.sb_rootino == ino)) {
+					/*
+					 * set the parent pointer information
+					 * in the root inode.
+					 */
+					free->di_parent = cpu_to_be64(ino);
+					free->di_poffset =
+					    cpu_to_be32(xfs_dir3_data_dotdot_offset(mp)
+						    >> XFS_DIR2_DATA_ALIGN_LOG);
+				}
 				free->di_ino = cpu_to_be64(ino);
 				ino++;
 				uuid_copy(&free->di_uuid, &mp->m_sb.sb_uuid);
Index: b/man/man8/mkfs.xfs.8
===================================================================
--- a/man/man8/mkfs.xfs.8
+++ b/man/man8/mkfs.xfs.8
@@ -364,6 +364,12 @@ This is used to enable 32bit quota proje
 is either 0 or 1, with 1 signifying that 32bit projid are to be enabled.
 If the value is omitted, 1 is assumed.  (This default changed
 in release version 3.2.0.)
+.TP
+.BI parent[= value ]
+This is used to enable parent inode pointers in CRC enabled filesystems. The
+.I value
+is either 0 or 1, with 1 signifying that parent inode pointers are to be enabled.
+If the value is omitted, 0 is assumed.
 .RE
 .TP
 .BI \-l " log_section_options"
Index: b/mkfs/xfs_mkfs.c
===================================================================
--- a/mkfs/xfs_mkfs.c
+++ b/mkfs/xfs_mkfs.c
@@ -109,6 +109,8 @@ char	*iopts[] = {
 	"attr",
 #define	I_PROJID32BIT	6
 	"projid32bit",
+#define	I_PARENT	7
+	"parent",
 	NULL
 };
 
@@ -149,7 +151,7 @@ char	*nopts[] = {
 	"version",
 #define	N_FTYPE		3
 	"ftype",
-	NULL,
+	NULL
 };
 
 char	*ropts[] = {
@@ -962,6 +964,7 @@ main(
 	struct fs_topology	ft;
 	int			lazy_sb_counters;
 	int			crcs_enabled;
+	int			parent;
 
 	progname = basename(argv[0]);
 	setlocale(LC_ALL, "");
@@ -995,6 +998,7 @@ main(
 	worst_freelist = 0;
 	lazy_sb_counters = 1;
 	crcs_enabled = 0;
+	parent = 0;
 	memset(&fsx, 0, sizeof(fsx));
 
 	memset(&xi, 0, sizeof(xi));
@@ -1316,6 +1320,14 @@ main(
 						illegal(value, "i projid32bit");
 					projid16bit = c ? 0 : 1;
 					break;
+				case I_PARENT:
+					if (!value || *value == '\0')
+						value = "0";
+					c = atoi(value);
+					if (c < 0 || c > 1)
+						illegal(value, "i parent");
+					parent = c;
+					break;
 				default:
 					unknown('i', value);
 				}
@@ -2463,12 +2475,14 @@ _("size %s specified for log subvolume i
 	if (crcs_enabled) {
 		sbp->sb_features_incompat = XFS_SB_FEAT_INCOMPAT_FTYPE;
 		dirftype = 1;
-	}
+		if (parent)
+			sbp->sb_features_incompat |= XFS_SB_FEAT_INCOMPAT_PARENT;
+	 }
 
 	if (!qflag || Nflag) {
 		printf(_(
 		   "meta-data=%-22s isize=%-6d agcount=%lld, agsize=%lld blks\n"
-		   "         =%-22s sectsz=%-5u attr=%u, projid32bit=%u\n"
+		   "         =%-22s sectsz=%-5u attr=%u, projid32bit=%u, parent=%d\n"
 		   "         =%-22s crc=%u\n"
 		   "data     =%-22s bsize=%-6u blocks=%llu, imaxpct=%u\n"
 		   "         =%-22s sunit=%-6u swidth=%u blks\n"
@@ -2477,7 +2491,7 @@ _("size %s specified for log subvolume i
 		   "         =%-22s sectsz=%-5u sunit=%d blks, lazy-count=%d\n"
 		   "realtime =%-22s extsz=%-6d blocks=%lld, rtextents=%lld\n"),
 			dfile, isize, (long long)agcount, (long long)agsize,
-			"", sectorsize, attrversion, !projid16bit,
+			"", sectorsize, attrversion, !projid16bit, parent,
 			"", crcs_enabled,
 			"", blocksize, (long long)dblocks, imaxpct,
 			"", dsunit, dswidth,
@@ -3085,7 +3099,7 @@ usage( void )
 			    sectlog=n|sectsize=num\n\
 /* force overwrite */	[-f]\n\
 /* inode size */	[-i log=n|perblock=n|size=num,maxpct=n,attr=0|1|2,\n\
-			    projid32bit=0|1]\n\
+			    projid32bit=0|1,parent==0|1]\n\
 /* no discard */	[-K]\n\
 /* log subvol */	[-l agnum=n,internal,size=num,logdev=xxx,version=n\n\
 			    sunit=value|su=num,sectlog=n|sectsize=num,\n\


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

  parent reply	other threads:[~2014-01-16  0:30 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-15 22:00 [RFC 00/17] RFC parent inode pointers Mark Tinguely
2014-01-15 22:00 ` [RFC 01/17] xfs: (parent ptr) get offset when adding directory name Mark Tinguely
2014-01-15 22:00 ` [RFC 02/17] xfs: (parent ptr) get offset when removing " Mark Tinguely
2014-01-15 22:00 ` [RFC 03/17] xfs: (parent ptr) get offset when replacing a " Mark Tinguely
2014-01-15 22:00 ` [RFC 04/17] xfs: (parent ptr) add parent pointer support to xfs_sb.h Mark Tinguely
2014-01-15 22:00 ` [RFC 05/17] xfs: (parent ptr) add parent pointer support to attribute code Mark Tinguely
2014-01-15 22:00 ` [RFC 06/17] xfs: (parent ptr) add parent pointer support to inode v5 Mark Tinguely
2014-01-15 22:00 ` [RFC 07/17] xfs: (parent ptr) add parent pointer support to xfs_create Mark Tinguely
2014-01-15 22:00 ` [RFC 08/17] xfs: (parent ptr) add parent pointer support to xfs_symlink Mark Tinguely
2014-01-15 22:00 ` [RFC 09/17] xfs: (parent ptr) add parent pointer support to xfs_link Mark Tinguely
2014-01-15 22:00 ` [RFC 10/17] xfs: (parent ptr) add parent pointer support to xfs_remove Mark Tinguely
2014-01-15 22:00 ` [RFC 11/17] xfs: (parent ptr) add parent pointer support to xfs_rename Mark Tinguely
2014-01-15 22:00 ` [RFC 12/17] xfs: (parent ptr) add parent pointer support for user space Mark Tinguely
2014-01-15 22:00 ` Mark Tinguely [this message]
2014-01-15 22:00 ` [RFC 14/17] xfsprogs: add parent pointer values to headers and fix repair Mark Tinguely
2014-01-15 22:00 ` [RFC 15/17] xfsprogs: add basic parent pointer support to xfs_db Mark Tinguely
2014-01-15 22:00 ` [RFC 16/17] xfsprogs: add parent pointer support to xfs_io Mark Tinguely
2014-01-15 22:00 ` [RFC 17/17] xfsprogs: add parent GEOM information Mark Tinguely
2014-01-16  5:56 ` [RFC 00/17] RFC parent inode pointers Dave Chinner
2014-01-17 21:25   ` Mark Tinguely
2014-01-18  3:12     ` Dave Chinner
2014-01-27 19:41       ` Mark Tinguely
2014-01-28  3:00         ` Dave Chinner
2014-01-28 22:02           ` Geoffrey Wehrman
2014-02-04  0:09             ` Dave Chinner
2014-02-04  5:37               ` Geoffrey Wehrman

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=20140116000852.319706063@sgi.com \
    --to=tinguely@sgi.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 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.