diff options
Diffstat (limited to 'fs/ext4/resize.c')
-rw-r--r-- | fs/ext4/resize.c | 82 |
1 files changed, 42 insertions, 40 deletions
diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c index f000fbe2cd93..b3d35604ea18 100644 --- a/fs/ext4/resize.c +++ b/fs/ext4/resize.c | |||
@@ -73,7 +73,7 @@ static int verify_group_input(struct super_block *sb, | |||
73 | "Inode bitmap not in group (block %llu)", | 73 | "Inode bitmap not in group (block %llu)", |
74 | (unsigned long long)input->inode_bitmap); | 74 | (unsigned long long)input->inode_bitmap); |
75 | else if (outside(input->inode_table, start, end) || | 75 | else if (outside(input->inode_table, start, end) || |
76 | outside(itend - 1, start, end)) | 76 | outside(itend - 1, start, end)) |
77 | ext4_warning(sb, __func__, | 77 | ext4_warning(sb, __func__, |
78 | "Inode table not in group (blocks %llu-%llu)", | 78 | "Inode table not in group (blocks %llu-%llu)", |
79 | (unsigned long long)input->inode_table, itend - 1); | 79 | (unsigned long long)input->inode_table, itend - 1); |
@@ -104,7 +104,7 @@ static int verify_group_input(struct super_block *sb, | |||
104 | (unsigned long long)input->inode_bitmap, | 104 | (unsigned long long)input->inode_bitmap, |
105 | start, metaend - 1); | 105 | start, metaend - 1); |
106 | else if (inside(input->inode_table, start, metaend) || | 106 | else if (inside(input->inode_table, start, metaend) || |
107 | inside(itend - 1, start, metaend)) | 107 | inside(itend - 1, start, metaend)) |
108 | ext4_warning(sb, __func__, | 108 | ext4_warning(sb, __func__, |
109 | "Inode table (%llu-%llu) overlaps" | 109 | "Inode table (%llu-%llu) overlaps" |
110 | "GDT table (%llu-%llu)", | 110 | "GDT table (%llu-%llu)", |
@@ -158,9 +158,9 @@ static int extend_or_restart_transaction(handle_t *handle, int thresh, | |||
158 | if (err) { | 158 | if (err) { |
159 | if ((err = ext4_journal_restart(handle, EXT4_MAX_TRANS_DATA))) | 159 | if ((err = ext4_journal_restart(handle, EXT4_MAX_TRANS_DATA))) |
160 | return err; | 160 | return err; |
161 | if ((err = ext4_journal_get_write_access(handle, bh))) | 161 | if ((err = ext4_journal_get_write_access(handle, bh))) |
162 | return err; | 162 | return err; |
163 | } | 163 | } |
164 | 164 | ||
165 | return 0; | 165 | return 0; |
166 | } | 166 | } |
@@ -416,11 +416,11 @@ static int add_new_gdb(handle_t *handle, struct inode *inode, | |||
416 | "EXT4-fs: ext4_add_new_gdb: adding group block %lu\n", | 416 | "EXT4-fs: ext4_add_new_gdb: adding group block %lu\n", |
417 | gdb_num); | 417 | gdb_num); |
418 | 418 | ||
419 | /* | 419 | /* |
420 | * If we are not using the primary superblock/GDT copy don't resize, | 420 | * If we are not using the primary superblock/GDT copy don't resize, |
421 | * because the user tools have no way of handling this. Probably a | 421 | * because the user tools have no way of handling this. Probably a |
422 | * bad time to do it anyways. | 422 | * bad time to do it anyways. |
423 | */ | 423 | */ |
424 | if (EXT4_SB(sb)->s_sbh->b_blocknr != | 424 | if (EXT4_SB(sb)->s_sbh->b_blocknr != |
425 | le32_to_cpu(EXT4_SB(sb)->s_es->s_first_data_block)) { | 425 | le32_to_cpu(EXT4_SB(sb)->s_es->s_first_data_block)) { |
426 | ext4_warning(sb, __func__, | 426 | ext4_warning(sb, __func__, |
@@ -507,14 +507,14 @@ static int add_new_gdb(handle_t *handle, struct inode *inode, | |||
507 | return 0; | 507 | return 0; |
508 | 508 | ||
509 | exit_inode: | 509 | exit_inode: |
510 | //ext4_journal_release_buffer(handle, iloc.bh); | 510 | /* ext4_journal_release_buffer(handle, iloc.bh); */ |
511 | brelse(iloc.bh); | 511 | brelse(iloc.bh); |
512 | exit_dindj: | 512 | exit_dindj: |
513 | //ext4_journal_release_buffer(handle, dind); | 513 | /* ext4_journal_release_buffer(handle, dind); */ |
514 | exit_primary: | 514 | exit_primary: |
515 | //ext4_journal_release_buffer(handle, *primary); | 515 | /* ext4_journal_release_buffer(handle, *primary); */ |
516 | exit_sbh: | 516 | exit_sbh: |
517 | //ext4_journal_release_buffer(handle, *primary); | 517 | /* ext4_journal_release_buffer(handle, *primary); */ |
518 | exit_dind: | 518 | exit_dind: |
519 | brelse(dind); | 519 | brelse(dind); |
520 | exit_bh: | 520 | exit_bh: |
@@ -773,7 +773,8 @@ int ext4_group_add(struct super_block *sb, struct ext4_new_group_data *input) | |||
773 | 773 | ||
774 | if (reserved_gdb || gdb_off == 0) { | 774 | if (reserved_gdb || gdb_off == 0) { |
775 | if (!EXT4_HAS_COMPAT_FEATURE(sb, | 775 | if (!EXT4_HAS_COMPAT_FEATURE(sb, |
776 | EXT4_FEATURE_COMPAT_RESIZE_INODE)){ | 776 | EXT4_FEATURE_COMPAT_RESIZE_INODE) |
777 | || !le16_to_cpu(es->s_reserved_gdt_blocks)) { | ||
777 | ext4_warning(sb, __func__, | 778 | ext4_warning(sb, __func__, |
778 | "No reserved GDT blocks, can't resize"); | 779 | "No reserved GDT blocks, can't resize"); |
779 | return -EPERM; | 780 | return -EPERM; |
@@ -818,12 +819,12 @@ int ext4_group_add(struct super_block *sb, struct ext4_new_group_data *input) | |||
818 | if ((err = ext4_journal_get_write_access(handle, sbi->s_sbh))) | 819 | if ((err = ext4_journal_get_write_access(handle, sbi->s_sbh))) |
819 | goto exit_journal; | 820 | goto exit_journal; |
820 | 821 | ||
821 | /* | 822 | /* |
822 | * We will only either add reserved group blocks to a backup group | 823 | * We will only either add reserved group blocks to a backup group |
823 | * or remove reserved blocks for the first group in a new group block. | 824 | * or remove reserved blocks for the first group in a new group block. |
824 | * Doing both would be mean more complex code, and sane people don't | 825 | * Doing both would be mean more complex code, and sane people don't |
825 | * use non-sparse filesystems anymore. This is already checked above. | 826 | * use non-sparse filesystems anymore. This is already checked above. |
826 | */ | 827 | */ |
827 | if (gdb_off) { | 828 | if (gdb_off) { |
828 | primary = sbi->s_group_desc[gdb_num]; | 829 | primary = sbi->s_group_desc[gdb_num]; |
829 | if ((err = ext4_journal_get_write_access(handle, primary))) | 830 | if ((err = ext4_journal_get_write_access(handle, primary))) |
@@ -835,24 +836,24 @@ int ext4_group_add(struct super_block *sb, struct ext4_new_group_data *input) | |||
835 | } else if ((err = add_new_gdb(handle, inode, input, &primary))) | 836 | } else if ((err = add_new_gdb(handle, inode, input, &primary))) |
836 | goto exit_journal; | 837 | goto exit_journal; |
837 | 838 | ||
838 | /* | 839 | /* |
839 | * OK, now we've set up the new group. Time to make it active. | 840 | * OK, now we've set up the new group. Time to make it active. |
840 | * | 841 | * |
841 | * Current kernels don't lock all allocations via lock_super(), | 842 | * Current kernels don't lock all allocations via lock_super(), |
842 | * so we have to be safe wrt. concurrent accesses the group | 843 | * so we have to be safe wrt. concurrent accesses the group |
843 | * data. So we need to be careful to set all of the relevant | 844 | * data. So we need to be careful to set all of the relevant |
844 | * group descriptor data etc. *before* we enable the group. | 845 | * group descriptor data etc. *before* we enable the group. |
845 | * | 846 | * |
846 | * The key field here is sbi->s_groups_count: as long as | 847 | * The key field here is sbi->s_groups_count: as long as |
847 | * that retains its old value, nobody is going to access the new | 848 | * that retains its old value, nobody is going to access the new |
848 | * group. | 849 | * group. |
849 | * | 850 | * |
850 | * So first we update all the descriptor metadata for the new | 851 | * So first we update all the descriptor metadata for the new |
851 | * group; then we update the total disk blocks count; then we | 852 | * group; then we update the total disk blocks count; then we |
852 | * update the groups count to enable the group; then finally we | 853 | * update the groups count to enable the group; then finally we |
853 | * update the free space counts so that the system can start | 854 | * update the free space counts so that the system can start |
854 | * using the new disk blocks. | 855 | * using the new disk blocks. |
855 | */ | 856 | */ |
856 | 857 | ||
857 | /* Update group descriptor block for new group */ | 858 | /* Update group descriptor block for new group */ |
858 | gdp = (struct ext4_group_desc *)((char *)primary->b_data + | 859 | gdp = (struct ext4_group_desc *)((char *)primary->b_data + |
@@ -946,7 +947,8 @@ exit_put: | |||
946 | return err; | 947 | return err; |
947 | } /* ext4_group_add */ | 948 | } /* ext4_group_add */ |
948 | 949 | ||
949 | /* Extend the filesystem to the new number of blocks specified. This entry | 950 | /* |
951 | * Extend the filesystem to the new number of blocks specified. This entry | ||
950 | * point is only used to extend the current filesystem to the end of the last | 952 | * point is only used to extend the current filesystem to the end of the last |
951 | * existing group. It can be accessed via ioctl, or by "remount,resize=<size>" | 953 | * existing group. It can be accessed via ioctl, or by "remount,resize=<size>" |
952 | * for emergencies (because it has no dependencies on reserved blocks). | 954 | * for emergencies (because it has no dependencies on reserved blocks). |
@@ -1024,7 +1026,7 @@ int ext4_group_extend(struct super_block *sb, struct ext4_super_block *es, | |||
1024 | o_blocks_count + add, add); | 1026 | o_blocks_count + add, add); |
1025 | 1027 | ||
1026 | /* See if the device is actually as big as what was requested */ | 1028 | /* See if the device is actually as big as what was requested */ |
1027 | bh = sb_bread(sb, o_blocks_count + add -1); | 1029 | bh = sb_bread(sb, o_blocks_count + add - 1); |
1028 | if (!bh) { | 1030 | if (!bh) { |
1029 | ext4_warning(sb, __func__, | 1031 | ext4_warning(sb, __func__, |
1030 | "can't read last block, resize aborted"); | 1032 | "can't read last block, resize aborted"); |