Remove an unnecessary field from struct blist. (The comment describing

what this field represented was also inaccurate.)  Suggested by: kib

In r178792, blist_create() grew a malloc flag, allowing M_NOWAIT to be
specified.  However, blist_create() was not modified to handle the
possibility that a malloc() call failed.  Address this omission.

Increase the width of the local variable "radix" to 64 bits.  (This
matches the width of the corresponding field in struct blist.)

Reviewed by:	kib
MFC after:	6 weeks
This commit is contained in:
Alan Cox 2017-06-10 16:11:39 +00:00
parent c645060dbb
commit 015d7db6b6
2 changed files with 13 additions and 9 deletions

View File

@ -156,7 +156,7 @@ blist_t
blist_create(daddr_t blocks, int flags)
{
blist_t bl;
int radix;
daddr_t nodes, radix;
int skip = 0;
/*
@ -170,13 +170,19 @@ blist_create(daddr_t blocks, int flags)
}
bl = malloc(sizeof(struct blist), M_SWAP, flags | M_ZERO);
if (bl == NULL)
return (NULL);
bl->bl_blocks = blocks;
bl->bl_radix = radix;
bl->bl_skip = skip;
bl->bl_rootblks = 1 +
blst_radix_init(NULL, bl->bl_radix, bl->bl_skip, blocks);
bl->bl_root = malloc(sizeof(blmeta_t) * bl->bl_rootblks, M_SWAP, flags);
nodes = 1 + blst_radix_init(NULL, radix, bl->bl_skip, blocks);
bl->bl_root = malloc(nodes * sizeof(blmeta_t), M_SWAP, flags);
if (bl->bl_root == NULL) {
free(bl, M_SWAP);
return (NULL);
}
blst_radix_init(bl->bl_root, radix, bl->bl_skip, blocks);
#if defined(BLIST_DEBUG)
printf(
@ -184,14 +190,13 @@ blist_create(daddr_t blocks, int flags)
", requiring %lldK of ram\n",
(long long)bl->bl_blocks,
(long long)bl->bl_blocks * 4 / 1024,
(long long)(bl->bl_rootblks * sizeof(blmeta_t) + 1023) / 1024
(long long)(nodes * sizeof(blmeta_t) + 1023) / 1024
);
printf("BLIST raw radix tree contains %lld records\n",
(long long)bl->bl_rootblks);
(long long)nodes);
#endif
blst_radix_init(bl->bl_root, bl->bl_radix, bl->bl_skip, blocks);
return(bl);
return (bl);
}
void

View File

@ -84,7 +84,6 @@ typedef struct blist {
daddr_t bl_skip; /* starting skip */
daddr_t bl_free; /* number of free blocks */
blmeta_t *bl_root; /* root of radix tree */
daddr_t bl_rootblks; /* daddr_t blks allocated for tree */
} *blist_t;
#define BLIST_META_RADIX 16