1. 22 10月, 2015 3 次提交
    • Q
      btrfs: delayed_ref: release and free qgroup reserved at proper timing · 297d750b
      Qu Wenruo 提交于
      Qgroup reserved space needs to be released from inode dirty map and get
      freed at different timing:
      
      1) Release when the metadata is written into tree
      After corresponding metadata is written into tree, any newer write will
      be COWed(don't include NOCOW case yet).
      So we must release its range from inode dirty range map, or we will
      forget to reserve needed range, causing accounting exceeding the limit.
      
      2) Free reserved bytes when delayed ref is run
      When delayed refs are run, qgroup accounting will follow soon and turn
      the reserved bytes into rfer/excl numbers.
      As run_delayed_refs and qgroup accounting are all done at
      commit_transaction() time, we are safe to free reserved space in
      run_delayed_ref time().
      
      With these timing to release/free reserved space, we should be able to
      resolve the long existing qgroup reserve space leak problem.
      Signed-off-by: NQu Wenruo <quwenruo@cn.fujitsu.com>
      Signed-off-by: NChris Mason <clm@fb.com>
      297d750b
    • Q
      btrfs: qgroup: Introduce functions to release/free qgroup reserve data · f695fdce
      Qu Wenruo 提交于
      space
      
      Introduce functions btrfs_qgroup_release/free_data() to release/free
      reserved data range.
      
      Release means, just remove the data range from io_tree, but doesn't
      free the reserved space.
      This is for normal buffered write case, when data is written into disc
      and its metadata is added into tree, its reserved space should still be
      kept until commit_trans().
      So in that case, we only release dirty range, but keep the reserved
      space recorded some other place until commit_tran().
      
      Free means not only remove data range, but also free reserved space.
      This is used for case for cleanup and invalidate page.
      Signed-off-by: NQu Wenruo <quwenruo@cn.fujitsu.com>
      Signed-off-by: NChris Mason <clm@fb.com>
      f695fdce
    • Q
      btrfs: qgroup: Introduce btrfs_qgroup_reserve_data function · 52472553
      Qu Wenruo 提交于
      Introduce a new function, btrfs_qgroup_reserve_data(), which will use
      io_tree to accurate qgroup reserve, to avoid reserved space leaking.
      Signed-off-by: NQu Wenruo <quwenruo@cn.fujitsu.com>
      Signed-off-by: NChris Mason <clm@fb.com>
      52472553
  2. 07 8月, 2015 2 次提交
  3. 01 7月, 2015 1 次提交
  4. 11 6月, 2015 10 次提交
  5. 03 6月, 2015 1 次提交
  6. 13 4月, 2015 15 次提交
  7. 27 3月, 2015 1 次提交
    • F
      Btrfs: change the insertion criteria for the qgroup operations rbtree · bf691960
      Filipe Manana 提交于
      After looking at Liu Bo's recent patch (titled
      "Btrfs: fix comp_oper to get right order") I realized the search made by
      qgroup_oper_exists() was buggy because its rbtree navigation comparison
      function, comp_oper_exist(), only looks at the fields bytenr and ref_root
      of a tree node, ignoring the seq field completely. This was wrong because
      when we insert a node into the rbtree we use comp_oper(), which takes a
      decision based first on bytenr, then on seq and then on the ref_root field.
      That means qgroup_oper_exists() could miss the fact that at least one
      operation with given bytenr and ref_root exists.
      
      Consider the following simple example of a 3 nodes qgroup operations
      rbtree (created using comp_oper before this patch), where each node's key
      is a tuple with the shape (bytenr, seq, ref_root, op):
      
                                [ (4096, 2, 20, op X) ]
                               /                       \
                              /                         \
         [ (4096, 1, 5, op Y) ]                         [ (4096, 3, 10, op Z) ]
      
      qgroup_oper_exists() when called to search for an existing operation for
      bytenr 4096 and ref root 10 wouldn't find anything because it would go to
      the left subtree instead of the right subtree, since comp_oper_exits()
      ignores the seq field completely.
      
      Fix this by changing the insertion navigation function to use the ref_root
      field right after using the bytenr field and before using the seq field,
      so that qgroup_oper_exists() / comp_oper_exist() work as expected.
      
      This patch applies on top of the patch mentioned above from Liu.
      Signed-off-by: NFilipe Manana <fdmanana@suse.com>
      Signed-off-by: NChris Mason <clm@fb.com>
      bf691960
  8. 14 3月, 2015 1 次提交
  9. 04 3月, 2015 1 次提交
  10. 17 2月, 2015 1 次提交
    • D
      Btrfs: disk-io: replace root args iff only fs_info used · 01d58472
      Daniel Dressler 提交于
      This is the 3rd independent patch of a larger project to cleanup btrfs's
      internal usage of btrfs_root. Many functions take btrfs_root only to
      grab the fs_info struct.
      
      By requiring a root these functions cause programmer overhead. That
      these functions can accept any valid root is not obvious until
      inspection.
      
      This patch reduces the specificity of such functions to accept the
      fs_info directly.
      
      These patches can be applied independently and thus are not being
      submitted as a patch series. There should be about 26 patches by the
      project's completion. Each patch will cleanup between 1 and 34 functions
      apiece.  Each patch covers a single file's functions.
      
      This patch affects the following function(s):
        1) csum_tree_block
        2) csum_dirty_buffer
        3) check_tree_block_fsid
        4) btrfs_find_tree_block
        5) clean_tree_block
      Signed-off-by: NDaniel Dressler <danieru.dressler@gmail.com>
      Signed-off-by: NDavid Sterba <dsterba@suse.cz>
      01d58472
  11. 22 1月, 2015 1 次提交
  12. 02 10月, 2014 1 次提交
  13. 18 9月, 2014 2 次提交
    • M
      btrfs: don't go readonly on existing qgroup items · 0b4699dc
      Mark Fasheh 提交于
      btrfs_drop_snapshot() leaves subvolume qgroup items on disk after
      completion. This can cause problems with snapshot creation. If a new
      snapshot tries to claim the deleted subvolumes id, btrfs will get -EEXIST
      from add_qgroup_item() and go read-only. The following commands will
      reproduce this problem (assume btrfs is on /dev/sda and is mounted at
      /btrfs)
      
      mkfs.btrfs -f /dev/sda
      mount -t btrfs /dev/sda /btrfs/
      btrfs quota enable /btrfs/
      btrfs su sna /btrfs/ /btrfs/snap
      btrfs su de /btrfs/snap
      sleep 45
      umount /btrfs/
      mount -t btrfs /dev/sda /btrfs/
      
      We can fix this by catching -EEXIST in add_qgroup_item() and
      initializing the existing items. We have the problem of orphaned
      relation items being on disk from an old snapshot but that is outside
      the scope of this patch.
      Signed-off-by: NMark Fasheh <mfasheh@suse.de>
      Signed-off-by: NChris Mason <clm@fb.com>
      0b4699dc
    • M
      btrfs: add trace for qgroup accounting · d3982100
      Mark Fasheh 提交于
      We want this to debug qgroup changes on live systems.
      Signed-off-by: NMark Fasheh <mfasheh@suse.de>
      Reviewed-by: NJosef Bacik <jbacik@fb.com>
      Signed-off-by: NChris Mason <clm@fb.com>
      d3982100