History

btrfs: qgroup: remove ASYNC_COMMIT mechanism in favor of reserve retry-after-EDQUOT

commit a514d63882c3 ("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.

Qu Wenruo committed 6 years ago

Commit adca4d91 parent c53e9655 files · +2 −62Browse files

Unified · Split

5 files
  1. fs/btrfs/ctree.h +0 −5
  2. fs/btrfs/disk-io.c +0 −1
  3. fs/btrfs/qgroup.c +2 −41
  4. fs/btrfs/transaction.c +0 −1
  5. fs/btrfs/transaction.h +0 −14
fs/btrfs/ctree.h+0−5
@@ -545,11 +545,6 @@ enum { · 544 unmodified lines
545545 * (device replace, resize, device add/delete, balance)
546546 */
547547 BTRFS_FS_EXCL_OP,
548− /*
549− * To info transaction_kthread we need an immediate commit so it
550− * doesn't need to wait for commit_interval
551− */
552− BTRFS_FS_NEED_ASYNC_COMMIT,
553548 /*
554549 * Indicate that balance has been set up from the ioctl and is in the
555550 * main phase. The fs_info::balance_ctl is initialized.
fs/btrfs/disk-io.c+0−1
@@ -1810,7 +1810,6 @@ static int transaction_kthread(void *arg) · 1809 unmodified lines
18101810
18111811 now = ktime_get_seconds();
18121812 if (cur->state < TRANS_STATE_COMMIT_START &&
1813− !test_bit(BTRFS_FS_NEED_ASYNC_COMMIT, &fs_info->flags) &&
18141813 (now < cur->start_time ||
18151814 now - cur->start_time < fs_info->commit_interval)) {
18161815 spin_unlock(&fs_info->trans_lock);
fs/btrfs/qgroup.c+2−41
@@ -11,7 +11,6 @@ · 10 unmodified lines
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"
@@ -2895,20 +2894,8 @@ out: · 2877 unmodified lines
28952894 return ret;
28962895 }
28972896
2898−/*
2899− * Two limits to commit transaction in advance.
2900− *
2901− * For RATIO, it will be 1/RATIO of the remaining limit as threshold.
2902− * For SIZE, it will be in byte unit as threshold.
2903− */
2904−#define QGROUP_FREE_RATIO 32
2905−#define QGROUP_FREE_SIZE SZ_32M
2906−static bool qgroup_check_limits(struct btrfs_fs_info *fs_info,
2907− const struct btrfs_qgroup *qg, u64 num_bytes)
2897+static bool qgroup_check_limits(const struct btrfs_qgroup *qg, u64 num_bytes)
29082898 {
2909− u64 free;
2910− u64 threshold;
2911−
29122899 if ((qg->lim_flags & BTRFS_QGROUP_LIMIT_MAX_RFER) &&
29132900 qgroup_rsv_total(qg) + (s64)qg->rfer + num_bytes > qg->max_rfer)
29142901 return false;
@@ -2917,32 +2904,6 @@ static bool qgroup_check_limits(struct btrfs_fs_info *fs_info, · 2 unmodified lines
29172904 qgroup_rsv_total(qg) + (s64)qg->excl + num_bytes > qg->max_excl)
29182905 return false;
29192906
2920− /*
2921− * Even if we passed the check, it's better to check if reservation
2922− * for meta_pertrans is pushing us near limit.
2923− * If there is too much pertrans reservation or it's near the limit,
2924− * let's try commit transaction to free some, using transaction_kthread
2925− */
2926− if ((qg->lim_flags & (BTRFS_QGROUP_LIMIT_MAX_RFER |
2927− BTRFS_QGROUP_LIMIT_MAX_EXCL))) {
2928− if (qg->lim_flags & BTRFS_QGROUP_LIMIT_MAX_EXCL) {
2929− free = qg->max_excl - qgroup_rsv_total(qg) - qg->excl;
2930− threshold = min_t(u64, qg->max_excl / QGROUP_FREE_RATIO,
2931− QGROUP_FREE_SIZE);
2932− } else {
2933− free = qg->max_rfer - qgroup_rsv_total(qg) - qg->rfer;
2934− threshold = min_t(u64, qg->max_rfer / QGROUP_FREE_RATIO,
2935− QGROUP_FREE_SIZE);
2936− }
2937−
2938− /*
2939− * Use transaction_kthread to commit transaction, so we no
2940− * longer need to bother nested transaction nor lock context.
2941− */
2942− if (free < threshold)
2943− btrfs_commit_transaction_locksafe(fs_info);
2944− }
2945−
29462907 return true;
29472908 }
29482909
@@ -2990,7 +2951,7 @@ static int qgroup_reserve(struct btrfs_root *root, u64 num_bytes, bool enforce, · 41 unmodified lines
29902951
29912952 qg = unode_aux_to_qgroup(unode);
29922953
2993− if (enforce && !qgroup_check_limits(fs_info, qg, num_bytes)) {
2954+ if (enforce && !qgroup_check_limits(qg, num_bytes)) {
29942955 ret = -EDQUOT;
29952956 goto out;
29962957 }
fs/btrfs/transaction.c+0−1
@@ -2351,7 +2351,6 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans) · 2350 unmodified lines
23512351 */
23522352 cur_trans->state = TRANS_STATE_COMPLETED;
23532353 wake_up(&cur_trans->commit_wait);
2354− clear_bit(BTRFS_FS_NEED_ASYNC_COMMIT, &fs_info->flags);
23552354
23562355 spin_lock(&fs_info->trans_lock);
23572356 list_del_init(&cur_trans->list);
fs/btrfs/transaction.h+0−14
@@ -210,20 +210,6 @@ int btrfs_clean_one_deleted_snapshot(struct btrfs_root *root); · 209 unmodified lines
210210 int btrfs_commit_transaction(struct btrfs_trans_handle *trans);
211211 int btrfs_commit_transaction_async(struct btrfs_trans_handle *trans,
212212 int wait_for_unblock);
213−
214−/*
215− * Try to commit transaction asynchronously, so this is safe to call
216− * even holding a spinlock.
217− *
218− * It's done by informing transaction_kthread to commit transaction without
219− * waiting for commit interval.
220− */
221−static inline void btrfs_commit_transaction_locksafe(
222− struct btrfs_fs_info *fs_info)
223−{
224− set_bit(BTRFS_FS_NEED_ASYNC_COMMIT, &fs_info->flags);
225− wake_up_process(fs_info->transaction_kthread);
226−}
227213 int btrfs_end_transaction_throttle(struct btrfs_trans_handle *trans);
228214 int btrfs_should_end_transaction(struct btrfs_trans_handle *trans);
229215 void btrfs_throttle(struct btrfs_fs_info *fs_info);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t