An error occurred fetching the project authors.
  1. 29 Apr, 2019 6 commits
    • David Sterba's avatar
      btrfs: use assertion helpers for spinning writers · 843ccf9f
      David Sterba authored
      Use the helpers where open coded. On non-debug builds, the warnings will
      not trigger and extent_buffer::spining_writers become unused and can be
      moved to the appropriate section, saving a few bytes.
      Reviewed-by: default avatarNikolay Borisov <nborisov@suse.com>
      Reviewed-by: default avatarJohannes Thumshirn <jthumshirn@suse.de>
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
      843ccf9f
    • Nikolay Borisov's avatar
      btrfs: Remove EXTENT_IOBITS · 8882679e
      Nikolay Borisov authored
      This flag just became synonymous to EXTENT_LOCKED, so just remove it and
      used EXTENT_LOCKED directly. No functional changes.
      Signed-off-by: default avatarNikolay Borisov <nborisov@suse.com>
      Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
      8882679e
    • Nikolay Borisov's avatar
      btrfs: Remove EXTENT_WRITEBACK · 4e586ca3
      Nikolay Borisov authored
      This flag was introduced in a52d9a80 ("Btrfs: Extent based page
      cache code.") and subsequently it's usage effectively was removed by
      1edbb734 ("Btrfs: reduce CPU usage in the extent_state tree") and
      f2a97a9d ("btrfs: remove all unused functions"). Just remove it,
      no functional changes.
      Signed-off-by: default avatarNikolay Borisov <nborisov@suse.com>
      Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
      4e586ca3
    • Qu Wenruo's avatar
      btrfs: tracepoints: Add trace events for extent_io_tree · a1d19847
      Qu Wenruo authored
      Although btrfs heavily relies on extent_io_tree, we don't really have
      any good trace events for them.
      
      This patch will add the folowing trace events:
      - trace_btrfs_set_extent_bit()
      - trace_btrfs_clear_extent_bit()
      - trace_btrfs_convert_extent_bit()
      
      Since selftests could create temporary extent_io_tree without fs_info,
      modify TP_fast_assign_fsid() to accept NULL as fs_info.  NULL fs_info
      will lead to all zero fsid.
      
      The output would be:
        btrfs_set_extent_bit: <FDID>: io_tree=INODE_IO ino=1 root=1 start=22036480 len=4096 set_bits=LOCKED
        btrfs_set_extent_bit: <FSID>: io_tree=INODE_IO ino=1 root=1 start=22040576 len=4096 set_bits=LOCKED
        btrfs_set_extent_bit: <FSID>: io_tree=INODE_IO ino=1 root=1 start=22044672 len=4096 set_bits=LOCKED
        btrfs_set_extent_bit: <FSID>: io_tree=INODE_IO ino=1 root=1 start=22048768 len=4096 set_bits=LOCKED
        btrfs_clear_extent_bit: <FSID>: io_tree=INODE_IO ino=1 root=1 start=22036480 len=16384 clear_bits=LOCKED
        ^^^ Extent buffer 22036480 read from disk, the locking progress
      
        btrfs_set_extent_bit: <FSID>: io_tree=TRANS_DIRTY_PAGES ino=1 root=1 start=30425088 len=16384 set_bits=DIRTY
        btrfs_set_extent_bit: <FSID>: io_tree=TRANS_DIRTY_PAGES ino=1 root=1 start=30441472 len=16384 set_bits=DIRTY
        ^^^ 2 new tree blocks allocated in one transaction
      
        btrfs_set_extent_bit: <FSID>: io_tree=FREED_EXTENTS0 ino=0 root=0 start=30523392 len=16384 set_bits=DIRTY
        btrfs_set_extent_bit: <FSID>: io_tree=FREED_EXTENTS0 ino=0 root=0 start=30556160 len=16384 set_bits=DIRTY
        ^^^ 2 old tree blocks get pinned down
      
      There is one point which need attention:
      1) Those trace events can be pretty heavy:
         The following workload would generate over 400 trace events.
      
      	mkfs.btrfs -f $dev
      	start_trace
      	mount $dev $mnt -o enospc_debug
      	sync
      	touch $mnt/file1
      	touch $mnt/file2
      	touch $mnt/file3
      	xfs_io -f -c "pwrite 0 16k" $mnt/file4
      	umount $mnt
      	end_trace
      
         It's not recommended to use them in real world environment.
      Signed-off-by: default avatarQu Wenruo <wqu@suse.com>
      Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
      [ rename enums ]
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
      a1d19847
    • Qu Wenruo's avatar
      btrfs: Introduce extent_io_tree::owner to distinguish different io_trees · 43eb5f29
      Qu Wenruo authored
      Btrfs has the following different extent_io_trees used:
      
      - fs_info::free_extents[2]
      - btrfs_inode::io_tree - for both normal inodes and the btree inode
      - btrfs_inode::io_failure_tree
      - btrfs_transaction::dirty_pages
      - btrfs_root::dirty_log_pages
      
      If we want to trace changes in those trees, it will be pretty hard to
      distinguish them.
      
      Instead of using hard-to-read pointer address, this patch will introduce
      a new member extent_io_tree::owner to track the owner.
      
      This modification needs all the callers of extent_io_tree_init() to
      accept a new parameter @owner.
      
      This patch provides the basis for later trace events.
      Signed-off-by: default avatarQu Wenruo <wqu@suse.com>
      Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
      43eb5f29
    • Qu Wenruo's avatar
      btrfs: Introduce fs_info to extent_io_tree · c258d6e3
      Qu Wenruo authored
      This patch will add a new member fs_info to extent_io_tree.
      
      This provides the basis for later trace events to distinguish the output
      between different btrfs filesystems. While this increases the size of
      the structure, we want to know the source of the trace events and
      passing the fs_info as an argument to all contexts is not possible.
      
      The selftests are now allowed to set it to NULL as they don't use the
      tracepoints.
      Signed-off-by: default avatarQu Wenruo <wqu@suse.com>
      Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
      c258d6e3
  2. 27 Feb, 2019 1 commit
    • Filipe Manana's avatar
      Btrfs: fix corruption reading shared and compressed extents after hole punching · 8e928218
      Filipe Manana authored
      In the past we had data corruption when reading compressed extents that
      are shared within the same file and they are consecutive, this got fixed
      by commit 005efedf ("Btrfs: fix read corruption of compressed and
      shared extents") and by commit 808f80b4 ("Btrfs: update fix for read
      corruption of compressed and shared extents"). However there was a case
      that was missing in those fixes, which is when the shared and compressed
      extents are referenced with a non-zero offset. The following shell script
      creates a reproducer for this issue:
      
        #!/bin/bash
      
        mkfs.btrfs -f /dev/sdc &> /dev/null
        mount -o compress /dev/sdc /mnt/sdc
      
        # Create a file with 3 consecutive compressed extents, each has an
        # uncompressed size of 128Kb and a compressed size of 4Kb.
        for ((i = 1; i <= 3; i++)); do
            head -c 4096 /dev/zero
            for ((j = 1; j <= 31; j++)); do
                head -c 4096 /dev/zero | tr '\0' "\377"
            done
        done > /mnt/sdc/foobar
        sync
      
        echo "Digest after file creation:   $(md5sum /mnt/sdc/foobar)"
      
        # Clone the first extent into offsets 128K and 256K.
        xfs_io -c "reflink /mnt/sdc/foobar 0 128K 128K" /mnt/sdc/foobar
        xfs_io -c "reflink /mnt/sdc/foobar 0 256K 128K" /mnt/sdc/foobar
        sync
      
        echo "Digest after cloning:         $(md5sum /mnt/sdc/foobar)"
      
        # Punch holes into the regions that are already full of zeroes.
        xfs_io -c "fpunch 0 4K" /mnt/sdc/foobar
        xfs_io -c "fpunch 128K 4K" /mnt/sdc/foobar
        xfs_io -c "fpunch 256K 4K" /mnt/sdc/foobar
        sync
      
        echo "Digest after hole punching:   $(md5sum /mnt/sdc/foobar)"
      
        echo "Dropping page cache..."
        sysctl -q vm.drop_caches=1
        echo "Digest after hole punching:   $(md5sum /mnt/sdc/foobar)"
      
        umount /dev/sdc
      
      When running the script we get the following output:
      
        Digest after file creation:   5a0888d80d7ab1fd31c229f83a3bbcc8  /mnt/sdc/foobar
        linked 131072/131072 bytes at offset 131072
        128 KiB, 1 ops; 0.0033 sec (36.960 MiB/sec and 295.6830 ops/sec)
        linked 131072/131072 bytes at offset 262144
        128 KiB, 1 ops; 0.0015 sec (78.567 MiB/sec and 628.5355 ops/sec)
        Digest after cloning:         5a0888d80d7ab1fd31c229f83a3bbcc8  /mnt/sdc/foobar
        Digest after hole punching:   5a0888d80d7ab1fd31c229f83a3bbcc8  /mnt/sdc/foobar
        Dropping page cache...
        Digest after hole punching:   fba694ae8664ed0c2e9ff8937e7f1484  /mnt/sdc/foobar
      
      This happens because after reading all the pages of the extent in the
      range from 128K to 256K for example, we read the hole at offset 256K
      and then when reading the page at offset 260K we don't submit the
      existing bio, which is responsible for filling all the page in the
      range 128K to 256K only, therefore adding the pages from range 260K
      to 384K to the existing bio and submitting it after iterating over the
      entire range. Once the bio completes, the uncompressed data fills only
      the pages in the range 128K to 256K because there's no more data read
      from disk, leaving the pages in the range 260K to 384K unfilled. It is
      just a slightly different variant of what was solved by commit
      005efedf ("Btrfs: fix read corruption of compressed and shared
      extents").
      
      Fix this by forcing a bio submit, during readpages(), whenever we find a
      compressed extent map for a page that is different from the extent map
      for the previous page or has a different starting offset (in case it's
      the same compressed extent), instead of the extent map's original start
      offset.
      
      A test case for fstests follows soon.
      Reported-by: default avatarZygo Blaxell <ce3g8jdj@umail.furryterror.org>
      Fixes: 808f80b4 ("Btrfs: update fix for read corruption of compressed and shared extents")
      Fixes: 005efedf ("Btrfs: fix read corruption of compressed and shared extents")
      Cc: stable@vger.kernel.org # 4.3+
      Tested-by: default avatarZygo Blaxell <ce3g8jdj@umail.furryterror.org>
      Signed-off-by: default avatarFilipe Manana <fdmanana@suse.com>
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
      8e928218
  3. 25 Feb, 2019 4 commits
  4. 15 Feb, 2019 3 commits
  5. 04 Jan, 2019 1 commit
  6. 17 Dec, 2018 25 commits