09 Oct, 2018

1 commit

  • When traversing slots in a btree (via btrfs_path) with btrfs_next_slot(),
    we didn't correctly identify that the last slot in the leaf was reached
    and we should jump to the next leaf.

    This could lead to any kind of runtime errors or corruptions, like:
    * file data not being read at all, or is read partially
    * file is read but is corrupted
    * (any) metadata being corrupted or not read at all, etc

    The easiest way to reproduce this is to read a large enough file that
    its EXTENT_DATA items don't fit into a single leaf.

    Signed-off-by: Yevgeny Popovych
    Cc: Marek Behun
    Tested-by: Marek Behún

    Yevgeny Popovych
     

01 Oct, 2018

1 commit

  • The btrfs implementation passes cache-unaligned buffers into the
    block layer, which triggers cache alignment problems down in the
    block device drivers. Align the buffers to prevent this.

    Signed-off-by: Marek Vasut
    Cc: Marek Behun

    Marek Vasut
     

21 Jul, 2018

1 commit

  • The comparison
    logical > item->logical + item->length
    in btrfs_map_logical_to_physical is wrong and should be instead
    logical >= item->logical + item->length
    For example, if
    item->logical = 4096
    item->length = 4096
    and we are looking for logical = 8192, it is not part of item (item is
    [4096, 8191]). But the comparison is false and we think we have found
    the correct item, although we should be searing in the right subtree.

    This fixes some bugs I encountered.

    Signed-off-by: Marek Behun

    Marek Behún
     

19 Jun, 2018

1 commit

  • This is the case when reading freshly created filesystem.
    The error message is like the following:
    btrfs_read_superblock: No valid root_backup found!

    Since the data from super_roots/root_backups is not actually used -
    decided to rework btrfs_newest_root_backup() into
    btrfs_check_super_roots() that will only check if super_roots
    array is valid and correctly handle empty scenario.

    As a result:
    * btrfs_read_superblock() now only checks if super_roots array is valid;
    the case when it is empty is considered OK.
    * removed root_backup pointer from btrfs_info,
    which would be NULL in case of empty super_roots.
    * btrfs_read_superblock() verifies number of devices from the superblock
    itself, not newest root_backup.

    Signed-off-by: Yevgeny Popovych
    Cc: Marek Behun
    Cc: Sergey Struzh

    Yevgeny Popovych
     

13 Jun, 2018

1 commit

  • This causes errors when translating logical addresses to physical:
    btrfs_map_logical_to_physical: Cannot map logical address to physical
    btrfs_file_read: Error reading extent

    The behavior of btrfs_map_logical_to_physical() is to stop traversing
    CHUNK_TREE when it encounters first non-CHUNK_ITEM, which makes
    only some portion of CHUNK_ITEMs being read.
    Change it to skip over non-chunk items.

    Signed-off-by: Yevgeny Popovych
    Cc: Marek Behun
    Cc: Sergey Struzh
    Reviewed-by: Marek Behun

    Yevgeny Popovych
     

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
     

07 Apr, 2018

1 commit


30 Jan, 2018

1 commit


29 Jan, 2018

1 commit

  • Loading files stored with lzo compression from a btrfs filesystem was
    producing unaligned memory accesses, which were causing a data abort
    and a reset on an Orange Pi Zero.

    The change in hash.c is not triggered by any error but follows the
    same pattern. Please confirm.

    Fixed according to doc/README.unaligned-memory-access.txt

    Signed-off-by: Alberto Sánchez Molero
    Tested-by: Robert Nelson

    Alberto Sánchez Molero
     

16 Oct, 2017

2 commits


03 Oct, 2017

5 commits

  • We specifically say that the last arg is u32, so use %lu.

    Signed-off-by: Tom Rini

    Tom Rini
     
  • Signed-off-by: Marek Behun

    create mode 100644 fs/btrfs/Kconfig
    create mode 100644 fs/btrfs/Makefile
    create mode 100644 fs/btrfs/btrfs.c
    create mode 100644 include/btrfs.h

    Marek Behún
     
  • This adds the proper implementation for the BTRFS filesystem.
    The implementation currently supports only read-only mode and
    the filesystem can be only on a single device.

    Checksums of data chunks is unimplemented.

    Compression is implemented (ZLIB + LZO).

    Signed-off-by: Marek Behun

    create mode 100644 fs/btrfs/btrfs.h
    create mode 100644 fs/btrfs/chunk-map.c
    create mode 100644 fs/btrfs/compression.c
    create mode 100644 fs/btrfs/ctree.c
    create mode 100644 fs/btrfs/dev.c
    create mode 100644 fs/btrfs/dir-item.c
    create mode 100644 fs/btrfs/extent-io.c
    create mode 100644 fs/btrfs/hash.c
    create mode 100644 fs/btrfs/inode.c
    create mode 100644 fs/btrfs/root.c
    create mode 100644 fs/btrfs/subvolume.c
    create mode 100644 fs/btrfs/super.c

    Marek Behún
     
  • BTRFS on disk structures are stored in Little Endian. Add functions
    to convert this structures to cpu and to disk format.

    On Little Endian hosts, these functions do nothing.

    On Big Endian the CALL_MACRO_FROM_EACH from variadic-macro.h is used
    to define all the members for each structure on which cpu_to_le* or
    le*_to_cpu is to be called.

    Signed-off-by: Marek Behun

    create mode 100644 fs/btrfs/conv-funcs.h

    Marek Behún
     
  • Add btrfs_tree.h and ctree.h from Linux which contains constants
    and structures for the BTRFS filesystem.

    Signed-off-by: Marek Behun

    create mode 100644 fs/btrfs/btrfs_tree.h
    create mode 100644 fs/btrfs/ctree.h

    Marek Behún