diff options
| author | Simon Glass <sjg@chromium.org> | 2012-10-03 11:37:49 +0000 | 
|---|---|---|
| committer | Tom Rini <trini@ti.com> | 2012-10-03 18:21:33 -0700 | 
| commit | 73c15c634dda388e21eaf0ebc85e324872df0d25 (patch) | |
| tree | 54790af1fde1e994a7ce858cb38caa9a3360667e /fs/ext4/ext4fs.c | |
| parent | bb64d1c92fbbc2441772f2eb9b4527499955c04e (diff) | |
| download | olio-uboot-2014.01-73c15c634dda388e21eaf0ebc85e324872df0d25.tar.xz olio-uboot-2014.01-73c15c634dda388e21eaf0ebc85e324872df0d25.zip | |
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>
Diffstat (limited to 'fs/ext4/ext4fs.c')
| -rw-r--r-- | fs/ext4/ext4fs.c | 99 | 
1 files changed, 50 insertions, 49 deletions
| diff --git a/fs/ext4/ext4fs.c b/fs/ext4/ext4fs.c index 93dcb7e8f..3a5ef20a4 100644 --- a/fs/ext4/ext4fs.c +++ b/fs/ext4/ext4fs.c @@ -209,14 +209,14 @@ static void ext4fs_update(void)  	/* 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 @@ fail:  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 @@ static void delete_single_indirect_block(struct ext2_inode *inode)  		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 @@ static void delete_single_indirect_block(struct ext2_inode *inode)  				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 @@ static void delete_double_indirect_block(struct ext2_inode *inode)  	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 @@ static void delete_double_indirect_block(struct ext2_inode *inode)  		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 @@ static void delete_double_indirect_block(struct ext2_inode *inode)  			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 @@ static void delete_double_indirect_block(struct ext2_inode *inode)  					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 @@ static void delete_double_indirect_block(struct ext2_inode *inode)  				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 @@ static void delete_triple_indirect_block(struct ext2_inode *inode)  	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 @@ static void delete_triple_indirect_block(struct ext2_inode *inode)  		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 @@ static void delete_triple_indirect_block(struct ext2_inode *inode)  							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 @@ static void delete_triple_indirect_block(struct ext2_inode *inode)  						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 @@ static void delete_triple_indirect_block(struct ext2_inode *inode)  				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 @@ static int ext4fs_delete_file(int inodeno)  	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 @@ static int ext4fs_delete_file(int inodeno)  			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 @@ static int ext4fs_delete_file(int inodeno)  						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 @@ static int ext4fs_delete_file(int inodeno)  	/* 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 @@ static int ext4fs_delete_file(int inodeno)  	/* 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 @@ int ext4fs_init(void)  		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 @@ int ext4fs_init(void)  	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 @@ int ext4fs_init(void)  	}  	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 @@ int ext4fs_init(void)  	 * 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 @@ void ext4fs_deinit(void)  	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 @@ int ext4fs_write(const char *fname, unsigned char *buffer,  		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 @@ int ext4fs_write(const char *fname, unsigned char *buffer,  	}  	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; |