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

Theodore Tso <[email protected]> Sat, 5 Aug 2006 14:49:58 -0400
Newsgroups gmane.comp.file-systems.ext2.devel
Message-ID <[email protected]>
On Wed, Aug 02, 2006 at 10:50:10AM -0600, Andreas Dilger wrote:
> 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.

Thanks, 

I removed the #else part of the #ifdef EXT2_DYNAMIC_REV since in the
version of ext2_fs.h that we include, it's guaranteed that
EXT2_DYNAMIC_REV is defined.  This was left over from when we tried to
use the system-provided ext2fs.h from the kernel header files, long,
loing ago.  The patch I applied is as follows.

						- Ted

# HG changeset patch
# User [email protected]
# Date 1153015700 14400
# Node ID 76bcbe906454c696c29874fab94a3da462829e51
# Parent  45ae75afc058396659aca3795ebb5e6ea03590d2
Allow default inode_size to be specified in mke2fs.conf and document mke2fs -I

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.

Clean up dead lines in ext2fs.h.

Signed-off-by: Andreas Dilger <[email protected]>
Signed-off-by: "Theodore Ts'o" <[email protected]>

diff -r 45ae75afc058 -r 76bcbe906454 lib/ext2fs/ChangeLog
--- a/lib/ext2fs/ChangeLog	Sat Jul 15 21:55:33 2006 -0400
+++ b/lib/ext2fs/ChangeLog	Sat Jul 15 22:08:20 2006 -0400
@@ -1,3 +1,8 @@ 2006-05-21  Theodore Tso  <[email protected]
+2006-07-15  Theodore Tso  <[email protected]>
+
+	* ext2fs.h: Remove unneeded #ifdef since EXT2_DYNAMIC_REV is
+		always defined in the e2fsprogs-provided ext2_fs.h
+
 2006-05-21  Theodore Tso  <[email protected]>
 
 	* openfs.c (ext2fs_open2): Fix type warning problem with sizeof()
diff -r 45ae75afc058 -r 76bcbe906454 lib/ext2fs/ext2fs.h
--- a/lib/ext2fs/ext2fs.h	Sat Jul 15 21:55:33 2006 -0400
+++ b/lib/ext2fs/ext2fs.h	Sat Jul 15 22:08:20 2006 -0400
@@ -117,15 +117,11 @@ typedef struct ext2fs_struct_generic_bit
 typedef struct ext2fs_struct_generic_bitmap *ext2fs_inode_bitmap;
 typedef struct ext2fs_struct_generic_bitmap *ext2fs_block_bitmap;
 
-#ifdef EXT2_DYNAMIC_REV
 #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)
-#endif
-
-/*
- * badblocks list definitions
+
+
+/*
+ * Badblocks list definitions
  */
 
 typedef struct ext2_struct_u32_list *ext2_badblocks_list;
diff -r 45ae75afc058 -r 76bcbe906454 misc/ChangeLog
--- a/misc/ChangeLog	Sat Jul 15 21:55:33 2006 -0400
+++ b/misc/ChangeLog	Sat Jul 15 22:08:20 2006 -0400
@@ -1,4 +1,12 @@ 2006-07-15  Theodore Tso  <[email protected]
 2006-07-15  Theodore Tso  <[email protected]>
+
+	* mke2fs.c (PRS): Look up the default inode size in the
+		mke2fs.conf file.
+
+	* mke2fs.8.in, mke2fs.c(usage): Document the -I option.	
+
+	* mke2fs.conf.5.in: Document the inode_size relation in [defaults]
+		and [fs_types].
 
 	* chattr.1.in: Fix spelling typo
 
diff -r 45ae75afc058 -r 76bcbe906454 misc/mke2fs.8.in
--- a/misc/mke2fs.8.in	Sat Jul 15 21:55:33 2006 -0400
+++ b/misc/mke2fs.8.in	Sat Jul 15 22:08:20 2006 -0400
@@ -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 45ae75afc058 -r 76bcbe906454 misc/mke2fs.c
--- a/misc/mke2fs.c	Sat Jul 15 21:55:33 2006 -0400
+++ b/misc/mke2fs.c	Sat Jul 15 22:08:20 2006 -0400
@@ -94,11 +94,12 @@ 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] "
-	"[-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"),
+	"[-f fragment-size]\n\t[-i bytes-per-inode] [-I inode-size] "
+	"[-j] [-J journal-options]\n"
+	"\t[-N number-of-inodes] [-m reserved-blocks-percentage] "
+	"[-o creator-os]\n\t[-g blocks-per-group] [-L volume-label] "
+	"[-M last-mounted-directory]\n\t[-O feature[,...]] "
+	"[-r fs-revision] [-R options] [-qvSV]\n\tdevice [blocks-count]\n"),
 		program_name);
 	exit(1);
 }
@@ -1076,7 +1077,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 +1085,6 @@ static void PRS(int argc, char *argv[])
 				exit(1);
 			}
 			break;
-#endif
 		case 'v':
 			verbose = 1;
 			break;
@@ -1413,7 +1412,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 +1432,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;
 	}
diff -r 45ae75afc058 -r 76bcbe906454 misc/mke2fs.conf.5.in
--- a/misc/mke2fs.conf.5.in	Sat Jul 15 21:55:33 2006 -0400
+++ b/misc/mke2fs.conf.5.in	Sat Jul 15 22:08:20 2006 -0400
@@ -131,6 +131,12 @@ specify one on the command line, and the
 specify one on the command line, and the filesystem-type
 specific section of the configuration file does not specify a default
 inode ratio.
+.TP
+.I inode_size
+This relation specifies the default inode size if the user does not
+specify one on the command line, and the filesystem-type
+specific section of the configuration file does not specify a default
+inode size.
 .SH THE [fs_types] STANZA
 Each tag in the
 .I [fs_types] 
@@ -181,6 +187,10 @@ specify a blocksize on the command line.
 .I inode_ratio
 This relation specifies the default inode ratio if the user does not
 specify one on the command line.
+.TP
+.I inode_size
+This relation specifies the default inode size if the user does not
+specify one on the command line.
 .SH FILES
 .TP
 .I /etc/mke2fs.conf

-------------------------------------------------------------------------
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