resize.c (149041070deb2e83cd36dc60bc72975b3cbf5bbe) resize.c (fd2d42912f9f09e5250cb3b024ee0625704e9cb7)
1/*
2 * linux/fs/ext4/resize.c
3 *
4 * Support for resizing an ext4 filesystem while it is mounted.
5 *
6 * Copyright (C) 2001, 2002 Andreas Dilger <adilger@clusterfs.com>
7 *
8 * This could probably be made into a module, because it is not often in use.

--- 14 unchanged lines hidden (view full) ---

23
24static int verify_group_input(struct super_block *sb,
25 struct ext4_new_group_data *input)
26{
27 struct ext4_sb_info *sbi = EXT4_SB(sb);
28 struct ext4_super_block *es = sbi->s_es;
29 ext4_fsblk_t start = ext4_blocks_count(es);
30 ext4_fsblk_t end = start + input->blocks_count;
1/*
2 * linux/fs/ext4/resize.c
3 *
4 * Support for resizing an ext4 filesystem while it is mounted.
5 *
6 * Copyright (C) 2001, 2002 Andreas Dilger <adilger@clusterfs.com>
7 *
8 * This could probably be made into a module, because it is not often in use.

--- 14 unchanged lines hidden (view full) ---

23
24static int verify_group_input(struct super_block *sb,
25 struct ext4_new_group_data *input)
26{
27 struct ext4_sb_info *sbi = EXT4_SB(sb);
28 struct ext4_super_block *es = sbi->s_es;
29 ext4_fsblk_t start = ext4_blocks_count(es);
30 ext4_fsblk_t end = start + input->blocks_count;
31 unsigned group = input->group;
31 ext4_group_t group = input->group;
32 ext4_fsblk_t itend = input->inode_table + sbi->s_itb_per_group;
33 unsigned overhead = ext4_bg_has_super(sb, group) ?
34 (1 + ext4_bg_num_gdb(sb, group) +
35 le16_to_cpu(es->s_reserved_gdt_blocks)) : 0;
36 ext4_fsblk_t metaend = start + overhead;
37 struct buffer_head *bh = NULL;
38 ext4_grpblk_t free_blocks_count, offset;
39 int err = -EINVAL;

--- 312 unchanged lines hidden (view full) ---

352 * Check that all of the backup GDT blocks are held in the primary GDT block.
353 * It is assumed that they are stored in group order. Returns the number of
354 * groups in current filesystem that have BACKUPS, or -ve error code.
355 */
356static int verify_reserved_gdb(struct super_block *sb,
357 struct buffer_head *primary)
358{
359 const ext4_fsblk_t blk = primary->b_blocknr;
32 ext4_fsblk_t itend = input->inode_table + sbi->s_itb_per_group;
33 unsigned overhead = ext4_bg_has_super(sb, group) ?
34 (1 + ext4_bg_num_gdb(sb, group) +
35 le16_to_cpu(es->s_reserved_gdt_blocks)) : 0;
36 ext4_fsblk_t metaend = start + overhead;
37 struct buffer_head *bh = NULL;
38 ext4_grpblk_t free_blocks_count, offset;
39 int err = -EINVAL;

--- 312 unchanged lines hidden (view full) ---

352 * Check that all of the backup GDT blocks are held in the primary GDT block.
353 * It is assumed that they are stored in group order. Returns the number of
354 * groups in current filesystem that have BACKUPS, or -ve error code.
355 */
356static int verify_reserved_gdb(struct super_block *sb,
357 struct buffer_head *primary)
358{
359 const ext4_fsblk_t blk = primary->b_blocknr;
360 const unsigned long end = EXT4_SB(sb)->s_groups_count;
360 const ext4_group_t end = EXT4_SB(sb)->s_groups_count;
361 unsigned three = 1;
362 unsigned five = 5;
363 unsigned seven = 7;
364 unsigned grp;
365 __le32 *p = (__le32 *)primary->b_data;
366 int gdbackups = 0;
367
368 while ((grp = ext4_list_backups(sb, &three, &five, &seven)) < end) {

--- 282 unchanged lines hidden (view full) ---

651 * need to worry about last changing from sbi->s_groups_count, because the
652 * worst that can happen is that we do not copy the full number of backups
653 * at this time. The resize which changed s_groups_count will backup again.
654 */
655static void update_backups(struct super_block *sb,
656 int blk_off, char *data, int size)
657{
658 struct ext4_sb_info *sbi = EXT4_SB(sb);
361 unsigned three = 1;
362 unsigned five = 5;
363 unsigned seven = 7;
364 unsigned grp;
365 __le32 *p = (__le32 *)primary->b_data;
366 int gdbackups = 0;
367
368 while ((grp = ext4_list_backups(sb, &three, &five, &seven)) < end) {

--- 282 unchanged lines hidden (view full) ---

651 * need to worry about last changing from sbi->s_groups_count, because the
652 * worst that can happen is that we do not copy the full number of backups
653 * at this time. The resize which changed s_groups_count will backup again.
654 */
655static void update_backups(struct super_block *sb,
656 int blk_off, char *data, int size)
657{
658 struct ext4_sb_info *sbi = EXT4_SB(sb);
659 const unsigned long last = sbi->s_groups_count;
659 const ext4_group_t last = sbi->s_groups_count;
660 const int bpg = EXT4_BLOCKS_PER_GROUP(sb);
661 unsigned three = 1;
662 unsigned five = 5;
663 unsigned seven = 7;
660 const int bpg = EXT4_BLOCKS_PER_GROUP(sb);
661 unsigned three = 1;
662 unsigned five = 5;
663 unsigned seven = 7;
664 unsigned group;
664 ext4_group_t group;
665 int rest = sb->s_blocksize - size;
666 handle_t *handle;
667 int err = 0, err2;
668
669 handle = ext4_journal_start_sb(sb, EXT4_MAX_TRANS_DATA);
670 if (IS_ERR(handle)) {
671 group = 1;
672 err = PTR_ERR(handle);

--- 38 unchanged lines hidden (view full) ---

711 * However, if we got here we have a journal problem too, so we
712 * can't really start a transaction to mark the superblock.
713 * Chicken out and just set the flag on the hope it will be written
714 * to disk, and if not - we will simply wait until next fsck.
715 */
716exit_err:
717 if (err) {
718 ext4_warning(sb, __FUNCTION__,
665 int rest = sb->s_blocksize - size;
666 handle_t *handle;
667 int err = 0, err2;
668
669 handle = ext4_journal_start_sb(sb, EXT4_MAX_TRANS_DATA);
670 if (IS_ERR(handle)) {
671 group = 1;
672 err = PTR_ERR(handle);

--- 38 unchanged lines hidden (view full) ---

711 * However, if we got here we have a journal problem too, so we
712 * can't really start a transaction to mark the superblock.
713 * Chicken out and just set the flag on the hope it will be written
714 * to disk, and if not - we will simply wait until next fsck.
715 */
716exit_err:
717 if (err) {
718 ext4_warning(sb, __FUNCTION__,
719 "can't update backup for group %d (err %d), "
719 "can't update backup for group %lu (err %d), "
720 "forcing fsck on next reboot", group, err);
721 sbi->s_mount_state &= ~EXT4_VALID_FS;
722 sbi->s_es->s_state &= cpu_to_le16(~EXT4_VALID_FS);
723 mark_buffer_dirty(sbi->s_sbh);
724 }
725}
726
727/* Add group descriptor data to an existing or new group descriptor block.

--- 219 unchanged lines hidden (view full) ---

947 * If we _really_ wanted, we could use default values to call ext4_group_add()
948 * allow the "remount" trick to work for arbitrary resizing, assuming enough
949 * GDT blocks are reserved to grow to the desired size.
950 */
951int ext4_group_extend(struct super_block *sb, struct ext4_super_block *es,
952 ext4_fsblk_t n_blocks_count)
953{
954 ext4_fsblk_t o_blocks_count;
720 "forcing fsck on next reboot", group, err);
721 sbi->s_mount_state &= ~EXT4_VALID_FS;
722 sbi->s_es->s_state &= cpu_to_le16(~EXT4_VALID_FS);
723 mark_buffer_dirty(sbi->s_sbh);
724 }
725}
726
727/* Add group descriptor data to an existing or new group descriptor block.

--- 219 unchanged lines hidden (view full) ---

947 * If we _really_ wanted, we could use default values to call ext4_group_add()
948 * allow the "remount" trick to work for arbitrary resizing, assuming enough
949 * GDT blocks are reserved to grow to the desired size.
950 */
951int ext4_group_extend(struct super_block *sb, struct ext4_super_block *es,
952 ext4_fsblk_t n_blocks_count)
953{
954 ext4_fsblk_t o_blocks_count;
955 unsigned long o_groups_count;
955 ext4_group_t o_groups_count;
956 ext4_grpblk_t last;
957 ext4_grpblk_t add;
958 struct buffer_head * bh;
959 handle_t *handle;
960 int err;
961 unsigned long freed_blocks;
962
963 /* We don't need to worry about locking wrt other resizers just

--- 108 unchanged lines hidden ---
956 ext4_grpblk_t last;
957 ext4_grpblk_t add;
958 struct buffer_head * bh;
959 handle_t *handle;
960 int err;
961 unsigned long freed_blocks;
962
963 /* We don't need to worry about locking wrt other resizers just

--- 108 unchanged lines hidden ---