Skip to contentSkip to conversation

xfsprogs: v4 inode type in directory

PATCH In review Mark Tinguely 4 participants 23 messages Oct 17, 2013 – Oct 24, 2013

lore
Share & tools
lore
#0 lore raw

v3 cover xfsprogs: v4 inode type in directory

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

Unchanged
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
New
patch 3: add feature to the xfs_db version command.

Fixed
patch 4: 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 v3 1/4 xfsprog: add xfs sb v4 support for dirent filetype field

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

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

---
v3 no change.

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

Reviewed-by on v3 1/4
#2 lore raw

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

Quoted 7 lines · Mark Tinguely

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

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

Signature · 7 lines
Dave Chinner
[email protected]

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

PATCH v3 2/4 xfsprog: add dirent filetype information for xfs_info

In reply to Mark Tinguely

Make xfs_info aware of the directory inode type by using the XFS_FSOP_GEOM_FLAGS_FTYPE set in the kernel.

---
v3 no change.

growfs/xfs_growfs.c | 14 +++++++++-----

 growfs/xfs_growfs.c |   14 +++++++++-----
 include/xfs_fs.h    |    3 ++-
 2 files changed, 11 insertions(+), 6 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 ftype=%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 +2 -1
Index: b/include/xfs_fs.h
===================================================================
@@ -233,10 +233,11 @@ typedef struct xfs_fsop_resblks {
 #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_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_FTYPE	0x10000	/* inode directory types */
 
 
 /*

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

Reviewed-by on v3 2/4
#5 lore raw

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

Quoted 4 lines · Mark Tinguely

Make xfs_info aware of the directory inode type by using the XFS_FSOP_GEOM_FLAGS_FTYPE set in the kernel.

Signature · 7 lines
Dave Chinner
[email protected]

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

PATCH v3 3/4 xfs_progs: add dirent filetype to xfs_db version

In reply to Mark Tinguely

Add directory inode type to the xfs_db version command.

---
new to v3

 db/sb.c |    2 ++
 1 file changed, 2 insertions(+)
db/sb.c +2 -0
Index: b/db/sb.c
===================================================================
@@ -644,6 +644,8 @@ version_string(
 		strcat(s, ",PROJID32BIT");
 	if (xfs_sb_version_hascrc(sbp))
 		strcat(s, ",CRC");
+	if (xfs_sb_version_hasftype(sbp))
+		strcat(s, ",FTYPE");
 	return s;
 }
 

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

#10 lore raw

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

In reply to Mark Tinguely

Add directory inode type feature to mkfs.xfs and its manual page.

In sb v4, "mkfs.xfs -n ftype=1" turns on the feature.

The feature is automatically turned on for "-m crc=1", but reject the use of the "-n ftype=0|1" with the "-m crc=1" option.

---
v3
Manual page changes
removed the "mkfs.xfs" before "-m crc=1".

make the "readdir(3)", "getdents(2)" and "-m crc=1" to be bold remove quotes from "-m crc=1".

removed the Linux version that ftype was first supported.

mkfs.xfs.c:
fixed the comparison variable that keeps "-m crc=1" and "-n ftype=X" from being used together.

fixed the condition check (!crcs_enable && dirftype) that enables the feature only for v4 superblocks.

add message that crcs and ftype cannot be used together before calling usage().

man/man8/mkfs.xfs.8 |    7 +++++++
 man/man8/mkfs.xfs.8 |   19 +++++++++++++++++++
 mkfs/xfs_mkfs.c     |   48 +++++++++++++++++++++++++++++++++++++-----------
 mkfs/xfs_mkfs.h     |    4 +++-
 3 files changed, 59 insertions(+), 12 deletions(-)
man/man8/mkfs.xfs.8 +19 -0
Index: b/man/man8/mkfs.xfs.8
===================================================================
@@ -517,6 +517,25 @@ 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
+This feature allows the inode type to be stored in the directory
+structure so that the
+.BR readdir (3)
+and
+.BR getdents (2)
+do not need to look up the inode to determine the inode type.
+
+The
+.I value
+is either 0 or 1, with 1 signifiying that filetype information
+will be stored in the directory structure. The default value is 0.
+
+When CRCs are enabled via
+.B \-m crc=1,
+the ftype functionality is always enabled. This feature can not be turned
+off for such filesystem configurations.
+.IP
 .RE
 .TP
 .BI \-p " protofile"
mkfs/xfs_mkfs.c +37 -11

121 lines not on this page · raw message

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

Reviewed-by on v3 4/4
#11 lore raw

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

Quoted 8 lines · Mark Tinguely

Add directory inode type feature to mkfs.xfs and its manual page.

In sb v4, "mkfs.xfs -n ftype=1" turns on the feature.

The feature is automatically turned on for "-m crc=1", but reject the use of the "-n ftype=0|1" with the "-m crc=1" option.

Looks OK now.

Signature · 7 lines
Dave Chinner
[email protected]

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

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

In reply to Mark Tinguely

This has been committed.

Thanks
--Rich

commit 4eb02d95b7e081b510a7015609f01385aab229a9

Author: Mark Tinguely <[email protected]>
Date:   Thu Oct 17 15:28:08 2013 +0000

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

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

#13 lore raw

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

In reply to Mark Tinguely
Quoted 6 lines · Mark Tinguely

Add directory inode type feature to mkfs.xfs and its manual page.

In sb v4, "mkfs.xfs -n ftype=1" turns on the feature.

The feature is automatically turned on for "-m crc=1", but reject the use of the "-n ftype=0|1" with the "-m crc=1" option.

Seems like this causes a spurious failure in xfs/206:

root/xfstests/results//xfs/206.out.bad renamed from xfs/206.out +5 -5
@@ -5,26 +5,26 @@
          =                       sectsz=512   attr=2
 data     =                       bsize=4096   blocks=3905982455, imaxpct=5
          =                       sunit=0      swidth=0 blks
-naming   =version 2              bsize=4096   ascii-ci=0
+naming   =version 2              bsize=4096   ascii-ci=0 ftype=0
 log      =internal log           bsize=4096   blocks=XXXXX, version=2
          =                       sectsz=512   sunit=0 blks, lazy-count=0
 realtime =none                   extsz=4096   blocks=0, rtextents=0
 === xfs_growfs ===
 meta-data=FILE                   isize=256    agcount=52, agsize=76288719 blks
-         =                       sectsz=512   attr=2
+         =                       sectsz=512   attr=2, projid32bit=1
 data     =                       bsize=4096   blocks=3905982455, imaxpct=5
          =                       sunit=0      swidth=0 blks
-naming   =version 2              bsize=4096   ascii-ci=0
+naming   =version 2              bsize=4096   ascii-ci=0 ftype=0
 log      =internal               bsize=4096   blocks=XXXXX, version=2
          =                       sectsz=512   sunit=0 blks, lazy-count=0
 realtime =none                   extsz=4096   blocks=0, rtextents=0
 data blocks changed from 3905982455 to 4882478016
 === xfs_info ===
 meta-data=FILE                   isize=256    agcount=64, agsize=76288719 blks
-         =                       sectsz=512   attr=2
+         =                       sectsz=512   attr=2, projid32bit=1
 data     =                       bsize=4096   blocks=4882478016, imaxpct=5
          =                       sunit=0      swidth=0 blks
-naming   =version 2              bsize=4096   ascii-ci=0
+naming   =version 2              bsize=4096   ascii-ci=0 ftype=0
 log      =internal               bsize=4096   blocks=XXXXX, version=2
          =                       sectsz=512   sunit=0 blks, lazy-count=0
 realtime =none                   extsz=4096   blocks=0, rtextents=0

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

#14 lore raw

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

Quoted 9 lines · Christoph Hellwig
Quoted 6 lines · Mark Tinguely

Add directory inode type feature to mkfs.xfs and its manual page.

In sb v4, "mkfs.xfs -n ftype=1" turns on the feature.

The feature is automatically turned on for "-m crc=1", but reject the use of the "-n ftype=0|1" with the "-m crc=1" option.

Seems like this causes a spurious failure in xfs/206:

Yes, it will. the xfstests repair filter needs to be updated every time a new option is added to the output.

Cheers,

Dave.

Signature · 7 lines
Dave Chinner
[email protected]

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

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

Quoted 9 lines · Dave Chinner
Quoted 8 lines · Christoph Hellwig
Quoted 6 lines · Mark Tinguely

Add directory inode type feature to mkfs.xfs and its manual page.

In sb v4, "mkfs.xfs -n ftype=1" turns on the feature.

The feature is automatically turned on for "-m crc=1", but reject the use of the "-n ftype=0|1" with the "-m crc=1" option.

Quoted 8 lines
Quoted 1 line

Seems like this causes a spurious failure in xfs/206:

Yes, it will. the xfstests repair filter needs to be updated every time a new option is added to the output.

Cheers,

Dave.

Thanks for the heads up.

--Mark.

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

#16 lore raw
In reply to Mark Tinguely
Quoted 10 lines · Mark Tinguely

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

Unchanged
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
New
patch 3: add feature to the xfs_db version command.

Quoted 4 lines

Fixed
patch 4: add the feature to mkfs.xfs and manual page.
note: this new feature is ignored for superblock v5
automatically turns on this feature.

FYI.

I saw the request for adding the filetype entry to block/leaf after posting.

I have it displaying unconditionally, but am trying to figure out how to make it display only for filesytems that support the ftype feature. I am missing something in the field.count().

--Mark.

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

#17 lore raw
Quoted 16 lines · Mark Tinguely
Quoted 10 lines · Mark Tinguely

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

Unchanged
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
New
patch 3: add feature to the xfs_db version command.

Quoted 4 lines

Fixed
patch 4: add the feature to mkfs.xfs and manual page.
note: this new feature is ignored for superblock v5
automatically turns on this feature.

Quoted 7 lines

FYI.

I saw the request for adding the filetype entry to block/leaf after posting.

I have it displaying unconditionally, but am trying to figure out how to make it display only for filesytems that support the ftype feature. I am missing something in the field.count().

The count function only tells the code whether a structure is present or not, but it does not tell you what the format of the structure is.

if you look at db/dir2.c, you'll see that the difference between the dir2_flds[] and the dir3_flds[] is mainly in the type, count and offset fields. For example:

const field_t   dir2_flds[] = {
        { "bhdr", FLDT_DIR2_DATA_HDR, OI(BOFF(magic)), dir2_block_hdr_count,
          FLD_COUNT, TYP_NONE }

...

const field_t dir3_flds[] = {
{ "bhdr", FLDT_DIR3_DATA_HDR, OI(B3OFF(hdr)), dir3_block_hdr_count,
FLD_COUNT, TYP_NONE },
...

if you look at dir[23]_block_hdr_count(), you'll see that they return a boolean value based on a magic number check. Hence when the code is trying to determine the type of the block that has been read (i.e. what the field definition is), if the magic number matches we know exactly what type of contents they contain.

For decoding the dtype, you need too look at how to select the correct structure for the FLDT_DIR2_DATA_UNION. If you don't have the feature set, you need to select the FLDT_DIR2_DATA_UNION structure type, and if it is set you need to select the FLDT_DIR3_DATA_UNION type. Hence you need both these types defined in the dir2_flds[] array, and some manner to ensure the correct values are returned from the count functions.

And just to make it hard, both the dir2 and dir3 data union count functions use the same function (dir2_data_u_count) so you're going to have to be careful that you don't break the v5 superblock directory decoding....

Cheers,

Dave.

Signature · 7 lines
Dave Chinner
[email protected]

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
#18 lore raw
Quoted 57 lines · Dave Chinner
Quoted 16 lines · Mark Tinguely
Quoted 10 lines · Mark Tinguely

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

Unchanged
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
New
patch 3: add feature to the xfs_db version command.

Quoted 4 lines

Fixed
patch 4: add the feature to mkfs.xfs and manual page.
note: this new feature is ignored for superblock v5
automatically turns on this feature.

Quoted 7 lines

FYI.

I saw the request for adding the filetype entry to block/leaf after posting.

I have it displaying unconditionally, but am trying to figure out how to make it display only for filesytems that support the ftype feature. I am missing something in the field.count().

The count function only tells the code whether a structure is present or not, but it does not tell you what the format of the structure is.

if you look at db/dir2.c, you'll see that the difference between the dir2_flds[] and the dir3_flds[] is mainly in the type, count and offset fields. For example:

const field_t   dir2_flds[] = {
         { "bhdr", FLDT_DIR2_DATA_HDR, OI(BOFF(magic)), dir2_block_hdr_count,
           FLD_COUNT, TYP_NONE }

...

const field_t dir3_flds[] = {
{ "bhdr", FLDT_DIR3_DATA_HDR, OI(B3OFF(hdr)), dir3_block_hdr_count,
FLD_COUNT, TYP_NONE },
...

if you look at dir[23]_block_hdr_count(), you'll see that they return a boolean value based on a magic number check. Hence when the code is trying to determine the type of the block that has been read (i.e. what the field definition is), if the magic number matches we know exactly what type of contents they contain.

For decoding the dtype, you need too look at how to select the correct structure for the FLDT_DIR2_DATA_UNION. If you don't have the feature set, you need to select the FLDT_DIR2_DATA_UNION structure type, and if it is set you need to select the FLDT_DIR3_DATA_UNION type. Hence you need both these types defined in the dir2_flds[] array, and some manner to ensure the correct values are returned from the count functions.

Quoted 8 lines

And just to make it hard, both the dir2 and dir3 data union count functions use the same function (dir2_data_u_count) so you're going to have to be careful that you don't break the v5 superblock directory decoding....

Cheers,

Dave.

Thanks Dave. I did some RTFS and found I was having problems with the field_t.flag.

Can't we add a filetype to the dir2 dir2_data_union_flds entry and use the count to turn it on/off? The problem I was having with this was the flag. Something like:

Add the directory field type information to xfs_db directory displays.

---
 db/dir2.c |   12 ++++++++++++
 1 file changed, 12 insertions(+)
db/dir2.c +12 -0
Index: b/db/dir2.c
===================================================================
@@ -52,6 +52,8 @@ static int	dir2_leaf_tail_count(void *ob
 static int	dir2_leaf_tail_offset(void *obj, int startoff, int idx);
 static int	dir2_node_btree_count(void *obj, int startoff);
 static int	dir2_node_hdr_count(void *obj, int startoff);
+static int	dir3_data_union_ftype_offset(void *obj, int startoff, int idx);
+static int	dir2_data_union_ftype_count(void *obj, int startoff);
 
 const field_t	dir2_hfld[] = {
 	{ "", FLDT_DIR2, OI(0), C1, 0, TYP_NONE },
@@ -130,6 +132,8 @@ const field_t	dir2_data_union_flds[] = {
 	  dir2_data_union_namelen_count, FLD_COUNT, TYP_NONE },
 	{ "name", FLDT_CHARNS, OI(DEOFF(name)), dir2_data_union_name_count,
 	  FLD_COUNT, TYP_NONE },
+	{ "filetype", FLDT_UINT8D, dir3_data_union_ftype_offset,
+	  dir2_data_union_ftype_count, FLD_OFFSET|FLD_COUNT, TYP_NONE },
 	{ "tag", FLDT_DIR2_DATA_OFF, dir2_data_union_tag_offset,
 	  dir2_data_union_tag_count, FLD_OFFSET|FLD_COUNT, TYP_NONE },
 	{ NULL }
@@ -454,6 +458,14 @@ dir2_data_union_name_count(
 }
 
 static int
+dir2_data_union_ftype_count(
+	void			*obj,
+	int			startoff)
+{
+	return xfs_sb_version_hasftype(&mp->m_sb);
+}
+
+static int
 dir2_data_union_namelen_count(
 	void			*obj,
 	int			startoff)

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

#19 lore raw
Quoted 68 lines · Mark Tinguely
Quoted 57 lines · Dave Chinner
Quoted 16 lines · Mark Tinguely
Quoted 10 lines · Mark Tinguely

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

Unchanged
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
New
patch 3: add feature to the xfs_db version command.

Quoted 4 lines

Fixed
patch 4: add the feature to mkfs.xfs and manual page.
note: this new feature is ignored for superblock v5
automatically turns on this feature.

Quoted 7 lines

FYI.

I saw the request for adding the filetype entry to block/leaf after posting.

I have it displaying unconditionally, but am trying to figure out how to make it display only for filesytems that support the ftype feature. I am missing something in the field.count().

The count function only tells the code whether a structure is present or not, but it does not tell you what the format of the structure is.

if you look at db/dir2.c, you'll see that the difference between the dir2_flds[] and the dir3_flds[] is mainly in the type, count and offset fields. For example:

const field_t   dir2_flds[] = {
        { "bhdr", FLDT_DIR2_DATA_HDR, OI(BOFF(magic)), dir2_block_hdr_count,
          FLD_COUNT, TYP_NONE }

...

const field_t dir3_flds[] = {
{ "bhdr", FLDT_DIR3_DATA_HDR, OI(B3OFF(hdr)), dir3_block_hdr_count,
FLD_COUNT, TYP_NONE },
...

if you look at dir[23]_block_hdr_count(), you'll see that they return a boolean value based on a magic number check. Hence when the code is trying to determine the type of the block that has been read (i.e. what the field definition is), if the magic number matches we know exactly what type of contents they contain.

For decoding the dtype, you need too look at how to select the correct structure for the FLDT_DIR2_DATA_UNION. If you don't have the feature set, you need to select the FLDT_DIR2_DATA_UNION structure type, and if it is set you need to select the FLDT_DIR3_DATA_UNION type. Hence you need both these types defined in the dir2_flds[] array, and some manner to ensure the correct values are returned from the count functions.

Quoted 8 lines

And just to make it hard, both the dir2 and dir3 data union count functions use the same function (dir2_data_u_count) so you're going to have to be careful that you don't break the v5 superblock directory decoding....

Cheers,

Dave.

Quoted 6 lines

Thanks Dave. I did some RTFS and found I was having problems with the field_t.flag.

Can't we add a filetype to the dir2 dir2_data_union_flds entry and use the count to turn it on/off? The problem I was having with this was the flag.

ISTR trying something like that previously when doing the dir3 changeover - I couldn't get it to work properly because parts of the structure could not be easily discriminated and so both the v2 and v3 count functions would return true because they were looking at different locations in the structure due to the header size differences.

In this case, because the structure itself doesn't have any child dependencies and the format will always be considered a v2 directory structure, I think what you propose should work. Did you test it to see if it works?

Cheers,

Dave.

Signature · 7 lines
Dave Chinner
[email protected]

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
#20 lore raw
Quoted 83 lines · Dave Chinner
Quoted 68 lines · Mark Tinguely
Quoted 57 lines · Dave Chinner
Quoted 16 lines · Mark Tinguely
Quoted 10 lines · Mark Tinguely

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

Unchanged
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
New
patch 3: add feature to the xfs_db version command.

Quoted 4 lines

Fixed
patch 4: add the feature to mkfs.xfs and manual page.
note: this new feature is ignored for superblock v5
automatically turns on this feature.

Quoted 7 lines

FYI.

I saw the request for adding the filetype entry to block/leaf after posting.

I have it displaying unconditionally, but am trying to figure out how to make it display only for filesytems that support the ftype feature. I am missing something in the field.count().

The count function only tells the code whether a structure is present or not, but it does not tell you what the format of the structure is.

if you look at db/dir2.c, you'll see that the difference between the dir2_flds[] and the dir3_flds[] is mainly in the type, count and offset fields. For example:

const field_t   dir2_flds[] = {
         { "bhdr", FLDT_DIR2_DATA_HDR, OI(BOFF(magic)), dir2_block_hdr_count,
           FLD_COUNT, TYP_NONE }

...

const field_t dir3_flds[] = {
{ "bhdr", FLDT_DIR3_DATA_HDR, OI(B3OFF(hdr)), dir3_block_hdr_count,
FLD_COUNT, TYP_NONE },
...

if you look at dir[23]_block_hdr_count(), you'll see that they return a boolean value based on a magic number check. Hence when the code is trying to determine the type of the block that has been read (i.e. what the field definition is), if the magic number matches we know exactly what type of contents they contain.

For decoding the dtype, you need too look at how to select the correct structure for the FLDT_DIR2_DATA_UNION. If you don't have the feature set, you need to select the FLDT_DIR2_DATA_UNION structure type, and if it is set you need to select the FLDT_DIR3_DATA_UNION type. Hence you need both these types defined in the dir2_flds[] array, and some manner to ensure the correct values are returned from the count functions.

Quoted 8 lines

And just to make it hard, both the dir2 and dir3 data union count functions use the same function (dir2_data_u_count) so you're going to have to be careful that you don't break the v5 superblock directory decoding....

Cheers,

Dave.

Quoted 6 lines

Thanks Dave. I did some RTFS and found I was having problems with the field_t.flag.

Can't we add a filetype to the dir2 dir2_data_union_flds entry and use the count to turn it on/off? The problem I was having with this was the flag.

ISTR trying something like that previously when doing the dir3 changeover - I couldn't get it to work properly because parts of the structure could not be easily discriminated and so both the v2 and v3 count functions would return true because they were looking at different locations in the structure due to the header size differences.

Quoted 8 lines

In this case, because the structure itself doesn't have any child dependencies and the format will always be considered a v2 directory structure, I think what you propose should work. Did you test it to see if it works?

Cheers,

Dave.

Yes, for example:

mkdir directory
mknod device c 100 100
touch file
ln -s file softlink

and on a short form directory:

u.sfdir3.hdr.count = 4
u.sfdir3.hdr.i8count = 0
u.sfdir3.hdr.parent.i4 = 128
u.sfdir3.list[0].namelen = 9
u.sfdir3.list[0].offset = 0x30
u.sfdir3.list[0].name = "directory"
u.sfdir3.list[0].inumber.i4 = 131
u.sfdir3.list[0].filetype = 2
u.sfdir3.list[1].namelen = 6
u.sfdir3.list[1].offset = 0x48
u.sfdir3.list[1].name = "device"
u.sfdir3.list[1].inumber.i4 = 132
u.sfdir3.list[1].filetype = 3
u.sfdir3.list[2].namelen = 4
u.sfdir3.list[2].offset = 0x60
u.sfdir3.list[2].name = "file"
u.sfdir3.list[2].inumber.i4 = 133
u.sfdir3.list[2].filetype = 1
u.sfdir3.list[3].namelen = 8
u.sfdir3.list[3].offset = 0x70
u.sfdir3.list[3].name = "softlink"
u.sfdir3.list[3].inumber.i4 = 134
u.sfdir3.list[3].filetype = 7

then covert it to a block directory:

xfs_db> dblock 0
xfs_db> p
bhdr.magic = 0x58443242
bhdr.bestfree[0].offset = 0x128
bhdr.bestfree[0].length = 0xe50
bhdr.bestfree[1].offset = 0
bhdr.bestfree[1].length = 0
bhdr.bestfree[2].offset = 0
bhdr.bestfree[2].length = 0
bu[0].inumber = 128
bu[0].namelen = 1
bu[0].name = "."
bu[0].filetype = 2
bu[0].tag = 0x10
bu[1].inumber = 128
bu[1].namelen = 2
bu[1].name = ".."
bu[1].filetype = 2
bu[1].tag = 0x20
bu[2].inumber = 131
bu[2].namelen = 9
bu[2].name = "directory"
bu[2].filetype = 2
bu[2].tag = 0x30
bu[3].inumber = 132
bu[3].namelen = 6
bu[3].name = "device"
bu[3].filetype = 3
bu[3].tag = 0x48
bu[4].inumber = 133
bu[4].namelen = 4
bu[4].name = "file"
bu[4].filetype = 1
bu[4].tag = 0x60
bu[5].inumber = 134
bu[5].namelen = 8
bu[5].name = "softlink"
bu[5].filetype = 7

and works without the file type feature turn off. The libxfs code does the heavy work.

--Mark

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

#21 lore raw
In reply to Mark Tinguely
Quoted 71 lines · Mark Tinguely
Quoted 57 lines · Dave Chinner
Quoted 16 lines · Mark Tinguely
Quoted 10 lines · Mark Tinguely

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

Unchanged
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
New
patch 3: add feature to the xfs_db version command.

Quoted 4 lines

Fixed
patch 4: add the feature to mkfs.xfs and manual page.
note: this new feature is ignored for superblock v5
automatically turns on this feature.

Quoted 7 lines

FYI.

I saw the request for adding the filetype entry to block/leaf after posting.

I have it displaying unconditionally, but am trying to figure out how to make it display only for filesytems that support the ftype feature. I am missing something in the field.count().

The count function only tells the code whether a structure is present or not, but it does not tell you what the format of the structure is.

if you look at db/dir2.c, you'll see that the difference between the dir2_flds[] and the dir3_flds[] is mainly in the type, count and offset fields. For example:

const field_t   dir2_flds[] = {
        { "bhdr", FLDT_DIR2_DATA_HDR, OI(BOFF(magic)), dir2_block_hdr_count,
          FLD_COUNT, TYP_NONE }

...

const field_t dir3_flds[] = {
{ "bhdr", FLDT_DIR3_DATA_HDR, OI(B3OFF(hdr)), dir3_block_hdr_count,
FLD_COUNT, TYP_NONE },
...

if you look at dir[23]_block_hdr_count(), you'll see that they return a boolean value based on a magic number check. Hence when the code is trying to determine the type of the block that has been read (i.e. what the field definition is), if the magic number matches we know exactly what type of contents they contain.

For decoding the dtype, you need too look at how to select the correct structure for the FLDT_DIR2_DATA_UNION. If you don't have the feature set, you need to select the FLDT_DIR2_DATA_UNION structure type, and if it is set you need to select the FLDT_DIR3_DATA_UNION type. Hence you need both these types defined in the dir2_flds[] array, and some manner to ensure the correct values are returned from the count functions.

Quoted 8 lines

And just to make it hard, both the dir2 and dir3 data union count functions use the same function (dir2_data_u_count) so you're going to have to be careful that you don't break the v5 superblock directory decoding....

Cheers,

Dave.

Thanks Dave. I did some RTFS and found I was having problems with the field_t.flag.

Quoted 6 lines

Can't we add a filetype to the dir2 dir2_data_union_flds entry and use the count to turn it on/off? The problem I was having with this was the flag. Something like:

Add the directory field type information to xfs_db directory displays.

Can you send this as a proper patch with SOB, etc?

Cheers,

Dave.

Signature · 7 lines
Dave Chinner
[email protected]

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

[patch 5/4] xfsprogs: add field types to v4 xfs_db directory entries

In reply to Mark Tinguely

Display the inode type field that follows the name in xfs_db for dir2 (non-crc filesystems) that enabled the feature (mkfs -n ftype).

---
 db/dir2.c |   12 ++++++++++++
 1 file changed, 12 insertions(+)
db/dir2.c +12 -0
Index: b/db/dir2.c
===================================================================
@@ -52,6 +52,8 @@ static int	dir2_leaf_tail_count(void *ob
 static int	dir2_leaf_tail_offset(void *obj, int startoff, int idx);
 static int	dir2_node_btree_count(void *obj, int startoff);
 static int	dir2_node_hdr_count(void *obj, int startoff);
+static int	dir3_data_union_ftype_offset(void *obj, int startoff, int idx);
+static int	dir2_data_union_ftype_count(void *obj, int startoff);
 
 const field_t	dir2_hfld[] = {
 	{ "", FLDT_DIR2, OI(0), C1, 0, TYP_NONE },
@@ -130,6 +132,8 @@ const field_t	dir2_data_union_flds[] = {
 	  dir2_data_union_namelen_count, FLD_COUNT, TYP_NONE },
 	{ "name", FLDT_CHARNS, OI(DEOFF(name)), dir2_data_union_name_count,
 	  FLD_COUNT, TYP_NONE },
+	{ "filetype", FLDT_UINT8D, dir3_data_union_ftype_offset,
+	  dir2_data_union_ftype_count, FLD_OFFSET|FLD_COUNT, TYP_NONE },
 	{ "tag", FLDT_DIR2_DATA_OFF, dir2_data_union_tag_offset,
 	  dir2_data_union_tag_count, FLD_OFFSET|FLD_COUNT, TYP_NONE },
 	{ NULL }
@@ -454,6 +458,14 @@ dir2_data_union_name_count(
 }
 
 static int
+dir2_data_union_ftype_count(
+	void			*obj,
+	int			startoff)
+{
+	return xfs_sb_version_hasftype(&mp->m_sb);
+}
+
+static int
 dir2_data_union_namelen_count(
 	void			*obj,
 	int			startoff)

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