Commit 58cefd2b authored by Linus Torvalds's avatar Linus Torvalds

Merge branch 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4

* 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4:
  ext4: fix bb_prealloc_list corruption due to wrong group locking
  ext4: fix bogus BUG_ONs in in mballoc code
  ext4: Print the find_group_flex() warning only once
  ext4: fix header check in ext4_ext_search_right() for deep extent trees.
parents ee568b25 d33a1976
...@@ -1122,7 +1122,8 @@ ext4_ext_search_right(struct inode *inode, struct ext4_ext_path *path, ...@@ -1122,7 +1122,8 @@ ext4_ext_search_right(struct inode *inode, struct ext4_ext_path *path,
struct ext4_extent_idx *ix; struct ext4_extent_idx *ix;
struct ext4_extent *ex; struct ext4_extent *ex;
ext4_fsblk_t block; ext4_fsblk_t block;
int depth, ee_len; int depth; /* Note, NOT eh_depth; depth from top of tree */
int ee_len;
BUG_ON(path == NULL); BUG_ON(path == NULL);
depth = path->p_depth; depth = path->p_depth;
...@@ -1179,7 +1180,8 @@ ext4_ext_search_right(struct inode *inode, struct ext4_ext_path *path, ...@@ -1179,7 +1180,8 @@ ext4_ext_search_right(struct inode *inode, struct ext4_ext_path *path,
if (bh == NULL) if (bh == NULL)
return -EIO; return -EIO;
eh = ext_block_hdr(bh); eh = ext_block_hdr(bh);
if (ext4_ext_check_header(inode, eh, depth)) { /* subtract from p_depth to get proper eh_depth */
if (ext4_ext_check_header(inode, eh, path->p_depth - depth)) {
put_bh(bh); put_bh(bh);
return -EIO; return -EIO;
} }
......
...@@ -698,6 +698,7 @@ struct inode *ext4_new_inode(handle_t *handle, struct inode *dir, int mode) ...@@ -698,6 +698,7 @@ struct inode *ext4_new_inode(handle_t *handle, struct inode *dir, int mode)
struct inode *ret; struct inode *ret;
ext4_group_t i; ext4_group_t i;
int free = 0; int free = 0;
static int once = 1;
ext4_group_t flex_group; ext4_group_t flex_group;
/* Cannot create files in a deleted directory */ /* Cannot create files in a deleted directory */
...@@ -719,7 +720,8 @@ struct inode *ext4_new_inode(handle_t *handle, struct inode *dir, int mode) ...@@ -719,7 +720,8 @@ struct inode *ext4_new_inode(handle_t *handle, struct inode *dir, int mode)
ret2 = find_group_flex(sb, dir, &group); ret2 = find_group_flex(sb, dir, &group);
if (ret2 == -1) { if (ret2 == -1) {
ret2 = find_group_other(sb, dir, &group); ret2 = find_group_other(sb, dir, &group);
if (ret2 == 0 && printk_ratelimit()) if (ret2 == 0 && once)
once = 0;
printk(KERN_NOTICE "ext4: find_group_flex " printk(KERN_NOTICE "ext4: find_group_flex "
"failed, fallback succeeded dir %lu\n", "failed, fallback succeeded dir %lu\n",
dir->i_ino); dir->i_ino);
......
...@@ -1447,7 +1447,7 @@ static void ext4_mb_measure_extent(struct ext4_allocation_context *ac, ...@@ -1447,7 +1447,7 @@ static void ext4_mb_measure_extent(struct ext4_allocation_context *ac,
struct ext4_free_extent *gex = &ac->ac_g_ex; struct ext4_free_extent *gex = &ac->ac_g_ex;
BUG_ON(ex->fe_len <= 0); BUG_ON(ex->fe_len <= 0);
BUG_ON(ex->fe_len >= EXT4_BLOCKS_PER_GROUP(ac->ac_sb)); BUG_ON(ex->fe_len > EXT4_BLOCKS_PER_GROUP(ac->ac_sb));
BUG_ON(ex->fe_start >= EXT4_BLOCKS_PER_GROUP(ac->ac_sb)); BUG_ON(ex->fe_start >= EXT4_BLOCKS_PER_GROUP(ac->ac_sb));
BUG_ON(ac->ac_status != AC_STATUS_CONTINUE); BUG_ON(ac->ac_status != AC_STATUS_CONTINUE);
...@@ -3292,7 +3292,7 @@ ext4_mb_normalize_request(struct ext4_allocation_context *ac, ...@@ -3292,7 +3292,7 @@ ext4_mb_normalize_request(struct ext4_allocation_context *ac,
} }
BUG_ON(start + size <= ac->ac_o_ex.fe_logical && BUG_ON(start + size <= ac->ac_o_ex.fe_logical &&
start > ac->ac_o_ex.fe_logical); start > ac->ac_o_ex.fe_logical);
BUG_ON(size <= 0 || size >= EXT4_BLOCKS_PER_GROUP(ac->ac_sb)); BUG_ON(size <= 0 || size > EXT4_BLOCKS_PER_GROUP(ac->ac_sb));
/* now prepare goal request */ /* now prepare goal request */
...@@ -3589,6 +3589,7 @@ static void ext4_mb_put_pa(struct ext4_allocation_context *ac, ...@@ -3589,6 +3589,7 @@ static void ext4_mb_put_pa(struct ext4_allocation_context *ac,
struct super_block *sb, struct ext4_prealloc_space *pa) struct super_block *sb, struct ext4_prealloc_space *pa)
{ {
ext4_group_t grp; ext4_group_t grp;
ext4_fsblk_t grp_blk;
if (!atomic_dec_and_test(&pa->pa_count) || pa->pa_free != 0) if (!atomic_dec_and_test(&pa->pa_count) || pa->pa_free != 0)
return; return;
...@@ -3603,8 +3604,12 @@ static void ext4_mb_put_pa(struct ext4_allocation_context *ac, ...@@ -3603,8 +3604,12 @@ static void ext4_mb_put_pa(struct ext4_allocation_context *ac,
pa->pa_deleted = 1; pa->pa_deleted = 1;
spin_unlock(&pa->pa_lock); spin_unlock(&pa->pa_lock);
/* -1 is to protect from crossing allocation group */ grp_blk = pa->pa_pstart;
ext4_get_group_no_and_offset(sb, pa->pa_pstart - 1, &grp, NULL); /* If linear, pa_pstart may be in the next group when pa is used up */
if (pa->pa_linear)
grp_blk--;
ext4_get_group_no_and_offset(sb, grp_blk, &grp, NULL);
/* /*
* possible race: * possible race:
......
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