btrfs-progs: unify naming of qgroup subvolid helpers

Kernel function name is btrfs_qgroup_subvolid so rename it in progs. The
libbtrfs can't API be changed without versioning so at least add the new
helper.

Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
David Sterba 2022-10-26 09:36:44 +02:00
parent 5b2889853a
commit 44efde7fa0
5 changed files with 23 additions and 18 deletions

View File

@ -493,7 +493,7 @@ static int account_one_extent(struct ulist *roots, u64 bytenr, u64 num_bytes)
printf("account (%llu, %llu), qgroup %llu/%llu, rfer %llu,"
" excl %llu, refs %llu, roots %llu\n", bytenr, num_bytes,
btrfs_qgroup_level(count->qgroupid),
btrfs_qgroup_subvid(count->qgroupid),
btrfs_qgroup_subvolid(count->qgroupid),
count->info.referenced, count->info.exclusive, nr_refs,
nr_roots);
#endif
@ -1294,7 +1294,7 @@ static int report_qgroup_difference(struct qgroup_count *count, int verbose)
if (verbose || (is_different && qgroup_printable(count))) {
printf("Counts for qgroup id: %llu/%llu %s\n",
btrfs_qgroup_level(count->qgroupid),
btrfs_qgroup_subvid(count->qgroupid),
btrfs_qgroup_subvolid(count->qgroupid),
is_different ? "are different" : "");
print_fields(info->referenced, info->referenced_compressed,
@ -1568,7 +1568,7 @@ static int repair_qgroup_info(struct btrfs_fs_info *info,
if (!silent)
printf("Repair qgroup %llu/%llu\n",
btrfs_qgroup_level(count->qgroupid),
btrfs_qgroup_subvid(count->qgroupid));
btrfs_qgroup_subvolid(count->qgroupid));
trans = btrfs_start_transaction(root, 1);
if (IS_ERR(trans))
@ -1582,7 +1582,7 @@ static int repair_qgroup_info(struct btrfs_fs_info *info,
if (ret) {
error("could not find disk item for qgroup %llu/%llu",
btrfs_qgroup_level(count->qgroupid),
btrfs_qgroup_subvid(count->qgroupid));
btrfs_qgroup_subvolid(count->qgroupid));
if (ret > 0)
ret = -ENOENT;
goto out;

View File

@ -247,7 +247,7 @@ static int print_parent_column(struct btrfs_qgroup *qgroup)
list_for_each_entry(list, &qgroup->qgroups, next_qgroup) {
len += printf("%llu/%llu",
btrfs_qgroup_level(list->qgroup->qgroupid),
btrfs_qgroup_subvid(list->qgroup->qgroupid));
btrfs_qgroup_subvolid(list->qgroup->qgroupid));
if (!list_is_last(&list->next_qgroup, &qgroup->qgroups))
len += printf(",");
}
@ -265,7 +265,7 @@ static int print_child_column(struct btrfs_qgroup *qgroup)
list_for_each_entry(list, &qgroup->members, next_member) {
len += printf("%llu/%llu",
btrfs_qgroup_level(list->member->qgroupid),
btrfs_qgroup_subvid(list->member->qgroupid));
btrfs_qgroup_subvolid(list->member->qgroupid));
if (!list_is_last(&list->next_member, &qgroup->members))
len += printf(",");
}
@ -300,7 +300,7 @@ void print_path_column(struct btrfs_qgroup *qgroup)
struct btrfs_qgroup *member = list->qgroup;
u64 qgroupid = member->qgroupid;
u64 level = btrfs_qgroup_level(qgroupid);
u64 sid = btrfs_qgroup_subvid(qgroupid);
u64 sid = btrfs_qgroup_subvolid(qgroupid);
if (count)
pr_verbose(LOG_DEFAULT, " ");
@ -338,7 +338,7 @@ static void print_qgroup_column(struct btrfs_qgroup *qgroup,
case BTRFS_QGROUP_QGROUPID:
len = printf("%llu/%llu",
btrfs_qgroup_level(qgroup->qgroupid),
btrfs_qgroup_subvid(qgroup->qgroupid));
btrfs_qgroup_subvolid(qgroup->qgroupid));
print_qgroup_column_add_blank(BTRFS_QGROUP_QGROUPID, len);
break;
case BTRFS_QGROUP_RFER:
@ -849,7 +849,7 @@ static int update_qgroup_relation(struct qgroup_lookup *qgroup_lookup,
if (!child) {
error("cannot find the qgroup %llu/%llu",
btrfs_qgroup_level(child_id),
btrfs_qgroup_subvid(child_id));
btrfs_qgroup_subvolid(child_id));
return -ENOENT;
}
@ -857,7 +857,7 @@ static int update_qgroup_relation(struct qgroup_lookup *qgroup_lookup,
if (!parent) {
error("cannot find the qgroup %llu/%llu",
btrfs_qgroup_level(parent_id),
btrfs_qgroup_subvid(parent_id));
btrfs_qgroup_subvolid(parent_id));
return -ENOENT;
}
@ -1120,7 +1120,7 @@ static void __update_columns_max_len(struct btrfs_qgroup *bq,
case BTRFS_QGROUP_QGROUPID:
sprintf(tmp, "%llu/%llu",
btrfs_qgroup_level(bq->qgroupid),
btrfs_qgroup_subvid(bq->qgroupid));
btrfs_qgroup_subvolid(bq->qgroupid));
len = strlen(tmp);
if (btrfs_qgroup_columns[column].max_len < len)
btrfs_qgroup_columns[column].max_len = len;
@ -1152,7 +1152,7 @@ static void __update_columns_max_len(struct btrfs_qgroup *bq,
list_for_each_entry(list, &bq->qgroups, next_qgroup) {
len += sprintf(tmp, "%llu/%llu",
btrfs_qgroup_level(list->qgroup->qgroupid),
btrfs_qgroup_subvid(list->qgroup->qgroupid));
btrfs_qgroup_subvolid(list->qgroup->qgroupid));
if (!list_is_last(&list->next_qgroup, &bq->qgroups))
len += 1;
}
@ -1164,7 +1164,7 @@ static void __update_columns_max_len(struct btrfs_qgroup *bq,
list_for_each_entry(list, &bq->members, next_member) {
len += sprintf(tmp, "%llu/%llu",
btrfs_qgroup_level(list->member->qgroupid),
btrfs_qgroup_subvid(list->member->qgroupid));
btrfs_qgroup_subvolid(list->member->qgroupid));
if (!list_is_last(&list->next_member, &bq->members))
len += 1;
}
@ -2112,13 +2112,13 @@ static int cmd_qgroup_clear_stale(const struct cmd_struct *cmd, int argc, char *
level = btrfs_qgroup_level(entry->qgroupid);
if (!entry->path && level == 0) {
pr_verbose(LOG_DEFAULT, "Delete stale qgroup %llu/%llu\n",
level, btrfs_qgroup_subvid(entry->qgroupid));
level, btrfs_qgroup_subvolid(entry->qgroupid));
args.qgroupid = entry->qgroupid;
ret = ioctl(fd, BTRFS_IOC_QGROUP_CREATE, &args);
if (ret < 0) {
error("cannot delete qgroup %llu/%llu: %m",
level,
btrfs_qgroup_subvid(entry->qgroupid));
btrfs_qgroup_subvolid(entry->qgroupid));
}
}
node = rb_next(node);

View File

@ -1076,7 +1076,7 @@ static inline u64 btrfs_qgroup_level(u64 qgroupid)
return qgroupid >> BTRFS_QGROUP_LEVEL_SHIFT;
}
static inline u64 btrfs_qgroup_subvid(u64 qgroupid)
static inline u64 btrfs_qgroup_subvolid(u64 qgroupid)
{
return qgroupid & ((1ULL << BTRFS_QGROUP_LEVEL_SHIFT) - 1);
}

View File

@ -707,7 +707,7 @@ void print_objectid(FILE *stream, u64 objectid, u8 type)
return;
case BTRFS_QGROUP_RELATION_KEY:
fprintf(stream, "%llu/%llu", btrfs_qgroup_level(objectid),
btrfs_qgroup_subvid(objectid));
btrfs_qgroup_subvolid(objectid));
return;
case BTRFS_UUID_KEY_SUBVOL:
case BTRFS_UUID_KEY_RECEIVED_SUBVOL:
@ -816,7 +816,7 @@ void btrfs_print_key(struct btrfs_disk_key *disk_key)
case BTRFS_QGROUP_INFO_KEY:
case BTRFS_QGROUP_LIMIT_KEY:
printf(" %llu/%llu)", btrfs_qgroup_level(offset),
btrfs_qgroup_subvid(offset));
btrfs_qgroup_subvolid(offset));
break;
case BTRFS_UUID_KEY_SUBVOL:
case BTRFS_UUID_KEY_RECEIVED_SUBVOL:

View File

@ -1114,6 +1114,11 @@ static inline u64 btrfs_qgroup_subvid(u64 qgroupid)
return qgroupid & ((1ULL << BTRFS_QGROUP_LEVEL_SHIFT) - 1);
}
static inline u64 btrfs_qgroup_subvolid(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)