* [U-Boot] [RESEND 1/4] fs:ext4:write: Add lldiv and do_div to perform 64-32 bits division
2012-12-05 18:06 [U-Boot] [RESEND 0/4] fs:ext4:fix: Fixes for ext4write command Lukasz Majewski
@ 2012-12-05 18:06 ` Lukasz Majewski
2012-12-05 18:06 ` [U-Boot] [RESEND 2/4] fs:ext4:write: Store block device descriptor in file system structure Lukasz Majewski
` (4 subsequent siblings)
5 siblings, 0 replies; 8+ messages in thread
From: Lukasz Majewski @ 2012-12-05 18:06 UTC (permalink / raw)
To: u-boot
The ext4write code has been using direct calls to 64-32 division
(/ and %).
Officially supported u-boot toolchains (eldk-5.[12].x) generate calls
to __aeabi_uldivmod(), which is niether defined in the toolchain libs
nor u-boot source tree.
Due to that, when the ext4write command has been executed, "undefined
instruction" execption was generated (since the __aeabi_uldivmod()
is not provided).
To fix this error, lldiv() for division and do_div() for modulo have
been used.
Those two functions are recommended for performing 64-32 bit number
division in u-boot.
Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
---
fs/ext4/ext4fs.c | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/fs/ext4/ext4fs.c b/fs/ext4/ext4fs.c
index 06536ba..80b3b90 100644
--- a/fs/ext4/ext4fs.c
+++ b/fs/ext4/ext4fs.c
@@ -40,6 +40,7 @@
#include <linux/stat.h>
#include <linux/time.h>
#include <asm/byteorder.h>
+#include <div64.h>
#include "ext4_common.h"
int ext4fs_symlinknest;
@@ -1051,8 +1052,8 @@ int ext4fs_write(const char *fname, unsigned char *buffer,
}
/* calucalate how many blocks required */
bytes_reqd_for_file = sizebytes;
- blks_reqd_for_file = bytes_reqd_for_file / fs->blksz;
- if (bytes_reqd_for_file % fs->blksz != 0) {
+ blks_reqd_for_file = lldiv(bytes_reqd_for_file, fs->blksz);
+ if (do_div(bytes_reqd_for_file, fs->blksz) != 0) {
blks_reqd_for_file++;
debug("total bytes for a file %u\n", blks_reqd_for_file);
}
--
1.7.2.3
^ permalink raw reply related [flat|nested] 8+ messages in thread* [U-Boot] [RESEND 2/4] fs:ext4:write: Store block device descriptor in file system structure
2012-12-05 18:06 [U-Boot] [RESEND 0/4] fs:ext4:fix: Fixes for ext4write command Lukasz Majewski
2012-12-05 18:06 ` [U-Boot] [RESEND 1/4] fs:ext4:write: Add lldiv and do_div to perform 64-32 bits division Lukasz Majewski
@ 2012-12-05 18:06 ` Lukasz Majewski
2012-12-05 18:06 ` [U-Boot] [RESEND 3/4] fs:ext4:fix: Code refactoring to suppress compiler warnings Lukasz Majewski
` (3 subsequent siblings)
5 siblings, 0 replies; 8+ messages in thread
From: Lukasz Majewski @ 2012-12-05 18:06 UTC (permalink / raw)
To: u-boot
The device block descriptor (block_dev_desc_t) )shall be stored at
ext4 early code (at ext4fs_set_blk_dev in this case) to be available
for latter use (like put_ext4()).
Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
---
fs/ext4/dev.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/fs/ext4/dev.c b/fs/ext4/dev.c
index 1596a92..464a67d 100644
--- a/fs/ext4/dev.c
+++ b/fs/ext4/dev.c
@@ -52,6 +52,7 @@ void ext4fs_set_blk_dev(block_dev_desc_t *rbdd, disk_partition_t *info)
part_info = info;
part_offset = info->start;
get_fs()->total_sect = (info->size * info->blksz) / SECTOR_SIZE;
+ get_fs()->dev_desc = rbdd;
}
int ext4fs_devread(int sector, int byte_offset, int byte_len, char *buf)
--
1.7.2.3
^ permalink raw reply related [flat|nested] 8+ messages in thread* [U-Boot] [RESEND 3/4] fs:ext4:fix: Code refactoring to suppress compiler warnings
2012-12-05 18:06 [U-Boot] [RESEND 0/4] fs:ext4:fix: Fixes for ext4write command Lukasz Majewski
2012-12-05 18:06 ` [U-Boot] [RESEND 1/4] fs:ext4:write: Add lldiv and do_div to perform 64-32 bits division Lukasz Majewski
2012-12-05 18:06 ` [U-Boot] [RESEND 2/4] fs:ext4:write: Store block device descriptor in file system structure Lukasz Majewski
@ 2012-12-05 18:06 ` Lukasz Majewski
2012-12-05 18:06 ` [U-Boot] [RESEND 4/4] fs:ext4:write: Initialize cache aligned filename buffer Lukasz Majewski
` (2 subsequent siblings)
5 siblings, 0 replies; 8+ messages in thread
From: Lukasz Majewski @ 2012-12-05 18:06 UTC (permalink / raw)
To: u-boot
Several fixes to suppress compiler's (eldk-5.[12].x gcc 4.6)
warning [-Wunused-but-set-variable]
Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
---
fs/ext4/ext4_common.c | 14 ++++++++++----
fs/ext4/ext4_journal.c | 3 +--
fs/ext4/ext4fs.c | 3 ---
3 files changed, 11 insertions(+), 9 deletions(-)
diff --git a/fs/ext4/ext4_common.c b/fs/ext4/ext4_common.c
index 323875f..f12b805 100644
--- a/fs/ext4/ext4_common.c
+++ b/fs/ext4/ext4_common.c
@@ -378,7 +378,6 @@ void ext4fs_update_parent_dentry(char *filename, int *p_ino, int file_type)
struct ext_filesystem *fs = get_fs();
/* directory entry */
struct ext2_dirent *dir;
- char *ptr = NULL;
char *temp_dir = NULL;
zero_buffer = zalloc(fs->blksz);
@@ -415,7 +414,6 @@ restart:
if (ext4fs_log_journal(root_first_block_buffer, first_block_no_of_root))
goto fail;
dir = (struct ext2_dirent *)root_first_block_buffer;
- ptr = (char *)dir;
totalbytes = 0;
while (dir->direntlen > 0) {
/*
@@ -483,14 +481,12 @@ restart:
break;
dir = (struct ext2_dirent *)((char *)dir + templength);
- ptr = (char *)dir;
}
/* make a pointer ready for creating next directory entry */
templength = dir->direntlen;
totalbytes = totalbytes + templength;
dir = (struct ext2_dirent *)((char *)dir + templength);
- ptr = (char *)dir;
/* get the next available inode number */
inodeno = ext4fs_get_new_inode_no();
@@ -1200,6 +1196,11 @@ static void alloc_double_indirect_block(struct ext2_inode *file_inode,
status = ext4fs_devread(di_blockno_parent *
fs->sect_perblk, 0,
fs->blksz, (char *)di_parent_buffer);
+
+ if (!status) {
+ printf("%s: Device read error!\n", __func__);
+ goto fail;
+ }
memset(di_parent_buffer, '\0', fs->blksz);
/*
@@ -1227,6 +1228,11 @@ static void alloc_double_indirect_block(struct ext2_inode *file_inode,
fs->sect_perblk, 0,
fs->blksz,
(char *)di_child_buff);
+
+ if (!status) {
+ printf("%s: Device read error!\n", __func__);
+ goto fail;
+ }
memset(di_child_buff, '\0', fs->blksz);
/* filling of actual datablocks for each child */
for (j = 0; j < (fs->blksz / sizeof(int)); j++) {
diff --git a/fs/ext4/ext4_journal.c b/fs/ext4/ext4_journal.c
index 8a252d6..9f01708 100644
--- a/fs/ext4/ext4_journal.c
+++ b/fs/ext4/ext4_journal.c
@@ -410,7 +410,7 @@ int ext4fs_check_journal_state(int recovery_flag)
int transaction_state = TRANSACTION_COMPLETE;
int prev_desc_logical_no = 0;
int curr_desc_logical_no = 0;
- int ofs, flags, block;
+ int ofs, flags;
struct ext2_inode inode_journal;
struct journal_superblock_t *jsb = NULL;
struct journal_header_t *jdb = NULL;
@@ -453,7 +453,6 @@ int ext4fs_check_journal_state(int recovery_flag)
i = be32_to_cpu(jsb->s_first);
while (1) {
- block = be32_to_cpu(jsb->s_first);
blknr = read_allocated_block(&inode_journal, i);
memset(temp_buff1, '\0', fs->blksz);
ext4fs_devread(blknr * fs->sect_perblk,
diff --git a/fs/ext4/ext4fs.c b/fs/ext4/ext4fs.c
index 80b3b90..64d8a6d 100644
--- a/fs/ext4/ext4fs.c
+++ b/fs/ext4/ext4fs.c
@@ -931,7 +931,6 @@ static int ext4fs_write_file(struct ext2_inode *file_inode,
int previous_block_number = -1;
int delayed_start = 0;
int delayed_extent = 0;
- int delayed_skipfirst = 0;
int delayed_next = 0;
char *delayed_buf = NULL;
@@ -964,7 +963,6 @@ static int ext4fs_write_file(struct ext2_inode *file_inode,
previous_block_number = blknr;
delayed_start = blknr;
delayed_extent = blockend;
- delayed_skipfirst = skipfirst;
delayed_buf = buf;
delayed_next = blknr +
(blockend >> SECTOR_BITS);
@@ -973,7 +971,6 @@ static int ext4fs_write_file(struct ext2_inode *file_inode,
previous_block_number = blknr;
delayed_start = blknr;
delayed_extent = blockend;
- delayed_skipfirst = skipfirst;
delayed_buf = buf;
delayed_next = blknr +
(blockend >> SECTOR_BITS);
--
1.7.2.3
^ permalink raw reply related [flat|nested] 8+ messages in thread* [U-Boot] [RESEND 4/4] fs:ext4:write: Initialize cache aligned filename buffer
2012-12-05 18:06 [U-Boot] [RESEND 0/4] fs:ext4:fix: Fixes for ext4write command Lukasz Majewski
` (2 preceding siblings ...)
2012-12-05 18:06 ` [U-Boot] [RESEND 3/4] fs:ext4:fix: Code refactoring to suppress compiler warnings Lukasz Majewski
@ 2012-12-05 18:06 ` Lukasz Majewski
2012-12-05 19:10 ` [U-Boot] [RESEND 0/4] fs:ext4:fix: Fixes for ext4write command Tom Rini
2012-12-07 15:51 ` Tom Rini
5 siblings, 0 replies; 8+ messages in thread
From: Lukasz Majewski @ 2012-12-05 18:06 UTC (permalink / raw)
To: u-boot
The filename buffer is allocated dynamically. It must be cache aligned.
Moreover, it is necessary to erase its content before we use it for
file name operations.
This prevents from corruption of written file names.
Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
---
fs/ext4/ext4fs.c | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/fs/ext4/ext4fs.c b/fs/ext4/ext4fs.c
index 64d8a6d..f02c215 100644
--- a/fs/ext4/ext4fs.c
+++ b/fs/ext4/ext4fs.c
@@ -1011,8 +1011,6 @@ int ext4fs_write(const char *fname, unsigned char *buffer,
unsigned int blks_reqd_for_file;
unsigned int blocks_remaining;
int existing_file_inodeno;
- char filename[256];
-
char *temp_ptr = NULL;
long int itable_blkno;
long int parent_itable_blkno;
@@ -1021,6 +1019,9 @@ int ext4fs_write(const char *fname, unsigned char *buffer,
unsigned int inodes_per_block;
unsigned int ibmap_idx;
struct ext_filesystem *fs = get_fs();
+ ALLOC_CACHE_ALIGN_BUFFER(char, filename, 256);
+ memset(filename, 0x00, sizeof(filename));
+
g_parent_inode = zalloc(sizeof(struct ext2_inode));
if (!g_parent_inode)
goto fail;
--
1.7.2.3
^ permalink raw reply related [flat|nested] 8+ messages in thread* [U-Boot] [RESEND 0/4] fs:ext4:fix: Fixes for ext4write command
2012-12-05 18:06 [U-Boot] [RESEND 0/4] fs:ext4:fix: Fixes for ext4write command Lukasz Majewski
` (3 preceding siblings ...)
2012-12-05 18:06 ` [U-Boot] [RESEND 4/4] fs:ext4:write: Initialize cache aligned filename buffer Lukasz Majewski
@ 2012-12-05 19:10 ` Tom Rini
2012-12-06 7:31 ` Lukasz Majewski
2012-12-07 15:51 ` Tom Rini
5 siblings, 1 reply; 8+ messages in thread
From: Tom Rini @ 2012-12-05 19:10 UTC (permalink / raw)
To: u-boot
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 12/05/12 13:06, Lukasz Majewski wrote:
> Several fixes for ext4write command including: - compiler warnings
> suppress - lldiv() and do_div() instead of "plain" / and %
> operands for 64-32 bits - Proper initialization of dev_desc -
> Proper definition of cache aligned filename buffer
>
> Lukasz Majewski (4): fs:ext4:write: Add lldiv and do_div to perform
> 64-32 bits division fs:ext4:write: Store block device descriptor in
> file system structure fs:ext4:fix: Code refactoring to suppress
> compiler warnings fs:ext4:write: Initialize cache aligned filename
> buffer
>
> fs/ext4/dev.c | 1 + fs/ext4/ext4_common.c | 14
> ++++++++++---- fs/ext4/ext4_journal.c | 3 +-- fs/ext4/ext4fs.c
> | 13 ++++++------- 4 files changed, 18 insertions(+), 13
> deletions(-)
OK, I know the wiki talks about resends, but has anything changed from
the last go-round? Thanks!
- --
Tom
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://www.enigmail.net/
iQIcBAEBAgAGBQJQv5wZAAoJENk4IS6UOR1WQFwP/juJGARGm/7f/Fyoy2UueWRq
K3NPEYuMLP+jyBjIno4jaZ1vkHceUv//1OLH3yUrgIF+CyUQAzLVtogxSXE+x444
i7vMs19jCJgw3i1P0wnnxqijaHnHLYQIiY2nCJzJ65wWO+gZv6lJ0okg319uxaTS
fe5HQzz+puLFIDLQUEavyotAWrVoG1xoxsJXc1LQ7iyRvzqgCWHvURzCmZ4m6pJI
WdZwLRRhS8/FSA7ILHlNmOTxWbMAPShb5HZ36QpsFa7LXAbXF0xh4N33AqDapLtA
dyJyjbiYxBYH9Jv/qK+Szt/DCwFqteBwcRXBL5wG2LF+CuTKhvLAmC7qi41SUa5E
O6T5etbbwjIB23g6ImRNAEJfW0OItZ5l12VXAHRYzIN0t2zTGqp0a4bfvKEOqa4U
nVL4f0xYes/WtoZiNVD+Jeck1VAIGOyvir/7QvIJun+9OmCfdBHkbZWb4LUsa/Hh
lWfpiASQ/fTYaFY9UfiV9zntcOgUacrQumroznz6JHhaTsNTwgkO4v6Xu11SkdId
a3DkN/TKk9T6Km6mpIfggIGFrvw8rBL2CPAh7GCMrOx2EZyoXfqYSy6SQs5XRysJ
jHu/7pjm0Fxjt9o6roaDivkJDRley6EWGVm0oFOqCDNt4goQNWslZnYMOcQb3b06
vUd3b7N9YO/JeyQbz+c+
=tm/c
-----END PGP SIGNATURE-----
^ permalink raw reply [flat|nested] 8+ messages in thread* [U-Boot] [RESEND 0/4] fs:ext4:fix: Fixes for ext4write command
2012-12-05 19:10 ` [U-Boot] [RESEND 0/4] fs:ext4:fix: Fixes for ext4write command Tom Rini
@ 2012-12-06 7:31 ` Lukasz Majewski
0 siblings, 0 replies; 8+ messages in thread
From: Lukasz Majewski @ 2012-12-06 7:31 UTC (permalink / raw)
To: u-boot
Hi Tom,
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> On 12/05/12 13:06, Lukasz Majewski wrote:
> > Several fixes for ext4write command including: - compiler warnings
> > suppress - lldiv() and do_div() instead of "plain" / and %
> > operands for 64-32 bits - Proper initialization of dev_desc -
> > Proper definition of cache aligned filename buffer
> >
> > Lukasz Majewski (4): fs:ext4:write: Add lldiv and do_div to perform
> > 64-32 bits division fs:ext4:write: Store block device descriptor in
> > file system structure fs:ext4:fix: Code refactoring to suppress
> > compiler warnings fs:ext4:write: Initialize cache aligned filename
> > buffer
> >
> > fs/ext4/dev.c | 1 + fs/ext4/ext4_common.c | 14
> > ++++++++++---- fs/ext4/ext4_journal.c | 3 +-- fs/ext4/ext4fs.c
> > | 13 ++++++------- 4 files changed, 18 insertions(+), 13
> > deletions(-)
>
> OK, I know the wiki talks about resends, but has anything changed from
> the last go-round? Thanks!
>
From the initial post, Simon Glass has acked one commit (3/4).
Moreover I've removed from the series TRATS dependent code and replaced
it with another fix (in the patch 4/4).
Due to that the patch set consists of only ext4 write related fixes.
I see it as an improvement when compared to the first round of patches.
> - --
> Tom
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.11 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://www.enigmail.net/
>
> iQIcBAEBAgAGBQJQv5wZAAoJENk4IS6UOR1WQFwP/juJGARGm/7f/Fyoy2UueWRq
> K3NPEYuMLP+jyBjIno4jaZ1vkHceUv//1OLH3yUrgIF+CyUQAzLVtogxSXE+x444
> i7vMs19jCJgw3i1P0wnnxqijaHnHLYQIiY2nCJzJ65wWO+gZv6lJ0okg319uxaTS
> fe5HQzz+puLFIDLQUEavyotAWrVoG1xoxsJXc1LQ7iyRvzqgCWHvURzCmZ4m6pJI
> WdZwLRRhS8/FSA7ILHlNmOTxWbMAPShb5HZ36QpsFa7LXAbXF0xh4N33AqDapLtA
> dyJyjbiYxBYH9Jv/qK+Szt/DCwFqteBwcRXBL5wG2LF+CuTKhvLAmC7qi41SUa5E
> O6T5etbbwjIB23g6ImRNAEJfW0OItZ5l12VXAHRYzIN0t2zTGqp0a4bfvKEOqa4U
> nVL4f0xYes/WtoZiNVD+Jeck1VAIGOyvir/7QvIJun+9OmCfdBHkbZWb4LUsa/Hh
> lWfpiASQ/fTYaFY9UfiV9zntcOgUacrQumroznz6JHhaTsNTwgkO4v6Xu11SkdId
> a3DkN/TKk9T6Km6mpIfggIGFrvw8rBL2CPAh7GCMrOx2EZyoXfqYSy6SQs5XRysJ
> jHu/7pjm0Fxjt9o6roaDivkJDRley6EWGVm0oFOqCDNt4goQNWslZnYMOcQb3b06
> vUd3b7N9YO/JeyQbz+c+
> =tm/c
> -----END PGP SIGNATURE-----
--
Best regards,
Lukasz Majewski
Samsung Poland R&D Center | Linux Platform Group
^ permalink raw reply [flat|nested] 8+ messages in thread
* [U-Boot] [RESEND 0/4] fs:ext4:fix: Fixes for ext4write command
2012-12-05 18:06 [U-Boot] [RESEND 0/4] fs:ext4:fix: Fixes for ext4write command Lukasz Majewski
` (4 preceding siblings ...)
2012-12-05 19:10 ` [U-Boot] [RESEND 0/4] fs:ext4:fix: Fixes for ext4write command Tom Rini
@ 2012-12-07 15:51 ` Tom Rini
5 siblings, 0 replies; 8+ messages in thread
From: Tom Rini @ 2012-12-07 15:51 UTC (permalink / raw)
To: u-boot
On Wed, Dec 05, 2012 at 07:06:36PM +0100, Lukasz Majewski wrote:
> Several fixes for ext4write command including:
> - compiler warnings suppress
> - lldiv() and do_div() instead of "plain" / and % operands for 64-32 bits
> - Proper initialization of dev_desc
> - Proper definition of cache aligned filename buffer
>
> Lukasz Majewski (4):
> fs:ext4:write: Add lldiv and do_div to perform 64-32 bits division
> fs:ext4:write: Store block device descriptor in file system structure
> fs:ext4:fix: Code refactoring to suppress compiler warnings
> fs:ext4:write: Initialize cache aligned filename buffer
>
> fs/ext4/dev.c | 1 +
> fs/ext4/ext4_common.c | 14 ++++++++++----
> fs/ext4/ext4_journal.c | 3 +--
> fs/ext4/ext4fs.c | 13 ++++++-------
> 4 files changed, 18 insertions(+), 13 deletions(-)
This series has been applied to u-boot/master, but please note that this
should have been labeled 'v2' rather than RESEND as you changed 4/4.
--
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20121207/cf904d5a/attachment.pgp>
^ permalink raw reply [flat|nested] 8+ messages in thread