@@ -23,7 +23,8 @@
*/
#define avl_for_each_range_safe(pos, n, l, first, last) \
- for (pos = (first), n = pos->avl_nextino, l = (last)->avl_nextino; pos != (l); \
+ for (pos = (first), n = pos->avl_nextino, l = (last)->avl_nextino; \
+ pos != (l); \
pos = n, n = pos ? pos->avl_nextino : NULL)
#define avl_for_each_safe(tree, pos, n) \
@@ -67,18 +68,18 @@ static struct avl64ops bitmap_ops = {
/* Initialize a bitmap. */
int
-bitmap_init(
+bitmap_alloc(
struct bitmap **bmapp)
{
struct bitmap *bmap;
bmap = calloc(1, sizeof(struct bitmap));
if (!bmap)
- return -ENOMEM;
+ return errno;
bmap->bt_tree = malloc(sizeof(struct avl64tree_desc));
if (!bmap->bt_tree) {
free(bmap);
- return -ENOMEM;
+ return errno;
}
pthread_mutex_init(&bmap->bt_lock, NULL);
@@ -139,12 +140,12 @@ __bitmap_insert(
ext = bitmap_node_init(start, length);
if (!ext)
- return -ENOMEM;
+ return errno;
node = avl64_insert(bmap->bt_tree, &ext->btn_node);
if (node == NULL) {
free(ext);
- return -EEXIST;
+ return EEXIST;
}
return 0;
@@ -11,7 +11,7 @@ struct bitmap {
struct avl64tree_desc *bt_tree;
};
-int bitmap_init(struct bitmap **bmap);
+int bitmap_alloc(struct bitmap **bmap);
void bitmap_free(struct bitmap **bmap);
int bitmap_set(struct bitmap *bmap, uint64_t start, uint64_t length);
int bitmap_iterate(struct bitmap *bmap, int (*fn)(uint64_t, uint64_t, void *),
@@ -490,13 +490,13 @@ rmap_store_ag_btree_rec(
error = init_slab_cursor(ag_rmap->ar_raw_rmaps, rmap_compare, &rm_cur);
if (error)
goto err;
- error = -bitmap_init(&own_ag_bitmap);
+ error = bitmap_alloc(&own_ag_bitmap);
if (error)
goto err_slab;
while ((rm_rec = pop_slab_cursor(rm_cur)) != NULL) {
if (rm_rec->rm_owner != XFS_RMAP_OWN_AG)
continue;
- error = -bitmap_set(own_ag_bitmap, rm_rec->rm_startblock,
+ error = bitmap_set(own_ag_bitmap, rm_rec->rm_startblock,
rm_rec->rm_blockcount);
if (error) {
/*
@@ -341,6 +341,7 @@ xfs_check_rmap_ioerr(
struct media_verify_state *vs = arg;
struct bitmap *tree;
dev_t dev;
+ int ret;
dev = xfs_disk_to_dev(ctx, disk);
@@ -355,9 +356,9 @@ xfs_check_rmap_ioerr(
else
tree = NULL;
if (tree) {
- errno = -bitmap_set(tree, start, length);
- if (errno)
- str_errno(ctx, ctx->mntpoint);
+ ret = bitmap_set(tree, start, length);
+ if (ret)
+ str_liberror(ctx, ret, _("setting bad block bitmap"));
}
snprintf(descr, DESCR_BUFSZ, _("dev %d:%d ioerr @ %"PRIu64":%"PRIu64" "),
@@ -454,16 +455,17 @@ xfs_scan_blocks(
{
struct media_verify_state vs = { NULL };
bool moveon = false;
+ int ret;
- errno = -bitmap_init(&vs.d_bad);
- if (errno) {
- str_errno(ctx, ctx->mntpoint);
+ ret = bitmap_alloc(&vs.d_bad);
+ if (ret) {
+ str_liberror(ctx, ret, _("creating datadev badblock bitmap"));
goto out;
}
- errno = -bitmap_init(&vs.r_bad);
- if (errno) {
- str_errno(ctx, ctx->mntpoint);
+ ret = bitmap_alloc(&vs.r_bad);
+ if (ret) {
+ str_liberror(ctx, ret, _("creating realtime badblock bitmap"));
goto out_dbad;
}