[PATCH] 04/13 e2fsprogs-inode_size allow large inodes by default

Andreas Dilger <[email protected]> Wed, 2 Aug 2006 10:50:10 -0600
Newsgroups gmane.comp.file-systems.ext2.devel
Message-ID <[email protected]>
This patch allows "inode_size" to be specified in the mke2fs.conf file,
and always compiles in the "-I" option.  In addition, it disallows
specifying the inode size on rev 0 filesystems, though I don't think
this was much of a danger anyways.

Document the -I option in the mke2fs(8) man page and the usage message.

=========================================================================
diff -r 46fd786b5562 lib/ext2fs/ext2fs.h
--- a/lib/ext2fs/ext2fs.h	Mon May 29 11:47:49 2006 -0400
+++ b/lib/ext2fs/ext2fs.h	Wed Jul  5 12:13:17 2006 -0600
@@ -121,7 +121,7 @@ typedef struct ext2fs_struct_generic_bit
 #define EXT2_FIRST_INODE(s)	EXT2_FIRST_INO(s)
 #else
 #define EXT2_FIRST_INODE(s)	EXT2_FIRST_INO
-#define EXT2_INODE_SIZE(s)	sizeof(struct ext2_inode)
+#define EXT2_INODE_SIZE(s)	EXT2_GOOD_OLD_INODE_SIZE
 #endif
 
 /*
diff -r 7c019255c280 misc/mke2fs.8.in
--- a/misc/mke2fs.8.in	Mon May 29 11:47:25 2006 -0400
+++ b/misc/mke2fs.8.in	Wed Jul  5 14:17:37 2006 -0600
@@ -28,6 +28,10 @@ mke2fs \- create an ext2/ext3 filesystem
 [
 .B \-i
 .I bytes-per-inode
+]
+[
+.B \-I
+.I inode-size
 ]
 [
 .B \-j
@@ -218,6 +222,23 @@ inodes will be made.  Be warned that is 
 inodes will be made.  Be warned that is not possible to expand the number 
 of inodes on a filesystem after it is created, so be careful deciding the
 correct value for this parameter. 
+.TP
+.BI \-I " inode-size"
+Specify the size of each inode in bytes. 
+.B mke2fs
+creates 128-byte inodes by default.  In kernels after 2.6.10 and some
+earlier vendor kernels it is possible to utilize larger inodes to store
+extended attributes for improved performance.  The 
+.I inode-size
+value must be a power of two larger or equal to 128.  The larger the 
+.I inode-size
+the more space the inode table will consume, and this reduces the usable
+space in the filesystem and can also negatively impact performance.  Using
+the default value is always safe, though it may be desirable to use 256-byte
+inodes if full backward compatibility is not a concern.  Extended attributes
+stored in large inodes are not visible with older kernels, and such
+filesystems will not be mountable with 2.4 kernels at all.  It is not
+possible to change this value after the filesystem is created.
 .TP 
 .B \-j
 Create the filesystem with an ext3 journal.  If the
diff -r 46fd786b5562 misc/mke2fs.c
--- a/misc/mke2fs.c	Mon May 29 11:47:49 2006 -0400
+++ b/misc/mke2fs.c	Thu Jun 22 00:52:43 2006 -0600
@@ -94,8 +94,9 @@ static void usage(void)
 static void usage(void)
 {
 	fprintf(stderr, _("Usage: %s [-c|-t|-l filename] [-b block-size] "
-	"[-f fragment-size]\n\t[-i bytes-per-inode] [-j] [-J journal-options]"
-	" [-N number-of-inodes]\n\t[-m reserved-blocks-percentage] "
+	"[-f fragment-size]\n\t[-i bytes-per-inode] [-I inode-size] "
+	"[-j] [-J journal-options] [-N number-of-inodes]\n"
+	"\t[-m reserved-blocks-percentage] "
 	"[-o creator-os] [-g blocks-per-group]\n\t[-L volume-label] "
 	"[-M last-mounted-directory] [-O feature[,...]]\n\t"
 	"[-r fs-revision] [-R options] [-qvSV] device [blocks-count]\n"),
@@ -1076,7 +1076,6 @@ static void PRS(int argc, char *argv[])
 		case 's':	/* deprecated */
 			s_opt = atoi(optarg);
 			break;
-#ifdef EXT2_DYNAMIC_REV
 		case 'I':
 			inode_size = strtoul(optarg, &tmp, 0);
 			if (*tmp) {
@@ -1085,7 +1084,6 @@ static void PRS(int argc, char *argv[])
 				exit(1);
 			}
 			break;
-#endif
 		case 'v':
 			verbose = 1;
 			break;
@@ -1413,7 +1411,15 @@ static void PRS(int argc, char *argv[])
 			"blocksizes greater than 4096\n\tusing ext3.  "
 			"Use -b 4096 if this is an issue for you.\n\n"));
 
-	if (inode_size) {
+	if (inode_size == 0) {
+		profile_get_integer(profile, "defaults", "inode_size", NULL,
+				    0, &inode_size);
+		profile_get_integer(profile, "fs_types", fs_type,
+				    "inode_size", inode_size,
+				    &inode_size);
+	}
+
+	if (inode_size && fs_param.s_rev_level >= EXT2_DYNAMIC_REV) {
 		if (inode_size < EXT2_GOOD_OLD_INODE_SIZE ||
 		    inode_size > EXT2_BLOCK_SIZE(&fs_param) ||
 		    inode_size & (inode_size - 1)) {
@@ -1425,7 +1431,7 @@ static void PRS(int argc, char *argv[])
 		}
 		if (inode_size != EXT2_GOOD_OLD_INODE_SIZE)
 			fprintf(stderr, _("Warning: %d-byte inodes not usable "
-				"on most systems\n"),
+				"on older systems\n"),
 				inode_size);
 		fs_param.s_inode_size = inode_size;
 	}

Cheers, Andreas
--
Andreas Dilger
Principal Software Engineer
Cluster File Systems, Inc.


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV