28 Mar, 2020

1 commit

  • We need to align the cache buffer to ARCH_DMA_MINALIGN in order to avoid
    access errors like

    CACHE: Misaligned operation at range [be0231e0, be0235e0]

    seen on the MCIMX7SABRE.

    Fixes: d5aee659f217 ("fs: ext4: cache extent data")
    Signed-off-by: Jan Kiszka
    Reviewed-by: Tom Rini
    Reviewed-by: Stephen Warren
    Tested-by: Peter Robinson

    Jan Kiszka
     

06 Feb, 2020

1 commit

  • At present dm/device.h includes the linux-compatible features. This
    requires including linux/compat.h which in turn includes a lot of headers.
    One of these is malloc.h which we thus end up including in every file in
    U-Boot. Apart from the inefficiency of this, it is problematic for sandbox
    which needs to use the system malloc() in some files.

    Move the compatibility features into a separate header file.

    Signed-off-by: Simon Glass

    Simon Glass
     

18 Jul, 2019

6 commits


10 Apr, 2019

5 commits

  • Ext4 allows for arbitrarily sized block group descriptors when 64-bit
    addressing is enabled, which was previously not properly supported. This
    patch dynamically allocates a chunk of memory of the correct size.

    Signed-off-by: Benjamin Lim

    Benjamin Lim
     
  • Hi,

    when I try to load a sparse file via ext4load, I am getting the error message
    'invalid extent'

    After a deeper look in the code, it seems to be an issue in the function ext4fs_get_extent_block in fs/ext4/ext4_common.c:

    The file starts with 1k of zeros. The blocksize is 1024. So the first extend block contains the following information:

    eh_entries: 1
    eh_depth: 1
    ei_block 1

    When the upper layer (ext4fs_read_file) asks for fileblock 0, we are running in the 'invalid extent' error message.
    For me it seems, that the code is not prepared for handling a sparse block at the beginning of the file. The following change, solved my problem:

    I am really not an expert in ext4 filesystems. Can somebody please have a look at this issue and give me a feedback, if I am totally wrong or not?

    Gero Schumacher
     
  • Re-use the functions used to write/create a file, to support creation of a
    symbolic link.
    The difference with a regular file are small:
    - The inode mode is flagged with S_IFLNK instead of S_IFREG
    - The ext2_dirent's filetype is FILETYPE_SYMLINK instead of FILETYPE_REG
    - Instead of storing the content of a file in allocated blocks, the path
    to the target is stored. And if the target's path is short enough, no block
    is allocated and the target's path is stored in ext2_inode.b.symlink

    As with regulars files, if a file/symlink with the same name exits, it is
    unlinked first and then re-created.

    Signed-off-by: Jean-Jacques Hiblot
    Reviewed-by: Tom Rini
    [trini: Fix ext4 env code]
    Signed-off-by: Tom Rini

    Jean-Jacques Hiblot
     
  • There is no need to modify the buffer passed to ext4fs_write_file().
    The memset() call is not required here and was likely copied from the
    equivalent part of the ext4fs_read_file() function where we do need it.

    Signed-off-by: Jean-Jacques Hiblot
    Reviewed-by: Tom Rini

    Jean-Jacques Hiblot
     
  • When a file contains extents, U-Boot currently reads extent-related data
    for each block in the file, even if that data is located in the same
    block each time. This significantly slows down loading of files that use
    extents. Implement a very dumb cache to prevent repeatedly reading the
    same block. Files with extents now load as fast as files without.

    Note: There are many cases where read_allocated_block() is called. This
    patch only addresses one of those places; all others still read redundant
    data in any case they did before. This is a minimal patch to fix the
    load command; other cases aren't fixed.

    Signed-off-by: Stephen Warren

    Stephen Warren
     

23 Mar, 2019

1 commit

  • U-Boot doesn't support metadata_csum feature. Writing to filesystem with
    metadata_csum feature makes the filesystem corrupted and unbootable by
    Linux:

    [ 2.527495] EXT4-fs (mmcblk0p2): ext4_check_descriptors: Checksum for group 0 failed (52188!=0)
    [ 2.537421] EXT4-fs (mmcblk0p2): ext4_check_descriptors: Checksum for group 1 failed (5262!=0)
    ...
    [ 2.653308] EXT4-fs (mmcblk0p2): ext4_check_descriptors: Checksum for group 14 failed (42611!=0)
    [ 2.662179] EXT4-fs (mmcblk0p2): ext4_check_descriptors: Checksum for group 15 failed (21527!=0)
    [ 2.687920] JBD2: journal checksum error
    [ 2.691982] EXT4-fs (mmcblk0p2): error loading journal
    [ 2.698292] VFS: Cannot open root device "mmcblk0p2" or unknown-block(179,2): error -74

    Don't write to filesystem with meatadata_csum feature to not corrupt the
    filesystem.

    Signed-off-by: Sébastien Szymanski

    Sébastien Szymanski
     

11 Sep, 2018

1 commit

  • In int-ll64.h, we always use the following typedefs:

    typedef unsigned int u32;
    typedef unsigned long uintptr_t;
    typedef unsigned long long u64;

    This does not need to match to the compiler's .
    Do not include it.

    The use of PRI* makes the code super-ugly. You can simply use
    "l" for printing uintptr_t, "ll" for u64, and no modifier for u32.

    Signed-off-by: Masahiro Yamada

    Masahiro Yamada
     

24 May, 2018

1 commit

  • Found a crash while issuing ext4ls with a non-existent directory.
    Crash test:

    => ext4ls mmc 0 1
    ** Can not find directory. **
    data abort
    pc : [] lr : []
    reloc pc : [] lr : []
    sp : 3f963338 ip : 3fdc3dc4 fp : 3fd6b370
    r10: 00000004 r9 : 3f967ec0 r8 : 3f96db68
    r7 : 3fdc99b4 r6 : 00000000 r5 : 3f96dc88 r4 : 3fdcbc8c
    r3 : fffffffa r2 : 00000000 r1 : 3f96e0bc r0 : 00000002
    Flags: nZCv IRQs off FIQs off Mode SVC_32
    Resetting CPU ...

    resetting ...

    Tested on SAMA5D2_Xplained board (sama5d2_xplained_mmc_defconfig)

    Looks like crash is introduced by commit:
    "fa9ca8a" fs/ext4/ext4fs.c: Free dirnode in error path of ext4fs_ls

    Issue is that dirnode is not initialized, and then freed if the call
    to ext4_ls fails. ext4_ls will not change the value of dirnode in this case
    thus we have a crash with data abort.

    I added initialization and a check for dirname being NULL.

    Fixes: "fa9ca8a" fs/ext4/ext4fs.c: Free dirnode in error path of ext4fs_ls
    Cc: Stefan Brüns
    Cc: Tom Rini
    Signed-off-by: Eugen Hristev
    Reviewed-by: Tom Rini

    Eugen Hristev
     

07 May, 2018

1 commit

  • When U-Boot started using SPDX tags we were among the early adopters and
    there weren't a lot of other examples to borrow from. So we picked the
    area of the file that usually had a full license text and replaced it
    with an appropriate SPDX-License-Identifier: entry. Since then, the
    Linux Kernel has adopted SPDX tags and they place it as the very first
    line in a file (except where shebangs are used, then it's second line)
    and with slightly different comment styles than us.

    In part due to community overlap, in part due to better tag visibility
    and in part for other minor reasons, switch over to that style.

    This commit changes all instances where we have a single declared
    license in the tag as both the before and after are identical in tag
    contents. There's also a few places where I found we did not have a tag
    and have introduced one.

    Signed-off-by: Tom Rini

    Tom Rini
     

10 Mar, 2018

1 commit


23 Jan, 2018

1 commit


20 Nov, 2017

1 commit

  • Some fixes when reading EXT files and directory entries were identified
    after using e2fuzz to corrupt an EXT3 filesystem:

    - Stop reading directory entries if the offset becomes badly aligned.

    - Avoid overwriting memory by clamping the length used to zero the buffer
    in ext4fs_read_file. Also sanity check blocksize.

    Signed-off-by: Ian Ray
    Signed-off-by: Martyn Welch
    Reviewed-by: Stefano Babic

    Ian Ray
     

06 Oct, 2017

2 commits

  • As reported by Coverity, we did not free dirnode in the case of failure.
    Do so now.

    Reported-by: Coverity (CID: 131221)
    Cc: Stefan Brüns
    Signed-off-by: Tom Rini

    Tom Rini
     
  • The current code doesn't compute the group descriptor checksum correctly
    for the filesystems that e2fsprogs 1.43.4 creates (they have
    'Group descriptor size: 64' as reported by tune2fs). Extend the checksum
    calculation to be done as ext4_group_desc_csum() does in Linux.

    This fixes these errors in dmesg from running fs-test.sh and makes it
    succeed again:

    [1671902.620699] EXT4-fs (loop1): ext4_check_descriptors: Checksum for group 0 failed (35782!=10965)
    [1671902.620706] EXT4-fs (loop1): group descriptors corrupted!

    Signed-off-by: Tuomas Tynkkynen

    Tuomas Tynkkynen
     

03 Oct, 2017

1 commit

  • The ext4, reiserfs and zfs filesystems all have their own implementation
    of the same function, *_devread. Generalize this function into fs_devread
    and put the code into fs/fs_internal.c.

    Signed-off-by: Marek Behun
    [trini: Move fs/fs_internal.o hunk to the end of fs/Makefile as all
    cases need it]
    Signed-off-by: Tom Rini

    Marek Behún
     

27 Aug, 2017

1 commit

  • While &p_jdb[fs->blksz] is a valid expression (it points *one* char
    sized element past the end of the array, e.g. &p_jdb[fs->blksz + 1] is
    invalid (according to the C standard (C99/C11)).

    Changing this to tag = (struct ext3_journal_block_tag *)(p_jdb + ofs);

    Cc: Stefan Brüns
    Suggested-by: Stefan Brüns
    Reported-by: Coverity (CID: 165117, 165110)
    Signed-off-by: Tom Rini
    Reviewed-by: Stefan Brüns

    Tom Rini
     

28 Apr, 2017

1 commit

  • In file ext4fs.c funtion ext4fs_read_file() compares an
    unsigned expression with < 0 like below

    lbaint_t blknr;
    blknr = read_allocated_block(&(node->inode), i);
    if (blknr < 0)
    return -1;

    blknr is of type ulong/uint64_t. read_allocated_block() returns
    long int. So comparing blknr with < 0 will always be false. Instead
    declare blknr as long int.

    Similarly ext4/dev.c does a similar comparison. Drop the redundant
    comparison.

    Signed-off-by: Lokesh Vutla
    Reviewed-by: Tom Rini

    Lokesh Vutla
     

28 Dec, 2016

1 commit


22 Nov, 2016

2 commits


24 Oct, 2016

3 commits


24 Sep, 2016

1 commit


23 Sep, 2016

8 commits