ext4: Rename block group descriptor table from gd to bgd
On x86 machines gd is unfortunately a #define, so we should avoid using
gd for anything. This patch changes uses of gd to bgd so that ext4fs
can be used on x86.
A better fix would be to remove the #define in x86, but I'm not sure
how to do that.
Signed-off-by: Simon Glass <sjg@chromium.org>
diff --git a/fs/ext4/ext4fs.c b/fs/ext4/ext4fs.c
index 93dcb7e..3a5ef20 100644
--- a/fs/ext4/ext4fs.c
+++ b/fs/ext4/ext4fs.c
@@ -209,14 +209,14 @@
/* update block groups */
for (i = 0; i < fs->no_blkgrp; i++) {
- fs->gd[i].bg_checksum = ext4fs_checksum_update(i);
- put_ext4((uint64_t)(fs->gd[i].block_id * fs->blksz),
+ fs->bgd[i].bg_checksum = ext4fs_checksum_update(i);
+ put_ext4((uint64_t)(fs->bgd[i].block_id * fs->blksz),
fs->blk_bmaps[i], fs->blksz);
}
/* update inode table groups */
for (i = 0; i < fs->no_blkgrp; i++) {
- put_ext4((uint64_t) (fs->gd[i].inode_id * fs->blksz),
+ put_ext4((uint64_t) (fs->bgd[i].inode_id * fs->blksz),
fs->inode_bmaps[i], fs->blksz);
}
@@ -266,7 +266,7 @@
static void delete_single_indirect_block(struct ext2_inode *inode)
{
- struct ext2_block_group *gd = NULL;
+ struct ext2_block_group *bgd = NULL;
static int prev_bg_bmap_idx = -1;
long int blknr;
int remainder;
@@ -280,7 +280,7 @@
return;
}
/* get block group descriptor table */
- gd = (struct ext2_block_group *)fs->gdtable;
+ bgd = (struct ext2_block_group *)fs->gdtable;
/* deleting the single indirect block associated with inode */
if (inode->b.blocks.indir_block != 0) {
@@ -295,18 +295,18 @@
bg_idx--;
}
ext4fs_reset_block_bmap(blknr, fs->blk_bmaps[bg_idx], bg_idx);
- gd[bg_idx].free_blocks++;
+ bgd[bg_idx].free_blocks++;
fs->sb->free_blocks++;
/* journal backup */
if (prev_bg_bmap_idx != bg_idx) {
status =
- ext4fs_devread(gd[bg_idx].block_id *
+ ext4fs_devread(bgd[bg_idx].block_id *
fs->sect_perblk, 0, fs->blksz,
journal_buffer);
if (status == 0)
goto fail;
if (ext4fs_log_journal
- (journal_buffer, gd[bg_idx].block_id))
+ (journal_buffer, bgd[bg_idx].block_id))
goto fail;
prev_bg_bmap_idx = bg_idx;
}
@@ -326,7 +326,7 @@
unsigned int blk_per_grp = ext4fs_root->sblock.blocks_per_group;
unsigned int *di_buffer = NULL;
unsigned int *DIB_start_addr = NULL;
- struct ext2_block_group *gd = NULL;
+ struct ext2_block_group *bgd = NULL;
struct ext_filesystem *fs = get_fs();
char *journal_buffer = zalloc(fs->blksz);
if (!journal_buffer) {
@@ -334,7 +334,7 @@
return;
}
/* get the block group descriptor table */
- gd = (struct ext2_block_group *)fs->gdtable;
+ bgd = (struct ext2_block_group *)fs->gdtable;
if (inode->b.blocks.double_indir_block != 0) {
di_buffer = zalloc(fs->blksz);
@@ -362,11 +362,11 @@
ext4fs_reset_block_bmap(*di_buffer,
fs->blk_bmaps[bg_idx], bg_idx);
di_buffer++;
- gd[bg_idx].free_blocks++;
+ bgd[bg_idx].free_blocks++;
fs->sb->free_blocks++;
/* journal backup */
if (prev_bg_bmap_idx != bg_idx) {
- status = ext4fs_devread(gd[bg_idx].block_id
+ status = ext4fs_devread(bgd[bg_idx].block_id
* fs->sect_perblk, 0,
fs->blksz,
journal_buffer);
@@ -374,7 +374,7 @@
goto fail;
if (ext4fs_log_journal(journal_buffer,
- gd[bg_idx].block_id))
+ bgd[bg_idx].block_id))
goto fail;
prev_bg_bmap_idx = bg_idx;
}
@@ -391,19 +391,19 @@
bg_idx--;
}
ext4fs_reset_block_bmap(blknr, fs->blk_bmaps[bg_idx], bg_idx);
- gd[bg_idx].free_blocks++;
+ bgd[bg_idx].free_blocks++;
fs->sb->free_blocks++;
/* journal backup */
if (prev_bg_bmap_idx != bg_idx) {
memset(journal_buffer, '\0', fs->blksz);
- status = ext4fs_devread(gd[bg_idx].block_id *
+ status = ext4fs_devread(bgd[bg_idx].block_id *
fs->sect_perblk, 0, fs->blksz,
journal_buffer);
if (status == 0)
goto fail;
if (ext4fs_log_journal(journal_buffer,
- gd[bg_idx].block_id))
+ bgd[bg_idx].block_id))
goto fail;
prev_bg_bmap_idx = bg_idx;
}
@@ -427,7 +427,7 @@
unsigned int *tib_start_addr = NULL;
unsigned int *tip_buffer = NULL;
unsigned int *tipb_start_addr = NULL;
- struct ext2_block_group *gd = NULL;
+ struct ext2_block_group *bgd = NULL;
struct ext_filesystem *fs = get_fs();
char *journal_buffer = zalloc(fs->blksz);
if (!journal_buffer) {
@@ -435,7 +435,7 @@
return;
}
/* get block group descriptor table */
- gd = (struct ext2_block_group *)fs->gdtable;
+ bgd = (struct ext2_block_group *)fs->gdtable;
if (inode->b.blocks.triple_indir_block != 0) {
tigp_buffer = zalloc(fs->blksz);
@@ -477,20 +477,21 @@
bg_idx);
tip_buffer++;
- gd[bg_idx].free_blocks++;
+ bgd[bg_idx].free_blocks++;
fs->sb->free_blocks++;
/* journal backup */
if (prev_bg_bmap_idx != bg_idx) {
status =
- ext4fs_devread(gd[bg_idx].block_id *
- fs->sect_perblk, 0,
- fs->blksz,
- journal_buffer);
+ ext4fs_devread(
+ bgd[bg_idx].block_id *
+ fs->sect_perblk, 0,
+ fs->blksz,
+ journal_buffer);
if (status == 0)
goto fail;
if (ext4fs_log_journal(journal_buffer,
- gd[bg_idx].
+ bgd[bg_idx].
block_id))
goto fail;
prev_bg_bmap_idx = bg_idx;
@@ -516,20 +517,20 @@
fs->blk_bmaps[bg_idx], bg_idx);
tigp_buffer++;
- gd[bg_idx].free_blocks++;
+ bgd[bg_idx].free_blocks++;
fs->sb->free_blocks++;
/* journal backup */
if (prev_bg_bmap_idx != bg_idx) {
memset(journal_buffer, '\0', fs->blksz);
status =
- ext4fs_devread(gd[bg_idx].block_id *
+ ext4fs_devread(bgd[bg_idx].block_id *
fs->sect_perblk, 0,
fs->blksz, journal_buffer);
if (status == 0)
goto fail;
if (ext4fs_log_journal(journal_buffer,
- gd[bg_idx].block_id))
+ bgd[bg_idx].block_id))
goto fail;
prev_bg_bmap_idx = bg_idx;
}
@@ -546,19 +547,19 @@
bg_idx--;
}
ext4fs_reset_block_bmap(blknr, fs->blk_bmaps[bg_idx], bg_idx);
- gd[bg_idx].free_blocks++;
+ bgd[bg_idx].free_blocks++;
fs->sb->free_blocks++;
/* journal backup */
if (prev_bg_bmap_idx != bg_idx) {
memset(journal_buffer, '\0', fs->blksz);
- status = ext4fs_devread(gd[bg_idx].block_id *
+ status = ext4fs_devread(bgd[bg_idx].block_id *
fs->sect_perblk, 0, fs->blksz,
journal_buffer);
if (status == 0)
goto fail;
if (ext4fs_log_journal(journal_buffer,
- gd[bg_idx].block_id))
+ bgd[bg_idx].block_id))
goto fail;
prev_bg_bmap_idx = bg_idx;
}
@@ -590,13 +591,13 @@
unsigned int blk_per_grp = ext4fs_root->sblock.blocks_per_group;
unsigned int inode_per_grp = ext4fs_root->sblock.inodes_per_group;
struct ext2_inode *inode_buffer = NULL;
- struct ext2_block_group *gd = NULL;
+ struct ext2_block_group *bgd = NULL;
struct ext_filesystem *fs = get_fs();
char *journal_buffer = zalloc(fs->blksz);
if (!journal_buffer)
return -ENOMEM;
/* get the block group descriptor table */
- gd = (struct ext2_block_group *)fs->gdtable;
+ bgd = (struct ext2_block_group *)fs->gdtable;
status = ext4fs_read_inode(ext4fs_root, inodeno, &inode);
if (status == 0)
goto fail;
@@ -631,19 +632,19 @@
debug("EXT4_EXTENTS Block releasing %ld: %d\n",
blknr, bg_idx);
- gd[bg_idx].free_blocks++;
+ bgd[bg_idx].free_blocks++;
fs->sb->free_blocks++;
/* journal backup */
if (prev_bg_bmap_idx != bg_idx) {
status =
- ext4fs_devread(gd[bg_idx].block_id *
+ ext4fs_devread(bgd[bg_idx].block_id *
fs->sect_perblk, 0,
fs->blksz, journal_buffer);
if (status == 0)
goto fail;
if (ext4fs_log_journal(journal_buffer,
- gd[bg_idx].block_id))
+ bgd[bg_idx].block_id))
goto fail;
prev_bg_bmap_idx = bg_idx;
}
@@ -676,19 +677,19 @@
bg_idx);
debug("ActualB releasing %ld: %d\n", blknr, bg_idx);
- gd[bg_idx].free_blocks++;
+ bgd[bg_idx].free_blocks++;
fs->sb->free_blocks++;
/* journal backup */
if (prev_bg_bmap_idx != bg_idx) {
memset(journal_buffer, '\0', fs->blksz);
- status = ext4fs_devread(gd[bg_idx].block_id
+ status = ext4fs_devread(bgd[bg_idx].block_id
* fs->sect_perblk,
0, fs->blksz,
journal_buffer);
if (status == 0)
goto fail;
if (ext4fs_log_journal(journal_buffer,
- gd[bg_idx].block_id))
+ bgd[bg_idx].block_id))
goto fail;
prev_bg_bmap_idx = bg_idx;
}
@@ -701,7 +702,7 @@
/* get the block no */
inodeno--;
- blkno = __le32_to_cpu(gd[ibmap_idx].inode_table_id) +
+ blkno = __le32_to_cpu(bgd[ibmap_idx].inode_table_id) +
(inodeno % __le32_to_cpu(inode_per_grp)) / inodes_per_block;
/* get the offset of the inode */
@@ -731,15 +732,15 @@
/* update the respective inode bitmaps */
inodeno++;
ext4fs_reset_inode_bmap(inodeno, fs->inode_bmaps[ibmap_idx], ibmap_idx);
- gd[ibmap_idx].free_inodes++;
+ bgd[ibmap_idx].free_inodes++;
fs->sb->free_inodes++;
/* journal backup */
memset(journal_buffer, '\0', fs->blksz);
- status = ext4fs_devread(gd[ibmap_idx].inode_id *
+ status = ext4fs_devread(bgd[ibmap_idx].inode_id *
fs->sect_perblk, 0, fs->blksz, journal_buffer);
if (status == 0)
goto fail;
- if (ext4fs_log_journal(journal_buffer, gd[ibmap_idx].inode_id))
+ if (ext4fs_log_journal(journal_buffer, bgd[ibmap_idx].inode_id))
goto fail;
ext4fs_update();
@@ -797,7 +798,7 @@
printf("Error in getting the block group descriptor table\n");
goto fail;
}
- fs->gd = (struct ext2_block_group *)fs->gdtable;
+ fs->bgd = (struct ext2_block_group *)fs->gdtable;
/* load all the available bitmap block of the partition */
fs->blk_bmaps = zalloc(fs->no_blkgrp * sizeof(char *));
@@ -811,7 +812,7 @@
for (i = 0; i < fs->no_blkgrp; i++) {
status =
- ext4fs_devread(fs->gd[i].block_id * fs->sect_perblk, 0,
+ ext4fs_devread(fs->bgd[i].block_id * fs->sect_perblk, 0,
fs->blksz, (char *)fs->blk_bmaps[i]);
if (status == 0)
goto fail;
@@ -828,7 +829,7 @@
}
for (i = 0; i < fs->no_blkgrp; i++) {
- status = ext4fs_devread(fs->gd[i].inode_id * fs->sect_perblk,
+ status = ext4fs_devread(fs->bgd[i].inode_id * fs->sect_perblk,
0, fs->blksz,
(char *)fs->inode_bmaps[i]);
if (status == 0)
@@ -842,7 +843,7 @@
* reboot of a linux kernel
*/
for (i = 0; i < fs->no_blkgrp; i++)
- real_free_blocks = real_free_blocks + fs->gd[i].free_blocks;
+ real_free_blocks = real_free_blocks + fs->bgd[i].free_blocks;
if (real_free_blocks != fs->sb->free_blocks)
fs->sb->free_blocks = real_free_blocks;
@@ -907,7 +908,7 @@
free(fs->gdtable);
fs->gdtable = NULL;
- fs->gd = NULL;
+ fs->bgd = NULL;
/*
* reinitiliazed the global inode and
* block bitmap first execution check variables
@@ -1087,7 +1088,7 @@
goto fail;
ibmap_idx = inodeno / ext4fs_root->sblock.inodes_per_group;
inodeno--;
- itable_blkno = __le32_to_cpu(fs->gd[ibmap_idx].inode_table_id) +
+ itable_blkno = __le32_to_cpu(fs->bgd[ibmap_idx].inode_table_id) +
(inodeno % __le32_to_cpu(sblock->inodes_per_group)) /
inodes_per_block;
blkoff = (inodeno % inodes_per_block) * fs->inodesz;
@@ -1105,7 +1106,7 @@
}
ibmap_idx = parent_inodeno / ext4fs_root->sblock.inodes_per_group;
parent_inodeno--;
- parent_itable_blkno = __le32_to_cpu(fs->gd[ibmap_idx].inode_table_id) +
+ parent_itable_blkno = __le32_to_cpu(fs->bgd[ibmap_idx].inode_table_id) +
(parent_inodeno %
__le32_to_cpu(sblock->inodes_per_group)) / inodes_per_block;
blkoff = (parent_inodeno % inodes_per_block) * fs->inodesz;