*/
#define BTRFS_SPACE_INFO_GLOBAL_RSV (1ULL << 49)
-#define BTRFS_QGROUP_STATUS_OFF 0
-#define BTRFS_QGROUP_STATUS_ON 1
-#define BTRFS_QGROUP_STATUS_SCANNING 2
+#define BTRFS_QGROUP_LEVEL_SHIFT 48
-#define BTRFS_QGROUP_STATUS_FLAG_INCONSISTENT (1 << 0)
+static inline u64 btrfs_qgroup_level(u64 qgroupid)
+{
+ return qgroupid >> BTRFS_QGROUP_LEVEL_SHIFT;
+}
+
+static inline u64 btrfs_qgroup_subvid(u64 qgroupid)
+{
+ return qgroupid & ((1ULL << BTRFS_QGROUP_LEVEL_SHIFT) - 1);
+}
+
+#define BTRFS_QGROUP_STATUS_FLAG_ON (1ULL << 0)
+#define BTRFS_QGROUP_STATUS_FLAG_RESCAN (1ULL << 1)
+#define BTRFS_QGROUP_STATUS_FLAG_INCONSISTENT (1ULL << 2)
struct btrfs_qgroup_status_item {
__le64 version;
printf("%llu", (unsigned long long)objectid); /* device id */
return;
case BTRFS_QGROUP_RELATION_KEY:
- printf("%llu/%llu", objectid >> 48,
- objectid & ((1ll << 48) - 1));
+ printf("%llu/%llu", btrfs_qgroup_level(objectid),
+ btrfs_qgroup_subvid(objectid));
return;
case BTRFS_UUID_KEY_SUBVOL:
case BTRFS_UUID_KEY_RECEIVED_SUBVOL:
case BTRFS_QGROUP_RELATION_KEY:
case BTRFS_QGROUP_INFO_KEY:
case BTRFS_QGROUP_LIMIT_KEY:
- printf(" %llu/%llu)", (unsigned long long)(offset >> 48),
- (unsigned long long)(offset & ((1ll << 48) - 1)));
+ printf(" %llu/%llu)", btrfs_qgroup_level(offset),
+ btrfs_qgroup_subvid(offset));
break;
case BTRFS_UUID_KEY_SUBVOL:
case BTRFS_UUID_KEY_RECEIVED_SUBVOL:
int len = 0;
list_for_each_entry(list, &qgroup->qgroups, next_qgroup) {
- len += printf("%llu/%llu", (list->qgroup)->qgroupid >> 48,
- ((1ll << 48) - 1) & (list->qgroup)->qgroupid);
+ len += printf("%llu/%llu",
+ btrfs_qgroup_level(list->qgroup->qgroupid),
+ btrfs_qgroup_subvid(list->qgroup->qgroupid));
if (!list_is_last(&list->next_qgroup, &qgroup->qgroups))
len += printf(",");
}
int len = 0;
list_for_each_entry(list, &qgroup->members, next_member) {
- len += printf("%llu/%llu", (list->member)->qgroupid >> 48,
- ((1ll << 48) - 1) & (list->member)->qgroupid);
+ len += printf("%llu/%llu",
+ btrfs_qgroup_level(list->member->qgroupid),
+ btrfs_qgroup_subvid(list->member->qgroupid));
if (!list_is_last(&list->next_member, &qgroup->members))
len += printf(",");
}
switch (column) {
case BTRFS_QGROUP_QGROUPID:
- len = printf("%llu/%llu", qgroup->qgroupid >> 48,
- ((1ll << 48) - 1) & qgroup->qgroupid);
+ len = printf("%llu/%llu",
+ btrfs_qgroup_level(qgroup->qgroupid),
+ btrfs_qgroup_subvid(qgroup->qgroupid));
print_qgroup_column_add_blank(BTRFS_QGROUP_QGROUPID, len);
break;
case BTRFS_QGROUP_RFER:
switch (column) {
case BTRFS_QGROUP_QGROUPID:
- sprintf(tmp, "%llu/%llu", (bq->qgroupid >> 48),
- bq->qgroupid & ((1ll << 48) - 1));
+ sprintf(tmp, "%llu/%llu",
+ btrfs_qgroup_level(bq->qgroupid),
+ btrfs_qgroup_subvid(bq->qgroupid));
len = strlen(tmp);
if (btrfs_qgroup_columns[column].max_len < len)
btrfs_qgroup_columns[column].max_len = len;
len = 0;
list_for_each_entry(list, &bq->qgroups, next_qgroup) {
len += sprintf(tmp, "%llu/%llu",
- (list->qgroup)->qgroupid >> 48,
- ((1ll << 48) - 1) & (list->qgroup)->qgroupid);
+ btrfs_qgroup_level(list->qgroup->qgroupid),
+ btrfs_qgroup_subvid(list->qgroup->qgroupid));
if (!list_is_last(&list->next_qgroup, &bq->qgroups))
len += 1;
}
len = 0;
list_for_each_entry(list, &bq->members, next_member) {
len += sprintf(tmp, "%llu/%llu",
- (list->member)->qgroupid >> 48,
- ((1ll << 48) - 1) & (list->member)->qgroupid);
+ btrfs_qgroup_level(list->member->qgroupid),
+ btrfs_qgroup_subvid(list->member->qgroupid));
if (!list_is_last(&list->next_member, &bq->members))
len += 1;
}