forked from Mirrors/btrfs-progs
btrfs-progs: qgroup: switch to common message helpers
Signed-off-by: David Sterba <dsterba@suse.com>master
parent
c027c13531
commit
26fbf0546d
42
qgroup.c
42
qgroup.c
|
@ -439,7 +439,7 @@ struct btrfs_qgroup_comparer_set *btrfs_qgroup_alloc_comparer_set(void)
|
||||||
sizeof(struct btrfs_qgroup_comparer);
|
sizeof(struct btrfs_qgroup_comparer);
|
||||||
set = calloc(1, size);
|
set = calloc(1, size);
|
||||||
if (!set) {
|
if (!set) {
|
||||||
fprintf(stderr, "memory allocation failed\n");
|
error("memory allocation failed");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -468,7 +468,7 @@ int btrfs_qgroup_setup_comparer(struct btrfs_qgroup_comparer_set **comp_set,
|
||||||
tmp = set;
|
tmp = set;
|
||||||
set = realloc(set, size);
|
set = realloc(set, size);
|
||||||
if (!set) {
|
if (!set) {
|
||||||
fprintf(stderr, "memory allocation failed\n");
|
error("memory allocation failed");
|
||||||
free(tmp);
|
free(tmp);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
@ -612,7 +612,7 @@ static int update_qgroup(struct qgroup_lookup *qgroup_lookup, u64 qgroupid,
|
||||||
if (pa && child) {
|
if (pa && child) {
|
||||||
list = malloc(sizeof(*list));
|
list = malloc(sizeof(*list));
|
||||||
if (!list) {
|
if (!list) {
|
||||||
fprintf(stderr, "memory allocation failed\n");
|
error("memory allocation failed");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
list->qgroup = pa;
|
list->qgroup = pa;
|
||||||
|
@ -641,7 +641,7 @@ static int add_qgroup(struct qgroup_lookup *qgroup_lookup, u64 qgroupid,
|
||||||
|
|
||||||
bq = calloc(1, sizeof(*bq));
|
bq = calloc(1, sizeof(*bq));
|
||||||
if (!bq) {
|
if (!bq) {
|
||||||
printf("memory allocation failed\n");
|
error("memory allocation failed");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
if (qgroupid) {
|
if (qgroupid) {
|
||||||
|
@ -670,7 +670,7 @@ static int add_qgroup(struct qgroup_lookup *qgroup_lookup, u64 qgroupid,
|
||||||
if (parent && child) {
|
if (parent && child) {
|
||||||
list = malloc(sizeof(*list));
|
list = malloc(sizeof(*list));
|
||||||
if (!list) {
|
if (!list) {
|
||||||
fprintf(stderr, "memory allocation failed\n");
|
error("memory allocation failed");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
list->qgroup = parent;
|
list->qgroup = parent;
|
||||||
|
@ -680,8 +680,8 @@ static int add_qgroup(struct qgroup_lookup *qgroup_lookup, u64 qgroupid,
|
||||||
}
|
}
|
||||||
ret = qgroup_tree_insert(qgroup_lookup, bq);
|
ret = qgroup_tree_insert(qgroup_lookup, bq);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
printf("failed to insert tree %llu\n",
|
error("failed to insert %llu into tree: %s",
|
||||||
bq->qgroupid);
|
(unsigned long long)bq->qgroupid, strerror(-ret));
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -809,7 +809,7 @@ struct btrfs_qgroup_filter_set *btrfs_qgroup_alloc_filter_set(void)
|
||||||
sizeof(struct btrfs_qgroup_filter);
|
sizeof(struct btrfs_qgroup_filter);
|
||||||
set = calloc(1, size);
|
set = calloc(1, size);
|
||||||
if (!set) {
|
if (!set) {
|
||||||
fprintf(stderr, "memory allocation failed\n");
|
error("memory allocation failed");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
set->total = BTRFS_QGROUP_NFILTERS_INCREASE;
|
set->total = BTRFS_QGROUP_NFILTERS_INCREASE;
|
||||||
|
@ -836,7 +836,7 @@ int btrfs_qgroup_setup_filter(struct btrfs_qgroup_filter_set **filter_set,
|
||||||
tmp = set;
|
tmp = set;
|
||||||
set = realloc(set, size);
|
set = realloc(set, size);
|
||||||
if (!set) {
|
if (!set) {
|
||||||
fprintf(stderr, "memory allocation failed\n");
|
error("memory allocation failed");
|
||||||
free(tmp);
|
free(tmp);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
@ -1025,14 +1025,11 @@ static void __filter_and_sort_qgroups(struct qgroup_lookup *all_qgroups,
|
||||||
static inline void print_status_flag_warning(u64 flags)
|
static inline void print_status_flag_warning(u64 flags)
|
||||||
{
|
{
|
||||||
if (!(flags & BTRFS_QGROUP_STATUS_FLAG_ON))
|
if (!(flags & BTRFS_QGROUP_STATUS_FLAG_ON))
|
||||||
fprintf(stderr,
|
warning("quota disabled, qgroup data may be out of date");
|
||||||
"WARNING: Quota disabled, qgroup data may be out of date\n");
|
|
||||||
else if (flags & BTRFS_QGROUP_STATUS_FLAG_RESCAN)
|
else if (flags & BTRFS_QGROUP_STATUS_FLAG_RESCAN)
|
||||||
fprintf(stderr,
|
warning("rescan is running, qgroup data may be incorrect");
|
||||||
"WARNING: Rescan is running, qgroup data may be incorrect\n");
|
|
||||||
else if (flags & BTRFS_QGROUP_STATUS_FLAG_INCONSISTENT)
|
else if (flags & BTRFS_QGROUP_STATUS_FLAG_INCONSISTENT)
|
||||||
fprintf(stderr,
|
warning("qgroup data inconsistent, rescan recommended");
|
||||||
"WARNING: Qgroup data inconsistent, rescan recommended\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int __qgroups_search(int fd, struct qgroup_lookup *qgroup_lookup)
|
static int __qgroups_search(int fd, struct qgroup_lookup *qgroup_lookup)
|
||||||
|
@ -1068,9 +1065,8 @@ static int __qgroups_search(int fd, struct qgroup_lookup *qgroup_lookup)
|
||||||
while (1) {
|
while (1) {
|
||||||
ret = ioctl(fd, BTRFS_IOC_TREE_SEARCH, &args);
|
ret = ioctl(fd, BTRFS_IOC_TREE_SEARCH, &args);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
fprintf(stderr,
|
error("cannot perform the search: %s",
|
||||||
"ERROR: can't perform the search - %s\n",
|
strerror(errno));
|
||||||
strerror(errno));
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
/* the ioctl returns the number of item it found in nr_items */
|
/* the ioctl returns the number of item it found in nr_items */
|
||||||
|
@ -1223,9 +1219,7 @@ u64 btrfs_get_path_rootid(int fd)
|
||||||
|
|
||||||
ret = ioctl(fd, BTRFS_IOC_INO_LOOKUP, &args);
|
ret = ioctl(fd, BTRFS_IOC_INO_LOOKUP, &args);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
fprintf(stderr,
|
error("cannot perform the search: %s", strerror(errno));
|
||||||
"ERROR: can't perform the search - %s\n",
|
|
||||||
strerror(errno));
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
return args.treeid;
|
return args.treeid;
|
||||||
|
@ -1305,7 +1299,7 @@ qgroup_inherit_realloc(struct btrfs_qgroup_inherit **inherit, int n, int pos)
|
||||||
|
|
||||||
out = calloc(sizeof(*out) + sizeof(out->qgroups[0]) * (nitems + n), 1);
|
out = calloc(sizeof(*out) + sizeof(out->qgroups[0]) * (nitems + n), 1);
|
||||||
if (out == NULL) {
|
if (out == NULL) {
|
||||||
fprintf(stderr, "ERROR: Not enough memory\n");
|
error("not enough memory");
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1333,7 +1327,7 @@ int qgroup_inherit_add_group(struct btrfs_qgroup_inherit **inherit, char *arg)
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
|
|
||||||
if (qgroupid == 0) {
|
if (qgroupid == 0) {
|
||||||
fprintf(stderr, "ERROR: bad qgroup specification\n");
|
error("invalid qgroup specification, qgroupid must not 0");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1360,7 +1354,7 @@ int qgroup_inherit_add_copy(struct btrfs_qgroup_inherit **inherit, char *arg,
|
||||||
p = strchr(arg, ':');
|
p = strchr(arg, ':');
|
||||||
if (!p) {
|
if (!p) {
|
||||||
bad:
|
bad:
|
||||||
fprintf(stderr, "ERROR: bad copy specification\n");
|
error("invalid copy specification, missing separator :");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
*p = 0;
|
*p = 0;
|
||||||
|
|
Loading…
Reference in New Issue