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()
1865 struct btrfs_qgroup *qg; in qgroup_update_refcnt() local
1872 qg = find_qgroup_rb(fs_info, unode->val); in qgroup_update_refcnt()
1873 if (!qg) in qgroup_update_refcnt()
1877 ret = ulist_add(qgroups, qg->qgroupid, qgroup_to_aux(qg), in qgroup_update_refcnt()
1881 ret = ulist_add(tmp, qg->qgroupid, qgroup_to_aux(qg), GFP_ATOMIC); in qgroup_update_refcnt()
1888 qg = unode_aux_to_qgroup(tmp_unode); in qgroup_update_refcnt()
1890 btrfs_qgroup_update_old_refcnt(qg, seq, 1); in qgroup_update_refcnt()
1892 btrfs_qgroup_update_new_refcnt(qg, seq, 1); in qgroup_update_refcnt()
1893 list_for_each_entry(glist, &qg->groups, next_group) { in qgroup_update_refcnt()
1954 struct btrfs_qgroup *qg; in qgroup_update_counters() local
1961 qg = unode_aux_to_qgroup(unode); in qgroup_update_counters()
1962 cur_old_count = btrfs_qgroup_get_old_refcnt(qg, seq); in qgroup_update_counters()
1963 cur_new_count = btrfs_qgroup_get_new_refcnt(qg, seq); in qgroup_update_counters()
1965 trace_qgroup_update_counters(fs_info, qg, cur_old_count, in qgroup_update_counters()
1970 qg->rfer += num_bytes; in qgroup_update_counters()
1971 qg->rfer_cmpr += num_bytes; in qgroup_update_counters()
1975 qg->rfer -= num_bytes; in qgroup_update_counters()
1976 qg->rfer_cmpr -= num_bytes; in qgroup_update_counters()
1986 qg->excl -= num_bytes; in qgroup_update_counters()
1987 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()
2011 qg->excl += num_bytes; in qgroup_update_counters()
2012 qg->excl_cmpr += num_bytes; in qgroup_update_counters()
2021 qg->excl -= num_bytes; in qgroup_update_counters()
2022 qg->excl_cmpr -= num_bytes; in qgroup_update_counters()
2030 qgroup_dirty(fs_info, qg); in qgroup_update_counters()
2485 const struct btrfs_qgroup *qg, u64 num_bytes) in qgroup_check_limits() argument
2490 if ((qg->lim_flags & BTRFS_QGROUP_LIMIT_MAX_RFER) && in qgroup_check_limits()
2491 qgroup_rsv_total(qg) + (s64)qg->rfer + num_bytes > qg->max_rfer) in qgroup_check_limits()
2494 if ((qg->lim_flags & BTRFS_QGROUP_LIMIT_MAX_EXCL) && in qgroup_check_limits()
2495 qgroup_rsv_total(qg) + (s64)qg->excl + num_bytes > qg->max_excl) in qgroup_check_limits()
2504 if ((qg->lim_flags & (BTRFS_QGROUP_LIMIT_MAX_RFER | in qgroup_check_limits()
2506 if (qg->lim_flags & BTRFS_QGROUP_LIMIT_MAX_EXCL) { in qgroup_check_limits()
2507 free = qg->max_excl - qgroup_rsv_total(qg) - qg->excl; in qgroup_check_limits()
2508 threshold = min_t(u64, qg->max_excl / QGROUP_FREE_RATIO, in qgroup_check_limits()
2511 free = qg->max_rfer - qgroup_rsv_total(qg) - qg->rfer; in qgroup_check_limits()
2512 threshold = min_t(u64, qg->max_rfer / QGROUP_FREE_RATIO, in qgroup_check_limits()
2568 struct btrfs_qgroup *qg; in qgroup_reserve() local
2571 qg = unode_aux_to_qgroup(unode); in qgroup_reserve()
2573 if (enforce && !qgroup_check_limits(fs_info, qg, num_bytes)) { in qgroup_reserve()
2578 list_for_each_entry(glist, &qg->groups, next_group) { in qgroup_reserve()
2592 struct btrfs_qgroup *qg; in qgroup_reserve() local
2594 qg = unode_aux_to_qgroup(unode); in qgroup_reserve()
2596 trace_qgroup_update_reserve(fs_info, qg, num_bytes, type); in qgroup_reserve()
2597 qgroup_rsv_add(fs_info, qg, num_bytes, type); in qgroup_reserve()
2658 struct btrfs_qgroup *qg; in btrfs_qgroup_free_refroot() local
2661 qg = unode_aux_to_qgroup(unode); in btrfs_qgroup_free_refroot()
2663 trace_qgroup_update_reserve(fs_info, qg, -(s64)num_bytes, type); in btrfs_qgroup_free_refroot()
2664 qgroup_rsv_release(fs_info, qg, num_bytes, type); in btrfs_qgroup_free_refroot()
2666 list_for_each_entry(glist, &qg->groups, next_group) { in btrfs_qgroup_free_refroot()
3380 struct btrfs_qgroup *qg; in qgroup_convert_meta() local
3383 qg = unode_aux_to_qgroup(unode); in qgroup_convert_meta()
3385 qgroup_rsv_release(fs_info, qg, num_bytes, in qgroup_convert_meta()
3387 qgroup_rsv_add(fs_info, qg, num_bytes, in qgroup_convert_meta()
3389 list_for_each_entry(glist, &qg->groups, next_group) { in qgroup_convert_meta()