Commit f287a1a5 authored by Theodore Ts'o's avatar Theodore Ts'o

ext4: Remove automatic enabling of the HUGE_FILE feature flag

If the HUGE_FILE feature flag is not set, don't allow the creation of
large files, instead of automatically enabling the feature flag.
Recent versions of mke2fs will set the HUGE_FILE flag automatically
anyway for ext4 filesystems.
Signed-off-by: default avatar"Theodore Ts'o" <tytso@mit.edu>
parent 3e624fc7
...@@ -4194,7 +4194,6 @@ static int ext4_inode_blocks_set(handle_t *handle, ...@@ -4194,7 +4194,6 @@ static int ext4_inode_blocks_set(handle_t *handle,
struct inode *inode = &(ei->vfs_inode); struct inode *inode = &(ei->vfs_inode);
u64 i_blocks = inode->i_blocks; u64 i_blocks = inode->i_blocks;
struct super_block *sb = inode->i_sb; struct super_block *sb = inode->i_sb;
int err = 0;
if (i_blocks <= ~0U) { if (i_blocks <= ~0U) {
/* /*
...@@ -4204,36 +4203,27 @@ static int ext4_inode_blocks_set(handle_t *handle, ...@@ -4204,36 +4203,27 @@ static int ext4_inode_blocks_set(handle_t *handle,
raw_inode->i_blocks_lo = cpu_to_le32(i_blocks); raw_inode->i_blocks_lo = cpu_to_le32(i_blocks);
raw_inode->i_blocks_high = 0; raw_inode->i_blocks_high = 0;
ei->i_flags &= ~EXT4_HUGE_FILE_FL; ei->i_flags &= ~EXT4_HUGE_FILE_FL;
} else if (i_blocks <= 0xffffffffffffULL) { return 0;
}
if (!EXT4_HAS_RO_COMPAT_FEATURE(sb, EXT4_FEATURE_RO_COMPAT_HUGE_FILE))
return -EFBIG;
if (i_blocks <= 0xffffffffffffULL) {
/* /*
* i_blocks can be represented in a 48 bit variable * i_blocks can be represented in a 48 bit variable
* as multiple of 512 bytes * as multiple of 512 bytes
*/ */
err = ext4_update_rocompat_feature(handle, sb,
EXT4_FEATURE_RO_COMPAT_HUGE_FILE);
if (err)
goto err_out;
/* i_block is stored in the split 48 bit fields */
raw_inode->i_blocks_lo = cpu_to_le32(i_blocks); raw_inode->i_blocks_lo = cpu_to_le32(i_blocks);
raw_inode->i_blocks_high = cpu_to_le16(i_blocks >> 32); raw_inode->i_blocks_high = cpu_to_le16(i_blocks >> 32);
ei->i_flags &= ~EXT4_HUGE_FILE_FL; ei->i_flags &= ~EXT4_HUGE_FILE_FL;
} else { } else {
/*
* i_blocks should be represented in a 48 bit variable
* as multiple of file system block size
*/
err = ext4_update_rocompat_feature(handle, sb,
EXT4_FEATURE_RO_COMPAT_HUGE_FILE);
if (err)
goto err_out;
ei->i_flags |= EXT4_HUGE_FILE_FL; ei->i_flags |= EXT4_HUGE_FILE_FL;
/* i_block is stored in file system block size */ /* i_block is stored in file system block size */
i_blocks = i_blocks >> (inode->i_blkbits - 9); i_blocks = i_blocks >> (inode->i_blkbits - 9);
raw_inode->i_blocks_lo = cpu_to_le32(i_blocks); raw_inode->i_blocks_lo = cpu_to_le32(i_blocks);
raw_inode->i_blocks_high = cpu_to_le16(i_blocks >> 32); raw_inode->i_blocks_high = cpu_to_le16(i_blocks >> 32);
} }
err_out: return 0;
return err;
} }
/* /*
......
...@@ -374,66 +374,6 @@ void ext4_update_dynamic_rev(struct super_block *sb) ...@@ -374,66 +374,6 @@ void ext4_update_dynamic_rev(struct super_block *sb)
*/ */
} }
int ext4_update_compat_feature(handle_t *handle,
struct super_block *sb, __u32 compat)
{
int err = 0;
if (!EXT4_HAS_COMPAT_FEATURE(sb, compat)) {
err = ext4_journal_get_write_access(handle,
EXT4_SB(sb)->s_sbh);
if (err)
return err;
EXT4_SET_COMPAT_FEATURE(sb, compat);
sb->s_dirt = 1;
handle->h_sync = 1;
BUFFER_TRACE(EXT4_SB(sb)->s_sbh,
"call ext4_journal_dirty_met adata");
err = ext4_journal_dirty_metadata(handle,
EXT4_SB(sb)->s_sbh);
}
return err;
}
int ext4_update_rocompat_feature(handle_t *handle,
struct super_block *sb, __u32 rocompat)
{
int err = 0;
if (!EXT4_HAS_RO_COMPAT_FEATURE(sb, rocompat)) {
err = ext4_journal_get_write_access(handle,
EXT4_SB(sb)->s_sbh);
if (err)
return err;
EXT4_SET_RO_COMPAT_FEATURE(sb, rocompat);
sb->s_dirt = 1;
handle->h_sync = 1;
BUFFER_TRACE(EXT4_SB(sb)->s_sbh,
"call ext4_journal_dirty_met adata");
err = ext4_journal_dirty_metadata(handle,
EXT4_SB(sb)->s_sbh);
}
return err;
}
int ext4_update_incompat_feature(handle_t *handle,
struct super_block *sb, __u32 incompat)
{
int err = 0;
if (!EXT4_HAS_INCOMPAT_FEATURE(sb, incompat)) {
err = ext4_journal_get_write_access(handle,
EXT4_SB(sb)->s_sbh);
if (err)
return err;
EXT4_SET_INCOMPAT_FEATURE(sb, incompat);
sb->s_dirt = 1;
handle->h_sync = 1;
BUFFER_TRACE(EXT4_SB(sb)->s_sbh,
"call ext4_journal_dirty_met adata");
err = ext4_journal_dirty_metadata(handle,
EXT4_SB(sb)->s_sbh);
}
return err;
}
/* /*
* Open the external journal device * Open the external journal device
*/ */
...@@ -1771,13 +1711,13 @@ static void ext4_orphan_cleanup(struct super_block *sb, ...@@ -1771,13 +1711,13 @@ static void ext4_orphan_cleanup(struct super_block *sb,
* *
* Note, this does *not* consider any metadata overhead for vfs i_blocks. * Note, this does *not* consider any metadata overhead for vfs i_blocks.
*/ */
static loff_t ext4_max_size(int blkbits) static loff_t ext4_max_size(int blkbits, int has_huge_files)
{ {
loff_t res; loff_t res;
loff_t upper_limit = MAX_LFS_FILESIZE; loff_t upper_limit = MAX_LFS_FILESIZE;
/* small i_blocks in vfs inode? */ /* small i_blocks in vfs inode? */
if (sizeof(blkcnt_t) < sizeof(u64)) { if (!has_huge_files || sizeof(blkcnt_t) < sizeof(u64)) {
/* /*
* CONFIG_LSF is not enabled implies the inode * CONFIG_LSF is not enabled implies the inode
* i_block represent total blocks in 512 bytes * i_block represent total blocks in 512 bytes
...@@ -1807,7 +1747,7 @@ static loff_t ext4_max_size(int blkbits) ...@@ -1807,7 +1747,7 @@ static loff_t ext4_max_size(int blkbits)
* block limit, and also a limit of (2^48 - 1) 512-byte sectors in i_blocks. * block limit, and also a limit of (2^48 - 1) 512-byte sectors in i_blocks.
* We need to be 1 filesystem block less than the 2^48 sector limit. * We need to be 1 filesystem block less than the 2^48 sector limit.
*/ */
static loff_t ext4_max_bitmap_size(int bits) static loff_t ext4_max_bitmap_size(int bits, int has_huge_files)
{ {
loff_t res = EXT4_NDIR_BLOCKS; loff_t res = EXT4_NDIR_BLOCKS;
int meta_blocks; int meta_blocks;
...@@ -1820,11 +1760,11 @@ static loff_t ext4_max_bitmap_size(int bits) ...@@ -1820,11 +1760,11 @@ static loff_t ext4_max_bitmap_size(int bits)
* total number of 512 bytes blocks of the file * total number of 512 bytes blocks of the file
*/ */
if (sizeof(blkcnt_t) < sizeof(u64)) { if (!has_huge_files || sizeof(blkcnt_t) < sizeof(u64)) {
/* /*
* CONFIG_LSF is not enabled implies the inode * !has_huge_files or CONFIG_LSF is not enabled
* i_block represent total blocks in 512 bytes * implies the inode i_block represent total blocks in
* 32 == size of vfs inode i_blocks * 8 * 512 bytes 32 == size of vfs inode i_blocks * 8
*/ */
upper_limit = (1LL << 32) - 1; upper_limit = (1LL << 32) - 1;
...@@ -1933,7 +1873,7 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) ...@@ -1933,7 +1873,7 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
int blocksize; int blocksize;
int db_count; int db_count;
int i; int i;
int needs_recovery; int needs_recovery, has_huge_files;
__le32 features; __le32 features;
__u64 blocks_count; __u64 blocks_count;
int err; int err;
...@@ -2074,7 +2014,9 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) ...@@ -2074,7 +2014,9 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
sb->s_id, le32_to_cpu(features)); sb->s_id, le32_to_cpu(features));
goto failed_mount; goto failed_mount;
} }
if (EXT4_HAS_RO_COMPAT_FEATURE(sb, EXT4_FEATURE_RO_COMPAT_HUGE_FILE)) { has_huge_files = EXT4_HAS_RO_COMPAT_FEATURE(sb,
EXT4_FEATURE_RO_COMPAT_HUGE_FILE);
if (has_huge_files) {
/* /*
* Large file size enabled file system can only be * Large file size enabled file system can only be
* mount if kernel is build with CONFIG_LSF * mount if kernel is build with CONFIG_LSF
...@@ -2124,8 +2066,9 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) ...@@ -2124,8 +2066,9 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
} }
} }
sbi->s_bitmap_maxbytes = ext4_max_bitmap_size(sb->s_blocksize_bits); sbi->s_bitmap_maxbytes = ext4_max_bitmap_size(sb->s_blocksize_bits,
sb->s_maxbytes = ext4_max_size(sb->s_blocksize_bits); has_huge_files);
sb->s_maxbytes = ext4_max_size(sb->s_blocksize_bits, has_huge_files);
if (le32_to_cpu(es->s_rev_level) == EXT4_GOOD_OLD_REV) { if (le32_to_cpu(es->s_rev_level) == EXT4_GOOD_OLD_REV) {
sbi->s_inode_size = EXT4_GOOD_OLD_INODE_SIZE; sbi->s_inode_size = EXT4_GOOD_OLD_INODE_SIZE;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment