ext4: Add support for 48 bit inode i_blocks.
PATCH 1/2 ext4: Add support for 48 bit inode i_blocks.
use the __le16 l_i_reserved1 field of the linux2 struct of ext4_inode to represet the higher 16 bits for i_blocks. With this change max_file size becomes (2**48 -1 )* 512 bytes.
--- fs/ext4/inode.c | 69 +++++++++++++++++++++++++++++++++++++++++++++- fs/ext4/super.c | 62 ++++++++++++++++++++++++++++++++++++++---- include/linux/ext4_fs.h | 11 +++++-- 3 files changed, 131 insertions(+), 11 deletions(-)
fs/ext4/inode.c +67 -2
@@ -2706,6 +2706,22 @@ void ext4_get_inode_flags(struct ext4_inode_info *ei)if (flags &S_DIRSYNC ) ei->i_flags |=EXT4_DIRSYNC_FL ; } +static blkcnt_t ext4_inode_blocks (struct ext4_inode *raw_inode, +struct ext4_inode_info *ei) +{ +blkcnt_t i_blocks ; +struct super_block *sb = ei->vfs_inode.i_sb; + +if (EXT4_HAS_RO_COMPAT_FEATURE (sb, +EXT4_FEATURE_RO_COMPAT_HUGE_FILE )) { +/* we are using combined 48 bit field */ + i_blocks = ((u64 )le16_to_cpu (raw_inode->i_blocks_high)) <<32 | +le32_to_cpu (raw_inode->i_blocks_lo); +return i_blocks; + }else { +return le32_to_cpu (raw_inode->i_blocks_lo); + } +}void ext4_read_inode (struct inode * inode) {
@@ -2755,8 +2771,8 @@ void ext4_read_inode(struct inode * inode)* recovery code: that's fine, we're about to complete * the process of deleting those. */ } - inode->i_blocks =le32_to_cpu (raw_inode->i_blocks); ei->i_flags =le32_to_cpu (raw_inode->i_flags); + inode->i_blocks =ext4_inode_blocks (raw_inode, ei); ei->i_file_acl =le32_to_cpu (raw_inode->i_file_acl);if (EXT4_SB (inode->i_sb)->s_es->s_creator_os !=cpu_to_le32 (EXT4_OS_HURD ))
@@ -2850,6 +2866,54 @@ bad_inode:return ; } +static int ext4_inode_blocks_set (handle_t *handle, +struct ext4_inode *raw_inode, +struct ext4_inode_info *ei) +{ +struct inode *inode = &(ei->vfs_inode); +u64 i_blocks = inode->i_blocks; +struct super_block *sb = inode->i_sb; +int err =0 ; + +if (i_blocks <= ~0U ) { +/* +* i_blocks can be represnted in a 32 bit variable +* as multiple of 512 bytes +*/ + raw_inode->i_blocks_lo =cpu_to_le32 ((u32 )i_blocks); + raw_inode->i_blocks_high =0 ; + }else if (i_blocks <=0xffffffffffffULL ) { +/* +* i_blocks can be represented in a 48 bit variable +* as multiple of 512 bytes +*/ +if (!EXT4_HAS_RO_COMPAT_FEATURE (sb, +EXT4_FEATURE_RO_COMPAT_HUGE_FILE )) { + + err =ext4_journal_get_write_access (handle, +EXT4_SB (sb)->s_sbh); +if (err) + goto err_out; +ext4_update_dynamic_rev (sb); +EXT4_SET_RO_COMPAT_FEATURE (sb, +EXT4_FEATURE_RO_COMPAT_HUGE_FILE ); + sb->s_dirt =1 ; + handle->h_sync =1 ; + err =ext4_journal_dirty_metadata (handle, +EXT4_SB (sb)->s_sbh); + } +/* i_block is stored in the split 48 bit fields */ + raw_inode->i_blocks_lo =cpu_to_le32 ((u32 )i_blocks); + raw_inode->i_blocks_high =cpu_to_le16 (i_blocks >>32 ); + }else { +ext4_error (sb, __FUNCTION__, +"Wrong inode i_blocks count %llu\n" , + (unsigned long long )inode->i_blocks); + } +err_out: +return err; +} +/* * Post the struct inode info into an on-disk inode location in the * buffer-cache. This gobbles the caller's reference to the
@@ -2905,7 +2969,8 @@ static int ext4_do_update_inode(handle_t *handle,EXT4_INODE_SET_XTIME (i_atime, inode, raw_inode);EXT4_EINODE_SET_XTIME (i_crtime, ei, raw_inode); - raw_inode->i_blocks =cpu_to_le32 (inode->i_blocks); +if (ext4_inode_blocks_set (handle, raw_inode, ei)) + goto out_brelse; raw_inode->i_dtime =cpu_to_le32 (ei->i_dtime); raw_inode->i_flags =cpu_to_le32 (ei->i_flags); if (EXT4_SB(inode->i_sb)->s_es->s_creator_os !=
fs/ext4/super.c +56 -6
85 lines not on this page · raw message
include/linux/ext4_fs.h +8 -3
@@ -310,7 +310,7 @@ struct ext4_inode {__le32 i_dtime;/* Deletion Time */ __le16 i_gid;/* Low 16 bits of Group Id */ __le16 i_links_count;/* Links count */ -__le32 i_blocks;/* Blocks count */ +__le32 i_blocks_lo;/* Blocks count */ __le32 i_flags;/* File flags */ union { struct {
@@ -330,7 +330,7 @@ struct ext4_inode {__le32 i_obso_faddr;/* Obsoleted fragment address */ union {struct { -__le16 l_i_reserved1;/* Obsoleted fragment number/size which are removed in ext4 */ +__le16 l_i_blocks_high;/* were l_i_reserved1 */ __le16 l_i_file_acl_high;__le16 l_i_uid_high;/* these 2 fields */ __le16 l_i_gid_high;/* were reserved2[0] */
@@ -436,6 +436,7 @@ do { \#if defined(__KERNEL__) || defined(__linux__)#define i_reserved1 osd1.linux1.l_i_reserved1#define i_file_acl_high osd2.linux2.l_i_file_acl_high +#define i_blocks_high osd2.linux2.l_i_blocks_high#define i_uid_low i_uid#define i_gid_low i_gid#define i_uid_high osd2.linux2.l_i_uid_high
@@ -706,6 +707,7 @@ static inline int ext4_valid_inum(struct super_block *sb, unsigned long ino)#define EXT4_FEATURE_RO_COMPAT_SPARSE_SUPER 0x0001#define EXT4_FEATURE_RO_COMPAT_LARGE_FILE 0x0002#define EXT4_FEATURE_RO_COMPAT_BTREE_DIR 0x0004 +#define EXT4_FEATURE_RO_COMPAT_HUGE_FILE 0x0008#define EXT4_FEATURE_RO_COMPAT_GDT_CSUM 0x0010#define EXT4_FEATURE_RO_COMPAT_DIR_NLINK 0x0020#define EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE 0x0040
@@ -717,6 +719,7 @@ static inline int ext4_valid_inum(struct super_block *sb, unsigned long ino)#define EXT4_FEATURE_INCOMPAT_META_BG 0x0010#define EXT4_FEATURE_INCOMPAT_EXTENTS 0x0040/* extents support */ #define EXT4_FEATURE_INCOMPAT_64BIT 0x0080 +#define EXT4_FEATURE_INCOMPAT_MMP 0x0100#define EXT4_FEATURE_INCOMPAT_FLEX_BG 0x0200#define EXT4_FEATURE_COMPAT_SUPP EXT2_FEATURE_COMPAT_EXT_ATTR
@@ -725,13 +728,15 @@ static inline int ext4_valid_inum(struct super_block *sb, unsigned long ino) EXT4_FEATURE_INCOMPAT_META_BG| \ EXT4_FEATURE_INCOMPAT_EXTENTS| \ EXT4_FEATURE_INCOMPAT_64BIT| \ + EXT4_FEATURE_INCOMPAT_MMP|\ EXT4_FEATURE_INCOMPAT_FLEX_BG)#define EXT4_FEATURE_RO_COMPAT_SUPP (EXT4_FEATURE_RO_COMPAT_SPARSE_SUPER| \ EXT4_FEATURE_RO_COMPAT_LARGE_FILE| \ EXT4_FEATURE_RO_COMPAT_GDT_CSUM| \ EXT4_FEATURE_RO_COMPAT_DIR_NLINK | \ EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE | \ - EXT4_FEATURE_RO_COMPAT_BTREE_DIR) + EXT4_FEATURE_RO_COMPAT_BTREE_DIR |\ + EXT4_FEATURE_RO_COMPAT_HUGE_FILE)/* * Default values for user and/or group using reserved blocks
Signature · 1 line
1.5.3.4.206.g58ba4-dirty
PATCH 2/2 ext4: Support large files
This patch converts ext4_inode i_blocks to represent total blocks occupied by the inode in file system block size. Earlier the variable used to represent this in 512 byte block size. This actually limited the total size of the file.
The feature is enabled transparently when we write an inode whose i_blocks cannot be represnted as 512 byte units in a 48 bit variable. We add a RO_COMPAT feature to the super block to indicate that some of the inode have i_blocks represented as file system block size units. Super block with this feature set cannot be mounted read write on a kernel with CONFIG_LSF disabled.
Super block flag EXT4_FEATURE_RO_COMPAT_HUGE_FILE inode flag EXT4_HUGE_FILE_FL
--- fs/ext4/inode.c | 41 +++++++++++++++++++++++++++++++++++------ fs/ext4/super.c | 9 ++++++--- include/linux/ext4_fs.h | 3 ++- 3 files changed, 43 insertions(+), 10 deletions(-)
fs/ext4/inode.c +35 -6
@@ -2710,14 +2710,20 @@ static blkcnt_t ext4_inode_blocks(struct ext4_inode *raw_inode, struct ext4_inode_info *ei) {blkcnt_t i_blocks ; -struct super_block *sb = ei->vfs_inode.i_sb; +struct inode *inode = &(ei->vfs_inode); +struct super_block *sb = inode->i_sb;if (EXT4_HAS_RO_COMPAT_FEATURE (sb,EXT4_FEATURE_RO_COMPAT_HUGE_FILE )) {/* we are using combined 48 bit field */ i_blocks = ((u64 )le16_to_cpu (raw_inode->i_blocks_high)) <<32 |le32_to_cpu (raw_inode->i_blocks_lo); -return i_blocks; +if (ei->i_flags &EXT4_HUGE_FILE_FL ) { +/* i_blocks represent file system block size */ +return i_blocks << (inode->i_blkbits -9 ); + }else { +return i_blocks; + } }else {return le32_to_cpu (raw_inode->i_blocks_lo); }
@@ -2882,6 +2888,7 @@ static int ext4_inode_blocks_set(handle_t *handle,*/ raw_inode->i_blocks_lo =cpu_to_le32 ((u32 )i_blocks); raw_inode->i_blocks_high =0 ; + ei->i_flags &= ~EXT4_HUGE_FILE_FL ; }else if (i_blocks <=0xffffffffffffULL ) {/* * i_blocks can be represented in a 48 bit variable
@@ -2905,10 +2912,32 @@ static int ext4_inode_blocks_set(handle_t *handle,/* i_block is stored in the split 48 bit fields */ raw_inode->i_blocks_lo =cpu_to_le32 ((u32 )i_blocks); raw_inode->i_blocks_high =cpu_to_le16 (i_blocks >>32 ); - }else { -ext4_error (sb, __FUNCTION__, -"Wrong inode i_blocks count %llu\n" , - (unsigned long long )inode->i_blocks); + ei->i_flags &= ~EXT4_HUGE_FILE_FL ; + }else { +/* +* i_blocks should be represented in a 48 bit variable +* as multiple of file system block size +*/ +if (!EXT4_HAS_RO_COMPAT_FEATURE (sb, +EXT4_FEATURE_RO_COMPAT_HUGE_FILE )) { + + err =ext4_journal_get_write_access (handle, +EXT4_SB (sb)->s_sbh); +if (err) + goto err_out; +ext4_update_dynamic_rev (sb); +EXT4_SET_RO_COMPAT_FEATURE (sb, +EXT4_FEATURE_RO_COMPAT_HUGE_FILE ); + sb->s_dirt =1 ; + handle->h_sync =1 ; + err =ext4_journal_dirty_metadata (handle, +EXT4_SB (sb)->s_sbh); + } + ei->i_flags |=EXT4_HUGE_FILE_FL ; +/* i_block is stored in file system block size */ + i_blocks = i_blocks >> (inode->i_blkbits -9 ); + raw_inode->i_blocks_lo =cpu_to_le32 ((u32 )i_blocks); + raw_inode->i_blocks_high =cpu_to_le16 (i_blocks >>32 ); } err_out:return err;
fs/ext4/super.c +6 -3
@@ -1531,11 +1531,14 @@ static loff_t ext4_max_size(int bits) upper_limit >>= (bits -9 ); }else { -/* We use 48 bit ext4_inode i_blocks */ +/* +* We use 48 bit ext4_inode i_blocks +* With EXT4_HUGE_FILE_FL set the i_blocks +* represent total number of blocks in +* file system block size +*/ upper_limit = (1LL <<48 ) -1 ; -/* total blocks in file system block size */ - upper_limit >>= (bits -9 ); }/* indirect blocks */
include/linux/ext4_fs.h +2 -1
@@ -205,8 +205,9 @@ struct ext4_group_desc#define EXT4_NOTAIL_FL 0x00008000/* file tail should not be merged */ #define EXT4_DIRSYNC_FL 0x00010000/* dirsync behaviour (directories only) */ #define EXT4_TOPDIR_FL 0x00020000/* Top of directory hierarchies*/ -#define EXT4_RESERVED_FL 0x80000000/* reserved for ext4 lib */ +#define EXT4_HUGE_FILE_FL 0x00040000/* Set to each huge file */ #define EXT4_EXTENTS_FL 0x00080000/* Inode uses extents */ +#define EXT4_RESERVED_FL 0x80000000/* reserved for ext4 lib */ #define EXT4_FL_USER_VISIBLE 0x000BDFFF/* User visible flags */ #define EXT4_FL_USER_MODIFIABLE 0x000380FF/* User modifiable flags */
Signature · 1 line
1.5.3.4.206.g58ba4-dirty
fs/ext4/inode.c bad_inode: · line 2871
Quoted 8 lines · Aneesh Kumar K.V
use the
__le16l_i_reserved1field of the linux2 struct ofext4_inodeto represet the higher 16 bits fori_blocks. With this changemax_filesize becomes (2**48 -1 )* 512 bytes.fs/ext4/inode.c +3
-0+static int ext4_inode_blocks_set (handle_t *handle, +struct ext4_inode *raw_inode, +struct ext4_inode_info *ei)
CodingStyle would suggest aligning the continued lines with the '('.
Quoted 7 lines
fs/ext4/inode.c +7
-0+{ + } else if (i_blocks <= 0xffffffffffffULL) { +if (!EXT4_HAS_RO_COMPAT_FEATURE (sb, +EXT4_FEATURE_RO_COMPAT_HUGE_FILE )) { + + err =ext4_journal_get_write_access (handle, +EXT4_SB (sb)->s_sbh);
fs/ext4/inode.c bad_inode: · line 2904
Quoted 10 lines
fs/ext4/inode.c +10
-0+if (err) + goto err_out; +ext4_update_dynamic_rev (sb); +EXT4_SET_RO_COMPAT_FEATURE (sb, +EXT4_FEATURE_RO_COMPAT_HUGE_FILE ); + sb->s_dirt =1 ; + handle->h_sync =1 ; + err =ext4_journal_dirty_metadata (handle, +EXT4_SB (sb)->s_sbh); + }
Can you please make a helper function for this, like:
int ext4_update_feature(sb, __u32 compat, __u32 rocompat, __u32 incompat)
as we have similar code in a few places already (HTREE, LARGE_FILE, EXTENTS). That could be done in a prerequisite patch.
fs/ext4/super.c static int ext4_fill_super (struct super_block *sb, void *data, int silent) · line 1728
Quoted 10 lines
fs/ext4/super.c +10
-0+if (EXT4_HAS_RO_COMPAT_FEATURE (sb,EXT4_FEATURE_RO_COMPAT_HUGE_FILE )) { +/* +* Large file size enabled file system can only be +* mount if kernel is build with CONFIG_LSF +*/ +if (sizeof (root->i_blocks) <sizeof (u64) && + !(sb->s_flags &MS_RDONLY )) { +printk (KERN_ERR "EXT4-fs: %s: Having huge file with " +"LSF off, you must mount filesystem " +"read-only.\n" , sb->s_id);
What do you think about changing the wording:
"Filesystem with huge files cannot mount read-write without CONFIG_LSF."
Quoted 4 lines
#define
EXT4_FEATURE_INCOMPAT_EXTENTS0x0040/* extents support */
#defineEXT4_FEATURE_INCOMPAT_64BIT0x0080
+#defineEXT4_FEATURE_INCOMPAT_MMP0x0100
#defineEXT4_FEATURE_INCOMPAT_FLEX_BG0x0200
Note that it is fine to add the #define for this flag.
include/linux/ext4_fs.h static inline int ext4_valid_inum(struct super_block *sb, unsigned long ino) · line 732
Quoted 4 lines
include/linux/ext4_fs.h +1
-0EXT4_FEATURE_INCOMPAT_EXTENTS | \EXT4_FEATURE_INCOMPAT_64BIT | \ +EXT4_FEATURE_INCOMPAT_MMP |\ EXT4_FEATURE_INCOMPAT_FLEX_BG)
Note it is NOT OK to add INCOMPAT_MMP to the INCOMPAT_SUPP flags, or you defeat the entire purpose of having the feature flag.
Cheers, Andreas
--
Andreas Dilger
Principal Software Engineer
Cluster File Systems, Inc.
Quoted 6 lines · Andreas Dilger
Quoted 5 lines · Aneesh Kumar K.V
use the
__le16l_i_reserved1field of the linux2 struct ofext4_inodeto represet the higher 16 bits fori_blocks. With this changemax_filesize becomes (2**48 -1 )* 512 bytes.
Quoted 6 lines
fs/ext4/inode.c bad_inode: · line 2871
Quoted 3 lines
fs/ext4/inode.c +3
-0+static int ext4_inode_blocks_set (handle_t *handle, +struct ext4_inode *raw_inode, +struct ext4_inode_info *ei)CodingStyle would suggest aligning the continued lines with the '('.
Will fix
Quoted 20 lines
Quoted 7 lines
fs/ext4/inode.c +7
-0+{ + } else if (i_blocks <= 0xffffffffffffULL) { +if (!EXT4_HAS_RO_COMPAT_FEATURE (sb, +EXT4_FEATURE_RO_COMPAT_HUGE_FILE )) { + + err =ext4_journal_get_write_access (handle, +EXT4_SB (sb)->s_sbh);fs/ext4/inode.c bad_inode: · line 2904
Quoted 10 lines
fs/ext4/inode.c +10
-0+if (err) + goto err_out; +ext4_update_dynamic_rev (sb); +EXT4_SET_RO_COMPAT_FEATURE (sb, +EXT4_FEATURE_RO_COMPAT_HUGE_FILE ); + sb->s_dirt =1 ; + handle->h_sync =1 ; + err =ext4_journal_dirty_metadata (handle, +EXT4_SB (sb)->s_sbh); + }Can you please make a helper function for this, like:
Quoted 4 lines
int ext4_update_feature(sb, __u32 compat, __u32 rocompat, __u32 incompat)as we have similar code in a few places already (HTREE,
LARGE_FILE, EXTENTS). That could be done in a prerequisite patch.
Will do
Quoted 23 lines
fs/ext4/super.c static int ext4_fill_super (struct super_block *sb, void *data, int silent) · line 1728
Quoted 11 lines
fs/ext4/super.c +10
-0+if (EXT4_HAS_RO_COMPAT_FEATURE (sb,EXT4_FEATURE_RO_COMPAT_HUGE_FILE )) { +/* +* Large file size enabled file system can only be +* mount if kernel is build with CONFIG_LSF +*/ +if (sizeof (root->i_blocks) <sizeof (u64) && + !(sb->s_flags &MS_RDONLY )) { +printk (KERN_ERR "EXT4-fs: %s: Having huge file with " +"LSF off, you must mount filesystem " +"read-only.\n" , sb->s_id);What do you think about changing the wording:
"Filesystem with huge files cannot mount read-write without
CONFIG_LSF."Quoted 4 lines
#define
EXT4_FEATURE_INCOMPAT_EXTENTS0x0040/* extents support */
#defineEXT4_FEATURE_INCOMPAT_64BIT0x0080
+#defineEXT4_FEATURE_INCOMPAT_MMP0x0100
#defineEXT4_FEATURE_INCOMPAT_FLEX_BG0x0200Note that it is fine to add the #define for this flag.
Quoted 9 lines
include/linux/ext4_fs.h static inline int ext4_valid_inum(struct super_block *sb, unsigned long ino) · line 732
Quoted 4 lines
include/linux/ext4_fs.h +1
-0EXT4_FEATURE_INCOMPAT_EXTENTS | \EXT4_FEATURE_INCOMPAT_64BIT | \ +EXT4_FEATURE_INCOMPAT_MMP |\ EXT4_FEATURE_INCOMPAT_FLEX_BG)Note it is NOT OK to add
INCOMPAT_MMPto theINCOMPAT_SUPPflags, or you defeat the entire purpose of having the feature flag.
Will fix.
-aneesh
Re: [PATCH 2/2] ext4: Support large files
In reply to Aneesh Kumar K.VQuoted 8 lines · Aneesh Kumar K.V
We add a
RO_COMPATfeature to the super
block to indicate that some of the inode havei_blocksrepresented as file system block size units. Super block with this feature set cannot be mounted read write on a kernel withCONFIG_LSFdisabled.Super block flag
EXT4_FEATURE_RO_COMPAT_HUGE_FILEinode flagEXT4_HUGE_FILE_FL
I was wondering where this part of the patch went...
fs/ext4/inode.c static int ext4_inode_blocks_set(handle_t *handle, · line 2914
Quoted 4 lines
fs/ext4/inode.c +0
-0@@ -2905,10 +2912,32 @@ static int ext4_inode_blocks_set(handle_t *handle,/* i_block is stored in the split 48 bit fields */ raw_inode->i_blocks_lo =cpu_to_le32 ((u32 )i_blocks); raw_inode->i_blocks_high =cpu_to_le16 (i_blocks >>32 );
I don't think we need to cast (u32) here, since cpu_to_le32() should do that already?
Quoted 16 lines
fs/ext4/inode.c +16
-0+ }else { +/* +* i_blocks should be represented in a 48 bit variable +* as multiple of file system block size +*/ +if (!EXT4_HAS_RO_COMPAT_FEATURE (sb, +EXT4_FEATURE_RO_COMPAT_HUGE_FILE )) { + + err =ext4_journal_get_write_access (handle, +EXT4_SB (sb)->s_sbh); +if (err) + goto err_out; +ext4_update_dynamic_rev (sb); +EXT4_SET_RO_COMPAT_FEATURE (sb, +EXT4_FEATURE_RO_COMPAT_HUGE_FILE ); + sb->s_dirt =1 ;
fs/ext4/inode.c static int ext4_inode_blocks_set(handle_t *handle, · line 2941
Quoted 10 lines
fs/ext4/inode.c +9
-0+ handle->h_sync =1 ; + err =ext4_journal_dirty_metadata (handle, +EXT4_SB (sb)->s_sbh); + } + ei->i_flags |=EXT4_HUGE_FILE_FL ; +/* i_block is stored in file system block size */ + i_blocks = i_blocks >> (inode->i_blkbits -9 ); + raw_inode->i_blocks_lo =cpu_to_le32 ((u32 )i_blocks); + raw_inode->i_blocks_high =cpu_to_le16 (i_blocks >>32 ); }
This "else" clause is a LOT like the previous case, maybe they can be merges? Having the feature helper I suggested will reduce that a lot, but it still seems like most of it is the same except for the shift.
Cheers, Andreas
--
Andreas Dilger
Principal Software Engineer
Cluster File Systems, Inc.
Re: [PATCH 2/2] ext4: Support large files
Quoted 11 lines · Andreas Dilger
Quoted 8 lines · Aneesh Kumar K.V
We add a
RO_COMPATfeature to the super
block to indicate that some of the inode havei_blocksrepresented as file system block size units. Super block with this feature set cannot be mounted read write on a kernel withCONFIG_LSFdisabled.Super block flag
EXT4_FEATURE_RO_COMPAT_HUGE_FILEinode flagEXT4_HUGE_FILE_FLI was wondering where this part of the patch went...
I fogot to update the commit message properly. right now it reads as below
ext4: Support large files
This patch converts ext4_inode i_blocks to represent total blocks occupied by the inode in file system block size. Earlier the variable used to represent this in 512 byte block size. This actually limited the total size of the file.
The feature is enabled transparently when we write an inode whose i_blocks cannot be represnted as 512 byte units in a 48 bit variable.
inode flag EXT4_HUGE_FILE_FL
EXT4_FEATURE_RO_COMPAT_HUGE_FILE is set when we start using the higher order 16 bit it is done in the previous patch. To enable that we need the CONFIG_LSF support. With CONFIG_LSF support enabled and if the inode have EXT4_HUGE_FILE_FL set that means i_blocks is represented in terms of file system block size.
Quoted 9 lines
fs/ext4/inode.c static int ext4_inode_blocks_set(handle_t *handle, · line 2914
Quoted 5 lines
fs/ext4/inode.c +0
-0@@ -2905,10 +2912,32 @@ static int ext4_inode_blocks_set(handle_t *handle,/* i_block is stored in the split 48 bit fields */ raw_inode->i_blocks_lo =cpu_to_le32 ((u32 )i_blocks); raw_inode->i_blocks_high =cpu_to_le16 (i_blocks >>32 );I don't think we need to cast (u32) here, since
cpu_to_le32()should do that already?
yes. will remove the same
Quoted 22 lines
Quoted 22 lines
fs/ext4/inode.c +22
-0+ }else { +/* +* i_blocks should be represented in a 48 bit variable +* as multiple of file system block size +*/ +if (!EXT4_HAS_RO_COMPAT_FEATURE (sb, +EXT4_FEATURE_RO_COMPAT_HUGE_FILE )) { + + err =ext4_journal_get_write_access (handle, +EXT4_SB (sb)->s_sbh); +if (err) + goto err_out; +ext4_update_dynamic_rev (sb); +EXT4_SET_RO_COMPAT_FEATURE (sb, +EXT4_FEATURE_RO_COMPAT_HUGE_FILE ); + sb->s_dirt =1 ; + handle->h_sync =1 ; + err =ext4_journal_dirty_metadata (handle, +EXT4_SB (sb)->s_sbh); + } + ei->i_flags |=EXT4_HUGE_FILE_FL ; +/* i_block is stored in file system block size */
Quoted 9 lines
fs/ext4/inode.c static int ext4_inode_blocks_set(handle_t *handle, · line 2941
Quoted 4 lines
fs/ext4/inode.c +3
-0+ i_blocks = i_blocks >> (inode->i_blkbits -9 ); + raw_inode->i_blocks_lo =cpu_to_le32 ((u32 )i_blocks); + raw_inode->i_blocks_high =cpu_to_le16 (i_blocks >>32 ); }This "else" clause is a LOT like the previous case, maybe they can be merges? Having the feature helper I suggested will reduce that a lot, but it still seems like most of it is the same except for the shift.
Yes. ext4_update_feature will simplify the above.
Thanks a lot for all your reviews.
-aneesh