Theodore Ts'o | 21c84b7 | 1997-04-29 16:15:03 +0000 | [diff] [blame] | 1 | /* |
| 2 | * alloc_tables.c --- Allocate tables for a newly initialized |
| 3 | * filesystem. Used by mke2fs when initializing a filesystem |
| 4 | * |
| 5 | * Copyright (C) 1996 Theodore Ts'o. |
| 6 | * |
| 7 | * %Begin-Header% |
Theodore Ts'o | 543547a | 2010-05-17 21:31:56 -0400 | [diff] [blame] | 8 | * This file may be redistributed under the terms of the GNU Library |
| 9 | * General Public License, version 2. |
Theodore Ts'o | 21c84b7 | 1997-04-29 16:15:03 +0000 | [diff] [blame] | 10 | * %End-Header% |
| 11 | */ |
| 12 | |
Theodore Ts'o | d1154eb | 2011-09-18 17:34:37 -0400 | [diff] [blame] | 13 | #include "config.h" |
Theodore Ts'o | 21c84b7 | 1997-04-29 16:15:03 +0000 | [diff] [blame] | 14 | #include <stdio.h> |
| 15 | #include <string.h> |
Theodore Ts'o | 4cbe8af | 1997-08-10 23:07:40 +0000 | [diff] [blame] | 16 | #if HAVE_UNISTD_H |
Theodore Ts'o | 21c84b7 | 1997-04-29 16:15:03 +0000 | [diff] [blame] | 17 | #include <unistd.h> |
Theodore Ts'o | 4cbe8af | 1997-08-10 23:07:40 +0000 | [diff] [blame] | 18 | #endif |
Theodore Ts'o | 21c84b7 | 1997-04-29 16:15:03 +0000 | [diff] [blame] | 19 | #include <fcntl.h> |
| 20 | #include <time.h> |
Theodore Ts'o | 1d2ff46 | 1997-10-19 23:00:21 +0000 | [diff] [blame] | 21 | #if HAVE_SYS_STAT_H |
Theodore Ts'o | 21c84b7 | 1997-04-29 16:15:03 +0000 | [diff] [blame] | 22 | #include <sys/stat.h> |
Theodore Ts'o | 1d2ff46 | 1997-10-19 23:00:21 +0000 | [diff] [blame] | 23 | #endif |
| 24 | #if HAVE_SYS_TYPES_H |
Theodore Ts'o | 21c84b7 | 1997-04-29 16:15:03 +0000 | [diff] [blame] | 25 | #include <sys/types.h> |
Theodore Ts'o | 1d2ff46 | 1997-10-19 23:00:21 +0000 | [diff] [blame] | 26 | #endif |
Theodore Ts'o | 21c84b7 | 1997-04-29 16:15:03 +0000 | [diff] [blame] | 27 | |
Theodore Ts'o | b5abe6f | 1998-01-19 14:47:53 +0000 | [diff] [blame] | 28 | #include "ext2_fs.h" |
Theodore Ts'o | 21c84b7 | 1997-04-29 16:15:03 +0000 | [diff] [blame] | 29 | #include "ext2fs.h" |
Valerie Aurora Henson | 95fd65b | 2009-08-23 19:20:03 -0400 | [diff] [blame] | 30 | #include "ext2fsP.h" |
Theodore Ts'o | 21c84b7 | 1997-04-29 16:15:03 +0000 | [diff] [blame] | 31 | |
Theodore Ts'o | 9ba4000 | 2008-04-22 08:27:01 -0400 | [diff] [blame] | 32 | /* |
| 33 | * This routine searches for free blocks that can allocate a full |
| 34 | * group of bitmaps or inode tables for a flexbg group. Returns the |
| 35 | * block number with a correct offset were the bitmaps and inode |
| 36 | * tables can be allocated continously and in order. |
| 37 | */ |
Theodore Ts'o | da3fc25 | 2010-06-13 09:00:00 -0400 | [diff] [blame] | 38 | static blk64_t flexbg_offset(ext2_filsys fs, dgrp_t group, blk64_t start_blk, |
Theodore Ts'o | 25567a7 | 2011-07-05 13:42:07 -0400 | [diff] [blame] | 39 | ext2fs_block_bitmap bmap, int rem_grp, |
Theodore Ts'o | da3fc25 | 2010-06-13 09:00:00 -0400 | [diff] [blame] | 40 | int elem_size) |
Theodore Ts'o | 9ba4000 | 2008-04-22 08:27:01 -0400 | [diff] [blame] | 41 | { |
Theodore Ts'o | 25567a7 | 2011-07-05 13:42:07 -0400 | [diff] [blame] | 42 | int flexbg, flexbg_size, size; |
Theodore Ts'o | da3fc25 | 2010-06-13 09:00:00 -0400 | [diff] [blame] | 43 | blk64_t last_blk, first_free = 0; |
Theodore Ts'o | 9ba4000 | 2008-04-22 08:27:01 -0400 | [diff] [blame] | 44 | dgrp_t last_grp; |
| 45 | |
Theodore Ts'o | c4d2d43 | 2011-07-07 13:50:49 -0400 | [diff] [blame] | 46 | flexbg_size = 1 << fs->super->s_log_groups_per_flex; |
| 47 | flexbg = group / flexbg_size; |
Theodore Ts'o | 25567a7 | 2011-07-05 13:42:07 -0400 | [diff] [blame] | 48 | size = rem_grp * elem_size; |
Theodore Ts'o | 9ba4000 | 2008-04-22 08:27:01 -0400 | [diff] [blame] | 49 | |
Theodore Ts'o | 8895f43 | 2008-06-07 11:53:56 -0400 | [diff] [blame] | 50 | if (size > (int) (fs->super->s_blocks_per_group / 8)) |
| 51 | size = (int) fs->super->s_blocks_per_group / 8; |
Theodore Ts'o | 9ba4000 | 2008-04-22 08:27:01 -0400 | [diff] [blame] | 52 | |
| 53 | /* |
Theodore Ts'o | ba4a021 | 2008-07-07 16:11:11 -0400 | [diff] [blame] | 54 | * Don't do a long search if the previous block |
Theodore Ts'o | 9ba4000 | 2008-04-22 08:27:01 -0400 | [diff] [blame] | 55 | * search is still valid. |
| 56 | */ |
Theodore Ts'o | 25567a7 | 2011-07-05 13:42:07 -0400 | [diff] [blame] | 57 | if (start_blk && ext2fs_test_block_bitmap_range2(bmap, start_blk, |
| 58 | elem_size)) |
| 59 | return start_blk; |
Theodore Ts'o | 9ba4000 | 2008-04-22 08:27:01 -0400 | [diff] [blame] | 60 | |
Theodore Ts'o | b49f78f | 2009-10-25 21:24:06 -0400 | [diff] [blame] | 61 | start_blk = ext2fs_group_first_block2(fs, flexbg_size * flexbg); |
Theodore Ts'o | 9ba4000 | 2008-04-22 08:27:01 -0400 | [diff] [blame] | 62 | last_grp = group | (flexbg_size - 1); |
Theodore Ts'o | 25567a7 | 2011-07-05 13:42:07 -0400 | [diff] [blame] | 63 | if (last_grp > fs->group_desc_count-1) |
| 64 | last_grp = fs->group_desc_count-1; |
Theodore Ts'o | b49f78f | 2009-10-25 21:24:06 -0400 | [diff] [blame] | 65 | last_blk = ext2fs_group_last_block2(fs, last_grp); |
Theodore Ts'o | 9ba4000 | 2008-04-22 08:27:01 -0400 | [diff] [blame] | 66 | |
| 67 | /* Find the first available block */ |
Theodore Ts'o | 25567a7 | 2011-07-05 13:42:07 -0400 | [diff] [blame] | 68 | if (ext2fs_get_free_blocks2(fs, start_blk, last_blk, size, |
| 69 | bmap, &first_free) == 0) |
Theodore Ts'o | 9ba4000 | 2008-04-22 08:27:01 -0400 | [diff] [blame] | 70 | return first_free; |
| 71 | |
Theodore Ts'o | 25567a7 | 2011-07-05 13:42:07 -0400 | [diff] [blame] | 72 | if (ext2fs_get_free_blocks2(fs, start_blk, last_blk, elem_size, |
| 73 | bmap, &first_free) == 0) |
| 74 | return first_free; |
| 75 | |
| 76 | if (ext2fs_get_free_blocks2(fs, 0, last_blk, elem_size, bmap, |
| 77 | &first_free) == 0) |
Theodore Ts'o | 9ba4000 | 2008-04-22 08:27:01 -0400 | [diff] [blame] | 78 | return first_free; |
| 79 | |
| 80 | return first_free; |
| 81 | } |
| 82 | |
Theodore Ts'o | 2eb374c | 1998-09-03 01:22:57 +0000 | [diff] [blame] | 83 | errcode_t ext2fs_allocate_group_table(ext2_filsys fs, dgrp_t group, |
Theodore Ts'o | 1e1da29 | 1997-06-09 14:51:29 +0000 | [diff] [blame] | 84 | ext2fs_block_bitmap bmap) |
Theodore Ts'o | 21c84b7 | 1997-04-29 16:15:03 +0000 | [diff] [blame] | 85 | { |
| 86 | errcode_t retval; |
Theodore Ts'o | fccdbac | 2014-01-19 16:47:21 -0500 | [diff] [blame] | 87 | blk64_t group_blk, start_blk, last_blk, new_blk; |
Theodore Ts'o | 8895f43 | 2008-06-07 11:53:56 -0400 | [diff] [blame] | 88 | dgrp_t last_grp = 0; |
Theodore Ts'o | d32c915 | 2011-07-07 13:50:22 -0400 | [diff] [blame] | 89 | int rem_grps = 0, flexbg_size = 0; |
Theodore Ts'o | 21c84b7 | 1997-04-29 16:15:03 +0000 | [diff] [blame] | 90 | |
Theodore Ts'o | b49f78f | 2009-10-25 21:24:06 -0400 | [diff] [blame] | 91 | group_blk = ext2fs_group_first_block2(fs, group); |
| 92 | last_blk = ext2fs_group_last_block2(fs, group); |
Theodore Ts'o | 2ecc6fe | 1997-04-29 17:57:00 +0000 | [diff] [blame] | 93 | |
Theodore Ts'o | 1e1da29 | 1997-06-09 14:51:29 +0000 | [diff] [blame] | 94 | if (!bmap) |
| 95 | bmap = fs->block_map; |
Theodore Ts'o | 9ba4000 | 2008-04-22 08:27:01 -0400 | [diff] [blame] | 96 | |
| 97 | if (EXT2_HAS_INCOMPAT_FEATURE(fs->super, |
| 98 | EXT4_FEATURE_INCOMPAT_FLEX_BG) && |
| 99 | fs->super->s_log_groups_per_flex) { |
| 100 | flexbg_size = 1 << fs->super->s_log_groups_per_flex; |
| 101 | last_grp = group | (flexbg_size - 1); |
Theodore Ts'o | 25567a7 | 2011-07-05 13:42:07 -0400 | [diff] [blame] | 102 | if (last_grp > fs->group_desc_count-1) |
| 103 | last_grp = fs->group_desc_count-1; |
| 104 | rem_grps = last_grp - group + 1; |
Theodore Ts'o | 9ba4000 | 2008-04-22 08:27:01 -0400 | [diff] [blame] | 105 | } |
Theodore Ts'o | efc6f62 | 2008-08-27 23:07:54 -0400 | [diff] [blame] | 106 | |
Theodore Ts'o | 1e1da29 | 1997-06-09 14:51:29 +0000 | [diff] [blame] | 107 | /* |
Theodore Ts'o | 1e1da29 | 1997-06-09 14:51:29 +0000 | [diff] [blame] | 108 | * Allocate the block and inode bitmaps, if necessary |
| 109 | */ |
| 110 | if (fs->stride) { |
Theodore Ts'o | da3fc25 | 2010-06-13 09:00:00 -0400 | [diff] [blame] | 111 | retval = ext2fs_get_free_blocks2(fs, group_blk, last_blk, |
| 112 | 1, bmap, &start_blk); |
Theodore Ts'o | bc2699f | 2006-05-13 08:46:37 -0400 | [diff] [blame] | 113 | if (retval) |
| 114 | return retval; |
| 115 | start_blk += fs->inode_blocks_per_group; |
Theodore Ts'o | 1e1da29 | 1997-06-09 14:51:29 +0000 | [diff] [blame] | 116 | start_blk += ((fs->stride * group) % |
Eric Sandeen | abf2343 | 2006-09-12 14:56:16 -0400 | [diff] [blame] | 117 | (last_blk - start_blk + 1)); |
| 118 | if (start_blk >= last_blk) |
Theodore Ts'o | a29f4d3 | 1997-04-29 21:26:48 +0000 | [diff] [blame] | 119 | start_blk = group_blk; |
Theodore Ts'o | 1e1da29 | 1997-06-09 14:51:29 +0000 | [diff] [blame] | 120 | } else |
| 121 | start_blk = group_blk; |
| 122 | |
Theodore Ts'o | 9ba4000 | 2008-04-22 08:27:01 -0400 | [diff] [blame] | 123 | if (flexbg_size) { |
Valerie Aurora Henson | 8f82ef9 | 2009-08-05 00:27:10 -0400 | [diff] [blame] | 124 | blk64_t prev_block = 0; |
| 125 | |
Theodore Ts'o | 25567a7 | 2011-07-05 13:42:07 -0400 | [diff] [blame] | 126 | if (group % flexbg_size) |
| 127 | prev_block = ext2fs_block_bitmap_loc(fs, group - 1) + 1; |
Theodore Ts'o | 9ba4000 | 2008-04-22 08:27:01 -0400 | [diff] [blame] | 128 | start_blk = flexbg_offset(fs, group, prev_block, bmap, |
Theodore Ts'o | 25567a7 | 2011-07-05 13:42:07 -0400 | [diff] [blame] | 129 | rem_grps, 1); |
Theodore Ts'o | b49f78f | 2009-10-25 21:24:06 -0400 | [diff] [blame] | 130 | last_blk = ext2fs_group_last_block2(fs, last_grp); |
Theodore Ts'o | 9ba4000 | 2008-04-22 08:27:01 -0400 | [diff] [blame] | 131 | } |
| 132 | |
Valerie Aurora Henson | d7cca6b | 2009-10-25 21:43:47 -0400 | [diff] [blame] | 133 | if (!ext2fs_block_bitmap_loc(fs, group)) { |
Theodore Ts'o | da3fc25 | 2010-06-13 09:00:00 -0400 | [diff] [blame] | 134 | retval = ext2fs_get_free_blocks2(fs, start_blk, last_blk, |
| 135 | 1, bmap, &new_blk); |
Theodore Ts'o | efc6f62 | 2008-08-27 23:07:54 -0400 | [diff] [blame] | 136 | if (retval == EXT2_ET_BLOCK_ALLOC_FAIL) |
Theodore Ts'o | da3fc25 | 2010-06-13 09:00:00 -0400 | [diff] [blame] | 137 | retval = ext2fs_get_free_blocks2(fs, group_blk, |
Theodore Ts'o | 03673db | 1998-06-10 20:39:43 +0000 | [diff] [blame] | 138 | last_blk, 1, bmap, &new_blk); |
Theodore Ts'o | 521e368 | 1997-04-29 17:48:10 +0000 | [diff] [blame] | 139 | if (retval) |
| 140 | return retval; |
Valerie Aurora Henson | 8f82ef9 | 2009-08-05 00:27:10 -0400 | [diff] [blame] | 141 | ext2fs_mark_block_bitmap2(bmap, new_blk); |
Valerie Aurora Henson | d7cca6b | 2009-10-25 21:43:47 -0400 | [diff] [blame] | 142 | ext2fs_block_bitmap_loc_set(fs, group, new_blk); |
Theodore Ts'o | 9ba4000 | 2008-04-22 08:27:01 -0400 | [diff] [blame] | 143 | if (flexbg_size) { |
Theodore Ts'o | 6493f8e | 2009-10-25 20:50:15 -0400 | [diff] [blame] | 144 | dgrp_t gr = ext2fs_group_of_blk2(fs, new_blk); |
Valerie Aurora Henson | d7cca6b | 2009-10-25 21:43:47 -0400 | [diff] [blame] | 145 | ext2fs_bg_free_blocks_count_set(fs, gr, ext2fs_bg_free_blocks_count(fs, gr) - 1); |
Valerie Aurora Henson | 4efbac6 | 2009-09-07 20:46:34 -0400 | [diff] [blame] | 146 | ext2fs_free_blocks_count_add(fs->super, -1); |
Eric Sandeen | e633b58 | 2009-10-25 21:41:32 -0400 | [diff] [blame] | 147 | ext2fs_bg_flags_clear(fs, gr, EXT2_BG_BLOCK_UNINIT); |
Theodore Ts'o | 9ba4000 | 2008-04-22 08:27:01 -0400 | [diff] [blame] | 148 | ext2fs_group_desc_csum_set(fs, gr); |
| 149 | } |
| 150 | } |
| 151 | |
| 152 | if (flexbg_size) { |
Valerie Aurora Henson | d7cca6b | 2009-10-25 21:43:47 -0400 | [diff] [blame] | 153 | blk64_t prev_block = 0; |
Theodore Ts'o | 25567a7 | 2011-07-05 13:42:07 -0400 | [diff] [blame] | 154 | if (group % flexbg_size) |
| 155 | prev_block = ext2fs_inode_bitmap_loc(fs, group - 1) + 1; |
| 156 | else |
| 157 | prev_block = ext2fs_block_bitmap_loc(fs, group) + |
| 158 | flexbg_size; |
Theodore Ts'o | 9ba4000 | 2008-04-22 08:27:01 -0400 | [diff] [blame] | 159 | start_blk = flexbg_offset(fs, group, prev_block, bmap, |
Theodore Ts'o | 25567a7 | 2011-07-05 13:42:07 -0400 | [diff] [blame] | 160 | rem_grps, 1); |
Theodore Ts'o | b49f78f | 2009-10-25 21:24:06 -0400 | [diff] [blame] | 161 | last_blk = ext2fs_group_last_block2(fs, last_grp); |
Theodore Ts'o | 1e1da29 | 1997-06-09 14:51:29 +0000 | [diff] [blame] | 162 | } |
Theodore Ts'o | 521e368 | 1997-04-29 17:48:10 +0000 | [diff] [blame] | 163 | |
Valerie Aurora Henson | d7cca6b | 2009-10-25 21:43:47 -0400 | [diff] [blame] | 164 | if (!ext2fs_inode_bitmap_loc(fs, group)) { |
Theodore Ts'o | da3fc25 | 2010-06-13 09:00:00 -0400 | [diff] [blame] | 165 | retval = ext2fs_get_free_blocks2(fs, start_blk, last_blk, |
| 166 | 1, bmap, &new_blk); |
Theodore Ts'o | efc6f62 | 2008-08-27 23:07:54 -0400 | [diff] [blame] | 167 | if (retval == EXT2_ET_BLOCK_ALLOC_FAIL) |
Theodore Ts'o | da3fc25 | 2010-06-13 09:00:00 -0400 | [diff] [blame] | 168 | retval = ext2fs_get_free_blocks2(fs, group_blk, |
| 169 | last_blk, 1, bmap, &new_blk); |
Theodore Ts'o | 521e368 | 1997-04-29 17:48:10 +0000 | [diff] [blame] | 170 | if (retval) |
| 171 | return retval; |
Valerie Aurora Henson | 8f82ef9 | 2009-08-05 00:27:10 -0400 | [diff] [blame] | 172 | ext2fs_mark_block_bitmap2(bmap, new_blk); |
Valerie Aurora Henson | d7cca6b | 2009-10-25 21:43:47 -0400 | [diff] [blame] | 173 | ext2fs_inode_bitmap_loc_set(fs, group, new_blk); |
Theodore Ts'o | 9ba4000 | 2008-04-22 08:27:01 -0400 | [diff] [blame] | 174 | if (flexbg_size) { |
Theodore Ts'o | 6493f8e | 2009-10-25 20:50:15 -0400 | [diff] [blame] | 175 | dgrp_t gr = ext2fs_group_of_blk2(fs, new_blk); |
Valerie Aurora Henson | d7cca6b | 2009-10-25 21:43:47 -0400 | [diff] [blame] | 176 | ext2fs_bg_free_blocks_count_set(fs, gr, ext2fs_bg_free_blocks_count(fs, gr) - 1); |
Valerie Aurora Henson | 4efbac6 | 2009-09-07 20:46:34 -0400 | [diff] [blame] | 177 | ext2fs_free_blocks_count_add(fs->super, -1); |
Eric Sandeen | e633b58 | 2009-10-25 21:41:32 -0400 | [diff] [blame] | 178 | ext2fs_bg_flags_clear(fs, gr, EXT2_BG_BLOCK_UNINIT); |
Theodore Ts'o | 9ba4000 | 2008-04-22 08:27:01 -0400 | [diff] [blame] | 179 | ext2fs_group_desc_csum_set(fs, gr); |
| 180 | } |
Theodore Ts'o | 1e1da29 | 1997-06-09 14:51:29 +0000 | [diff] [blame] | 181 | } |
Theodore Ts'o | 76dd5e5 | 2002-10-30 23:07:21 -0500 | [diff] [blame] | 182 | |
| 183 | /* |
| 184 | * Allocate the inode table |
| 185 | */ |
Theodore Ts'o | 9ba4000 | 2008-04-22 08:27:01 -0400 | [diff] [blame] | 186 | if (flexbg_size) { |
Valerie Aurora Henson | d7cca6b | 2009-10-25 21:43:47 -0400 | [diff] [blame] | 187 | blk64_t prev_block = 0; |
Theodore Ts'o | 25567a7 | 2011-07-05 13:42:07 -0400 | [diff] [blame] | 188 | |
| 189 | if (group % flexbg_size) |
| 190 | prev_block = ext2fs_inode_table_loc(fs, group - 1) + |
| 191 | fs->inode_blocks_per_group; |
| 192 | else |
| 193 | prev_block = ext2fs_inode_bitmap_loc(fs, group) + |
| 194 | flexbg_size; |
| 195 | |
Theodore Ts'o | 9ba4000 | 2008-04-22 08:27:01 -0400 | [diff] [blame] | 196 | group_blk = flexbg_offset(fs, group, prev_block, bmap, |
Theodore Ts'o | 25567a7 | 2011-07-05 13:42:07 -0400 | [diff] [blame] | 197 | rem_grps, fs->inode_blocks_per_group); |
Theodore Ts'o | b49f78f | 2009-10-25 21:24:06 -0400 | [diff] [blame] | 198 | last_blk = ext2fs_group_last_block2(fs, last_grp); |
Theodore Ts'o | 9ba4000 | 2008-04-22 08:27:01 -0400 | [diff] [blame] | 199 | } |
| 200 | |
Valerie Aurora Henson | d7cca6b | 2009-10-25 21:43:47 -0400 | [diff] [blame] | 201 | if (!ext2fs_inode_table_loc(fs, group)) { |
Theodore Ts'o | da3fc25 | 2010-06-13 09:00:00 -0400 | [diff] [blame] | 202 | retval = ext2fs_get_free_blocks2(fs, group_blk, last_blk, |
Theodore Ts'o | 76dd5e5 | 2002-10-30 23:07:21 -0500 | [diff] [blame] | 203 | fs->inode_blocks_per_group, |
| 204 | bmap, &new_blk); |
| 205 | if (retval) |
| 206 | return retval; |
Theodore Ts'o | fccdbac | 2014-01-19 16:47:21 -0500 | [diff] [blame] | 207 | if (flexbg_size) |
| 208 | ext2fs_block_alloc_stats_range(fs, new_blk, |
| 209 | fs->inode_blocks_per_group, +1); |
| 210 | else |
| 211 | ext2fs_mark_block_bitmap_range2(fs->block_map, |
| 212 | new_blk, fs->inode_blocks_per_group); |
Valerie Aurora Henson | d7cca6b | 2009-10-25 21:43:47 -0400 | [diff] [blame] | 213 | ext2fs_inode_table_loc_set(fs, group, new_blk); |
Theodore Ts'o | 76dd5e5 | 2002-10-30 23:07:21 -0500 | [diff] [blame] | 214 | } |
Jose R. Santos | d4f34d4 | 2007-10-21 21:03:25 -0500 | [diff] [blame] | 215 | ext2fs_group_desc_csum_set(fs, group); |
Theodore Ts'o | 1e1da29 | 1997-06-09 14:51:29 +0000 | [diff] [blame] | 216 | return 0; |
| 217 | } |
Theodore Ts'o | 521e368 | 1997-04-29 17:48:10 +0000 | [diff] [blame] | 218 | |
Theodore Ts'o | 1e1da29 | 1997-06-09 14:51:29 +0000 | [diff] [blame] | 219 | errcode_t ext2fs_allocate_tables(ext2_filsys fs) |
| 220 | { |
| 221 | errcode_t retval; |
Theodore Ts'o | 2eb374c | 1998-09-03 01:22:57 +0000 | [diff] [blame] | 222 | dgrp_t i; |
Valerie Aurora Henson | 95fd65b | 2009-08-23 19:20:03 -0400 | [diff] [blame] | 223 | struct ext2fs_numeric_progress_struct progress; |
| 224 | |
Theodore Ts'o | dfe74c5 | 2012-07-30 17:16:51 -0400 | [diff] [blame] | 225 | if (fs->progress_ops && fs->progress_ops->init) |
| 226 | (fs->progress_ops->init)(fs, &progress, NULL, |
| 227 | fs->group_desc_count); |
Theodore Ts'o | 1e1da29 | 1997-06-09 14:51:29 +0000 | [diff] [blame] | 228 | |
| 229 | for (i = 0; i < fs->group_desc_count; i++) { |
Theodore Ts'o | dfe74c5 | 2012-07-30 17:16:51 -0400 | [diff] [blame] | 230 | if (fs->progress_ops && fs->progress_ops->update) |
| 231 | (fs->progress_ops->update)(fs, &progress, i); |
Theodore Ts'o | 1e1da29 | 1997-06-09 14:51:29 +0000 | [diff] [blame] | 232 | retval = ext2fs_allocate_group_table(fs, i, fs->block_map); |
| 233 | if (retval) |
| 234 | return retval; |
Theodore Ts'o | 21c84b7 | 1997-04-29 16:15:03 +0000 | [diff] [blame] | 235 | } |
Theodore Ts'o | dfe74c5 | 2012-07-30 17:16:51 -0400 | [diff] [blame] | 236 | if (fs->progress_ops && fs->progress_ops->close) |
| 237 | (fs->progress_ops->close)(fs, &progress, NULL); |
Theodore Ts'o | 21c84b7 | 1997-04-29 16:15:03 +0000 | [diff] [blame] | 238 | return 0; |
| 239 | } |
| 240 | |