Skip to content

Commit c7796c3

Browse files
adam900710smb49
authored andcommitted
btrfs: qgroup: remove ASYNC_COMMIT mechanism in favor of reserve retry-after-EDQUOT
BugLink: https://bugs.launchpad.net/bugs/1943484 commit adca4d9 upstream commit a514d63 ("btrfs: qgroup: Commit transaction in advance to reduce early EDQUOT") tries to reduce the early EDQUOT problems by checking the qgroup free against threshold and tries to wake up commit kthread to free some space. The problem of that mechanism is, it can only free qgroup per-trans metadata space, can't do anything to data, nor prealloc qgroup space. Now since we have the ability to flush qgroup space, and implemented retry-after-EDQUOT behavior, such mechanism can be completely replaced. So this patch will cleanup such mechanism in favor of retry-after-EDQUOT. Reviewed-by: Josef Bacik <josef@toxicpanda.com> Signed-off-by: Qu Wenruo <wqu@suse.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com> Signed-off-by: Anand Jain <anand.jain@oracle.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Kamal Mostafa <kamal@canonical.com> Signed-off-by: Luke Nowakowski-Krijger <luke.nowakowskikrijger@canonical.com>
1 parent ad54221 commit c7796c3

5 files changed

Lines changed: 2 additions & 62 deletions

File tree

fs/btrfs/ctree.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -504,11 +504,6 @@ enum {
504504
* (device replace, resize, device add/delete, balance)
505505
*/
506506
BTRFS_FS_EXCL_OP,
507-
/*
508-
* To info transaction_kthread we need an immediate commit so it
509-
* doesn't need to wait for commit_interval
510-
*/
511-
BTRFS_FS_NEED_ASYNC_COMMIT,
512507
/*
513508
* Indicate that balance has been set up from the ioctl and is in the
514509
* main phase. The fs_info::balance_ctl is initialized.

fs/btrfs/disk-io.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1749,7 +1749,6 @@ static int transaction_kthread(void *arg)
17491749

17501750
now = ktime_get_seconds();
17511751
if (cur->state < TRANS_STATE_COMMIT_START &&
1752-
!test_bit(BTRFS_FS_NEED_ASYNC_COMMIT, &fs_info->flags) &&
17531752
(now < cur->start_time ||
17541753
now - cur->start_time < fs_info->commit_interval)) {
17551754
spin_unlock(&fs_info->trans_lock);

fs/btrfs/qgroup.c

Lines changed: 2 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#include <linux/slab.h>
1212
#include <linux/workqueue.h>
1313
#include <linux/btrfs.h>
14-
#include <linux/sizes.h>
1514

1615
#include "ctree.h"
1716
#include "transaction.h"
@@ -2840,20 +2839,8 @@ int btrfs_qgroup_inherit(struct btrfs_trans_handle *trans, u64 srcid,
28402839
return ret;
28412840
}
28422841

2843-
/*
2844-
* Two limits to commit transaction in advance.
2845-
*
2846-
* For RATIO, it will be 1/RATIO of the remaining limit as threshold.
2847-
* For SIZE, it will be in byte unit as threshold.
2848-
*/
2849-
#define QGROUP_FREE_RATIO 32
2850-
#define QGROUP_FREE_SIZE SZ_32M
2851-
static bool qgroup_check_limits(struct btrfs_fs_info *fs_info,
2852-
const struct btrfs_qgroup *qg, u64 num_bytes)
2842+
static bool qgroup_check_limits(const struct btrfs_qgroup *qg, u64 num_bytes)
28532843
{
2854-
u64 free;
2855-
u64 threshold;
2856-
28572844
if ((qg->lim_flags & BTRFS_QGROUP_LIMIT_MAX_RFER) &&
28582845
qgroup_rsv_total(qg) + (s64)qg->rfer + num_bytes > qg->max_rfer)
28592846
return false;
@@ -2862,32 +2849,6 @@ static bool qgroup_check_limits(struct btrfs_fs_info *fs_info,
28622849
qgroup_rsv_total(qg) + (s64)qg->excl + num_bytes > qg->max_excl)
28632850
return false;
28642851

2865-
/*
2866-
* Even if we passed the check, it's better to check if reservation
2867-
* for meta_pertrans is pushing us near limit.
2868-
* If there is too much pertrans reservation or it's near the limit,
2869-
* let's try commit transaction to free some, using transaction_kthread
2870-
*/
2871-
if ((qg->lim_flags & (BTRFS_QGROUP_LIMIT_MAX_RFER |
2872-
BTRFS_QGROUP_LIMIT_MAX_EXCL))) {
2873-
if (qg->lim_flags & BTRFS_QGROUP_LIMIT_MAX_EXCL) {
2874-
free = qg->max_excl - qgroup_rsv_total(qg) - qg->excl;
2875-
threshold = min_t(u64, qg->max_excl / QGROUP_FREE_RATIO,
2876-
QGROUP_FREE_SIZE);
2877-
} else {
2878-
free = qg->max_rfer - qgroup_rsv_total(qg) - qg->rfer;
2879-
threshold = min_t(u64, qg->max_rfer / QGROUP_FREE_RATIO,
2880-
QGROUP_FREE_SIZE);
2881-
}
2882-
2883-
/*
2884-
* Use transaction_kthread to commit transaction, so we no
2885-
* longer need to bother nested transaction nor lock context.
2886-
*/
2887-
if (free < threshold)
2888-
btrfs_commit_transaction_locksafe(fs_info);
2889-
}
2890-
28912852
return true;
28922853
}
28932854

@@ -2937,7 +2898,7 @@ static int qgroup_reserve(struct btrfs_root *root, u64 num_bytes, bool enforce,
29372898

29382899
qg = unode_aux_to_qgroup(unode);
29392900

2940-
if (enforce && !qgroup_check_limits(fs_info, qg, num_bytes)) {
2901+
if (enforce && !qgroup_check_limits(qg, num_bytes)) {
29412902
ret = -EDQUOT;
29422903
goto out;
29432904
}

fs/btrfs/transaction.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2297,7 +2297,6 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans)
22972297
*/
22982298
cur_trans->state = TRANS_STATE_COMPLETED;
22992299
wake_up(&cur_trans->commit_wait);
2300-
clear_bit(BTRFS_FS_NEED_ASYNC_COMMIT, &fs_info->flags);
23012300

23022301
spin_lock(&fs_info->trans_lock);
23032302
list_del_init(&cur_trans->list);

fs/btrfs/transaction.h

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -207,20 +207,6 @@ int btrfs_clean_one_deleted_snapshot(struct btrfs_root *root);
207207
int btrfs_commit_transaction(struct btrfs_trans_handle *trans);
208208
int btrfs_commit_transaction_async(struct btrfs_trans_handle *trans,
209209
int wait_for_unblock);
210-
211-
/*
212-
* Try to commit transaction asynchronously, so this is safe to call
213-
* even holding a spinlock.
214-
*
215-
* It's done by informing transaction_kthread to commit transaction without
216-
* waiting for commit interval.
217-
*/
218-
static inline void btrfs_commit_transaction_locksafe(
219-
struct btrfs_fs_info *fs_info)
220-
{
221-
set_bit(BTRFS_FS_NEED_ASYNC_COMMIT, &fs_info->flags);
222-
wake_up_process(fs_info->transaction_kthread);
223-
}
224210
int btrfs_end_transaction_throttle(struct btrfs_trans_handle *trans);
225211
int btrfs_should_end_transaction(struct btrfs_trans_handle *trans);
226212
void btrfs_throttle(struct btrfs_fs_info *fs_info);

0 commit comments

Comments
 (0)