diff options
author | Jan Kara <jack@suse.cz> | 2021-07-12 17:43:11 +0200 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2021-08-03 14:22:30 -0400 |
commit | 22bb83c4255fb4aae8a0fa32763efdef6d05948c (patch) | |
tree | a18dab08c51fc1d78dfc1985ae28bd314d7dcccc | |
parent | 361815c7386b8e2c5450063513d3746baa706f03 (diff) | |
download | e2fsprogs-22bb83c4255fb4aae8a0fa32763efdef6d05948c.tar.gz |
mke2fs: Add support for orphan_file feature
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
-rw-r--r-- | misc/mke2fs.8.in | 5 | ||||
-rw-r--r-- | misc/mke2fs.c | 36 |
2 files changed, 40 insertions, 1 deletions
diff --git a/misc/mke2fs.8.in b/misc/mke2fs.8.in index 84248ffc9..3747c93a0 100644 --- a/misc/mke2fs.8.in +++ b/misc/mke2fs.8.in @@ -403,6 +403,11 @@ filesystem to change based on the user running \fBmke2fs\fR. Set a flag in the filesystem superblock indicating that it may be mounted using experimental kernel code, such as the ext4dev filesystem. .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 31e8de1ac..81c435352 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| @@ -3455,6 +3472,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 " + "flag 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) |