1. 27 Apr, 2012 7 commits
  2. 18 Apr, 2012 19 commits
  3. 13 Apr, 2012 1 commit
  4. 12 Apr, 2012 6 commits
  5. 29 Mar, 2012 7 commits
    • Chris Mason's avatar
      Btrfs: update the checks for mixed block groups with big metadata blocks · bc3f116f
      Chris Mason authored
      Dave Sterba had put in patches to look for mixed data/metadata groups
      with metadata bigger than 4KB.  But these ended up in the wrong place
      and it wasn't testing the feature flag correctly.
      
      This updates the tests to make sure our sizes are matching
      Signed-off-by: default avatarChris Mason <chris.mason@oracle.com>
      bc3f116f
    • Liu Bo's avatar
      Btrfs: update to the right index of defragment · e1f041e1
      Liu Bo authored
      When we use autodefrag, we forget to update the index which indicates
      the last page we've dirty.  And we'll set dirty flags on a same set of
      pages again and again.
      Signed-off-by: default avatarLiu Bo <liubo2009@cn.fujitsu.com>
      Signed-off-by: default avatarChris Mason <chris.mason@oracle.com>
      e1f041e1
    • Liu Bo's avatar
      Btrfs: do not bother to defrag an extent if it is a big real extent · 66c26892
      Liu Bo authored
      $ mkfs.btrfs /dev/sdb7
      $ mount /dev/sdb7 /mnt/btrfs/ -oautodefrag
      $ dd if=/dev/zero of=/mnt/btrfs/foobar bs=4k count=10 oflag=direct 2>/dev/null
      $ filefrag -v /mnt/btrfs/foobar
      Filesystem type is: 9123683e
      File size of /mnt/btrfs/foobar is 40960 (10 blocks, blocksize 4096)
       ext logical physical expected length flags
         0       0     3072              10 eof
      /mnt/btrfs/foobar: 1 extent found
      
      Now we have a big real extent [0, 40960), but autodefrag will still defrag it.
      
      $ sync
      $ filefrag -v /mnt/btrfs/foobar
      Filesystem type is: 9123683e
      File size of /mnt/btrfs/foobar is 40960 (10 blocks, blocksize 4096)
       ext logical physical expected length flags
         0       0     3082              10 eof
      /mnt/btrfs/foobar: 1 extent found
      
      So if we already find a big real extent, we're ok about that, just skip it.
      Signed-off-by: default avatarLiu Bo <liubo2009@cn.fujitsu.com>
      Signed-off-by: default avatarChris Mason <chris.mason@oracle.com>
      66c26892
    • Liu Bo's avatar
      Btrfs: add a check to decide if we should defrag the range · 17ce6ef8
      Liu Bo authored
      If our file's layout is as follows:
      | hole | data1 | hole | data2 |
      
      we do not need to defrag this file, because this file has holes and
      cannot be merged into one extent.
      Signed-off-by: default avatarLiu Bo <liubo2009@cn.fujitsu.com>
      Signed-off-by: default avatarChris Mason <chris.mason@oracle.com>
      17ce6ef8
    • Liu Bo's avatar
      Btrfs: fix recursive defragment with autodefrag option · 4cb13e5d
      Liu Bo authored
      $ mkfs.btrfs disk
      $ mount disk /mnt -o autodefrag
      $ dd if=/dev/zero of=/mnt/foobar bs=4k count=10 2>/dev/null && sync
      $ for i in `seq 9 -2 0`; do dd if=/dev/zero of=/mnt/foobar bs=4k count=1 \
        seek=$i conv=notrunc 2> /dev/null; done && sync
      
      then we'll get to defrag "foobar" again and again.
      So does option "-o autodefrag,compress".
      
      Reasons:
      When the cleaner kthread gets to fetch inodes from the defrag tree and defrag
      them, it will dirty pages and submit them, this will comes to another DATA COW
      where the processing inode will be inserted to the defrag tree again.
      
      This patch sets a rule for COW code, i.e. insert an inode when we're really
      going to make some defragments.
      Signed-off-by: default avatarLiu Bo <liubo2009@cn.fujitsu.com>
      Signed-off-by: default avatarChris Mason <chris.mason@oracle.com>
      4cb13e5d
    • Liu Bo's avatar
      Btrfs: fix the mismatch of page->mapping · 1f12bd06
      Liu Bo authored
      commit 600a45e1
      (Btrfs: fix deadlock on page lock when doing auto-defragment)
      fixes the deadlock on page, but it also introduces another bug.
      
      A page may have been truncated after unlock & lock.
      So we need to find it again to get the right one.
      
      And since we've held i_mutex lock, inode size remains unchanged and
      we can drop isize overflow checks.
      Signed-off-by: default avatarLiu Bo <liubo2009@cn.fujitsu.com>
      Signed-off-by: default avatarMiao Xie <miaox@cn.fujitsu.com>
      Signed-off-by: default avatarChris Mason <chris.mason@oracle.com>
      1f12bd06
    • Liu Bo's avatar
      Btrfs: fix race between direct io and autodefrag · ecb8bea8
      Liu Bo authored
      The bug is from running xfstests 209 with autodefrag.
      
      The race is as follows:
             t1                       t2(autodefrag)
         direct IO
           invalidate pagecache
           dio(old data)             add_inode_defrag
           invalidate pagecache
         endio
      
         direct IO
           invalidate pagecache
                                      run_defrag
                                        readpage(old data)
                                        set page dirty (old data)
           dio(new data, rewrite)
           invalidate pagecache (*)
           endio
      
      t2(autodefrag) will get old data into pagecache via readpage and set
      pagecache dirty.  Meanwhile, invalidate pagecache(*) will fail due to
      dirty flags in pages.  So the old data may be flushed into disk by
      flush thread, which will lead to data loss.
      
      And so does the case of user defragment progs.
      
      The patch fixes this race by holding i_mutex when we readpage and set page dirty.
      Signed-off-by: default avatarLiu Bo <liubo2009@cn.fujitsu.com>
      Signed-off-by: default avatarMiao Xie <miaox@cn.fujitsu.com>
      Signed-off-by: default avatarChris Mason <chris.mason@oracle.com>
      ecb8bea8