tune2fs, debugfs, libext2fs: Add support for ext4 default mount options

Add support for 2.6.35's new default mount options which can be
specified in the superblock.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
This commit is contained in:
Theodore Ts'o 2010-09-18 19:38:22 -04:00
parent 61ef2474c2
commit 9345f02671
7 changed files with 76 additions and 2 deletions

View File

@ -139,6 +139,7 @@ static struct field_set_info super_fields[] = {
{ "snapshot_r_blocks_count", &set_sb.s_snapshot_r_blocks_count, 8,
parse_uint },
{ "snapshot_list", &set_sb.s_snapshot_list, 4, parse_uint },
{ "mount_opts", &set_sb.s_mount_opts, 64, parse_string },
{ 0, 0, 0, 0 }
};

View File

@ -211,6 +211,8 @@ void list_super2(struct ext2_super_block * sb, FILE *f)
print_features(sb, f);
print_super_flags(sb, f);
print_mntopts(sb, f);
if (sb->s_mount_opts[0])
fprintf(f, "Mount options: %s\n", sb->s_mount_opts);
fprintf(f, "Filesystem state: ");
print_fs_state (f, sb->s_state);
fprintf(f, "\n");

View File

@ -31,6 +31,10 @@ static struct mntopt mntopt_list[] = {
{ EXT3_DEFM_JMODE_DATA, "journal_data" },
{ EXT3_DEFM_JMODE_ORDERED, "journal_data_ordered" },
{ EXT3_DEFM_JMODE_WBACK, "journal_data_writeback" },
{ EXT4_DEFM_NOBARRIER, "nobarrier" },
{ EXT4_DEFM_BLOCK_VALIDITY, "block_validity" },
{ EXT4_DEFM_DISCARD, "discard"},
{ EXT4_DEFM_NODELALLOC, "nodelalloc"},
{ 0, 0 },
};

View File

@ -612,8 +612,9 @@ struct ext2_super_block {
__u32 s_last_error_line; /* line number where error happened */
__u64 s_last_error_block; /* block involved of last error */
__u8 s_last_error_func[32]; /* function where the error happened */
#define EXT4_S_ERR_END ext4_offsetof(struct ext2_super_block, s_error_count)
__u32 s_reserved[128]; /* Padding to the end of the block */
#define EXT4_S_ERR_END ext4_offsetof(struct ext2_super_block, s_mount_opts)
__u8 s_mount_opts[64];
__u32 s_reserved[112]; /* Padding to the end of the block */
};
#define EXT4_S_ERR_LEN (EXT4_S_ERR_END - EXT4_S_ERR_START)
@ -710,6 +711,10 @@ struct ext2_super_block {
#define EXT3_DEFM_JMODE_DATA 0x0020
#define EXT3_DEFM_JMODE_ORDERED 0x0040
#define EXT3_DEFM_JMODE_WBACK 0x0060
#define EXT4_DEFM_NOBARRIER 0x0100
#define EXT4_DEFM_BLOCK_VALIDITY 0x0200
#define EXT4_DEFM_DISCARD 0x0400
#define EXT4_DEFM_NODELALLOC 0x0800
/*
* Structure of a directory entry

View File

@ -122,6 +122,7 @@ void check_superblock_fields()
check_field(s_last_error_line);
check_field(s_last_error_block);
check_field(s_last_error_func);
check_field(s_mount_opts);
check_field(s_reserved);
printf("Ending offset is %d\n\n", cur_offset);
#endif

View File

@ -187,6 +187,26 @@ directories. Valid algorithms accepted are:
and
.IR tea .
.TP
.BI mount_opts= mount_option_string
Set a set of default mount options which will be used when the file
system is mounted. Unlike the bitmask-based default mount options which
can be specified with the
.B -o
option,
.I mount_option_string
is an arbitrary string with a maximum length of 63 bytes, which is
stored in the superblock.
.IP
The ext4 file system driver will first apply
the bitmask-based default options, and then parse the
.IR mount_option_string ,
before parsing the mount options passed from the
.BR mount (8)
program.
.IP
This superblock setting is only honored in 2.6.35+ kernels;
and not at all by the ext2 and ext3 file system drivers.
.TP
.B test_fs
Set a flag in the filesystem superblock indicating that it may be
mounted using experimental kernel code, such as the ext4dev filesystem.
@ -419,6 +439,35 @@ When the filesystem is mounted with journalling enabled, data may be
written into the main filesystem after its metadata has been committed
to the journal. This may increase throughput, however, it may allow old
data to appear in files after a crash and journal recovery.
.TP
.B nobarrier
The file system will be mounted with barrier operations in the journal
disabled. (This option is currently only supported by the ext4 file
system driver in 2.6.35+ kernels.)
.TP
.B block_validity
The file system will be mounted with the block_validity option enabled,
which causes extra checks to be performed after reading or writing from
the file system. This prevents corrupted metadata blocks from causing
file system damage by overwriting parts of the inode table or block
group descriptors. This comes at the cost of increased memory and CPU
overhead, so it is enabled only for debugging purposes. (This option is
currently only supported by the ext4 file system driver in 2.6.35+
kernels.)
.TP
.B discard
The file system will be mouinted with the discard mount option. This will
cause the file system driver to attempt to use the trim/discard feature
of some storage devices (such as SSD's and thin-provisioned drives
available in some enterprise storage arrays) to inform the storage
device that blocks belonging to deleted files can be reused for other
purposes. (This option is currently only supported by the ext4 file
system driver in 2.6.35+ kernels.)
.TP
.B nodelalloc
The file system will be mounted with the nodelalloc mount option. This
will disable the delayed allocation feature. (This option is currently
only supported by the ext4 file system driver in 2.6.35+ kernels.)
.RE
.TP
.BR \-O " [^]\fIfeature\fR[,...]"

View File

@ -979,6 +979,18 @@ static void parse_extended_opts(ext2_filsys fs, const char *opts)
"to %s (%d)\n"),
arg, hash_alg);
ext2fs_mark_super_dirty(fs);
} else if (strcmp(token, "mount-options")) {
if (!arg) {
r_usage++;
continue;
}
if (strlen(arg) >= sizeof(fs->super->s_mount_opts)) {
fprintf(stderr,
"Extended mount options too long\n");
continue;
}
strcpy(fs->super->s_mount_opts, arg);
ext2fs_mark_super_dirty(fs);
} else
r_usage++;
}