From 44efde7fa0d7a814cf6c533712068a5473427d6c Mon Sep 17 00:00:00 2001 From: David Sterba Date: Wed, 26 Oct 2022 09:36:44 +0200 Subject: [PATCH] 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 --- check/qgroup-verify.c | 8 ++++---- cmds/qgroup.c | 22 +++++++++++----------- kernel-shared/ctree.h | 2 +- kernel-shared/print-tree.c | 4 ++-- libbtrfs/ctree.h | 5 +++++ 5 files changed, 23 insertions(+), 18 deletions(-) diff --git a/check/qgroup-verify.c b/check/qgroup-verify.c index ab93d7e0..c23a07f7 100644 --- a/check/qgroup-verify.c +++ b/check/qgroup-verify.c @@ -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; diff --git a/cmds/qgroup.c b/cmds/qgroup.c index db0b2f8f..42b8fb5a 100644 --- a/cmds/qgroup.c +++ b/cmds/qgroup.c @@ -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); diff --git a/kernel-shared/ctree.h b/kernel-shared/ctree.h index 7a9fd1cb..cd1f9274 100644 --- a/kernel-shared/ctree.h +++ b/kernel-shared/ctree.h @@ -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); } diff --git a/kernel-shared/print-tree.c b/kernel-shared/print-tree.c index 0e0404ab..e67c18d3 100644 --- a/kernel-shared/print-tree.c +++ b/kernel-shared/print-tree.c @@ -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: diff --git a/libbtrfs/ctree.h b/libbtrfs/ctree.h index 69903f67..2c7ce41d 100644 --- a/libbtrfs/ctree.h +++ b/libbtrfs/ctree.h @@ -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)