Skip to content

Commit

Permalink
filehash: move to separate allocation
Browse files Browse the repository at this point in the history
We currently make it part of the thread structure allocation, but
there's no need to do that since we have smalloc available.

Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
axboe committed Sep 26, 2016
1 parent cab2472 commit 63a26e0
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
9 changes: 6 additions & 3 deletions filehash.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@
#include "flist.h"
#include "hash.h"
#include "filehash.h"
#include "smalloc.h"
#include "lib/bloom.h"

#define HASH_BUCKETS 512
#define HASH_MASK (HASH_BUCKETS - 1)

#define BLOOM_SIZE 16*1024*1024

unsigned int file_hash_size = HASH_BUCKETS * sizeof(struct flist_head);
static unsigned int file_hash_size = HASH_BUCKETS * sizeof(struct flist_head);

static struct flist_head *file_hash;
static struct fio_mutex *hash_lock;
Expand Down Expand Up @@ -116,18 +117,20 @@ void file_hash_exit(void)
if (has_entries)
log_err("fio: file hash not empty on exit\n");

sfree(file_hash);
file_hash = NULL;
fio_mutex_remove(hash_lock);
hash_lock = NULL;
bloom_free(file_bloom);
file_bloom = NULL;
}

void file_hash_init(void *ptr)
void file_hash_init(void)
{
unsigned int i;

file_hash = ptr;
file_hash = smalloc(file_hash_size);

for (i = 0; i < HASH_BUCKETS; i++)
INIT_FLIST_HEAD(&file_hash[i]);

Expand Down
4 changes: 1 addition & 3 deletions filehash.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@

#include "lib/types.h"

extern unsigned int file_hash_size;

extern void file_hash_init(void *);
extern void file_hash_init(void);
extern void file_hash_exit(void);
extern struct fio_file *lookup_file_hash(const char *);
extern struct fio_file *add_file_hash(struct fio_file *);
Expand Down
6 changes: 2 additions & 4 deletions init.c
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,6 @@ static int setup_thread_area(void)
do {
size_t size = max_jobs * sizeof(struct thread_data);

size += file_hash_size;
size += sizeof(unsigned int);

#ifndef CONFIG_NO_SHM
Expand Down Expand Up @@ -366,11 +365,10 @@ static int setup_thread_area(void)
#endif

memset(threads, 0, max_jobs * sizeof(struct thread_data));
hash = (void *) threads + max_jobs * sizeof(struct thread_data);
fio_debug_jobp = (void *) hash + file_hash_size;
fio_debug_jobp = (void *) threads + max_jobs * sizeof(struct thread_data);
*fio_debug_jobp = -1;
file_hash_init(hash);

file_hash_init();
flow_init();

return 0;
Expand Down

0 comments on commit 63a26e0

Please sign in to comment.