diff options
author | Yongqiang Yang <xiaoqiangnk@gmail.com> | 2012-01-03 23:18:50 -0500 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2012-01-03 23:18:50 -0500 |
commit | 18e3143848f1abdd07e7d9879cf67f4e147ff8b7 (patch) | |
tree | a2f76cfff641ed9246ea8e9bd7442c791b75ae09 /fs | |
parent | 597d508c17a6dcd17770f4dd9da873d93cc15493 (diff) |
ext4: add a function which extends a group without checking parameters
This patch added a function named ext4_group_extend_no_check() whose code
is copied from ext4_group_extend(). ext4_group_extend_no_check() assumes
the parameter is valid and has been checked by caller.
Signed-off-by: Yongqiang Yang <xiaoqiangnk@gmail.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/ext4/resize.c | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c index 996780ab4f4e..1c3c2b56049d 100644 --- a/fs/ext4/resize.c +++ b/fs/ext4/resize.c | |||
@@ -969,6 +969,57 @@ exit_put: | |||
969 | } /* ext4_group_add */ | 969 | } /* ext4_group_add */ |
970 | 970 | ||
971 | /* | 971 | /* |
972 | * extend a group without checking assuming that checking has been done. | ||
973 | */ | ||
974 | static int ext4_group_extend_no_check(struct super_block *sb, | ||
975 | ext4_fsblk_t o_blocks_count, ext4_grpblk_t add) | ||
976 | { | ||
977 | struct ext4_super_block *es = EXT4_SB(sb)->s_es; | ||
978 | handle_t *handle; | ||
979 | int err = 0, err2; | ||
980 | |||
981 | /* We will update the superblock, one block bitmap, and | ||
982 | * one group descriptor via ext4_group_add_blocks(). | ||
983 | */ | ||
984 | handle = ext4_journal_start_sb(sb, 3); | ||
985 | if (IS_ERR(handle)) { | ||
986 | err = PTR_ERR(handle); | ||
987 | ext4_warning(sb, "error %d on journal start", err); | ||
988 | return err; | ||
989 | } | ||
990 | |||
991 | err = ext4_journal_get_write_access(handle, EXT4_SB(sb)->s_sbh); | ||
992 | if (err) { | ||
993 | ext4_warning(sb, "error %d on journal write access", err); | ||
994 | goto errout; | ||
995 | } | ||
996 | |||
997 | ext4_blocks_count_set(es, o_blocks_count + add); | ||
998 | ext4_debug("freeing blocks %llu through %llu\n", o_blocks_count, | ||
999 | o_blocks_count + add); | ||
1000 | /* We add the blocks to the bitmap and set the group need init bit */ | ||
1001 | err = ext4_group_add_blocks(handle, sb, o_blocks_count, add); | ||
1002 | if (err) | ||
1003 | goto errout; | ||
1004 | ext4_handle_dirty_super(handle, sb); | ||
1005 | ext4_debug("freed blocks %llu through %llu\n", o_blocks_count, | ||
1006 | o_blocks_count + add); | ||
1007 | errout: | ||
1008 | err2 = ext4_journal_stop(handle); | ||
1009 | if (err2 && !err) | ||
1010 | err = err2; | ||
1011 | |||
1012 | if (!err) { | ||
1013 | if (test_opt(sb, DEBUG)) | ||
1014 | printk(KERN_DEBUG "EXT4-fs: extended group to %llu " | ||
1015 | "blocks\n", ext4_blocks_count(es)); | ||
1016 | update_backups(sb, EXT4_SB(sb)->s_sbh->b_blocknr, (char *)es, | ||
1017 | sizeof(struct ext4_super_block)); | ||
1018 | } | ||
1019 | return err; | ||
1020 | } | ||
1021 | |||
1022 | /* | ||
972 | * Extend the filesystem to the new number of blocks specified. This entry | 1023 | * Extend the filesystem to the new number of blocks specified. This entry |
973 | * point is only used to extend the current filesystem to the end of the last | 1024 | * point is only used to extend the current filesystem to the end of the last |
974 | * existing group. It can be accessed via ioctl, or by "remount,resize=<size>" | 1025 | * existing group. It can be accessed via ioctl, or by "remount,resize=<size>" |