diff options
| author | Frederic Leroy <fredo@starox.org> | 2013-06-26 18:11:25 +0200 | 
|---|---|---|
| committer | Tom Rini <trini@ti.com> | 2013-07-15 17:06:13 -0400 | 
| commit | 04735e9c5578dd4f3584be5454b9779e8e5c2af9 (patch) | |
| tree | 5641d35f98ffda64ff900a8356639eeb88f320a5 /fs/ext4/ext4_journal.c | |
| parent | 0eb33ad253026d5a773854dd42b2a56937678aa9 (diff) | |
| download | olio-uboot-2014.01-04735e9c5578dd4f3584be5454b9779e8e5c2af9.tar.xz olio-uboot-2014.01-04735e9c5578dd4f3584be5454b9779e8e5c2af9.zip | |
Fix ext2/ext4 filesystem accesses beyond 2TiB
With CONFIG_SYS_64BIT_LBA, lbaint_t gets defined as a 64-bit type,
which is required to represent block numbers for storage devices that
exceed 2TiB (the block size usually is 512B), e.g. recent hard drives
We now use lbaint_t for partition offset to reflect the lbaint_t change,
and access partitions beyond or crossing the 2.1TiB limit.
This required changes to signature of ext4fs_devread(), and type of all
variables relatives to block sector.
ext2/ext4 fs uses logical block represented by a 32 bit value. Logical
block is a multiple of device block sector. To avoid overflow problem
when calling ext4fs_devread(), we need to cast the sector parameter.
Signed-off-by: Frédéric Leroy <fredo@starox.org>
Diffstat (limited to 'fs/ext4/ext4_journal.c')
| -rw-r--r-- | fs/ext4/ext4_journal.c | 19 | 
1 files changed, 12 insertions, 7 deletions
| diff --git a/fs/ext4/ext4_journal.c b/fs/ext4/ext4_journal.c index 81aa5fc0f..a540367a7 100644 --- a/fs/ext4/ext4_journal.c +++ b/fs/ext4/ext4_journal.c @@ -360,7 +360,8 @@ void recover_transaction(int prev_desc_logical_no)  			  (struct ext2_inode *)&inode_journal);  	blknr = read_allocated_block((struct ext2_inode *)  				     &inode_journal, i); -	ext4fs_devread(blknr * fs->sect_perblk, 0, fs->blksz, temp_buff); +	ext4fs_devread((lbaint_t)blknr * fs->sect_perblk, 0, fs->blksz, +		       temp_buff);  	p_jdb = (char *)temp_buff;  	jdb = (struct journal_header_t *) temp_buff;  	ofs = sizeof(struct journal_header_t); @@ -384,7 +385,7 @@ void recover_transaction(int prev_desc_logical_no)  				continue;  		}  		blknr = read_allocated_block(&inode_journal, i); -		ext4fs_devread(blknr * fs->sect_perblk, 0, +		ext4fs_devread((lbaint_t)blknr * fs->sect_perblk, 0,  			       fs->blksz, metadata_buff);  		put_ext4((uint64_t)(be32_to_cpu(tag->block) * fs->blksz),  			 metadata_buff, (uint32_t) fs->blksz); @@ -431,7 +432,8 @@ int ext4fs_check_journal_state(int recovery_flag)  	ext4fs_read_inode(ext4fs_root, EXT2_JOURNAL_INO, &inode_journal);  	blknr = read_allocated_block(&inode_journal, EXT2_JOURNAL_SUPERBLOCK); -	ext4fs_devread(blknr * fs->sect_perblk, 0, fs->blksz, temp_buff); +	ext4fs_devread((lbaint_t)blknr * fs->sect_perblk, 0, fs->blksz, +		       temp_buff);  	jsb = (struct journal_superblock_t *) temp_buff;  	if (fs->sb->feature_incompat & EXT3_FEATURE_INCOMPAT_RECOVER) { @@ -455,7 +457,7 @@ int ext4fs_check_journal_state(int recovery_flag)  	while (1) {  		blknr = read_allocated_block(&inode_journal, i);  		memset(temp_buff1, '\0', fs->blksz); -		ext4fs_devread(blknr * fs->sect_perblk, +		ext4fs_devread((lbaint_t)blknr * fs->sect_perblk,  			       0, fs->blksz, temp_buff1);  		jdb = (struct journal_header_t *) temp_buff1; @@ -574,7 +576,8 @@ static void update_descriptor_block(long int blknr)  	ext4fs_read_inode(ext4fs_root, EXT2_JOURNAL_INO, &inode_journal);  	jsb_blknr = read_allocated_block(&inode_journal,  					 EXT2_JOURNAL_SUPERBLOCK); -	ext4fs_devread(jsb_blknr * fs->sect_perblk, 0, fs->blksz, temp_buff); +	ext4fs_devread((lbaint_t)jsb_blknr * fs->sect_perblk, 0, fs->blksz, +		       temp_buff);  	jsb = (struct journal_superblock_t *) temp_buff;  	jdb.h_blocktype = cpu_to_be32(EXT3_JOURNAL_DESCRIPTOR_BLOCK); @@ -621,10 +624,12 @@ static void update_commit_block(long int blknr)  	if (!temp_buff)  		return; -	ext4fs_read_inode(ext4fs_root, EXT2_JOURNAL_INO, &inode_journal); +	ext4fs_read_inode(ext4fs_root, EXT2_JOURNAL_INO, +			  &inode_journal);  	jsb_blknr = read_allocated_block(&inode_journal,  					 EXT2_JOURNAL_SUPERBLOCK); -	ext4fs_devread(jsb_blknr * fs->sect_perblk, 0, fs->blksz, temp_buff); +	ext4fs_devread((lbaint_t)jsb_blknr * fs->sect_perblk, 0, fs->blksz, +		       temp_buff);  	jsb = (struct journal_superblock_t *) temp_buff;  	jdb.h_blocktype = cpu_to_be32(EXT3_JOURNAL_COMMIT_BLOCK); |