summaryrefslogtreecommitdiff
path: root/qgroup.c
diff options
context:
space:
mode:
authorLu Fengqi <lufq.fnst@cn.fujitsu.com>2017-11-13 13:33:15 +0800
committerDavid Sterba <dsterba@suse.com>2018-01-08 19:22:43 +0100
commitf0445b8a344b496e6c070c733e445bf79a8fad58 (patch)
tree22edfdf8a3a0c3b84d093709ead970030cc9f08e /qgroup.c
parent82ee5aec231058ef88e18b26e9dbd7117accd491 (diff)
btrfs-progs: qgroup: move btrfs_show_qgroups's error handler to __qgroup_search
We have to process the return value of BTRFS_IOC_TREE_SEARCH ioctl in advance, so that we can distinguish between the two case where quota is not enabled (ioctl return -ENOENT) and either parent qgroup or child qgroup does not exist (update_qgroup_relation return -ENOENT). Besides this, any error in this routine has been reported, so we don't need to report again in cmd_qgroup_show. Signed-off-by: Lu Fengqi <lufq.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'qgroup.c')
-rw-r--r--qgroup.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/qgroup.c b/qgroup.c
index 156825fd..23463d8a 100644
--- a/qgroup.c
+++ b/qgroup.c
@@ -1065,8 +1065,18 @@ static int __qgroups_search(int fd, struct qgroup_lookup *qgroup_lookup)
while (1) {
ret = ioctl(fd, BTRFS_IOC_TREE_SEARCH, &args);
- if (ret < 0)
- return -errno;
+ 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;
+ }
+
+ break;
+ }
/* the ioctl returns the number of item it found in nr_items */
if (sk->nr_items == 0)