]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
ext4: fix calculating inode blkcount for non-512 blocksize filesystems
authorMarek Szyprowski <m.szyprowski@samsung.com>
Fri, 21 Jun 2019 13:32:51 +0000 (15:32 +0200)
committerTom Rini <trini@konsulko.com>
Thu, 18 Jul 2019 15:31:24 +0000 (11:31 -0400)
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>
fs/ext4/ext4_common.c
fs/ext4/ext4_write.c
include/ext_common.h

index 464c33d0d74ccbc7c1746b69632f0bdbd73d454a..8a142e2e6a1868a6e9679c416f721bc7bdd414ac 100644 (file)
@@ -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
index 504d23a8956cc157f843de22a9c15e72c2290595..3368bd8c005ae0a343987558c47f08177b30a383 100644 (file)
@@ -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)
index 17c92f1750b4ec92fb855271a442c887f45bc35c..1c10c50474840cbeccde7c97e7b7fa8e2a762940 100644 (file)
@@ -21,6 +21,7 @@
 #define __EXT_COMMON__
 #include <command.h>
 #define SECTOR_SIZE            0x200
+#define LOG2_SECTOR_SIZE       9
 
 /* Magic value used to identify an ext2 filesystem.  */
 #define        EXT2_MAGIC                      0xEF53