From: Theodore Ts'o <tytso@mit.edu>
To: Ext4 Developers List <linux-ext4@vger.kernel.org>
Cc: Theodore Ts'o <tytso@mit.edu>
Subject: [PATCH 12/12] mke2fs: allow metadata blocks to be at the beginning of the file system
Date: Mon, 20 Jan 2014 00:54:14 -0500 [thread overview]
Message-ID: <1390197254-14583-13-git-send-email-tytso@mit.edu> (raw)
In-Reply-To: <1390197254-14583-1-git-send-email-tytso@mit.edu>
Add the extended options packed_meta_blocks and journal_location_front
which causes mke2fs to place the metadata blocks at the beginning of
the file system.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
---
lib/ext2fs/ext2fs.h | 1 +
lib/ext2fs/mkjournal.c | 5 +++-
misc/mke2fs.8.in | 14 +++++++++++
misc/mke2fs.c | 65 +++++++++++++++++++++++++++++++++++++++++++++++++-
misc/mke2fs.conf.5.in | 4 ++++
5 files changed, 87 insertions(+), 2 deletions(-)
diff --git a/lib/ext2fs/ext2fs.h b/lib/ext2fs/ext2fs.h
index efe0964..fed6410 100644
--- a/lib/ext2fs/ext2fs.h
+++ b/lib/ext2fs/ext2fs.h
@@ -204,6 +204,7 @@ typedef struct ext2_file *ext2_file_t;
#define EXT2_MKJOURNAL_V1_SUPER 0x0000001 /* create V1 superblock (deprecated) */
#define EXT2_MKJOURNAL_LAZYINIT 0x0000002 /* don't zero journal inode before use*/
#define EXT2_MKJOURNAL_NO_MNT_CHECK 0x0000004 /* don't check mount status */
+#define EXT2_MKJOURNAL_LOCATION_FRONT 0x0000004 /* journal at the beginning */
struct opaque_ext2_group_desc;
diff --git a/lib/ext2fs/mkjournal.c b/lib/ext2fs/mkjournal.c
index d09c458..aa6d9af 100644
--- a/lib/ext2fs/mkjournal.c
+++ b/lib/ext2fs/mkjournal.c
@@ -360,7 +360,10 @@ static errcode_t write_journal_inode(ext2_filsys fs, ext2_ino_t journal_ino,
ext2fs_bg_free_blocks_count(fs, group))
group = i;
- es.goal = ext2fs_group_first_block2(fs, group);
+ if (flags & EXT2_MKJOURNAL_LOCATION_FRONT)
+ es.goal = 0;
+ else
+ es.goal = ext2fs_group_first_block2(fs, group);
retval = ext2fs_block_iterate3(fs, journal_ino, BLOCK_FLAG_APPEND,
0, mkjournal_proc, &es);
if (es.err) {
diff --git a/misc/mke2fs.8.in b/misc/mke2fs.8.in
index 483fb1c..9f8c9f6 100644
--- a/misc/mke2fs.8.in
+++ b/misc/mke2fs.8.in
@@ -280,6 +280,20 @@ If the
file system feature is enabled this option controls whether there will
be 0, 1, or 2 backup superblocks created in the file system.
.TP
+.B packed_meta_blocks\fR[\fB= \fI<0 to disable, 1 to enable>\fR]
+Place the allocation bitmaps and the inode table at the beginning of the
+disk. This option requires that the flex_bg file system feature to be
+enabled in order for it to have effect, and also implies the
+extended option
+.IR journal_location_front .
+This option is useful for flash devices that use SLC flash at the beginning of
+the disk. It also maximizes the range of contiguous data blocks, which
+can be useful for certain specialized use cases, such as supported
+Shingled Drives.
+.TP
+.B journal_location_front\fR[\fB= \fI<0 to disable, 1 to enable>\fR]
+Place the journal at the beginning of the file system.
+.TP
.BI root_owner [=uid:gid]
Specify the numeric user and group ID of the root directory. If no UID:GID
is specified, use the user and group ID of the user running \fBmke2fs\fR.
diff --git a/misc/mke2fs.c b/misc/mke2fs.c
index efb068a..363e96b 100644
--- a/misc/mke2fs.c
+++ b/misc/mke2fs.c
@@ -94,6 +94,7 @@ static gid_t root_gid;
int journal_size;
int journal_flags;
static int lazy_itable_init;
+static int packed_meta_blocks;
static char *bad_blocks_filename = NULL;
static __u32 fs_stride;
static int quotatype = -1; /* Initialize both user and group quotas by default */
@@ -310,6 +311,40 @@ _("Warning: the backup superblock/group descriptors at block %u contain\n"
ext2fs_badblocks_list_iterate_end(bb_iter);
}
+static errcode_t packed_allocate_tables(ext2_filsys fs)
+{
+ errcode_t retval;
+ dgrp_t i;
+ blk64_t goal = 0;
+
+ for (i = 0; i < fs->group_desc_count; i++) {
+ retval = ext2fs_new_block2(fs, goal, NULL, &goal);
+ if (retval)
+ return retval;
+ ext2fs_block_alloc_stats2(fs, goal, +1);
+ ext2fs_block_bitmap_loc_set(fs, i, goal);
+ }
+ for (i = 0; i < fs->group_desc_count; i++) {
+ retval = ext2fs_new_block2(fs, goal, NULL, &goal);
+ if (retval)
+ return retval;
+ ext2fs_block_alloc_stats2(fs, goal, +1);
+ ext2fs_inode_bitmap_loc_set(fs, i, goal);
+ }
+ for (i = 0; i < fs->group_desc_count; i++) {
+ blk64_t end = ext2fs_blocks_count(fs->super) - 1;
+ retval = ext2fs_get_free_blocks2(fs, goal, end,
+ fs->inode_blocks_per_group,
+ fs->block_map, &goal);
+ if (retval)
+ return retval;
+ ext2fs_block_alloc_stats_range(fs, goal,
+ fs->inode_blocks_per_group, +1);
+ ext2fs_inode_table_loc_set(fs, i, goal);
+ }
+ return 0;
+}
+
static void write_inode_tables(ext2_filsys fs, int lazy_flag, int itable_zeroed)
{
errcode_t retval;
@@ -712,6 +747,14 @@ static void parse_extended_opts(struct ext2_super_block *param,
continue;
}
param->s_desc_size = desc_size;
+ } else if (strcmp(token, "journal_location_front") == 0) {
+ unsigned long front = 1;
+ if (arg)
+ front = strtoul(arg, &p, 0);
+ if (front)
+ journal_flags |= EXT2_MKJOURNAL_LOCATION_FRONT;
+ else
+ journal_flags &= ~EXT2_MKJOURNAL_LOCATION_FRONT;
} else if (strcmp(token, "offset") == 0) {
if (!arg) {
r_usage++;
@@ -754,6 +797,15 @@ static void parse_extended_opts(struct ext2_super_block *param,
r_usage++;
continue;
}
+ } else if (strcmp(token, "packed_meta_blocks") == 0) {
+ if (arg)
+ packed_meta_blocks = strtoul(arg, &p, 0);
+ else
+ packed_meta_blocks = 1;
+ if (packed_meta_blocks)
+ journal_flags |= EXT2_MKJOURNAL_LOCATION_FRONT;
+ else
+ journal_flags &= ~EXT2_MKJOURNAL_LOCATION_FRONT;
} else if (strcmp(token, "stride") == 0) {
if (!arg) {
r_usage++;
@@ -915,8 +967,10 @@ static void parse_extended_opts(struct ext2_super_block *param,
"\tstripe-width=<RAID stride * data disks in blocks>\n"
"\toffset=<offset to create the file system>\n"
"\tresize=<resize maximum size in blocks>\n"
+ "\tpacked_meta_blocks=<0 to disable, 1 to enable>\n"
"\tlazy_itable_init=<0 to disable, 1 to enable>\n"
"\tlazy_journal_init=<0 to disable, 1 to enable>\n"
+ "\tjournal_location_front=<0 to disable, 1 to enable>\n"
"\troot_uid=<uid of root directory>\n"
"\troot_gid=<gid of root directory>\n"
"\ttest_fs\n"
@@ -2030,6 +2084,11 @@ profile_error:
EXT2_MKJOURNAL_LAZYINIT : 0;
journal_flags |= EXT2_MKJOURNAL_NO_MNT_CHECK;
+ packed_meta_blocks = get_bool_from_profile(fs_types,
+ "packed_meta_blocks", 0);
+ if (packed_meta_blocks)
+ journal_flags |= EXT2_MKJOURNAL_LOCATION_FRONT;
+
/* Get options from profile */
for (cpp = fs_types; *cpp; cpp++) {
tmp = NULL;
@@ -2624,7 +2683,11 @@ int main (int argc, char *argv[])
fs->stride = fs_stride = fs->super->s_raid_stride;
if (!quiet)
printf("%s", _("Allocating group tables: "));
- retval = ext2fs_allocate_tables(fs);
+ if ((fs->super->s_feature_incompat & EXT4_FEATURE_INCOMPAT_FLEX_BG) &&
+ packed_meta_blocks)
+ retval = packed_allocate_tables(fs);
+ else
+ retval = ext2fs_allocate_tables(fs);
if (retval) {
com_err(program_name, retval, "%s",
_("while trying to allocate filesystem tables"));
diff --git a/misc/mke2fs.conf.5.in b/misc/mke2fs.conf.5.in
index 43bb91e..1aba87b 100644
--- a/misc/mke2fs.conf.5.in
+++ b/misc/mke2fs.conf.5.in
@@ -362,6 +362,10 @@ This relation indicates whether file systems with the
.B sparse_super2
feature enabled should be created with 0, 1, or 2 backup superblocks.
.TP
+.I packed_meta_blocks
+This boolean relation specifes whether the allocation bitmaps, inode
+table, and journal should be located at the beginning of the file system.
+.TP
.I inode_ratio
This relation specifies the default inode ratio if the user does not
specify one on the command line.
--
1.8.5.rc3.362.gdf10213
next prev parent reply other threads:[~2014-01-20 5:54 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-20 5:54 [PATCH 00/12] e2fsprogs mke2fs optimizations and new features Theodore Ts'o
2014-01-20 5:54 ` [PATCH 01/12] libext2fs: fix off-by-one bug in ext2fs_extent_insert() Theodore Ts'o
2014-01-20 5:54 ` [PATCH 02/12] libext2fs: clean up generic handling of ext2fs_find_first_{set,zero}_*() Theodore Ts'o
2014-01-20 5:54 ` [PATCH 03/12] libext2fs: build tst_bitmaps with rep invariants checking enabled Theodore Ts'o
2014-01-20 5:54 ` [PATCH 04/12] libext: optimize find_first_set() for bitarray-based bitmaps Theodore Ts'o
2014-01-20 5:54 ` [PATCH 05/12] libext2fs: optimize find_first_{zero,set}() for red-black tree based bitmaps Theodore Ts'o
2014-01-20 5:54 ` [PATCH 06/12] libext2fs: further clean up and rename check_block_uninit Theodore Ts'o
2014-01-20 20:17 ` Darrick J. Wong
2014-01-20 5:54 ` [PATCH 07/12] libext2fs: add ext2fs_block_alloc_stats_range() Theodore Ts'o
2014-02-13 21:50 ` Darrick J. Wong
2014-01-20 5:54 ` [PATCH 08/12] libext2fs: optimize ext2fs_allocate_group_table() Theodore Ts'o
2014-01-20 5:54 ` [PATCH 09/12] libext2: optimize ext2fs_new_block2() Theodore Ts'o
2014-01-20 21:52 ` Andreas Dilger
2014-01-21 15:54 ` Theodore Ts'o
2014-01-20 5:54 ` [PATCH 10/12] mke2fs: optimize fix_cluster_bg_counts() Theodore Ts'o
2014-01-20 5:54 ` [PATCH 11/12] Add support for new compat feature "sparse_super2" Theodore Ts'o
2014-01-20 21:49 ` Andreas Dilger
[not found] ` <alpine.DEB.2.10.1402051559390.16807@tglase.lan.tarent.de>
2014-02-05 16:17 ` Theodore Ts'o
2014-01-20 5:54 ` Theodore Ts'o [this message]
2014-01-20 16:30 ` [PATCH 12/12] mke2fs: allow metadata blocks to be at the beginning of the file system Theodore Ts'o
2014-01-20 23:25 ` Andreas Dilger
2014-01-21 6:23 ` Theodore Ts'o
2014-01-23 21:28 ` Andreas Dilger
2014-01-20 16:30 ` [PATCH 00/12] e2fsprogs mke2fs optimizations and new features Theodore Ts'o
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=1390197254-14583-13-git-send-email-tytso@mit.edu \
--to=tytso@mit.edu \
--cc=linux-ext4@vger.kernel.org \
/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).