From: Jan Kara <jack@suse.cz>
To: Ted Tso <tytso@mit.edu>
Cc: <linux-ext4@vger.kernel.org>, Jan Kara <jack@suse.cz>
Subject: [PATCH 2/5] mke2fs: Add support for orphan_file feature
Date: Thu, 26 Aug 2021 00:11:31 +0200 [thread overview]
Message-ID: <20210825221143.30705-2-jack@suse.cz> (raw)
In-Reply-To: <20210825220922.4157-1-jack@suse.cz>
Signed-off-by: Jan Kara <jack@suse.cz>
---
misc/mke2fs.8.in | 5 +++++
misc/mke2fs.c | 53 +++++++++++++++++++++++++++++++++++++++++++++---
2 files changed, 55 insertions(+), 3 deletions(-)
diff --git a/misc/mke2fs.8.in b/misc/mke2fs.8.in
index c0b5324569a1..b378e4d7c5e1 100644
--- a/misc/mke2fs.8.in
+++ b/misc/mke2fs.8.in
@@ -403,6 +403,11 @@ file system to change based on the user running \fBmke2fs\fR.
Set a flag in the file system superblock indicating that it may be
mounted using experimental kernel code, such as the ext4dev file system.
.TP
+.BI orphan_file_size= size
+Set size of the file for tracking unlinked but still open inodes and inodes
+with truncate in progress. Larger file allows for better scalability, reserving
+a few blocks per cpu is ideal.
+.TP
.B discard
Attempt to discard blocks at mkfs time (discarding blocks initially is useful
on solid state devices and sparse / thin-provisioned storage). When the device
diff --git a/misc/mke2fs.c b/misc/mke2fs.c
index 04b2fbce638a..c955b318e960 100644
--- a/misc/mke2fs.c
+++ b/misc/mke2fs.c
@@ -94,6 +94,7 @@ static gid_t root_gid;
int journal_size;
int journal_flags;
int journal_fc_size;
+static e2_blkcnt_t orphan_file_blocks;
static int lazy_itable_init;
static int packed_meta_blocks;
int no_copy_xattrs;
@@ -1089,6 +1090,21 @@ static void parse_extended_opts(struct ext2_super_block *param,
continue;
}
encoding_flags = arg;
+ } else if (!strcmp(token, "orphan_file_size")) {
+ if (!arg) {
+ r_usage++;
+ badopt = token;
+ continue;
+ }
+ orphan_file_blocks = parse_num_blocks2(arg,
+ fs_param.s_log_block_size);
+ if (orphan_file_blocks == 0) {
+ fprintf(stderr,
+ _("Invalid size of orphan file %s\n"),
+ arg);
+ r_usage++;
+ continue;
+ }
} else {
r_usage++;
badopt = token;
@@ -1156,7 +1172,8 @@ static __u32 ok_features[3] = {
EXT2_FEATURE_COMPAT_EXT_ATTR |
EXT4_FEATURE_COMPAT_SPARSE_SUPER2 |
EXT4_FEATURE_COMPAT_FAST_COMMIT |
- EXT4_FEATURE_COMPAT_STABLE_INODES,
+ EXT4_FEATURE_COMPAT_STABLE_INODES |
+ EXT4_FEATURE_COMPAT_ORPHAN_FILE,
/* Incompat */
EXT2_FEATURE_INCOMPAT_FILETYPE|
EXT3_FEATURE_INCOMPAT_EXTENTS|
@@ -1551,6 +1568,7 @@ static void PRS(int argc, char *argv[])
int lsector_size = 0, psector_size = 0;
int show_version_only = 0, is_device = 0;
unsigned long long num_inodes = 0; /* unsigned long long to catch too-large input */
+ int default_orphan_file = 0;
errcode_t retval;
char * oldpath = getenv("PATH");
char * extended_opts = 0;
@@ -2101,8 +2119,20 @@ profile_error:
ext2fs_clear_feature_ea_inode(&fs_param);
ext2fs_clear_feature_casefold(&fs_param);
}
- edit_feature(fs_features ? fs_features : tmp,
- &fs_param.s_feature_compat);
+ if (!fs_features && tmp)
+ edit_feature(tmp, &fs_param.s_feature_compat);
+ /*
+ * Now all the defaults are incorporated in fs_param. Check the state
+ * of orphan_file feature so that we know whether we should silently
+ * disabled in case journal gets disabled.
+ */
+ if (ext2fs_has_feature_orphan_file(&fs_param))
+ default_orphan_file = 1;
+ if (fs_features)
+ edit_feature(fs_features, &fs_param.s_feature_compat);
+ /* Silently disable orphan_file if user chose fs without journal */
+ if (default_orphan_file && !ext2fs_has_feature_journal(&fs_param))
+ ext2fs_clear_feature_orphan_file(&fs_param);
if (tmp)
free(tmp);
(void) ext2fs_free_mem(&fs_features);
@@ -3471,6 +3501,23 @@ no_journal:
fix_cluster_bg_counts(fs);
if (ext2fs_has_feature_quota(&fs_param))
create_quota_inodes(fs);
+ if (ext2fs_has_feature_orphan_file(&fs_param)) {
+ if (!ext2fs_has_feature_journal(&fs_param)) {
+ com_err(program_name, 0, _("cannot set orphan_file "
+ "feature without a journal."));
+ exit(1);
+ }
+ if (!orphan_file_blocks) {
+ orphan_file_blocks =
+ ext2fs_default_orphan_file_blocks(fs);
+ }
+ retval = ext2fs_create_orphan_file(fs, orphan_file_blocks);
+ if (retval) {
+ com_err(program_name, retval,
+ _("while creating orphan file"));
+ exit(1);
+ }
+ }
retval = mk_hugefiles(fs, device_name);
if (retval)
--
2.26.2
next prev parent reply other threads:[~2021-08-25 22:11 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-25 22:11 [PATCH 0/5 v6] e2fsprogs: Support for orphan file feature Jan Kara
2021-08-25 22:11 ` [PATCH 1/5] libext2fs: " Jan Kara
2021-10-01 2:00 ` Theodore Ts'o
2021-08-25 22:11 ` Jan Kara [this message]
2021-08-25 22:11 ` [PATCH 3/5] e2fsck: Add support for handling orphan file Jan Kara
2021-08-25 22:11 ` [PATCH 4/5] tune2fs: Add support for orphan_file feature Jan Kara
2021-08-25 22:11 ` [PATCH 5/5] dumpe2fs, debugfs, e2image: Add support for orphan file Jan Kara
-- strict thread matches above, loose matches on Subject: below --
2021-08-11 10:30 [PATCH 0/5 v5] e2fsprogs: Support for orphan file feature Jan Kara
2021-08-11 10:30 ` [PATCH 2/5] mke2fs: Add support for orphan_file feature Jan Kara
2015-05-26 7:51 [PATCH 0/4 v2] e2fsprogs: Support for orphan file feature Jan Kara
2015-05-26 7:51 ` [PATCH 2/5] mke2fs: Add support for orphan_file feature 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=20210825221143.30705-2-jack@suse.cz \
--to=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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.