Skip to contentSkip to conversation

xfsprogs: v4 inode type in directory

PATCH In review Mark Tinguely 2 participants 7 messages Sep 19, 2013

lore
Share & tools
lore
#5 lore raw

PATCH 3/3 xfsprog: add mkfs.xfs sb v4 support for dirent filetype field

In reply to Mark Tinguely

Add directory inode type feature to mkfs.xfs.

In sb v4, "-n ftype=1" turns on the feature. The feature is still automatically turned on for sb v5.

---

man/man8/mkfs.xfs.8 |    7 +++++++
 man/man8/mkfs.xfs.8 |   10 ++++++++++
 mkfs/xfs_mkfs.c     |   40 +++++++++++++++++++++++++++-------------
 mkfs/xfs_mkfs.h     |    4 +++-
 3 files changed, 40 insertions(+), 14 deletions(-)
man/man8/mkfs.xfs.8 +10 -0
Index: b/man/man8/mkfs.xfs.8
===================================================================
@@ -517,6 +517,16 @@ option enables ASCII only case-insensiti
 are stored in directories using the case they were created with.
 .IP
 Note: Version 1 directories are not supported.
+.TP
+.BI ftype= value
+Version 4 superblock supports the inode type stored in the directory feature.
+.I value
+can be either 0 or 1.
+With 0 meaning not supported (default) and 1 meaning supported.
+.IP
+Version 5 superblocks automatically support this feature and this
+setting will be ignored.
+.IP
 .RE
 .TP
 .BI \-p " protofile"
mkfs/xfs_mkfs.c +27 -13
Index: b/mkfs/xfs_mkfs.c
===================================================================
@@ -147,6 +147,8 @@ char	*nopts[] = {
 	"size",
 #define	N_VERSION	2
 	"version",
+#define	N_FTYPE		3
+	"ftype",
 	NULL,
 };
 
@@ -885,6 +887,7 @@ main(
 	char			*dfile;
 	int			dirblocklog;
 	int			dirblocksize;
+	int			dirftype;
 	int			dirversion;
 	char			*dsize;
 	int			dsu;
@@ -930,6 +933,7 @@ main(
 	int			nodsflag;
 	int			norsflag;
 	xfs_alloc_rec_t		*nrec;
+	int			niflag;
 	int			nsflag;
 	int			nvflag;
 	int			nci;
@@ -976,8 +980,8 @@ main(
 	loginternal = 1;
 	logversion = 2;
 	logagno = logblocks = rtblocks = rtextblocks = 0;
-	Nflag = nlflag = nsflag = nvflag = nci = 0;
-	dirblocklog = dirblocksize = 0;
+	Nflag = niflag = nlflag = nsflag = nvflag = nci = 0;
+	dirftype = dirblocklog = dirblocksize = 0;
 	dirversion = XFS_DFL_DIR_VERSION;
 	qflag = 0;
 	imaxpct = inodelog = inopblock = isize = 0;
@@ -1533,6 +1537,14 @@ main(
 					}
 					nvflag = 1;
 					break;
+				case N_FTYPE:
+					if (!value || *value == '\0')
+						reqval('n', nopts, N_FTYPE);
+					if (niflag)
+						respec('n', nopts, N_FTYPE);
+					dirftype = atoi(value);
+					niflag = 1;
+					break;
 				default:
 					unknown('n', value);
 				}
@@ -2434,6 +2446,14 @@ _("size %s specified for log subvolume i
 	}
 	validate_log_size(logblocks, blocklog, min_logblocks);
 
+	/*
+	 * dirent filetype field always enabled on v5 superblocks
+	 */
+	if (crcs_enabled) {
+		sbp->sb_features_incompat = XFS_SB_FEAT_INCOMPAT_FTYPE;
+		dirftype = 1;
+	}
+
 	if (!qflag || Nflag) {
 		printf(_(
 		   "meta-data=%-22s isize=%-6d agcount=%lld, agsize=%lld blks\n"
@@ -2441,7 +2461,7 @@ _("size %s specified for log subvolume i
 		   "         =%-22s crc=%u\n"
 		   "data     =%-22s bsize=%-6u blocks=%llu, imaxpct=%u\n"
 		   "         =%-22s sunit=%-6u swidth=%u blks\n"
-		   "naming   =version %-14u bsize=%-6u ascii-ci=%d\n"
+		   "naming   =version %-14u bsize=%-6u ascii-ci=%d ftype=%d\n"
 		   "log      =%-22s bsize=%-6d blocks=%lld, version=%d\n"
 		   "         =%-22s sectsz=%-5u sunit=%d blks, lazy-count=%d\n"
 		   "realtime =%-22s extsz=%-6d blocks=%lld, rtextents=%lld\n"),
@@ -2450,7 +2470,7 @@ _("size %s specified for log subvolume i
 			"", crcs_enabled,
 			"", blocksize, (long long)dblocks, imaxpct,
 			"", dsunit, dswidth,
-			dirversion, dirblocksize, nci,
+			dirversion, dirblocksize, nci, dirftype,
 			logfile, 1 << blocklog, (long long)logblocks,
 			logversion, "", lsectorsize, lsunit, lazy_sb_counters,
 			rtfile, rtextblocks << blocklog,
@@ -2512,8 +2532,9 @@ _("size %s specified for log subvolume i
 		sbp->sb_logsectlog = 0;
 		sbp->sb_logsectsize = 0;
 	}
+
 	sbp->sb_features2 = XFS_SB_VERSION2_MKFS(crcs_enabled, lazy_sb_counters,
-					attrversion == 2, !projid16bit, 0);
+				   attrversion == 2, !projid16bit, 0, dirftype);
 	sbp->sb_versionnum = XFS_SB_VERSION_MKFS(crcs_enabled, iaflag,
 					dsunit != 0,
 					logversion == 2, attrversion == 1,
@@ -2521,13 +2542,6 @@ _("size %s specified for log subvolume i
 							lsectorsize != BBSIZE),
 					nci, sbp->sb_features2 != 0);
 	/*
-	 * dirent filetype field always enabled on v5 superblocks
-	 */
-	if (crcs_enabled) {
-		sbp->sb_features_incompat = XFS_SB_FEAT_INCOMPAT_FTYPE;
-	}
-
-	/*
 	 * Due to a structure alignment issue, sb_features2 ended up in one
 	 * of two locations, the second "incorrect" location represented by
 	 * the sb_bad_features2 field. To avoid older kernels mounting
@@ -3065,7 +3079,7 @@ usage( void )
 			    sunit=value|su=num,sectlog=n|sectsize=num,\n\
 			    lazy-count=0|1]\n\
 /* label */		[-L label (maximum 12 characters)]\n\
-/* naming */		[-n log=n|size=num,version=2|ci]\n\
+/* naming */		[-n log=n|size=num,version=2|ci,ftype=0|1]\n\
 /* no-op info only */	[-N]\n\
 /* prototype file */	[-p fname]\n\
 /* quiet */		[-q]\n\
mkfs/xfs_mkfs.h +3 -1
Index: b/mkfs/xfs_mkfs.h
===================================================================
@@ -36,12 +36,14 @@
 	        XFS_DFL_SB_VERSION_BITS |                               \
 	0 ) : XFS_SB_VERSION_1 )
 
-#define XFS_SB_VERSION2_MKFS(crc, lazycount, attr2, projid32bit, parent) (\
+#define XFS_SB_VERSION2_MKFS(crc, lazycount, attr2, projid32bit, parent, \
+			     ftype) (\
 	((lazycount) ? XFS_SB_VERSION2_LAZYSBCOUNTBIT : 0) |		\
 	((attr2) ? XFS_SB_VERSION2_ATTR2BIT : 0) |			\
 	((projid32bit) ? XFS_SB_VERSION2_PROJID32BIT : 0) |		\
 	((parent) ? XFS_SB_VERSION2_PARENTBIT : 0) |			\
 	((crc) ? XFS_SB_VERSION2_CRCBIT : 0) |				\
+	((ftype) ? XFS_SB_VERSION2_FTYPE : 0) |				\
 	0 )
 
 #define	XFS_DFL_BLOCKSIZE_LOG	12		/* 4096 byte blocks */

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#0 lore raw

cover xfsprogs: v4 inode type in directory

Here are the patches that enable the inode in the directory feature in v4 superblocks.

patch 1: add the entries to xfs_sb.h (sync with kernel)
patch 2: add the XFS_FSOP_GEOM_FLAGS_FTYPE to xfs_fs.h (sync with kernel)
add the entry to repair so that xfs_info reports the feature
patch 3: add the feature to mkfs.xfs and manual page.
note: this new feature is ignored for superblock v5
automatically turns on this feature.

--Mark.

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#1 lore raw

PATCH 1/3 xfsprog: add xfs sb v4 support for dirent filetype field

Add xfsprog superblock v4 support for the directory inode type in xfs_sb.h.

This support adds a feature bit for version 4 superblocks and leaves the original superblock 5 incompatibility bit.

---
include/xfs_sb.h | 20 ++++++++++++--------

 include/xfs_sb.h |   10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
include/xfs_sb.h +7 -3
Index: b/include/xfs_sb.h
===================================================================
@@ -84,11 +84,13 @@ struct xfs_trans;
 #define XFS_SB_VERSION2_PARENTBIT	0x00000010	/* parent pointers */
 #define XFS_SB_VERSION2_PROJID32BIT	0x00000080	/* 32 bit project id */
 #define XFS_SB_VERSION2_CRCBIT		0x00000100	/* metadata CRCs */
+#define XFS_SB_VERSION2_FTYPE		0x00000200	/* inode type in dir */
 
 #define	XFS_SB_VERSION2_OKREALFBITS	\
 	(XFS_SB_VERSION2_LAZYSBCOUNTBIT	| \
 	 XFS_SB_VERSION2_ATTR2BIT	| \
-	 XFS_SB_VERSION2_PROJID32BIT)
+	 XFS_SB_VERSION2_PROJID32BIT	| \
+	 XFS_SB_VERSION2_FTYPE)
 #define	XFS_SB_VERSION2_OKSASHFBITS	\
 	(0)
 #define XFS_SB_VERSION2_OKREALBITS	\
@@ -631,8 +633,10 @@ static inline int xfs_sb_version_has_pqu
 
 static inline int xfs_sb_version_hasftype(struct xfs_sb *sbp)
 {
-	return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5 &&
-		xfs_sb_has_incompat_feature(sbp, XFS_SB_FEAT_INCOMPAT_FTYPE);
+	return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5 &&
+		xfs_sb_has_incompat_feature(sbp, XFS_SB_FEAT_INCOMPAT_FTYPE)) ||
+	       (xfs_sb_version_hasmorebits(sbp) &&
+		 (sbp->sb_features2 & XFS_SB_VERSION2_FTYPE));
 }
 
 /*

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#3 lore raw

PATCH 2/3 xfsprog: add dirent filetype information for xfs_info

In reply to Mark Tinguely

Make xfs_info aware of the directory inode type.

---
 growfs/xfs_growfs.c |   14 +++++++++-----
 include/xfs_fs.h    |   31 ++++++++++++++++---------------
 2 files changed, 25 insertions(+), 20 deletions(-)
growfs/xfs_growfs.c +9 -5
Index: b/growfs/xfs_growfs.c
===================================================================
@@ -55,7 +55,8 @@ report_info(
 	int		attrversion,
 	int		projid32bit,
 	int		crcs_enabled,
-	int		cimode)
+	int		cimode,
+	int		ftype_enabled)
 {
 	printf(_(
 	    "meta-data=%-22s isize=%-6u agcount=%u, agsize=%u blks\n"
@@ -63,7 +64,7 @@ report_info(
 	    "         =%-22s crc=%u\n"
 	    "data     =%-22s bsize=%-6u blocks=%llu, imaxpct=%u\n"
 	    "         =%-22s sunit=%-6u swidth=%u blks\n"
-	    "naming   =version %-14u bsize=%-6u ascii-ci=%d\n"
+	    "naming   =version %-14u bsize=%-6u ascii-ci=%d field=%d\n"
 	    "log      =%-22s bsize=%-6u blocks=%u, version=%u\n"
 	    "         =%-22s sectsz=%-5u sunit=%u blks, lazy-count=%u\n"
 	    "realtime =%-22s extsz=%-6u blocks=%llu, rtextents=%llu\n"),
@@ -74,7 +75,7 @@ report_info(
 		"", geo.blocksize, (unsigned long long)geo.datablocks,
 			geo.imaxpct,
 		"", geo.sunit, geo.swidth,
-  		dirversion, geo.dirblocksize, cimode,
+  		dirversion, geo.dirblocksize, cimode, ftype_enabled,
 		isint ? _("internal") : logname ? logname : _("external"),
 			geo.blocksize, geo.logblocks, logversion,
 		"", geo.logsectsize, geo.logsunit / geo.blocksize, lazycount,
@@ -121,6 +122,7 @@ main(int argc, char **argv)
 	libxfs_init_t		xi;	/* libxfs structure */
 	int			projid32bit;
 	int			crcs_enabled;
+	int			ftype_enabled = 0;
 
 	progname = basename(argv[0]);
 	setlocale(LC_ALL, "");
@@ -242,10 +244,12 @@ main(int argc, char **argv)
 	ci = geo.flags & XFS_FSOP_GEOM_FLAGS_DIRV2CI ? 1 : 0;
 	projid32bit = geo.flags & XFS_FSOP_GEOM_FLAGS_PROJID32 ? 1 : 0;
 	crcs_enabled = geo.flags & XFS_FSOP_GEOM_FLAGS_V5SB ? 1 : 0;
+	ftype_enabled = geo.flags & XFS_FSOP_GEOM_FLAGS_FTYPE ? 1 : 0;
 	if (nflag) {
 		report_info(geo, datadev, isint, logdev, rtdev,
 				lazycount, dirversion, logversion,
-				attrversion, projid32bit, crcs_enabled, ci);
+				attrversion, projid32bit, crcs_enabled, ci,
+				ftype_enabled);
 		exit(0);
 	}
 
@@ -282,7 +286,7 @@ main(int argc, char **argv)
 
 	report_info(geo, datadev, isint, logdev, rtdev,
 			lazycount, dirversion, logversion,
-			attrversion, projid32bit, crcs_enabled, ci);
+			attrversion, projid32bit, crcs_enabled, ci, ftype_enabled);
 
 	ddsize = xi.dsize;
 	dlsize = ( xi.logBBsize? xi.logBBsize :
include/xfs_fs.h +16 -15
Index: b/include/xfs_fs.h
===================================================================
@@ -222,21 +222,22 @@ typedef struct xfs_fsop_resblks {
 
 #define XFS_FSOP_GEOM_VERSION	0
 
-#define XFS_FSOP_GEOM_FLAGS_ATTR	0x0001	/* attributes in use	*/
-#define XFS_FSOP_GEOM_FLAGS_NLINK	0x0002	/* 32-bit nlink values	*/
-#define XFS_FSOP_GEOM_FLAGS_QUOTA	0x0004	/* quotas enabled	*/
-#define XFS_FSOP_GEOM_FLAGS_IALIGN	0x0008	/* inode alignment	*/
-#define XFS_FSOP_GEOM_FLAGS_DALIGN	0x0010	/* large data alignment */
-#define XFS_FSOP_GEOM_FLAGS_SHARED	0x0020	/* read-only shared	*/
-#define XFS_FSOP_GEOM_FLAGS_EXTFLG	0x0040	/* special extent flag	*/
-#define XFS_FSOP_GEOM_FLAGS_DIRV2	0x0080	/* directory version 2	*/
-#define XFS_FSOP_GEOM_FLAGS_LOGV2	0x0100	/* log format version 2	*/
-#define XFS_FSOP_GEOM_FLAGS_SECTOR	0x0200	/* sector sizes >1BB	*/
-#define XFS_FSOP_GEOM_FLAGS_ATTR2	0x0400	/* inline attributes rework */
-#define XFS_FSOP_GEOM_FLAGS_PROJID32	0x0800  /* 32-bit project IDs	*/
-#define XFS_FSOP_GEOM_FLAGS_DIRV2CI	0x1000	/* ASCII only CI names	*/
-#define XFS_FSOP_GEOM_FLAGS_LAZYSB	0x4000	/* lazy superblock counters */
-#define XFS_FSOP_GEOM_FLAGS_V5SB	0x8000	/* version 5 superblock */
+#define XFS_FSOP_GEOM_FLAGS_ATTR	0x00001	/* attributes in use	*/
+#define XFS_FSOP_GEOM_FLAGS_NLINK	0x00002	/* 32-bit nlink values	*/
+#define XFS_FSOP_GEOM_FLAGS_QUOTA	0x00004	/* quotas enabled	*/
+#define XFS_FSOP_GEOM_FLAGS_IALIGN	0x00008	/* inode alignment	*/
+#define XFS_FSOP_GEOM_FLAGS_DALIGN	0x00010	/* large data alignment */
+#define XFS_FSOP_GEOM_FLAGS_SHARED	0x00020	/* read-only shared	*/
+#define XFS_FSOP_GEOM_FLAGS_EXTFLG	0x00040	/* special extent flag	*/
+#define XFS_FSOP_GEOM_FLAGS_DIRV2	0x00080	/* directory version 2	*/
+#define XFS_FSOP_GEOM_FLAGS_LOGV2	0x00100	/* log format version 2	*/
+#define XFS_FSOP_GEOM_FLAGS_SECTOR	0x00200	/* sector sizes >1BB	*/
+#define XFS_FSOP_GEOM_FLAGS_ATTR2	0x00400	/* inline attributes rework */
+#define XFS_FSOP_GEOM_FLAGS_PROJID32	0x00800	/* 32-bit project IDs	*/
+#define XFS_FSOP_GEOM_FLAGS_DIRV2CI	0x01000	/* ASCII only CI names	*/
+#define XFS_FSOP_GEOM_FLAGS_LAZYSB	0x04000	/* lazy superblock counters */
+#define XFS_FSOP_GEOM_FLAGS_V5SB	0x08000	/* version 5 superblock */
+#define XFS_FSOP_GEOM_FLAGS_FTYPE	0x10000	/* inode directory types */
 
 
 /*

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#2 lore raw

Re: [PATCH 1/3] xfsprog: add xfs sb v4 support for dirent filetype field

In reply to Mark Tinguely
Quoted 32 lines · Mark Tinguely

Add xfsprog superblock v4 support for the directory inode type in xfs_sb.h.

This support adds a feature bit for version 4 superblocks and leaves the original superblock 5 incompatibility bit.

---
include/xfs_sb.h | 20 ++++++++++++--------

 include/xfs_sb.h |   10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

Index: b/include/xfs_sb.h
===================================================================

include/xfs_sb.h +3 -1
@@ -84,11 +84,13 @@ struct xfs_trans;
 #define XFS_SB_VERSION2_PARENTBIT	0x00000010	/* parent pointers */
 #define XFS_SB_VERSION2_PROJID32BIT	0x00000080	/* 32 bit project id */
 #define XFS_SB_VERSION2_CRCBIT		0x00000100	/* metadata CRCs */
+#define XFS_SB_VERSION2_FTYPE		0x00000200	/* inode type in dir */
 
 #define	XFS_SB_VERSION2_OKREALFBITS	\
 	(XFS_SB_VERSION2_LAZYSBCOUNTBIT	| \
 	 XFS_SB_VERSION2_ATTR2BIT	| \
-	 XFS_SB_VERSION2_PROJID32BIT)
+	 XFS_SB_VERSION2_PROJID32BIT	| \
+	 XFS_SB_VERSION2_FTYPE)
 #define	XFS_SB_VERSION2_OKSASHFBITS	\
 	(0)
 #define XFS_SB_VERSION2_OKREALBITS	\

include/xfs_sb.h static inline int xfs_sb_version_has_pqu · line 639

Quoted 9 lines
include/xfs_sb.h +4 -2
@@ -631,8 +633,10 @@ static inline int xfs_sb_version_has_pqu
 
 static inline int xfs_sb_version_hasftype(struct xfs_sb *sbp)
 {
-	return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5 &&
-		xfs_sb_has_incompat_feature(sbp, XFS_SB_FEAT_INCOMPAT_FTYPE);
+	return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5 &&
+		xfs_sb_has_incompat_feature(sbp, XFS_SB_FEAT_INCOMPAT_FTYPE)) ||
+	       (xfs_sb_version_hasmorebits(sbp) &&
+		 (sbp->sb_features2 & XFS_SB_VERSION2_FTYPE));

This is kinda inefficient. Seeing as I didn't review the kernel version, I'll review it now. Expand it out:

	return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5 &&
		xfs_sb_has_incompat_feature(sbp, XFS_SB_FEAT_INCOMPAT_FTYPE)) ||
	       ((XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5) ||
	        (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4 &&
	        (sbp->sb_versionnum & XFS_SB_VERSION_MOREBITSBIT))) &&
	       (sbp->sb_features2 & XFS_SB_VERSION2_FTYPE));

so, really, the check could be refined to:

	return XFS_SB_VERSION_NUM(sbp) >= XFS_SB_VERSION_4 &&
	       (xfs_sb_has_incompat_feature(sbp, XFS_SB_FEAT_INCOMPAT_FTYPE) ||
	        ((sbp->sb_versionnum & XFS_SB_VERSION_MOREBITSBIT) &&
		 (sbp->sb_features2 & XFS_SB_VERSION2_FTYPE)));

Cheers,

Dave.

Signature · 7 lines
Dave Chinner
[email protected]

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
#4 lore raw

Re: [PATCH 2/3] xfsprog: add dirent filetype information for xfs_info

In reply to Mark Tinguely
Quoted 23 lines · Mark Tinguely

Make xfs_info aware of the directory inode type.

---
 growfs/xfs_growfs.c |   14 +++++++++-----
 include/xfs_fs.h    |   31 ++++++++++++++++---------------
 2 files changed, 25 insertions(+), 20 deletions(-)

Index: b/growfs/xfs_growfs.c
===================================================================

growfs/xfs_growfs.c +2 -1
@@ -55,7 +55,8 @@ report_info(
 	int		attrversion,
 	int		projid32bit,
 	int		crcs_enabled,
-	int		cimode)
+	int		cimode,
+	int		ftype_enabled)
 {
 	printf(_(
 	    "meta-data=%-22s isize=%-6u agcount=%u, agsize=%u blks\n"

growfs/xfs_growfs.c report_info( · line 67

Quoted 5 lines
growfs/xfs_growfs.c +1 -1
@@ -63,7 +64,7 @@ report_info(
 	    "         =%-22s crc=%u\n"
 	    "data     =%-22s bsize=%-6u blocks=%llu, imaxpct=%u\n"
 	    "         =%-22s sunit=%-6u swidth=%u blks\n"
-	    "naming   =version %-14u bsize=%-6u ascii-ci=%d\n"
+	    "naming   =version %-14u bsize=%-6u ascii-ci=%d field=%d\n"

What does "field" mean? It doesn't describe the feature at all. "dtype" or "ftype" would be a better description of what is different in the directory structure...

Cheers,

Dave.

Signature · 7 lines
Dave Chinner
[email protected]

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
#6 lore raw

Re: [PATCH 3/3] xfsprog: add mkfs.xfs sb v4 support for dirent filetype field

In reply to Mark Tinguely
Quoted 4 lines · Mark Tinguely

Add directory inode type feature to mkfs.xfs.

In sb v4, "-n ftype=1" turns on the feature. The feature is still automatically turned on for sb v5.

Ok, so you named it "ftype" here. that's what needs to be in the xfs_info output, and mkfs output....

Quoted 13 lines

---

man/man8/mkfs.xfs.8 |    7 +++++++
 man/man8/mkfs.xfs.8 |   10 ++++++++++
 mkfs/xfs_mkfs.c     |   40 +++++++++++++++++++++++++++-------------
 mkfs/xfs_mkfs.h     |    4 +++-
 3 files changed, 40 insertions(+), 14 deletions(-)

Index: b/man/man8/mkfs.xfs.8
===================================================================

man/man8/mkfs.xfs.8 option enables ASCII only case-insensiti · line 522

Quoted 6 lines
man/man8/mkfs.xfs.8 +3 -0
@@ -517,6 +517,16 @@ option enables ASCII only case-insensiti
 are stored in directories using the case they were created with.
 .IP
 Note: Version 1 directories are not supported.
+.TP
+.BI ftype= value
+Version 4 superblock supports the inode type stored in the directory feature.

It's a very brief description of the feature. Nobody is really going to understand it from that. You need to mention that allows the type of object a directory entry points to to be stored in the directory structure so that inodes don't have to be read to traverse the filesystem or determine the type of a directory entry. And that the inforamtion is returned to readdir(3) and getdents(2), so users should see the those man poages for how to access the information....

man/man8/mkfs.xfs.8 option enables ASCII only case-insensiti · line 525

Quoted 3 lines
man/man8/mkfs.xfs.8 +3 -0
+.I value
+can be either 0 or 1.
+With 0 meaning not supported (default) and 1 meaning supported.

The value is either 0 or 1, with 1 signifiying that filetype information will be stored in the directory structure. The default value is 0.

man/man8/mkfs.xfs.8 option enables ASCII only case-insensiti · line 528

Quoted 3 lines
man/man8/mkfs.xfs.8 +3 -0
+.IP
+Version 5 superblocks automatically support this feature and this
+setting will be ignored.

Users don't know what a "version 5 superblock" means, really. So what this should say is something like this:

"When CRCs are enabled via -m crc=1, the ftype functionality is always enabled. This feature can not be turned off for such filesystem configurations."

As it is, trying to turn off ftype on a crc enabled filesystem should throw an error, not be ignored.

man/man8/mkfs.xfs.8 option enables ASCII only case-insensiti

Quoted 7 lines
man/man8/mkfs.xfs.8 +2 -2
 	loginternal = 1;
 	logversion = 2;
 	logagno = logblocks = rtblocks = rtextblocks = 0;
-	Nflag = nlflag = nsflag = nvflag = nci = 0;
-	dirblocklog = dirblocksize = 0;
+	Nflag = niflag = nlflag = nsflag = nvflag = nci = 0;
+	dirftype = dirblocklog = dirblocksize = 0;

two flags?

Also, can you put them on their own line for initialisation rather than add more to the existing multi-variable assignments..

Quoted 5 lines
man/man8/mkfs.xfs.8 +0 -0
 	dirversion = XFS_DFL_DIR_VERSION;
 	qflag = 0;
 	imaxpct = inodelog = inopblock = isize = 0;
@@ -1533,6 +1537,14 @@ main(
 					}

man/man8/mkfs.xfs.8 main( · line 1547

Quoted 10 lines
man/man8/mkfs.xfs.8 +8 -0
 					nvflag = 1;
 					break;
+				case N_FTYPE:
+					if (!value || *value == '\0')
+						reqval('n', nopts, N_FTYPE);
+					if (niflag)
+						respec('n', nopts, N_FTYPE);
+					dirftype = atoi(value);
+					niflag = 1;
+					break;

So, niflag indicates that the cli option has been set. Where does that get used? what does the "i" in niflag mean? Wouldn't "nftype_flag" be a better name?

And then if it is set, it should be rejected if crcs_enabled is also set, dumping the usage information...

Quoted 4 lines
man/man8/mkfs.xfs.8 +0 -0
 				default:
 					unknown('n', value);
 				}

man/man8/mkfs.xfs.8 _("size %s specified for log subvolume i · line 2455

Quoted 10 lines
man/man8/mkfs.xfs.8 +7 -0
@@ -2434,6 +2446,14 @@ _("size %s specified for log subvolume i
 	}
 	validate_log_size(logblocks, blocklog, min_logblocks);
 
+	/*
+	 * dirent filetype field always enabled on v5 superblocks
+	 */
+	if (crcs_enabled) {
+		sbp->sb_features_incompat = XFS_SB_FEAT_INCOMPAT_FTYPE;
+		dirftype = 1;
+	}

So dirftype is set for crc enabled filesystems....

man/man8/mkfs.xfs.8 _("size %s specified for log subvolume i · line 2464

Quoted 10 lines
man/man8/mkfs.xfs.8 +2 -1
+
 	if (!qflag || Nflag) {
 		printf(_(
 		   "meta-data=%-22s isize=%-6d agcount=%lld, agsize=%lld blks\n"
@@ -2441,7 +2461,7 @@ _("size %s specified for log subvolume i
 		   "         =%-22s crc=%u\n"
 		   "data     =%-22s bsize=%-6u blocks=%llu, imaxpct=%u\n"
 		   "         =%-22s sunit=%-6u swidth=%u blks\n"
-		   "naming   =version %-14u bsize=%-6u ascii-ci=%d\n"
+		   "naming   =version %-14u bsize=%-6u ascii-ci=%d ftype=%d\n"

Yup, you named it "ftype" here....

man/man8/mkfs.xfs.8 _("size %s specified for log subvolume i · line 2473

Quoted 9 lines
man/man8/mkfs.xfs.8 +1 -1
 		   "log      =%-22s bsize=%-6d blocks=%lld, version=%d\n"
 		   "         =%-22s sectsz=%-5u sunit=%d blks, lazy-count=%d\n"
 		   "realtime =%-22s extsz=%-6d blocks=%lld, rtextents=%lld\n"),
@@ -2450,7 +2470,7 @@ _("size %s specified for log subvolume i
 			"", crcs_enabled,
 			"", blocksize, (long long)dblocks, imaxpct,
 			"", dsunit, dswidth,
-			dirversion, dirblocksize, nci,
+			dirversion, dirblocksize, nci, dirftype,

dirftype is used here for output...

man/man8/mkfs.xfs.8 _("size %s specified for log subvolume i · line 2537

Quoted 11 lines
man/man8/mkfs.xfs.8 +2 -1
 			logfile, 1 << blocklog, (long long)logblocks,
 			logversion, "", lsectorsize, lsunit, lazy_sb_counters,
 			rtfile, rtextblocks << blocklog,
@@ -2512,8 +2532,9 @@ _("size %s specified for log subvolume i
 		sbp->sb_logsectlog = 0;
 		sbp->sb_logsectsize = 0;
 	}
+
 	sbp->sb_features2 = XFS_SB_VERSION2_MKFS(crcs_enabled, lazy_sb_counters,
-					attrversion == 2, !projid16bit, 0);
+				   attrversion == 2, !projid16bit, 0, dirftype);

and for setting the v4 feature bit.

Hmmm, that maybe a problem - on v5 filesystems that's setting both the v4 feature and the v5 feature bit. I don't think that is the right thing to do here. It might be fine for an incompat v5 feature bit, but if this was a read-only compat feature bit then the v4 feature bit would prevent the v5 feature bit from working correctly.

Hence for new "dual v4/v5 feature bit features", only the relevant feature bit for the filesystem version should be set.

Cheers,

Dave.

Signature · 7 lines
Dave Chinner
[email protected]

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs