FreeBSD kernel kern code
subr_blist.c File Reference
#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/lock.h>
#include <sys/kernel.h>
#include <sys/blist.h>
#include <sys/malloc.h>
#include <sys/sbuf.h>
#include <sys/proc.h>
#include <sys/mutex.h>
Include dependency graph for subr_blist.c:

Go to the source code of this file.

Data Structures

struct  gap_stats
 

Macros

#define BLIST_MASK   (BLIST_RADIX - 1)
 

Functions

 __FBSDID ("$FreeBSD$")
 
static daddr_t blst_leaf_alloc (blmeta_t *scan, daddr_t blk, int *count, int maxcount)
 
static daddr_t blst_meta_alloc (blmeta_t *scan, daddr_t cursor, int *count, int maxcount, u_daddr_t radix)
 
static void blst_leaf_free (blmeta_t *scan, daddr_t relblk, int count)
 
static void blst_meta_free (blmeta_t *scan, daddr_t freeBlk, daddr_t count, u_daddr_t radix)
 
static void blst_copy (blmeta_t *scan, daddr_t blk, daddr_t radix, blist_t dest, daddr_t count)
 
static daddr_t blst_leaf_fill (blmeta_t *scan, daddr_t blk, int count)
 
static daddr_t blst_meta_fill (blmeta_t *scan, daddr_t allocBlk, daddr_t count, u_daddr_t radix)
 
static MALLOC_DEFINE (M_SWAP, "SWAP", "Swap space")
 
static daddr_t radix_to_skip (daddr_t radix)
 
static u_daddr_t bitrange (int n, int count)
 
static int generic_bitpos (u_daddr_t mask)
 
static int bitpos (u_daddr_t mask)
 
blist_t blist_create (daddr_t blocks, int flags)
 
void blist_destroy (blist_t bl)
 
daddr_t blist_alloc (blist_t bl, int *count, int maxcount)
 
daddr_t blist_avail (blist_t bl)
 
void blist_free (blist_t bl, daddr_t blkno, daddr_t count)
 
daddr_t blist_fill (blist_t bl, daddr_t blkno, daddr_t count)
 
void blist_resize (blist_t *pbl, daddr_t count, int freenew, int flags)
 
static bool gap_stats_counting (const struct gap_stats *stats)
 
static void init_gap_stats (struct gap_stats *stats)
 
static void update_gap_stats (struct gap_stats *stats, daddr_t posn)
 
static void dump_gap_stats (const struct gap_stats *stats, struct sbuf *s)
 
void blist_stats (blist_t bl, struct sbuf *s)
 
static int blst_next_leaf_alloc (blmeta_t *scan, daddr_t start, int count, int maxcount)
 

Variables

static const u_daddr_t fib []
 

Macro Definition Documentation

◆ BLIST_MASK

#define BLIST_MASK   (BLIST_RADIX - 1)

Definition at line 153 of file subr_blist.c.

Function Documentation

◆ __FBSDID()

__FBSDID ( "$FreeBSD$"  )

◆ bitpos()

static int bitpos ( u_daddr_t  mask)
inlinestatic

Definition at line 208 of file subr_blist.c.

References generic_bitpos(), and mask.

Referenced by blist_stats(), blst_leaf_alloc(), blst_meta_alloc(), and blst_next_leaf_alloc().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ bitrange()

static u_daddr_t bitrange ( int  n,
int  count 
)
inlinestatic

Definition at line 180 of file subr_blist.c.

References count.

Referenced by blist_stats(), blst_leaf_alloc(), blst_leaf_fill(), blst_leaf_free(), blst_meta_alloc(), blst_meta_free(), and generic_bitpos().

Here is the caller graph for this function:

◆ blist_alloc()

daddr_t blist_alloc ( blist_t  bl,
int *  count,
int  maxcount 
)

Definition at line 294 of file subr_blist.c.

References blst_meta_alloc(), count, and maxcount.

Here is the call graph for this function:

◆ blist_avail()

daddr_t blist_avail ( blist_t  bl)

Definition at line 328 of file subr_blist.c.

◆ blist_create()

blist_t blist_create ( daddr_t  blocks,
int  flags 
)

Definition at line 236 of file subr_blist.c.

References flags, malloc(), and printf().

Referenced by blist_resize().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ blist_destroy()

void blist_destroy ( blist_t  bl)

Definition at line 282 of file subr_blist.c.

References free().

Referenced by blist_resize().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ blist_fill()

daddr_t blist_fill ( blist_t  bl,
daddr_t  blkno,
daddr_t  count 
)

Definition at line 356 of file subr_blist.c.

References blst_meta_fill(), and count.

Here is the call graph for this function:

◆ blist_free()

void blist_free ( blist_t  bl,
daddr_t  blkno,
daddr_t  count 
)

Definition at line 339 of file subr_blist.c.

References blst_meta_free(), and count.

Referenced by blist_resize(), and blst_copy().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ blist_resize()

void blist_resize ( blist_t *  pbl,
daddr_t  count,
int  freenew,
int  flags 
)

Definition at line 376 of file subr_blist.c.

References blist_create(), blist_destroy(), blist_free(), blst_copy(), count, and flags.

Here is the call graph for this function:

◆ blist_stats()

void blist_stats ( blist_t  bl,
struct sbuf *  s 
)

Definition at line 539 of file subr_blist.c.

References bitpos(), bitrange(), BLIST_MASK, dump_gap_stats(), gap_stats_counting(), init_gap_stats(), mask, radix_to_skip(), and update_gap_stats().

Here is the call graph for this function:

◆ blst_copy()

static void blst_copy ( blmeta_t *  scan,
daddr_t  blk,
daddr_t  radix,
blist_t  dest,
daddr_t  count 
)
static

Definition at line 942 of file subr_blist.c.

References blist_free(), blst_copy(), count, and radix_to_skip().

Referenced by blist_resize(), and blst_copy().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ blst_leaf_alloc()

static daddr_t blst_leaf_alloc ( blmeta_t *  scan,
daddr_t  blk,
int *  count,
int  maxcount 
)
static

Definition at line 700 of file subr_blist.c.

References bitpos(), bitrange(), BLIST_MASK, blst_next_leaf_alloc(), count, mask, and maxcount.

Referenced by blst_meta_alloc().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ blst_leaf_fill()

static daddr_t blst_leaf_fill ( blmeta_t *  scan,
daddr_t  blk,
int  count 
)
static

Definition at line 998 of file subr_blist.c.

References bitrange(), BLIST_MASK, count, and mask.

Referenced by blst_meta_fill().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ blst_leaf_free()

static void blst_leaf_free ( blmeta_t *  scan,
daddr_t  relblk,
int  count 
)
static

Definition at line 870 of file subr_blist.c.

References bitrange(), BLIST_MASK, count, and mask.

Referenced by blst_meta_free().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ blst_meta_alloc()

static daddr_t blst_meta_alloc ( blmeta_t *  scan,
daddr_t  cursor,
int *  count,
int  maxcount,
u_daddr_t  radix 
)
static

Definition at line 802 of file subr_blist.c.

References bitpos(), bitrange(), BLIST_MASK, blst_leaf_alloc(), blst_meta_alloc(), count, mask, maxcount, and radix_to_skip().

Referenced by blist_alloc(), and blst_meta_alloc().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ blst_meta_fill()

static daddr_t blst_meta_fill ( blmeta_t *  scan,
daddr_t  allocBlk,
daddr_t  count,
u_daddr_t  radix 
)
static

Definition at line 1021 of file subr_blist.c.

References BLIST_MASK, blst_leaf_fill(), blst_meta_fill(), count, and radix_to_skip().

Referenced by blist_fill(), and blst_meta_fill().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ blst_meta_free()

static void blst_meta_free ( blmeta_t *  scan,
daddr_t  freeBlk,
daddr_t  count,
u_daddr_t  radix 
)
static

Definition at line 898 of file subr_blist.c.

References bitrange(), BLIST_MASK, blst_leaf_free(), blst_meta_free(), count, and radix_to_skip().

Referenced by blist_free(), and blst_meta_free().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ blst_next_leaf_alloc()

static int blst_next_leaf_alloc ( blmeta_t *  scan,
daddr_t  start,
int  count,
int  maxcount 
)
static

Definition at line 618 of file subr_blist.c.

References bitpos(), BLIST_MASK, count, maxcount, radix_to_skip(), and start.

Referenced by blst_leaf_alloc().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ dump_gap_stats()

static void dump_gap_stats ( const struct gap_stats stats,
struct sbuf *  s 
)
inlinestatic

Definition at line 504 of file subr_blist.c.

References gap_stats::avg, fib, gap_stats::histo, gap_stats::max, gap_stats::max_bucket, gap_stats::num, and sbuf_printf().

Referenced by blist_stats().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gap_stats_counting()

static bool gap_stats_counting ( const struct gap_stats stats)
inlinestatic

Definition at line 437 of file subr_blist.c.

References gap_stats::start.

Referenced by blist_stats(), and update_gap_stats().

Here is the caller graph for this function:

◆ generic_bitpos()

static int generic_bitpos ( u_daddr_t  mask)
inlinestatic

Definition at line 191 of file subr_blist.c.

References bitrange(), and mask.

Referenced by bitpos().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ init_gap_stats()

static void init_gap_stats ( struct gap_stats stats)
inlinestatic

Definition at line 447 of file subr_blist.c.

References gap_stats::start.

Referenced by blist_stats().

Here is the caller graph for this function:

◆ MALLOC_DEFINE()

static MALLOC_DEFINE ( M_SWAP  ,
"SWAP"  ,
"Swap space"   
)
static

◆ radix_to_skip()

static daddr_t radix_to_skip ( daddr_t  radix)
inlinestatic

Definition at line 170 of file subr_blist.c.

References BLIST_MASK.

Referenced by blist_stats(), blst_copy(), blst_meta_alloc(), blst_meta_fill(), blst_meta_free(), and blst_next_leaf_alloc().

Here is the caller graph for this function:

◆ update_gap_stats()

static void update_gap_stats ( struct gap_stats stats,
daddr_t  posn 
)
static

Definition at line 458 of file subr_blist.c.

References gap_stats::avg, gap_stats::err, fib, gap_stats_counting(), gap_stats::histo, gap_stats::max, gap_stats::max_bucket, gap_stats::num, and gap_stats::start.

Referenced by blist_stats().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ fib

const u_daddr_t fib[]
static
Initial value:
= {
1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584,
4181, 6765, 10946, 17711, 28657, 46368, 75025, 121393, 196418, 317811,
514229, 832040, 1346269, 2178309, 3524578,
}

Definition at line 413 of file subr_blist.c.

Referenced by dump_gap_stats(), and update_gap_stats().