• Jeff Mahoney's avatar
    btrfs: allow unlink to exceed subvolume quota · 003d7c59
    Jeff Mahoney authored
    Once a qgroup limit is exceeded, it's impossible to restore normal
    operation to the subvolume without modifying the limit or removing
    the subvolume.  This is a surprising situation for many users used
    to the typical workflow with quotas on other file systems where it's
    possible to remove files until the used space is back under the limit.
    
    When we go to unlink a file and start the transaction, we'll hit
    the qgroup limit while trying to reserve space for the items we'll
    modify while removing the file.  We discussed last month how best
    to handle this situation and agreed that there is no perfect solution.
    The best principle-of-least-surprise solution is to handle it similarly
    to how we already handle ENOSPC when unlinking, which is to allow
    the operation to succeed with the expectation that it will ultimately
    release space under most circumstances.
    
    This patch modifies the transaction start path to select whether to
    honor the qgroups limits.  btrfs_start_transaction_fallback_global_rsv
    is the only caller that skips enforcement.  The reservation and tracking
    still happens normally -- it just skips the enforcement step.
    Signed-off-by: default avatarJeff Mahoney <jeffm@suse.com>
    Reviewed-by: default avatarQu Wenruo <quwenruo@cn.fujitsu.com>
    Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
    003d7c59
qgroup.c 74.2 KB