All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] ext4: fix calculating inode blkcount for non-512 blocksize filesystems
       [not found] <CGME20190621133316eucas1p2dc0538511904be2f0efe8fceccb823bb@eucas1p2.samsung.com>
@ 2019-06-21 13:32 ` Marek Szyprowski
  2019-06-24  9:32   ` Lukasz Majewski
  2019-07-18 23:56   ` Tom Rini
  0 siblings, 2 replies; 3+ messages in thread
From: Marek Szyprowski @ 2019-06-21 13:32 UTC (permalink / raw
  To: u-boot

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>
---
 fs/ext4/ext4_common.c | 2 +-
 fs/ext4/ext4_write.c  | 2 +-
 include/ext_common.h  | 1 +
 3 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/fs/ext4/ext4_common.c b/fs/ext4/ext4_common.c
index 464c33d0d74..8a142e2e6a1 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 504d23a8956..3368bd8c005 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)
diff --git a/include/ext_common.h b/include/ext_common.h
index 17c92f1750b..1c10c504748 100644
--- a/include/ext_common.h
+++ b/include/ext_common.h
@@ -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
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [U-Boot] [PATCH] ext4: fix calculating inode blkcount for non-512 blocksize filesystems
  2019-06-21 13:32 ` [U-Boot] [PATCH] ext4: fix calculating inode blkcount for non-512 blocksize filesystems Marek Szyprowski
@ 2019-06-24  9:32   ` Lukasz Majewski
  2019-07-18 23:56   ` Tom Rini
  1 sibling, 0 replies; 3+ messages in thread
From: Lukasz Majewski @ 2019-06-24  9:32 UTC (permalink / raw
  To: u-boot

On Fri, 21 Jun 2019 15:32:51 +0200
Marek Szyprowski <m.szyprowski@samsung.com> wrote:

> 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>
> ---
>  fs/ext4/ext4_common.c | 2 +-
>  fs/ext4/ext4_write.c  | 2 +-
>  include/ext_common.h  | 1 +
>  3 files changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/ext4/ext4_common.c b/fs/ext4/ext4_common.c
> index 464c33d0d74..8a142e2e6a1 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 504d23a8956..3368bd8c005 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)
> diff --git a/include/ext_common.h b/include/ext_common.h
> index 17c92f1750b..1c10c504748 100644
> --- a/include/ext_common.h
> +++ b/include/ext_common.h
> @@ -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

Reviewed-by: Lukasz Majewski <lukma@denx.de>


Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma at denx.de
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20190624/474186e5/attachment.sig>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [U-Boot] [PATCH] ext4: fix calculating inode blkcount for non-512 blocksize filesystems
  2019-06-21 13:32 ` [U-Boot] [PATCH] ext4: fix calculating inode blkcount for non-512 blocksize filesystems Marek Szyprowski
  2019-06-24  9:32   ` Lukasz Majewski
@ 2019-07-18 23:56   ` Tom Rini
  1 sibling, 0 replies; 3+ messages in thread
From: Tom Rini @ 2019-07-18 23:56 UTC (permalink / raw
  To: u-boot

On Fri, Jun 21, 2019 at 03:32:51PM +0200, Marek Szyprowski wrote:

> 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>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20190718/9630186d/attachment.sig>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-07-18 23:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <CGME20190621133316eucas1p2dc0538511904be2f0efe8fceccb823bb@eucas1p2.samsung.com>
2019-06-21 13:32 ` [U-Boot] [PATCH] ext4: fix calculating inode blkcount for non-512 blocksize filesystems Marek Szyprowski
2019-06-24  9:32   ` Lukasz Majewski
2019-07-18 23:56   ` Tom Rini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.