From: Jan Kara <jack@suse.com>
To: linux-ext4@vger.kernel.org
Cc: Ted Tso <tytso@mit.edu>,
"Darrick J. Wong" <darrick.wong@oracle.com>,
Jan Kara <jack@suse.cz>
Subject: [PATCH 09/21] mke2fs: Allow specifying number of reserved inodes
Date: Wed, 26 Aug 2015 18:22:24 +0200 [thread overview]
Message-ID: <1440606156-5754-10-git-send-email-jack@suse.com> (raw)
In-Reply-To: <1440606156-5754-1-git-send-email-jack@suse.com>
From: Jan Kara <jack@suse.cz>
Add option to specify number of reserved inodes in the created
filesystem.
Signed-off-by: Jan Kara <jack@suse.cz>
---
misc/mke2fs.8.in | 6 ++++++
misc/mke2fs.c | 40 +++++++++++++++++++++++++++++++++++++++-
2 files changed, 45 insertions(+), 1 deletion(-)
diff --git a/misc/mke2fs.8.in b/misc/mke2fs.8.in
index 40c40d3ed065..4165c0a9d051 100644
--- a/misc/mke2fs.8.in
+++ b/misc/mke2fs.8.in
@@ -384,6 +384,12 @@ Do not attempt to discard blocks at mkfs time.
@QUOTA_MAN_COMMENT@.B quota
@QUOTA_MAN_COMMENT@feature is set. Without this extended option, the default
@QUOTA_MAN_COMMENT@behavior is to initialize both user and group quotas.
+.TP
+.BI reserved_inodes= number
+Specify the number of inodes reserved for system files. This number must be
+at least 10. Currently 10 is enough but future features may require additional
+reserved inodes. Reserving more inodes after the file system is created
+requires full file system scan which can take a long time.
.RE
.TP
.BI \-f " fragment-size"
diff --git a/misc/mke2fs.c b/misc/mke2fs.c
index 78b1252d8519..d61d1a332e67 100644
--- a/misc/mke2fs.c
+++ b/misc/mke2fs.c
@@ -1024,6 +1024,34 @@ static void parse_extended_opts(struct ext2_super_block *param,
r_usage++;
continue;
}
+ } else if (!strcmp(token, "reserved_inodes")) {
+ unsigned int reserved_inodes;
+
+ if (!arg) {
+ r_usage++;
+ badopt = token;
+ continue;
+ }
+ reserved_inodes = strtoul(arg, &p, 0);
+ if (*p) {
+ fprintf(stderr,
+ _("Invalid number of reserved inodes "
+ "%s\n"),
+ arg);
+ r_usage++;
+ continue;
+ }
+ /* Ino 0 is invalid so bump by 1... */
+ reserved_inodes++;
+ if (reserved_inodes < EXT2_GOOD_OLD_FIRST_INO) {
+ fprintf(stderr,
+ _("Too few reserved inodes "
+ "%s (must be at least %u)\n"),
+ arg, EXT2_GOOD_OLD_FIRST_INO - 1);
+ r_usage++;
+ continue;
+ }
+ param->s_first_ino = reserved_inodes;
} else {
r_usage++;
badopt = token;
@@ -1049,7 +1077,8 @@ static void parse_extended_opts(struct ext2_super_block *param,
"\ttest_fs\n"
"\tdiscard\n"
"\tnodiscard\n"
- "\tquotatype=<usr OR grp>\n\n"),
+ "\tquotatype=<usr OR grp>\n"
+ "\treserved_inodes=<number of reserved inodes>\n\n"),
badopt ? badopt : "");
free(buf);
exit(1);
@@ -2422,6 +2451,15 @@ profile_error:
exit(1);
}
+ /* Count with one more inode for lost+found */
+ if (fs_param.s_first_ino >= fs_param.s_inodes_count + 1) {
+ com_err(program_name, 0, _("asked for more reserved inodes than filesystem has "
+ "available (%u >= %u)\n"),
+ (unsigned int)fs_param.s_first_ino,
+ (unsigned int)fs_param.s_inodes_count + 1);
+ exit(1);
+ }
+
/*
* Calculate number of blocks to reserve
*/
--
2.1.4
next prev parent reply other threads:[~2015-08-26 16:22 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-26 16:22 [PATCH 00/21 v2] e2fsprogs: Resizing rewrite Jan Kara
2015-08-26 16:22 ` [PATCH 01/21] ext2fs: Add pointer to allocator private data into ext2_filsys Jan Kara
2015-08-26 16:22 ` [PATCH 02/21] ext2fs: Implement ext2fs_allocate_group_table2() Jan Kara
2015-08-26 16:22 ` [PATCH 03/21] resize2fs: Use ext2fs_allocate_group_table2() Jan Kara
2015-08-26 16:22 ` [PATCH 04/21] ext2fs: Provide helper for wiping resize inode Jan Kara
2015-08-26 16:22 ` [PATCH 05/21] ext2fs: Implement block moving in libext2fs Jan Kara
2015-08-26 16:22 ` [PATCH 06/21] ext2fs: Implement inode " Jan Kara
2015-08-26 16:22 ` [PATCH 07/21] tune2fs: Implement setting and disabling of 64-bit feature Jan Kara
2015-08-26 16:22 ` [PATCH 08/21] tests: Convert tests for 64bit feature to use tune2fs Jan Kara
2015-08-26 16:22 ` Jan Kara [this message]
2015-08-26 16:22 ` [PATCH 10/21] ext2fs: Fixup inline directory test Jan Kara
2015-08-26 16:22 ` [PATCH 11/21] tests: Specify number of reserved inodes for tests where it matters Jan Kara
2015-08-26 16:22 ` [PATCH 12/21] libext2fs: Bump default number of reserved inodes to 64 Jan Kara
2015-08-26 16:22 ` [PATCH 13/21] tune2fs: Add support for changing number of reserved inodes Jan Kara
2015-08-26 16:22 ` [PATCH 14/21] mke2fs, tune2fs: Tests for handling reserved_inodes option Jan Kara
2015-08-26 16:22 ` [PATCH 15/21] resize2fs: Rip out 64-bit feature handling from resize2fs Jan Kara
2015-08-26 16:22 ` [PATCH 16/21] ext2fs: Remove old block mapping function Jan Kara
2015-08-26 16:22 ` [PATCH 17/21] resize2fs: Remove duplicate condition Jan Kara
2015-08-26 16:22 ` [PATCH 18/21] ext2fs: Add extent dumping function to extent mapping code Jan Kara
2015-08-26 16:22 ` [PATCH 19/21] resize2fs: Remove " Jan Kara
2015-08-26 16:22 ` [PATCH 20/21] ext2fs: Move extent mapping test Jan Kara
2015-08-26 16:22 ` [PATCH 21/21] resize2fs: Use libextfs2 helpers for resizing Jan Kara
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=1440606156-5754-10-git-send-email-jack@suse.com \
--to=jack@suse.com \
--cc=darrick.wong@oracle.com \
--cc=jack@suse.cz \
--cc=linux-ext4@vger.kernel.org \
--cc=tytso@mit.edu \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).