On 3/7/18 3:02 AM, Misono, Tomohiro wrote: > On 2018/03/03 3:47, jeffm@suse.com wrote: >> From: Jeff Mahoney >> >> The only mechanism we have in the progs for searching qgroups is to load >> all of them and filter the results. This works for qgroup show but >> to add quota information to 'btrfs subvoluem show' it's pretty wasteful. >> >> This patch splits out setting up the search and performing the search so >> we can search for a single qgroupid more easily. >> >> Signed-off-by: Jeff Mahoney >> --- >> qgroup.c | 98 +++++++++++++++++++++++++++++++++++++++++++++------------------- >> qgroup.h | 7 +++++ >> 2 files changed, 77 insertions(+), 28 deletions(-) >> >> diff --git a/qgroup.c b/qgroup.c >> index b1be3311..2d0a6947 100644 >> --- a/qgroup.c >> +++ b/qgroup.c >> @@ -1146,11 +1146,11 @@ static inline void print_status_flag_warning(u64 flags) >> warning("qgroup data inconsistent, rescan recommended"); >> } >> >> -static int __qgroups_search(int fd, struct qgroup_lookup *qgroup_lookup) >> +static int __qgroups_search(int fd, struct btrfs_ioctl_search_args *args, >> + struct qgroup_lookup *qgroup_lookup) >> { >> int ret; >> - struct btrfs_ioctl_search_args args; >> - struct btrfs_ioctl_search_key *sk = &args.key; >> + struct btrfs_ioctl_search_key *sk = &args->key; >> struct btrfs_ioctl_search_header *sh; >> unsigned long off = 0; >> unsigned int i; >> @@ -1161,30 +1161,12 @@ static int __qgroups_search(int fd, struct qgroup_lookup *qgroup_lookup) >> u64 qgroupid; >> u64 qgroupid1; >> >> - memset(&args, 0, sizeof(args)); >> - >> - sk->tree_id = BTRFS_QUOTA_TREE_OBJECTID; >> - sk->max_type = BTRFS_QGROUP_RELATION_KEY; >> - sk->min_type = BTRFS_QGROUP_STATUS_KEY; >> - sk->max_objectid = (u64)-1; >> - sk->max_offset = (u64)-1; >> - sk->max_transid = (u64)-1; >> - sk->nr_items = 4096; >> - >> qgroup_lookup_init(qgroup_lookup); >> >> while (1) { >> - ret = ioctl(fd, BTRFS_IOC_TREE_SEARCH, &args); >> + ret = ioctl(fd, BTRFS_IOC_TREE_SEARCH, args); >> if (ret < 0) { >> - if (errno == ENOENT) { >> - error("can't list qgroups: quotas not enabled"); >> - ret = -ENOTTY; >> - } else { >> - error("can't list qgroups: %s", >> - strerror(errno)); >> - ret = -errno; >> - } >> - >> + ret = -errno; > > Originally, -ENOTTY would be returned when qgroup is disabled > but this changes to return -ENOENT. so, it seems that error check > in 7th patch would not work correctly when qgroup is disabled. > Good catch. Thanks, -Jeff -- Jeff Mahoney SUSE Labs