• Q
    btrfs: qgroup: Add quick exit for non-fs extents · 5edfd9fd
    Qu Wenruo 提交于
    Modify btrfs_qgroup_account_extent() to exit quicker for non-fs extents.
    
    The quick exit condition is:
    1) The extent belongs to a non-fs tree
       Only fs-tree extents can affect qgroup numbers and is the only case
       where extent can be shared between different trees.
    
       Although strictly speaking extent in data-reloc or tree-reloc tree
       can be shared, data/tree-reloc root won't appear in the result of
       btrfs_find_all_roots(), so we can ignore such case.
    
       So we can check the first root in old_roots/new_roots ulist.
       - if we find the 1st root is a not a fs/subvol root, then we can skip
         the extent
       - if we find the 1st root is a fs/subvol root, then we must continue
         calculation
    
    OR
    
    2) both 'nr_old_roots' and 'nr_new_roots' are 0
       This means either such extent got allocated then freed in current
       transaction or it's a new reloc tree extent, whose nr_new_roots is 0.
       Either way it won't affect qgroup accounting and can be skipped
       safely.
    
    Such quick exit can make trace output more quite and less confusing:
    (example with fs uuid and time stamp removed)
    
    Before:
    ------
    add_delayed_tree_ref: bytenr=29556736 num_bytes=16384 action=ADD_DELAYED_REF parent=0(-) ref_root=2(EXTENT_TREE) level=0 type=TREE_BLOCK_REF seq=0
    btrfs_qgroup_account_extent: bytenr=29556736 num_bytes=16384 nr_old_roots=0 nr_new_roots=1
    ------
    Extent tree block will trigger btrfs_qgroup_account_extent() trace point
    while no qgroup number is changed, as extent tree won't affect qgroup
    accounting.
    
    After:
    ------
    add_delayed_tree_ref: bytenr=29556736 num_bytes=16384 action=ADD_DELAYED_REF parent=0(-) ref_root=2(EXTENT_TREE) level=0 type=TREE_BLOCK_REF seq=0
    ------
    Now such unrelated extent won't trigger btrfs_qgroup_account_extent()
    trace point, making the trace less noisy.
    Signed-off-by: NQu Wenruo <quwenruo@cn.fujitsu.com>
    [ changelog and comment adjustments ]
    Signed-off-by: NDavid Sterba <dsterba@suse.com>
    5edfd9fd
qgroup.c 75.6 KB