ext4: Convert bg_block_bitmap to bg_block_bitmap_lo
PATCH 1/7 ext4: Convert bg_block_bitmap to bg_block_bitmap_lo
Convert bg_block_bitmap to bg_block_bitmap_lo
This helps in catching some BUGS due to direct
partial access of these split fields.
--- fs/ext4/super.c | 6 +++--- include/linux/ext4_fs.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-)
fs/ext4/super.c +3 -3
@@ -70,9 +70,9 @@ static void ext4_write_super_lockfs(struct super_block *sb);ext4_fsblk_t ext4_block_bitmap (struct super_block *sb,struct ext4_group_desc *bg) { -return le32_to_cpu (bg->bg_block_bitmap) | +return le32_to_cpu (bg->bg_block_bitmap_lo) | (EXT4_DESC_SIZE (sb) >=EXT4_MIN_DESC_SIZE_64BIT ? - (ext4_fsblk_t )le32_to_cpu (bg->bg_block_bitmap_hi) <<32 :0 ); + (ext4_fsblk_t )le32_to_cpu (bg->bg_block_bitmap_hi) <<32 :0 ); } ext4_fsblk_t ext4_inode_bitmap(struct super_block *sb,
@@ -94,7 +94,7 @@ ext4_fsblk_t ext4_inode_table(struct super_block *sb,void ext4_block_bitmap_set (struct super_block *sb,struct ext4_group_desc *bg,ext4_fsblk_t blk) { - bg->bg_block_bitmap =cpu_to_le32 ((u32 )blk); + bg->bg_block_bitmap_lo =cpu_to_le32 ((u32 )blk);if (EXT4_DESC_SIZE (sb) >=EXT4_MIN_DESC_SIZE_64BIT ) bg->bg_block_bitmap_hi =cpu_to_le32 (blk >>32 ); }
include/linux/ext4_fs.h +1 -1
@@ -150,7 +150,7 @@ struct ext4_allocation_request {*/ struct ext4_group_desc { -__le32 bg_block_bitmap;/* Blocks bitmap block */ +__le32 bg_block_bitmap_lo;/* Blocks bitmap block */ __le32 bg_inode_bitmap;/* Inodes bitmap block */ __le32 bg_inode_table;/* Inodes table block */ __le16 bg_free_blocks_count;/* Free blocks count */
Signature · 1 line
1.5.3.1.91.gd3392-dirty
PATCH 2/7 ext4: Convert bg_inode_bitmap and bg_inode_table
Convert bg_inode_bitmap and bg_inode_table to bg_inode_bitmap_lo and bg_inode_table_lo. This helps in finding BUGs due to direct partial access of these split 64 bit values
Also fix one direct partial access
--- fs/ext4/balloc.c | 2 +- fs/ext4/super.c | 12 ++++++------ include/linux/ext4_fs.h | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-)
fs/ext4/balloc.c +1 -1
@@ -103,7 +103,7 @@ unsigned ext4_init_block_bitmap(struct super_block *sb, struct buffer_head *bh,/* Set bits for block and inode bitmaps, and inode table */ ext4_set_bit (ext4_block_bitmap (sb, gdp) - start, bh->b_data);ext4_set_bit (ext4_inode_bitmap (sb, gdp) - start, bh->b_data); -for (bit =le32_to_cpu (gdp->bg_inode_table) - start, +for (bit = (ext4_inode_table (sb, gdp) - start), bit_max = bit + sbi->s_itb_per_group; bit < bit_max; bit++)ext4_set_bit (bit, bh->b_data); }
fs/ext4/super.c +6 -6
@@ -78,17 +78,17 @@ ext4_fsblk_t ext4_block_bitmap(struct super_block *sb,ext4_fsblk_t ext4_inode_bitmap (struct super_block *sb,struct ext4_group_desc *bg) { -return le32_to_cpu (bg->bg_inode_bitmap) | +return le32_to_cpu (bg->bg_inode_bitmap_lo) | (EXT4_DESC_SIZE (sb) >=EXT4_MIN_DESC_SIZE_64BIT ? - (ext4_fsblk_t )le32_to_cpu (bg->bg_inode_bitmap_hi) <<32 :0 ); + (ext4_fsblk_t )le32_to_cpu (bg->bg_inode_bitmap_hi) <<32 :0 ); }ext4_fsblk_t ext4_inode_table (struct super_block *sb,struct ext4_group_desc *bg) { -return le32_to_cpu (bg->bg_inode_table) | +return le32_to_cpu (bg->bg_inode_table_lo) | (EXT4_DESC_SIZE (sb) >=EXT4_MIN_DESC_SIZE_64BIT ? - (ext4_fsblk_t )le32_to_cpu (bg->bg_inode_table_hi) <<32 :0 ); + (ext4_fsblk_t )le32_to_cpu (bg->bg_inode_table_hi) <<32 :0 ); } void ext4_block_bitmap_set(struct super_block *sb,
@@ -102,7 +102,7 @@ void ext4_block_bitmap_set(struct super_block *sb,void ext4_inode_bitmap_set (struct super_block *sb,struct ext4_group_desc *bg,ext4_fsblk_t blk) { - bg->bg_inode_bitmap =cpu_to_le32 ((u32 )blk); + bg->bg_inode_bitmap_lo =cpu_to_le32 ((u32 )blk);if (EXT4_DESC_SIZE (sb) >=EXT4_MIN_DESC_SIZE_64BIT ) bg->bg_inode_bitmap_hi =cpu_to_le32 (blk >>32 ); }
@@ -110,7 +110,7 @@ void ext4_inode_bitmap_set(struct super_block *sb,void ext4_inode_table_set (struct super_block *sb,struct ext4_group_desc *bg,ext4_fsblk_t blk) { - bg->bg_inode_table =cpu_to_le32 ((u32 )blk); + bg->bg_inode_table_lo =cpu_to_le32 ((u32 )blk);if (EXT4_DESC_SIZE (sb) >=EXT4_MIN_DESC_SIZE_64BIT ) bg->bg_inode_table_hi =cpu_to_le32 (blk >>32 ); }
include/linux/ext4_fs.h +2 -2
@@ -151,8 +151,8 @@ struct ext4_allocation_request {struct ext4_group_desc {__le32 bg_block_bitmap_lo;/* Blocks bitmap block */ -__le32 bg_inode_bitmap;/* Inodes bitmap block */ -__le32 bg_inode_table;/* Inodes table block */ +__le32 bg_inode_bitmap_lo;/* Inodes bitmap block */ +__le32 bg_inode_table_lo;/* Inodes table block */ __le16 bg_free_blocks_count;/* Free blocks count */ __le16 bg_free_inodes_count;/* Free inodes count */ __le16 bg_used_dirs_count;/* Directories count */
Signature · 1 line
1.5.3.1.91.gd3392-dirty
PATCH 3/7 ext4: Convert s_blocks_count to s_blocks_count_lo
Convert s_blocks_count to s_blocks_count_lo
This helps in finding BUGs due to direct partial access of these split 64 bit values
Also fix direct partial access in ext4 code
--- fs/ext4/mballoc.c | 4 ++-- fs/ext4/super.c | 4 ++-- include/linux/ext4_fs.h | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-)
fs/ext4/mballoc.c +2 -2
@@ -4036,7 +4036,7 @@ int ext4_mb_initialize_context(struct ext4_allocation_context *ac,/* start searching from the goal */ goal = ar->goal;if (goal <le32_to_cpu (es->s_first_data_block) || - goal >=le32_to_cpu (es->s_blocks_count)) + goal >=ext4_blocks_count (es)) goal =le32_to_cpu (es->s_first_data_block);ext4_get_group_no_and_offset (sb, goal, &group, &block);
@@ -4337,7 +4337,7 @@ void ext4_mb_free_blocks(handle_t *handle, struct inode *inode, es =EXT4_SB (sb)->s_es;if (block <le32_to_cpu (es->s_first_data_block) || block + count < block || - block + count >le32_to_cpu (es->s_blocks_count)) { + block + count >ext4_blocks_count (es)) {ext4_error (sb, __FUNCTION__,"Freeing blocks not in datazone - " "block = %lu, count = %lu" , block, count);
fs/ext4/super.c +2 -2
@@ -2653,7 +2653,7 @@ static int ext4_statfs (struct dentry * dentry, struct kstatfs * buf)if (test_opt (sb,MINIX_DF )) { sbi->s_overhead_last =0 ; - }else if (sbi->s_blocks_last !=le32_to_cpu (es->s_blocks_count)) { + }else if (sbi->s_blocks_last !=ext4_blocks_count (es)) {unsigned long ngroups = sbi->s_groups_count, i;ext4_fsblk_t overhead =0 ;smp_rmb ();
@@ -2688,7 +2688,7 @@ static int ext4_statfs (struct dentry * dentry, struct kstatfs * buf) overhead += ngroups * (2 + sbi->s_itb_per_group); sbi->s_overhead_last = overhead;smp_wmb (); - sbi->s_blocks_last =le32_to_cpu (es->s_blocks_count); + sbi->s_blocks_last =ext4_blocks_count (es); } buf->f_type =EXT4_SUPER_MAGIC ;
include/linux/ext4_fs.h +3 -3
@@ -563,7 +563,7 @@ do { \*/ struct ext4_super_block {/*00*/ __le32 s_inodes_count;/* Inodes count */ -__le32 s_blocks_count;/* Blocks count */ +__le32 s_blocks_count_lo;/* Blocks count */ __le32 s_r_blocks_count;/* Reserved blocks count */ __le32 s_free_blocks_count;/* Free blocks count */ /*10*/ __le32 s_free_inodes_count;/* Free inodes count */
@@ -1067,7 +1067,7 @@ extern void ext4_inode_table_set(struct super_block *sb,static inline ext4_fsblk_t ext4_blocks_count (struct ext4_super_block *es) {return ((ext4_fsblk_t )le32_to_cpu (es->s_blocks_count_hi) <<32 ) | -le32_to_cpu (es->s_blocks_count); +le32_to_cpu (es->s_blocks_count_lo); }static inline ext4_fsblk_t ext4_r_blocks_count (struct ext4_super_block *es)
@@ -1085,7 +1085,7 @@ static inline ext4_fsblk_t ext4_free_blocks_count(struct ext4_super_block *es)static inline void ext4_blocks_count_set (struct ext4_super_block *es,ext4_fsblk_t blk) { - es->s_blocks_count =cpu_to_le32 ((u32 )blk); + es->s_blocks_count_lo =cpu_to_le32 ((u32 )blk); es->s_blocks_count_hi =cpu_to_le32 (blk >>32 ); }
Signature · 1 line
1.5.3.1.91.gd3392-dirty
PATCH 4/7 ext4: Convert s_r_blocks_count and s_free_blocks_count
Convert s_r_blocks_count and s_free_blocks_count to s_r_blocks_count_lo and s_free_blocks_count_lo
This helps in finding BUGs due to direct partial access of these split 64 bit values
Also fix direct partial access in ext4 code
--- fs/ext4/super.c | 2 +- include/linux/ext4_fs.h | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-)
fs/ext4/super.c +1 -1
@@ -2695,7 +2695,7 @@ static int ext4_statfs (struct dentry * dentry, struct kstatfs * buf) buf->f_bsize = sb->s_blocksize; buf->f_blocks =ext4_blocks_count (es) - sbi->s_overhead_last; buf->f_bfree =percpu_counter_sum (&sbi->s_freeblocks_counter); - es->s_free_blocks_count =cpu_to_le32 (buf->f_bfree); +ext4_free_blocks_count_set (es, buf->f_bfree); buf->f_bavail = buf->f_bfree -ext4_r_blocks_count (es);if (buf->f_bfree <ext4_r_blocks_count (es)) buf->f_bavail =0 ;
include/linux/ext4_fs.h +6 -6
@@ -564,8 +564,8 @@ do { \struct ext4_super_block {/*00*/ __le32 s_inodes_count;/* Inodes count */ __le32 s_blocks_count_lo;/* Blocks count */ -__le32 s_r_blocks_count;/* Reserved blocks count */ -__le32 s_free_blocks_count;/* Free blocks count */ +__le32 s_r_blocks_count_lo;/* Reserved blocks count */ +__le32 s_free_blocks_count_lo;/* Free blocks count */ /*10*/ __le32 s_free_inodes_count;/* Free inodes count */ __le32 s_first_data_block;/* First Data Block */ __le32 s_log_block_size;/* Block size */
@@ -1073,13 +1073,13 @@ static inline ext4_fsblk_t ext4_blocks_count(struct ext4_super_block *es)static inline ext4_fsblk_t ext4_r_blocks_count (struct ext4_super_block *es) {return ((ext4_fsblk_t )le32_to_cpu (es->s_r_blocks_count_hi) <<32 ) | -le32_to_cpu (es->s_r_blocks_count); +le32_to_cpu (es->s_r_blocks_count_lo); }static inline ext4_fsblk_t ext4_free_blocks_count (struct ext4_super_block *es) {return ((ext4_fsblk_t )le32_to_cpu (es->s_free_blocks_count_hi) <<32 ) | -le32_to_cpu (es->s_free_blocks_count); +le32_to_cpu (es->s_free_blocks_count_lo); } static inline void ext4_blocks_count_set(struct ext4_super_block *es,
@@ -1092,14 +1092,14 @@ static inline void ext4_blocks_count_set(struct ext4_super_block *es,static inline void ext4_free_blocks_count_set (struct ext4_super_block *es,ext4_fsblk_t blk) { - es->s_free_blocks_count =cpu_to_le32 ((u32 )blk); + es->s_free_blocks_count_lo =cpu_to_le32 ((u32 )blk); es->s_free_blocks_count_hi =cpu_to_le32 (blk >>32 ); }static inline void ext4_r_blocks_count_set (struct ext4_super_block *es,ext4_fsblk_t blk) { - es->s_r_blocks_count =cpu_to_le32 ((u32 )blk); + es->s_r_blocks_count_lo =cpu_to_le32 ((u32 )blk); es->s_r_blocks_count_hi =cpu_to_le32 (blk >>32 ); }
Signature · 1 line
1.5.3.1.91.gd3392-dirty
PATCH 5/7 ext4: Convert ext4_extent.ee_start to ext4_extent.ee_start_lo
Convert ext4_extent.ee_start to ext4_extent.ee_start_lo This helps in finding BUGs due to direct partial access of these split 48 bit values
Also fix direct partial access in ext4 code
--- fs/ext4/extents.c | 8 +++----- fs/ext4/migrate.c | 2 +- include/linux/ext4_fs_extents.h | 2 +- 3 files changed, 5 insertions(+), 7 deletions(-)
fs/ext4/extents.c +3 -5
@@ -52,7 +52,7 @@ static ext4_fsblk_t ext_pblock(struct ext4_extent *ex) {ext4_fsblk_t block; - block =le32_to_cpu (ex->ee_start); + block =le32_to_cpu (ex->ee_start_lo); block |= ((ext4_fsblk_t )le16_to_cpu (ex->ee_start_hi) <<31 ) <<1 ;return block; }
@@ -77,7 +77,7 @@ static ext4_fsblk_t idx_pblock(struct ext4_extent_idx *ix)*/ static void ext4_ext_store_pblock (struct ext4_extent *ex,ext4_fsblk_t pb) { - ex->ee_start =cpu_to_le32 ((unsigned long ) (pb &0xffffffff )); + ex->ee_start_lo =cpu_to_le32 ((unsigned long ) (pb &0xffffffff )); ex->ee_start_hi =cpu_to_le16 ((unsigned long ) ((pb >>31 ) >>1 ) &0xffff ); }
@@ -1551,8 +1551,7 @@ has_space: eh->eh_entries =cpu_to_le16 (le16_to_cpu (eh->eh_entries)+1 ); nearex = path[depth].p_ext; nearex->ee_block = newext->ee_block; - nearex->ee_start = newext->ee_start; - nearex->ee_start_hi = newext->ee_start_hi; +ext4_ext_store_pblock (nearex,ext_pblock (newext)); nearex->ee_len = newext->ee_len; merge:
@@ -2321,7 +2320,6 @@ int ext4_ext_convert_to_initialized(handle_t *handle, struct inode *inode, }/* ex2: iblock to iblock + maxblocks-1 : initialised */ ex2->ee_block =cpu_to_le32 (iblock); - ex2->ee_start =cpu_to_le32 (newblock);ext4_ext_store_pblock (ex2, newblock); ex2->ee_len =cpu_to_le16 (allocated);if (ex2 != ex)
fs/ext4/migrate.c +1 -1
@@ -24,7 +24,7 @@ struct list_blocks_struct {/* will go away */ static void ext4_ext_store_pblock (struct ext4_extent *ex,ext4_fsblk_t pb) { - ex->ee_start =cpu_to_le32 ((unsigned long ) (pb &0xffffffff )); + ex->ee_start_lo =cpu_to_le32 ((unsigned long ) (pb &0xffffffff )); ex->ee_start_hi =cpu_to_le16 ((unsigned long ) ((pb >>31 ) >>1 ) &0xffff ); }
include/linux/ext4_fs_extents.h +1 -1
@@ -74,7 +74,7 @@ struct ext4_extent {__le32 ee_block;/* first logical block extent covers */ __le16 ee_len;/* number of blocks covered by extent */ __le16 ee_start_hi;/* high 16 bits of physical block */ -__le32 ee_start;/* low 32 bits of physical block */ +__le32 ee_start_lo;/* low 32 bits of physical block */ };/*
Signature · 1 line
1.5.3.1.91.gd3392-dirty
PATCH 6/7 ext4: Convert ext4_extent_idx.ei_leaf ext4_extent_idx.ei_leaf_lo
Convert ext4_extent_idx.ei_leaf ext4_extent_idx.ei_leaf_lo This helps in finding BUGs due to direct partial access of these split 48 bit values.
--- fs/ext4/extents.c | 4 ++-- fs/ext4/migrate.c | 2 +- include/linux/ext4_fs_extents.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-)
fs/ext4/extents.c +2 -2
@@ -65,7 +65,7 @@ static ext4_fsblk_t idx_pblock(struct ext4_extent_idx *ix) {ext4_fsblk_t block; - block =le32_to_cpu (ix->ei_leaf); + block =le32_to_cpu (ix->ei_leaf_lo); block |= ((ext4_fsblk_t )le16_to_cpu (ix->ei_leaf_hi) <<31 ) <<1 ;return block; }
@@ -88,7 +88,7 @@ static void ext4_ext_store_pblock(struct ext4_extent *ex, ext4_fsblk_t pb)*/ static void ext4_idx_store_pblock (struct ext4_extent_idx *ix,ext4_fsblk_t pb) { - ix->ei_leaf =cpu_to_le32 ((unsigned long ) (pb &0xffffffff )); + ix->ei_leaf_lo =cpu_to_le32 ((unsigned long ) (pb &0xffffffff )); ix->ei_leaf_hi =cpu_to_le16 ((unsigned long ) ((pb >>31 ) >>1 ) &0xffff ); }
fs/ext4/migrate.c +1 -1
@@ -375,7 +375,7 @@ static ext4_fsblk_t idx_pblock(struct ext4_extent_idx *ix) {ext4_fsblk_t block; - block =le32_to_cpu (ix->ei_leaf); + block =le32_to_cpu (ix->ei_leaf_lo); block |= ((ext4_fsblk_t )le16_to_cpu (ix->ei_leaf_hi) <<31 ) <<1 ;return block; }
include/linux/ext4_fs_extents.h +1 -1
@@ -83,7 +83,7 @@ struct ext4_extent {*/ struct ext4_extent_idx {__le32 ei_block;/* index covers logical blocks from 'block' */ -__le32 ei_leaf;/* pointer to the physical block of the next * +__le32 ei_leaf_lo;/* pointer to the physical block of the next * * level. leaf or next index could be there */ __le16 ei_leaf_hi;/* high 16 bits of physical block */ __u16 ei_unused;
Signature · 1 line
1.5.3.1.91.gd3392-dirty
PATCH 7/7 ext4: sparse fixes
--- fs/ext4/fsync.c | 2 +- fs/ext4/inode.c | 2 +- fs/ext4/xattr.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-)
fs/ext4/fsync.c +1 -1
@@ -47,7 +47,7 @@ int ext4_sync_file(struct file * file, struct dentry *dentry, int datasync)struct inode *inode = dentry->d_inode;int ret =0 ; -J_ASSERT (ext4_journal_current_handle () ==0 ); +J_ASSERT (ext4_journal_current_handle () ==NULL );/* * data=writeback:
fs/ext4/inode.c +1 -1
@@ -976,7 +976,7 @@ struct buffer_head *ext4_getblk(handle_t *handle, struct inode *inode, }if (buffer_new (&dummy)) {J_ASSERT (create !=0 ); -J_ASSERT (handle !=0 ); +J_ASSERT (handle !=NULL );/* * Now that we do not always journal data, we should
fs/ext4/xattr.c +2 -2
@@ -1120,7 +1120,7 @@ int ext4_expand_extra_isize_ea(struct inode *inode, int new_extra_isize,int total_ino, total_blk;void *base, *start, *end;int extra_isize =0 , error =0 , tried_min_extra_isize =0 ; -int s_min_extra_isize =EXT4_SB (inode->i_sb)->s_es->s_min_extra_isize; +int s_min_extra_isize =le16_to_cpu (EXT4_SB (inode->i_sb)->s_es->s_min_extra_isize);down_write (&EXT4_I (inode)->xattr_sem); retry:
@@ -1292,7 +1292,7 @@ retry: i.name = b_entry_name; i.value = buffer; - i.value_len =cpu_to_le32 (size); + i.value_len = size; error =ext4_xattr_block_find (inode, &i, bs);if (error) goto cleanup;
Signature · 1 line
1.5.3.1.91.gd3392-dirty