diff options
Diffstat (limited to 'fs/ext4/ialloc.c')
-rw-r--r-- | fs/ext4/ialloc.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c index 3f98ee712ff4..2f645732e3b7 100644 --- a/fs/ext4/ialloc.c +++ b/fs/ext4/ialloc.c | |||
@@ -799,7 +799,7 @@ err_ret: | |||
799 | * group to find a free inode. | 799 | * group to find a free inode. |
800 | */ | 800 | */ |
801 | struct inode *ext4_new_inode(handle_t *handle, struct inode *dir, int mode, | 801 | struct inode *ext4_new_inode(handle_t *handle, struct inode *dir, int mode, |
802 | const struct qstr *qstr) | 802 | const struct qstr *qstr, __u32 goal) |
803 | { | 803 | { |
804 | struct super_block *sb; | 804 | struct super_block *sb; |
805 | struct buffer_head *inode_bitmap_bh = NULL; | 805 | struct buffer_head *inode_bitmap_bh = NULL; |
@@ -830,6 +830,16 @@ struct inode *ext4_new_inode(handle_t *handle, struct inode *dir, int mode, | |||
830 | ei = EXT4_I(inode); | 830 | ei = EXT4_I(inode); |
831 | sbi = EXT4_SB(sb); | 831 | sbi = EXT4_SB(sb); |
832 | 832 | ||
833 | if (!goal) | ||
834 | goal = sbi->s_inode_goal; | ||
835 | |||
836 | if (goal && goal < le32_to_cpu(sbi->s_es->s_inodes_count)) { | ||
837 | group = (goal - 1) / EXT4_INODES_PER_GROUP(sb); | ||
838 | ino = (goal - 1) % EXT4_INODES_PER_GROUP(sb); | ||
839 | ret2 = 0; | ||
840 | goto got_group; | ||
841 | } | ||
842 | |||
833 | if (sbi->s_log_groups_per_flex && test_opt(sb, OLDALLOC)) { | 843 | if (sbi->s_log_groups_per_flex && test_opt(sb, OLDALLOC)) { |
834 | ret2 = find_group_flex(sb, dir, &group); | 844 | ret2 = find_group_flex(sb, dir, &group); |
835 | if (ret2 == -1) { | 845 | if (ret2 == -1) { |
@@ -858,7 +868,7 @@ got_group: | |||
858 | if (ret2 == -1) | 868 | if (ret2 == -1) |
859 | goto out; | 869 | goto out; |
860 | 870 | ||
861 | for (i = 0; i < ngroups; i++) { | 871 | for (i = 0; i < ngroups; i++, ino = 0) { |
862 | err = -EIO; | 872 | err = -EIO; |
863 | 873 | ||
864 | gdp = ext4_get_group_desc(sb, group, &group_desc_bh); | 874 | gdp = ext4_get_group_desc(sb, group, &group_desc_bh); |
@@ -870,8 +880,6 @@ got_group: | |||
870 | if (!inode_bitmap_bh) | 880 | if (!inode_bitmap_bh) |
871 | goto fail; | 881 | goto fail; |
872 | 882 | ||
873 | ino = 0; | ||
874 | |||
875 | repeat_in_this_group: | 883 | repeat_in_this_group: |
876 | ino = ext4_find_next_zero_bit((unsigned long *) | 884 | ino = ext4_find_next_zero_bit((unsigned long *) |
877 | inode_bitmap_bh->b_data, | 885 | inode_bitmap_bh->b_data, |