• Qu Wenruo's avatar
    btrfs: automatically remove the subvolume qgroup · 839d6ea4
    Qu Wenruo authored
    Currently if we fully clean a subvolume (not only delete its directory,
    but fully clean all it's related data and root item), the associated
    qgroup would not be removed.
    
    We have "btrfs qgroup clear-stale" to handle such 0 level qgroups.
    
    Change the behavior to automatically removie the qgroup of a fully
    cleaned subvolume when possible:
    
    - Full qgroup but still consistent
      We can and should remove the qgroup.
      The qgroup numbers should be 0, without any rsv.
    
    - Full qgroup but inconsistent
      Can happen with drop_subtree_threshold feature (skip accounting
      and mark qgroup inconsistent).
    
      We can and should remove the qgroup.
      Higher level qgroup numbers will be incorrect, but since qgroup
      is already inconsistent, it should not be a problem.
    
    - Squota mode
      This is the special case, we can only drop the qgroup if its numbers
      are all 0.
    
      This would be handled by can_delete_qgroup(), so we only need to check
      the return value and ignore the -EBUSY error.
    
    Link: https://bugzilla.suse.com/show_bug.cgi?id=1222847Reviewed-by: default avatarBoris Burkov <boris@bur.io>
    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>
    839d6ea4
extent-tree.c 174 KB