mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-22 02:27:36 +03:00
Move range_tree, btree, highbit64 to common code
Break out the range_tree, btree, and highbit64/lowbit64 code from kernel space into shared kernel and userspace code. This is needed for the updated `zpool status -vv` error byte range reporting that will be coming in a future commit. That commit needs the range_tree code in kernel and userspace. Reviewed-by: Rob Norris <robn@despairlabs.com> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Tony Hutter <hutter2@llnl.gov> Closes #18133
This commit is contained in:
+16
-1
@@ -21,7 +21,11 @@
|
||||
#include <sys/bitops.h>
|
||||
#include <sys/zfs_context.h>
|
||||
|
||||
kmem_cache_t *zfs_btree_leaf_cache;
|
||||
#ifndef _KERNEL
|
||||
#define panic(...) PANIC(__VA_ARGS__)
|
||||
#endif
|
||||
|
||||
kmem_cache_t *zfs_btree_leaf_cache = NULL;
|
||||
|
||||
/*
|
||||
* Control the extent of the verification that occurs when zfs_btree_verify is
|
||||
@@ -106,6 +110,8 @@ zfs_btree_poison_node(zfs_btree_t *tree, zfs_btree_hdr_t *hdr)
|
||||
tree->bt_leaf_size - offsetof(zfs_btree_leaf_t, btl_elems) -
|
||||
(hdr->bth_first + hdr->bth_count) * size);
|
||||
}
|
||||
#else
|
||||
(void) tree; (void) hdr;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -132,6 +138,8 @@ zfs_btree_poison_node_at(zfs_btree_t *tree, zfs_btree_hdr_t *hdr,
|
||||
(void) memset(leaf->btl_elems +
|
||||
(hdr->bth_first + idx) * size, 0x0f, count * size);
|
||||
}
|
||||
#else
|
||||
(void) tree; (void) hdr; (void) idx; (void) count;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -158,6 +166,8 @@ zfs_btree_verify_poison_at(zfs_btree_t *tree, zfs_btree_hdr_t *hdr,
|
||||
* size + i], ==, 0x0f);
|
||||
}
|
||||
}
|
||||
#else
|
||||
(void) tree; (void) hdr; (void) idx;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -196,6 +206,9 @@ void
|
||||
zfs_btree_create(zfs_btree_t *tree, int (*compar) (const void *, const void *),
|
||||
bt_find_in_buf_f bt_find_in_buf, size_t size)
|
||||
{
|
||||
/* Verify zfs_btree_init() was called before zfs_btree_create() */
|
||||
ASSERT(zfs_btree_leaf_cache != NULL);
|
||||
|
||||
zfs_btree_create_custom(tree, compar, bt_find_in_buf, size,
|
||||
BTREE_LEAF_SIZE);
|
||||
}
|
||||
@@ -2185,6 +2198,8 @@ zfs_btree_verify_poison(zfs_btree_t *tree)
|
||||
if (tree->bt_height == -1)
|
||||
return;
|
||||
zfs_btree_verify_poison_helper(tree, tree->bt_root);
|
||||
#else
|
||||
(void) tree;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
+14
-6
@@ -34,6 +34,16 @@
|
||||
#include <sys/dnode.h>
|
||||
#include <sys/zio.h>
|
||||
#include <sys/range_tree.h>
|
||||
#include <sys/sysmacros.h>
|
||||
|
||||
#ifndef _KERNEL
|
||||
/*
|
||||
* Need the extra 'abort()' here since is possible for PANIC() to return, and
|
||||
* our panic() usage in this file assumes it's NORETURN.
|
||||
*/
|
||||
#define panic(...) do {PANIC(__VA_ARGS__); abort(); } while (0);
|
||||
#define zfs_panic_recover(...) panic(__VA_ARGS__)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Range trees are tree-based data structures that can be used to
|
||||
@@ -116,12 +126,10 @@ zfs_range_tree_stat_verify(zfs_range_tree_t *rt)
|
||||
}
|
||||
|
||||
for (i = 0; i < ZFS_RANGE_TREE_HISTOGRAM_SIZE; i++) {
|
||||
if (hist[i] != rt->rt_histogram[i]) {
|
||||
zfs_dbgmsg("i=%d, hist=%px, hist=%llu, rt_hist=%llu",
|
||||
i, hist, (u_longlong_t)hist[i],
|
||||
(u_longlong_t)rt->rt_histogram[i]);
|
||||
}
|
||||
VERIFY3U(hist[i], ==, rt->rt_histogram[i]);
|
||||
VERIFY3UF(hist[i], ==, rt->rt_histogram[i],
|
||||
"i=%d, hist=%px, hist=%llu, rt_hist=%llu",
|
||||
i, hist, (u_longlong_t)hist[i],
|
||||
(u_longlong_t)rt->rt_histogram[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user