Lines Matching refs:qg
114 static void btrfs_qgroup_update_old_refcnt(struct btrfs_qgroup *qg, u64 seq, in btrfs_qgroup_update_old_refcnt() argument
117 if (qg->old_refcnt < seq) in btrfs_qgroup_update_old_refcnt()
118 qg->old_refcnt = seq; in btrfs_qgroup_update_old_refcnt()
119 qg->old_refcnt += mod; in btrfs_qgroup_update_old_refcnt()
122 static void btrfs_qgroup_update_new_refcnt(struct btrfs_qgroup *qg, u64 seq, in btrfs_qgroup_update_new_refcnt() argument
125 if (qg->new_refcnt < seq) in btrfs_qgroup_update_new_refcnt()
126 qg->new_refcnt = seq; in btrfs_qgroup_update_new_refcnt()
127 qg->new_refcnt += mod; in btrfs_qgroup_update_new_refcnt()
130 static inline u64 btrfs_qgroup_get_old_refcnt(struct btrfs_qgroup *qg, u64 seq) in btrfs_qgroup_get_old_refcnt() argument
132 if (qg->old_refcnt < seq) in btrfs_qgroup_get_old_refcnt()
134 return qg->old_refcnt - seq; in btrfs_qgroup_get_old_refcnt()
137 static inline u64 btrfs_qgroup_get_new_refcnt(struct btrfs_qgroup *qg, u64 seq) in btrfs_qgroup_get_new_refcnt() argument
139 if (qg->new_refcnt < seq) in btrfs_qgroup_get_new_refcnt()
141 return qg->new_refcnt - seq; in btrfs_qgroup_get_new_refcnt()
154 static inline u64 qgroup_to_aux(struct btrfs_qgroup *qg) in qgroup_to_aux() argument
156 return (u64)(uintptr_t)qg; in qgroup_to_aux()
1841 struct btrfs_qgroup *qg; in qgroup_update_refcnt() local
1848 qg = find_qgroup_rb(fs_info, unode->val); in qgroup_update_refcnt()
1849 if (!qg) in qgroup_update_refcnt()
1853 ret = ulist_add(qgroups, qg->qgroupid, qgroup_to_aux(qg), in qgroup_update_refcnt()
1857 ret = ulist_add(tmp, qg->qgroupid, qgroup_to_aux(qg), GFP_ATOMIC); in qgroup_update_refcnt()
1864 qg = unode_aux_to_qgroup(tmp_unode); in qgroup_update_refcnt()
1866 btrfs_qgroup_update_old_refcnt(qg, seq, 1); in qgroup_update_refcnt()
1868 btrfs_qgroup_update_new_refcnt(qg, seq, 1); in qgroup_update_refcnt()
1869 list_for_each_entry(glist, &qg->groups, next_group) { in qgroup_update_refcnt()
1930 struct btrfs_qgroup *qg; in qgroup_update_counters() local
1937 qg = unode_aux_to_qgroup(unode); in qgroup_update_counters()
1938 cur_old_count = btrfs_qgroup_get_old_refcnt(qg, seq); in qgroup_update_counters()
1939 cur_new_count = btrfs_qgroup_get_new_refcnt(qg, seq); in qgroup_update_counters()
1941 trace_qgroup_update_counters(fs_info, qg, cur_old_count, in qgroup_update_counters()
1946 qg->rfer += num_bytes; in qgroup_update_counters()
1947 qg->rfer_cmpr += num_bytes; in qgroup_update_counters()
1951 qg->rfer -= num_bytes; in qgroup_update_counters()
1952 qg->rfer_cmpr -= num_bytes; in qgroup_update_counters()
1962 qg->excl -= num_bytes; in qgroup_update_counters()
1963 qg->excl_cmpr -= num_bytes; in qgroup_update_counters()
1973 qg->excl += num_bytes; in qgroup_update_counters()
1974 qg->excl_cmpr += num_bytes; in qgroup_update_counters()
1987 qg->excl += num_bytes; in qgroup_update_counters()
1988 qg->excl_cmpr += num_bytes; in qgroup_update_counters()
1997 qg->excl -= num_bytes; in qgroup_update_counters()
1998 qg->excl_cmpr -= num_bytes; in qgroup_update_counters()
2006 qgroup_dirty(fs_info, qg); in qgroup_update_counters()
2430 const struct btrfs_qgroup *qg, u64 num_bytes) in qgroup_check_limits() argument
2435 if ((qg->lim_flags & BTRFS_QGROUP_LIMIT_MAX_RFER) && in qgroup_check_limits()
2436 qgroup_rsv_total(qg) + (s64)qg->rfer + num_bytes > qg->max_rfer) in qgroup_check_limits()
2439 if ((qg->lim_flags & BTRFS_QGROUP_LIMIT_MAX_EXCL) && in qgroup_check_limits()
2440 qgroup_rsv_total(qg) + (s64)qg->excl + num_bytes > qg->max_excl) in qgroup_check_limits()
2449 if ((qg->lim_flags & (BTRFS_QGROUP_LIMIT_MAX_RFER | in qgroup_check_limits()
2451 if (qg->lim_flags & BTRFS_QGROUP_LIMIT_MAX_EXCL) in qgroup_check_limits()
2452 limit = qg->max_excl; in qgroup_check_limits()
2454 limit = qg->max_rfer; in qgroup_check_limits()
2455 threshold = (limit - qg->rsv.values[BTRFS_QGROUP_RSV_DATA] - in qgroup_check_limits()
2456 qg->rsv.values[BTRFS_QGROUP_RSV_META_PREALLOC]) / in qgroup_check_limits()
2464 if (qg->rsv.values[BTRFS_QGROUP_RSV_META_PERTRANS] > threshold) in qgroup_check_limits()
2512 struct btrfs_qgroup *qg; in qgroup_reserve() local
2515 qg = unode_aux_to_qgroup(unode); in qgroup_reserve()
2517 if (enforce && !qgroup_check_limits(fs_info, qg, num_bytes)) { in qgroup_reserve()
2522 list_for_each_entry(glist, &qg->groups, next_group) { in qgroup_reserve()
2536 struct btrfs_qgroup *qg; in qgroup_reserve() local
2538 qg = unode_aux_to_qgroup(unode); in qgroup_reserve()
2540 trace_qgroup_update_reserve(fs_info, qg, num_bytes, type); in qgroup_reserve()
2541 qgroup_rsv_add(fs_info, qg, num_bytes, type); in qgroup_reserve()
2602 struct btrfs_qgroup *qg; in btrfs_qgroup_free_refroot() local
2605 qg = unode_aux_to_qgroup(unode); in btrfs_qgroup_free_refroot()
2607 trace_qgroup_update_reserve(fs_info, qg, -(s64)num_bytes, type); in btrfs_qgroup_free_refroot()
2608 qgroup_rsv_release(fs_info, qg, num_bytes, type); in btrfs_qgroup_free_refroot()
2610 list_for_each_entry(glist, &qg->groups, next_group) { in btrfs_qgroup_free_refroot()
3298 struct btrfs_qgroup *qg; in qgroup_convert_meta() local
3301 qg = unode_aux_to_qgroup(unode); in qgroup_convert_meta()
3303 qgroup_rsv_release(fs_info, qg, num_bytes, in qgroup_convert_meta()
3305 qgroup_rsv_add(fs_info, qg, num_bytes, in qgroup_convert_meta()
3307 list_for_each_entry(glist, &qg->groups, next_group) { in qgroup_convert_meta()