X-Git-Url: https://git.kernel.dk/?a=blobdiff_plain;f=filehash.c;h=1bb1eb237606096a8d0bbec6b0ec583f34bafc00;hb=28727df79348d4ebbd8fd4b0dd89bbca035f68d0;hp=dab60fe32e88d0e45e729335c0027c8cdb9e2317;hpb=8954110682922232b8bccfe2b7e734d04ce71b96;p=fio.git diff --git a/filehash.c b/filehash.c index dab60fe3..1bb1eb23 100644 --- a/filehash.c +++ b/filehash.c @@ -3,7 +3,7 @@ #include "fio.h" #include "flist.h" -#include "crc/crc16.h" +#include "hash.h" #define HASH_BUCKETS 512 #define HASH_MASK (HASH_BUCKETS - 1) @@ -15,17 +15,17 @@ static struct fio_mutex *hash_lock; static unsigned short hash(const char *name) { - return crc16((const unsigned char *) name, strlen(name)) & HASH_MASK; + return jhash(name, strlen(name), 0) & HASH_MASK; } void remove_file_hash(struct fio_file *f) { fio_mutex_down(hash_lock); - if (f->flags & FIO_FILE_HASHED) { + if (fio_file_hashed(f)) { assert(!flist_empty(&f->hash_list)); flist_del_init(&f->hash_list); - f->flags &= ~FIO_FILE_HASHED; + fio_file_clear_hashed(f); } fio_mutex_up(hash_lock); @@ -65,7 +65,7 @@ struct fio_file *add_file_hash(struct fio_file *f) { struct fio_file *alias; - if (f->flags & FIO_FILE_HASHED) + if (fio_file_hashed(f)) return NULL; INIT_FLIST_HEAD(&f->hash_list); @@ -74,7 +74,7 @@ struct fio_file *add_file_hash(struct fio_file *f) alias = __lookup_file_hash(f->file_name); if (!alias) { - f->flags |= FIO_FILE_HASHED; + fio_file_set_hashed(f); flist_add_tail(&f->hash_list, &file_hash[hash(f->file_name)]); }