Commit 02d0c3df authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] rename locals in ext2_new_block()

Renames the local variables `bh2', `i', `j', 'k', and `tmp' to
something meanigful.  This brings ext2_new_block() into line with
ext3_new_block().
parent 7dcaa802
...@@ -315,9 +315,12 @@ int ext2_new_block (struct inode * inode, unsigned long goal, ...@@ -315,9 +315,12 @@ int ext2_new_block (struct inode * inode, unsigned long goal,
u32 * prealloc_count, u32 * prealloc_block, int * err) u32 * prealloc_count, u32 * prealloc_block, int * err)
{ {
struct buffer_head *bitmap_bh = NULL; struct buffer_head *bitmap_bh = NULL;
struct buffer_head *bh2; struct buffer_head *gdp_bh; /* bh2 */
struct ext2_group_desc *desc; struct ext2_group_desc *desc;
int i, j, k, tmp; int group_no; /* i */
int ret_block; /* j */
int bit; /* k */
int target_block; /* tmp */
int block = 0; int block = 0;
struct super_block *sb = inode->i_sb; struct super_block *sb = inode->i_sb;
struct ext2_sb_info *sbi = EXT2_SB(sb); struct ext2_sb_info *sbi = EXT2_SB(sb);
...@@ -353,82 +356,88 @@ int ext2_new_block (struct inode * inode, unsigned long goal, ...@@ -353,82 +356,88 @@ int ext2_new_block (struct inode * inode, unsigned long goal,
if (goal < le32_to_cpu(es->s_first_data_block) || if (goal < le32_to_cpu(es->s_first_data_block) ||
goal >= le32_to_cpu(es->s_blocks_count)) goal >= le32_to_cpu(es->s_blocks_count))
goal = le32_to_cpu(es->s_first_data_block); goal = le32_to_cpu(es->s_first_data_block);
i = (goal - le32_to_cpu(es->s_first_data_block)) / group_size; group_no = (goal - le32_to_cpu(es->s_first_data_block)) / group_size;
desc = ext2_get_group_desc (sb, i, &bh2); desc = ext2_get_group_desc (sb, group_no, &gdp_bh);
if (!desc) if (!desc)
goto io_error; goto io_error;
group_alloc = group_reserve_blocks(desc, bh2, es_alloc); group_alloc = group_reserve_blocks(desc, gdp_bh, es_alloc);
if (group_alloc) { if (group_alloc) {
j = ((goal - le32_to_cpu(es->s_first_data_block)) % group_size); ret_block = ((goal - le32_to_cpu(es->s_first_data_block)) %
group_size);
brelse(bitmap_bh); brelse(bitmap_bh);
bitmap_bh = read_block_bitmap(sb, i); bitmap_bh = read_block_bitmap(sb, group_no);
if (!bitmap_bh) if (!bitmap_bh)
goto io_error; goto io_error;
ext2_debug ("goal is at %d:%d.\n", i, j); ext2_debug("goal is at %d:%d.\n", group_no, ret_block);
j = grab_block(bitmap_bh->b_data, group_size, j); ret_block = grab_block(bitmap_bh->b_data,
if (j >= 0) group_size, ret_block);
if (ret_block >= 0)
goto got_block; goto got_block;
group_release_blocks(desc, bh2, group_alloc); group_release_blocks(desc, gdp_bh, group_alloc);
group_alloc = 0; group_alloc = 0;
} }
ext2_debug ("Bit not found in block group %d.\n", i); ext2_debug ("Bit not found in block group %d.\n", group_no);
/* /*
* Now search the rest of the groups. We assume that * Now search the rest of the groups. We assume that
* i and desc correctly point to the last group visited. * i and desc correctly point to the last group visited.
*/ */
for (k = 0; !group_alloc && k < sbi->s_groups_count; k++) { for (bit = 0; !group_alloc &&
i++; bit < sbi->s_groups_count; bit++) {
if (i >= sbi->s_groups_count) group_no++;
i = 0; if (group_no >= sbi->s_groups_count)
desc = ext2_get_group_desc (sb, i, &bh2); group_no = 0;
desc = ext2_get_group_desc(sb, group_no, &gdp_bh);
if (!desc) if (!desc)
goto io_error; goto io_error;
group_alloc = group_reserve_blocks(desc, bh2, es_alloc); group_alloc = group_reserve_blocks(desc, gdp_bh, es_alloc);
} }
if (k >= sbi->s_groups_count) if (bit >= sbi->s_groups_count)
goto out_release; goto out_release;
brelse(bitmap_bh); brelse(bitmap_bh);
bitmap_bh = read_block_bitmap(sb, i); bitmap_bh = read_block_bitmap(sb, group_no);
if (!bitmap_bh) if (!bitmap_bh)
goto io_error; goto io_error;
j = grab_block(bitmap_bh->b_data, group_size, 0); ret_block = grab_block(bitmap_bh->b_data, group_size, 0);
if (j < 0) { if (ret_block < 0) {
ext2_error (sb, "ext2_new_block", ext2_error (sb, "ext2_new_block",
"Free blocks count corrupted for block group %d", i); "Free blocks count corrupted for block group %d",
group_no);
group_alloc = 0; group_alloc = 0;
goto out_release; goto out_release;
} }
got_block: got_block:
ext2_debug("using block group %d(%d)\n", i, desc->bg_free_blocks_count); ext2_debug("using block group %d(%d)\n",
group_no, desc->bg_free_blocks_count);
tmp = j + i * group_size + le32_to_cpu(es->s_first_data_block); target_block = ret_block + group_no * group_size +
le32_to_cpu(es->s_first_data_block);
if (tmp == le32_to_cpu(desc->bg_block_bitmap) || if (target_block == le32_to_cpu(desc->bg_block_bitmap) ||
tmp == le32_to_cpu(desc->bg_inode_bitmap) || target_block == le32_to_cpu(desc->bg_inode_bitmap) ||
in_range (tmp, le32_to_cpu(desc->bg_inode_table), in_range(target_block, le32_to_cpu(desc->bg_inode_table),
sbi->s_itb_per_group)) sbi->s_itb_per_group))
ext2_error (sb, "ext2_new_block", ext2_error (sb, "ext2_new_block",
"Allocating block in system zone - " "Allocating block in system zone - "
"block = %u", tmp); "block = %u", target_block);
if (tmp >= le32_to_cpu(es->s_blocks_count)) { if (target_block >= le32_to_cpu(es->s_blocks_count)) {
ext2_error (sb, "ext2_new_block", ext2_error (sb, "ext2_new_block",
"block(%d) >= blocks count(%d) - " "block(%d) >= blocks count(%d) - "
"block_group = %d, es == %p ",j, "block_group = %d, es == %p ", ret_block,
le32_to_cpu(es->s_blocks_count), i, es); le32_to_cpu(es->s_blocks_count), group_no, es);
goto out_release; goto out_release;
} }
block = tmp; block = target_block;
/* OK, we _had_ allocated something */ /* OK, we _had_ allocated something */
ext2_debug ("found bit %d\n", j); ext2_debug("found bit %d\n", ret_block);
dq_alloc--; dq_alloc--;
es_alloc--; es_alloc--;
...@@ -441,8 +450,8 @@ int ext2_new_block (struct inode * inode, unsigned long goal, ...@@ -441,8 +450,8 @@ int ext2_new_block (struct inode * inode, unsigned long goal,
if (group_alloc && !*prealloc_count) { if (group_alloc && !*prealloc_count) {
unsigned n; unsigned n;
for (n = 0; n < group_alloc && ++j < group_size; n++) { for (n = 0; n < group_alloc && ++ret_block < group_size; n++) {
if (ext2_set_bit(j, bitmap_bh->b_data)) if (ext2_set_bit(ret_block, bitmap_bh->b_data))
break; break;
} }
*prealloc_block = block + 1; *prealloc_block = block + 1;
...@@ -462,7 +471,7 @@ int ext2_new_block (struct inode * inode, unsigned long goal, ...@@ -462,7 +471,7 @@ int ext2_new_block (struct inode * inode, unsigned long goal,
ext2_debug ("allocating block %d. ", block); ext2_debug ("allocating block %d. ", block);
out_release: out_release:
group_release_blocks(desc, bh2, group_alloc); group_release_blocks(desc, gdp_bh, group_alloc);
release_blocks(sb, es_alloc); release_blocks(sb, es_alloc);
*err = 0; *err = 0;
out_unlock: out_unlock:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment