Retire the SWIF_DUMP_TREE code, this is in the way for a rework of
the swap_pager layout.
This commit is contained in:
parent
9c76f2b9d6
commit
5243b6799b
@ -69,7 +69,6 @@ struct kvm_swap {
|
||||
int ksw_reserved2;
|
||||
};
|
||||
|
||||
#define SWIF_DUMP_TREE 0x0001
|
||||
#define SWIF_DEV_PREFIX 0x0002
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
@ -51,8 +51,6 @@ static int nswdev;
|
||||
static int unswdev; /* number of found swap dev's */
|
||||
static int dmmax;
|
||||
|
||||
static void getswapinfo_radix(kvm_t *kd, struct kvm_swap *swap_ary,
|
||||
int swap_max, int flags);
|
||||
static int kvm_getswapinfo2(kvm_t *kd, struct kvm_swap *swap_ary,
|
||||
int swap_max, int flags);
|
||||
static int kvm_getswapinfo_kvm(kvm_t *, struct kvm_swap *, int, int);
|
||||
@ -108,23 +106,6 @@ kvm_getswapinfo(
|
||||
return(0);
|
||||
}
|
||||
|
||||
rv = kvm_getswapinfo2(kd, swap_ary, swap_max, flags);
|
||||
|
||||
/* This is only called when the tree shall be dumped. It needs kvm. */
|
||||
if (flags & SWIF_DUMP_TREE) {
|
||||
getswapinfo_radix(kd, swap_ary, swap_max, flags);
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
static int
|
||||
kvm_getswapinfo2(
|
||||
kvm_t *kd,
|
||||
struct kvm_swap *swap_ary,
|
||||
int swap_max,
|
||||
int flags
|
||||
) {
|
||||
if (ISALIVE(kd)) {
|
||||
return kvm_getswapinfo_sysctl(kd, swap_ary, swap_max, flags);
|
||||
} else {
|
||||
@ -199,177 +180,6 @@ kvm_getswapinfo_kvm(
|
||||
return(ti);
|
||||
}
|
||||
|
||||
/*
|
||||
* scanradix() - support routine for radix scanner
|
||||
*/
|
||||
|
||||
#define TABME tab, tab, ""
|
||||
|
||||
static int
|
||||
scanradix(
|
||||
blmeta_t *scan,
|
||||
daddr_t blk,
|
||||
daddr_t radix,
|
||||
daddr_t skip,
|
||||
daddr_t count,
|
||||
kvm_t *kd,
|
||||
int dmmax,
|
||||
int nswdev,
|
||||
struct kvm_swap *swap_ary,
|
||||
int swap_max,
|
||||
int tab,
|
||||
int flags
|
||||
) {
|
||||
blmeta_t meta;
|
||||
|
||||
KGET2(scan, &meta, sizeof(meta), "blmeta_t");
|
||||
|
||||
/*
|
||||
* Terminator
|
||||
*/
|
||||
if (meta.bm_bighint == (daddr_t)-1) {
|
||||
if (flags & SWIF_DUMP_TREE) {
|
||||
printf("%*.*s(0x%06x,%d) Terminator\n",
|
||||
TABME,
|
||||
blk,
|
||||
radix
|
||||
);
|
||||
}
|
||||
return(-1);
|
||||
}
|
||||
|
||||
if (radix == BLIST_BMAP_RADIX) {
|
||||
/*
|
||||
* Leaf bitmap
|
||||
*/
|
||||
|
||||
if (flags & SWIF_DUMP_TREE) {
|
||||
printf("%*.*s(0x%06x,%d) Bitmap %08x big=%d\n",
|
||||
TABME,
|
||||
blk,
|
||||
radix,
|
||||
(int)meta.u.bmu_bitmap,
|
||||
meta.bm_bighint
|
||||
);
|
||||
}
|
||||
|
||||
} else if (meta.u.bmu_avail == radix) {
|
||||
/*
|
||||
* Meta node if all free
|
||||
*/
|
||||
if (flags & SWIF_DUMP_TREE) {
|
||||
printf("%*.*s(0x%06x,%d) Submap ALL-FREE {\n",
|
||||
TABME,
|
||||
blk,
|
||||
radix
|
||||
);
|
||||
}
|
||||
} else if (meta.u.bmu_avail == 0) {
|
||||
/*
|
||||
* Meta node if all used
|
||||
*/
|
||||
if (flags & SWIF_DUMP_TREE) {
|
||||
printf("%*.*s(0x%06x,%d) Submap ALL-ALLOCATED\n",
|
||||
TABME,
|
||||
blk,
|
||||
radix
|
||||
);
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
* Meta node if not all free
|
||||
*/
|
||||
int i;
|
||||
int next_skip;
|
||||
|
||||
if (flags & SWIF_DUMP_TREE) {
|
||||
printf("%*.*s(0x%06x,%d) Submap avail=%d big=%d {\n",
|
||||
TABME,
|
||||
blk,
|
||||
radix,
|
||||
(int)meta.u.bmu_avail,
|
||||
meta.bm_bighint
|
||||
);
|
||||
}
|
||||
|
||||
radix /= BLIST_META_RADIX;
|
||||
next_skip = skip / BLIST_META_RADIX;
|
||||
|
||||
for (i = 1; i <= skip; i += next_skip) {
|
||||
int r;
|
||||
daddr_t vcount = (count > radix) ? radix : count;
|
||||
|
||||
r = scanradix(
|
||||
&scan[i],
|
||||
blk,
|
||||
radix,
|
||||
next_skip - 1,
|
||||
vcount,
|
||||
kd,
|
||||
dmmax,
|
||||
nswdev,
|
||||
swap_ary,
|
||||
swap_max,
|
||||
tab + 4,
|
||||
flags
|
||||
);
|
||||
if (r < 0)
|
||||
break;
|
||||
blk += radix;
|
||||
}
|
||||
if (flags & SWIF_DUMP_TREE) {
|
||||
printf("%*.*s}\n", TABME);
|
||||
}
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
static void
|
||||
getswapinfo_radix(kvm_t *kd, struct kvm_swap *swap_ary, int swap_max, int flags)
|
||||
{
|
||||
struct blist *swapblist = NULL;
|
||||
struct blist blcopy = { 0 };
|
||||
|
||||
if (!nlist_init(kd)) {
|
||||
fprintf(stderr, "radix tree: nlist_init failed!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
KGET(NL_SWAPBLIST, swapblist);
|
||||
|
||||
if (swapblist == NULL) {
|
||||
if (flags & SWIF_DUMP_TREE)
|
||||
printf("radix tree: NULL - no swap in system\n");
|
||||
return;
|
||||
}
|
||||
|
||||
KGET2(swapblist, &blcopy, sizeof(blcopy), "*swapblist");
|
||||
|
||||
if (flags & SWIF_DUMP_TREE) {
|
||||
printf("radix tree: %d/%d/%d blocks, %dK wired\n",
|
||||
blcopy.bl_free,
|
||||
blcopy.bl_blocks,
|
||||
blcopy.bl_radix,
|
||||
(int)((blcopy.bl_rootblks * sizeof(blmeta_t) + 1023)/
|
||||
1024)
|
||||
);
|
||||
}
|
||||
scanradix(
|
||||
blcopy.bl_root,
|
||||
0,
|
||||
blcopy.bl_radix,
|
||||
blcopy.bl_skip,
|
||||
blcopy.bl_rootblks,
|
||||
kd,
|
||||
dmmax,
|
||||
nswdev,
|
||||
swap_ary,
|
||||
swap_max,
|
||||
0,
|
||||
flags
|
||||
);
|
||||
}
|
||||
|
||||
#define GETSYSCTL(kd, name, var) \
|
||||
getsysctl(kd, name, &(var), sizeof(var))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user