summaryrefslogtreecommitdiff
path: root/fs/ext4
diff options
context:
space:
mode:
authorMarek Szyprowski <m.szyprowski@samsung.com>2019-06-21 15:32:51 +0200
committerTom Rini <trini@konsulko.com>2019-07-18 11:31:24 -0400
commit1c9f8f6412de4447c4f6fadeac1919c89de005f7 (patch)
tree3129fc1583e8d7b9a08c43ef1b72c86448517848 /fs/ext4
parent55f2bc7dd655b6c26cd5fd211a086406416510a6 (diff)
ext4: fix calculating inode blkcount for non-512 blocksize filesystems
The block count entry in the EXT4 filesystem disk structures uses standard 512-bytes units for most of the typical files. The only exception are HUGE files, which use the filesystem block size, but those are not supported by uboot's EXT4 implementation anyway. This patch fixes the EXT4 code to use proper unit count for inode block count. This fixes errors reported by fsck.ext4 on disks with non-standard (i.e. 4KiB, in case of new flash drives) PHYSICAL block size after using 'ext4write' uboot's command. Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com> Reviewed-by: Lukasz Majewski <lukma@denx.de>
Diffstat (limited to 'fs/ext4')
-rw-r--r--fs/ext4/ext4_common.c2
-rw-r--r--fs/ext4/ext4_write.c2
2 files changed, 2 insertions, 2 deletions
diff --git a/fs/ext4/ext4_common.c b/fs/ext4/ext4_common.c
index 464c33d0d7..8a142e2e6a 100644
--- a/fs/ext4/ext4_common.c
+++ b/fs/ext4/ext4_common.c
@@ -570,7 +570,7 @@ restart_read:
g_parent_inode->size = cpu_to_le32(new_size);
new_blockcnt = le32_to_cpu(g_parent_inode->blockcnt);
- new_blockcnt += fs->sect_perblk;
+ new_blockcnt += fs->blksz >> LOG2_SECTOR_SIZE;
g_parent_inode->blockcnt = cpu_to_le32(new_blockcnt);
if (ext4fs_put_metadata
diff --git a/fs/ext4/ext4_write.c b/fs/ext4/ext4_write.c
index 504d23a895..3368bd8c00 100644
--- a/fs/ext4/ext4_write.c
+++ b/fs/ext4/ext4_write.c
@@ -957,7 +957,7 @@ int ext4fs_write(const char *fname, const char *buffer,
ext4fs_allocate_blocks(file_inode, blocks_remaining,
&blks_reqd_for_file);
file_inode->blockcnt = cpu_to_le32((blks_reqd_for_file * fs->blksz) >>
- fs->dev_desc->log2blksz);
+ LOG2_SECTOR_SIZE);
temp_ptr = zalloc(fs->blksz);
if (!temp_ptr)