btrfs: qgroup: Commit transaction in advance to reduce early EDQUOT
authorQu Wenruo <wqu@suse.com>
Fri, 22 Dec 2017 08:06:39 +0000 (16:06 +0800)
committerDavid Sterba <dsterba@suse.com>
Wed, 18 Apr 2018 14:46:47 +0000 (16:46 +0200)
commita514d63882c3d2063b21b865447266ebcb18b04c
tree17476c6edb8409e6c46a976382fd1b0bb6ae698e
parent5d41be6f702f19f72db816c17175caf9dbdcdfa6
btrfs: qgroup: Commit transaction in advance to reduce early EDQUOT

Unlike previous method that tries to commit transaction inside
qgroup_reserve(), this time we will try to commit transaction using
fs_info->transaction_kthread to avoid nested transaction and no need to
worry about locking context.

Since it's an asynchronous function call and we won't wait for
transaction commit, unlike previous method, we must call it before we
hit the qgroup limit.

So this patch will use the ratio and size of qgroup meta_pertrans
reservation as indicator to check if we should trigger a transaction
commit.  (meta_prealloc won't be cleaned in transaction committ, it's
useless anyway)

Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/ctree.h
fs/btrfs/disk-io.c
fs/btrfs/qgroup.c
fs/btrfs/transaction.c
fs/btrfs/transaction.h