aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/qgroup.c
diff options
context:
space:
mode:
authorDavid Sterba <DSterba@suse.com>2016-10-26 10:23:50 -0400
committerDavid Sterba <dsterba@suse.com>2016-11-30 07:45:15 -0500
commitef2fff64fd541af1e23eeae48d6ffdfcd92ae2a3 (patch)
tree9c3b5da4daae59409708325557185b3f87030cc0 /fs/btrfs/qgroup.c
parent5d9dbe617a9e4e85c5fc9790c354cec903b88b57 (diff)
btrfs: rename helper macros for qgroup and aux data casts
The helpers are not meant to be generic, the name is misleading. Convert them to static inlines for type checking. Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs/qgroup.c')
-rw-r--r--fs/btrfs/qgroup.c35
1 files changed, 21 insertions, 14 deletions
diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c
index 11f4fffe503e..50b32cb25bdb 100644
--- a/fs/btrfs/qgroup.c
+++ b/fs/btrfs/qgroup.c
@@ -131,8 +131,15 @@ struct btrfs_qgroup_list {
131 struct btrfs_qgroup *member; 131 struct btrfs_qgroup *member;
132}; 132};
133 133
134#define ptr_to_u64(x) ((u64)(uintptr_t)x) 134static inline u64 qgroup_to_aux(struct btrfs_qgroup *qg)
135#define u64_to_ptr(x) ((struct btrfs_qgroup *)(uintptr_t)x) 135{
136 return (u64)(uintptr_t)qg;
137}
138
139static inline struct btrfs_qgroup* unode_aux_to_qgroup(struct ulist_node *n)
140{
141 return (struct btrfs_qgroup *)(uintptr_t)n->aux;
142}
136 143
137static int 144static int
138qgroup_rescan_init(struct btrfs_fs_info *fs_info, u64 progress_objectid, 145qgroup_rescan_init(struct btrfs_fs_info *fs_info, u64 progress_objectid,
@@ -1066,7 +1073,7 @@ static int __qgroup_excl_accounting(struct btrfs_fs_info *fs_info,
1066 /* Get all of the parent groups that contain this qgroup */ 1073 /* Get all of the parent groups that contain this qgroup */
1067 list_for_each_entry(glist, &qgroup->groups, next_group) { 1074 list_for_each_entry(glist, &qgroup->groups, next_group) {
1068 ret = ulist_add(tmp, glist->group->qgroupid, 1075 ret = ulist_add(tmp, glist->group->qgroupid,
1069 ptr_to_u64(glist->group), GFP_ATOMIC); 1076 qgroup_to_aux(glist->group), GFP_ATOMIC);
1070 if (ret < 0) 1077 if (ret < 0)
1071 goto out; 1078 goto out;
1072 } 1079 }
@@ -1074,7 +1081,7 @@ static int __qgroup_excl_accounting(struct btrfs_fs_info *fs_info,
1074 /* Iterate all of the parents and adjust their reference counts */ 1081 /* Iterate all of the parents and adjust their reference counts */
1075 ULIST_ITER_INIT(&uiter); 1082 ULIST_ITER_INIT(&uiter);
1076 while ((unode = ulist_next(tmp, &uiter))) { 1083 while ((unode = ulist_next(tmp, &uiter))) {
1077 qgroup = u64_to_ptr(unode->aux); 1084 qgroup = unode_aux_to_qgroup(unode);
1078 qgroup->rfer += sign * num_bytes; 1085 qgroup->rfer += sign * num_bytes;
1079 qgroup->rfer_cmpr += sign * num_bytes; 1086 qgroup->rfer_cmpr += sign * num_bytes;
1080 WARN_ON(sign < 0 && qgroup->excl < num_bytes); 1087 WARN_ON(sign < 0 && qgroup->excl < num_bytes);
@@ -1087,7 +1094,7 @@ static int __qgroup_excl_accounting(struct btrfs_fs_info *fs_info,
1087 /* Add any parents of the parents */ 1094 /* Add any parents of the parents */
1088 list_for_each_entry(glist, &qgroup->groups, next_group) { 1095 list_for_each_entry(glist, &qgroup->groups, next_group) {
1089 ret = ulist_add(tmp, glist->group->qgroupid, 1096 ret = ulist_add(tmp, glist->group->qgroupid,
1090 ptr_to_u64(glist->group), GFP_ATOMIC); 1097 qgroup_to_aux(glist->group), GFP_ATOMIC);
1091 if (ret < 0) 1098 if (ret < 0)
1092 goto out; 1099 goto out;
1093 } 1100 }
@@ -1535,30 +1542,30 @@ static int qgroup_update_refcnt(struct btrfs_fs_info *fs_info,
1535 continue; 1542 continue;
1536 1543
1537 ulist_reinit(tmp); 1544 ulist_reinit(tmp);
1538 ret = ulist_add(qgroups, qg->qgroupid, ptr_to_u64(qg), 1545 ret = ulist_add(qgroups, qg->qgroupid, qgroup_to_aux(qg),
1539 GFP_ATOMIC); 1546 GFP_ATOMIC);
1540 if (ret < 0) 1547 if (ret < 0)
1541 return ret; 1548 return ret;
1542 ret = ulist_add(tmp, qg->qgroupid, ptr_to_u64(qg), GFP_ATOMIC); 1549 ret = ulist_add(tmp, qg->qgroupid, qgroup_to_aux(qg), GFP_ATOMIC);
1543 if (ret < 0) 1550 if (ret < 0)
1544 return ret; 1551 return ret;
1545 ULIST_ITER_INIT(&tmp_uiter); 1552 ULIST_ITER_INIT(&tmp_uiter);
1546 while ((tmp_unode = ulist_next(tmp, &tmp_uiter))) { 1553 while ((tmp_unode = ulist_next(tmp, &tmp_uiter))) {
1547 struct btrfs_qgroup_list *glist; 1554 struct btrfs_qgroup_list *glist;
1548 1555
1549 qg = u64_to_ptr(tmp_unode->aux); 1556 qg = unode_aux_to_qgroup(tmp_unode);
1550 if (update_old) 1557 if (update_old)
1551 btrfs_qgroup_update_old_refcnt(qg, seq, 1); 1558 btrfs_qgroup_update_old_refcnt(qg, seq, 1);
1552 else 1559 else
1553 btrfs_qgroup_update_new_refcnt(qg, seq, 1); 1560 btrfs_qgroup_update_new_refcnt(qg, seq, 1);
1554 list_for_each_entry(glist, &qg->groups, next_group) { 1561 list_for_each_entry(glist, &qg->groups, next_group) {
1555 ret = ulist_add(qgroups, glist->group->qgroupid, 1562 ret = ulist_add(qgroups, glist->group->qgroupid,
1556 ptr_to_u64(glist->group), 1563 qgroup_to_aux(glist->group),
1557 GFP_ATOMIC); 1564 GFP_ATOMIC);
1558 if (ret < 0) 1565 if (ret < 0)
1559 return ret; 1566 return ret;
1560 ret = ulist_add(tmp, glist->group->qgroupid, 1567 ret = ulist_add(tmp, glist->group->qgroupid,
1561 ptr_to_u64(glist->group), 1568 qgroup_to_aux(glist->group),
1562 GFP_ATOMIC); 1569 GFP_ATOMIC);
1563 if (ret < 0) 1570 if (ret < 0)
1564 return ret; 1571 return ret;
@@ -1619,7 +1626,7 @@ static int qgroup_update_counters(struct btrfs_fs_info *fs_info,
1619 while ((unode = ulist_next(qgroups, &uiter))) { 1626 while ((unode = ulist_next(qgroups, &uiter))) {
1620 bool dirty = false; 1627 bool dirty = false;
1621 1628
1622 qg = u64_to_ptr(unode->aux); 1629 qg = unode_aux_to_qgroup(unode);
1623 cur_old_count = btrfs_qgroup_get_old_refcnt(qg, seq); 1630 cur_old_count = btrfs_qgroup_get_old_refcnt(qg, seq);
1624 cur_new_count = btrfs_qgroup_get_new_refcnt(qg, seq); 1631 cur_new_count = btrfs_qgroup_get_new_refcnt(qg, seq);
1625 1632
@@ -2125,7 +2132,7 @@ static int qgroup_reserve(struct btrfs_root *root, u64 num_bytes)
2125 struct btrfs_qgroup *qg; 2132 struct btrfs_qgroup *qg;
2126 struct btrfs_qgroup_list *glist; 2133 struct btrfs_qgroup_list *glist;
2127 2134
2128 qg = u64_to_ptr(unode->aux); 2135 qg = unode_aux_to_qgroup(unode);
2129 2136
2130 if ((qg->lim_flags & BTRFS_QGROUP_LIMIT_MAX_RFER) && 2137 if ((qg->lim_flags & BTRFS_QGROUP_LIMIT_MAX_RFER) &&
2131 qg->reserved + (s64)qg->rfer + num_bytes > 2138 qg->reserved + (s64)qg->rfer + num_bytes >
@@ -2157,7 +2164,7 @@ static int qgroup_reserve(struct btrfs_root *root, u64 num_bytes)
2157 while ((unode = ulist_next(fs_info->qgroup_ulist, &uiter))) { 2164 while ((unode = ulist_next(fs_info->qgroup_ulist, &uiter))) {
2158 struct btrfs_qgroup *qg; 2165 struct btrfs_qgroup *qg;
2159 2166
2160 qg = u64_to_ptr(unode->aux); 2167 qg = unode_aux_to_qgroup(unode);
2161 2168
2162 qg->reserved += num_bytes; 2169 qg->reserved += num_bytes;
2163 } 2170 }
@@ -2202,7 +2209,7 @@ void btrfs_qgroup_free_refroot(struct btrfs_fs_info *fs_info,
2202 struct btrfs_qgroup *qg; 2209 struct btrfs_qgroup *qg;
2203 struct btrfs_qgroup_list *glist; 2210 struct btrfs_qgroup_list *glist;
2204 2211
2205 qg = u64_to_ptr(unode->aux); 2212 qg = unode_aux_to_qgroup(unode);
2206 2213
2207 qg->reserved -= num_bytes; 2214 qg->reserved -= num_bytes;
2208 2215