Import TBBT (NFS trace replay).
[bluesky.git] / TBBT / trace_play / hash.h
1 #ifndef RFS_HASH_H
2 #define RFS_HASH_H
3
4 /* 
5  * hash.h: 
6  *              header file for routines to manipulate hash_tble lookup, 
7  *              insert and delete.
8  * 
9  * $Id: hash.h,v 1.1 2002/03/11 20:25:52 ningning Exp $
10  *
11  * Changes:
12  *              $Log: hash.h,v $
13  *              Revision 1.1  2002/03/11 20:25:52  ningning
14  *              hash function for file handle map completely implemented.
15  *              
16  */
17
18 #include <sys/stat.h>
19 #include <sys/time.h>
20 #include <fcntl.h>
21 #include <unistd.h>
22 #include <stdio.h>
23 #include "../common/rfs_defines.h"
24 #include "rfsu_defines.h"
25
26 typedef struct rfsfh rfskey_t;
27
28 struct hash_ent_struct {
29 #ifdef HASH_DOUBLE_SAFE
30         struct timeval time;
31 #endif
32         rfskey_t key;
33         int entry;
34         struct hash_ent_struct * next;
35 };
36
37 typedef struct hash_ent_struct hash_ent_t;
38
39 typedef struct {
40         int size;
41         int used_entry; /* number of hash table entrie which contains valid data */
42         int valid_num;  /* number of valid data including those on the chain */
43         int (*hash_func) (rfskey_t * key, int size);    
44                 /*  it's not C++ class, so we have to get size from outside */
45         hash_ent_t * buf;
46 } hash_tbl_t;
47  
48 inline int hash_func1 (rfskey_t * key, int size);
49 inline int blk_hash_func (blkkey_t * key, int size);
50 int hash_tbl_init (hash_tbl_t * hash_tbl);
51 int hash_tbl_insert (hash_tbl_t * hash_tbl, rfskey_t * key, int entry, int mode);
52 int hash_tbl_delete (hash_tbl_t * hash_tbl, rfskey_t * key);
53 int hash_tbl_lookup (hash_tbl_t * hash_tbl, rfskey_t * key);
54
55 #ifdef ULFS
56
57 struct blk_hash_ent_struct {
58 #ifdef HASH_DOUBLE_SAFE
59         struct timeval time;
60 #endif
61         blkkey_t key;
62         int entry;
63         struct blk_hash_ent_struct * next;
64 };
65
66 typedef struct blk_hash_ent_struct blk_hash_ent_t;
67
68 typedef struct {
69         int size;
70         int keysize;
71         int entsize;
72         int quiet_flag;
73         int used_entry; /* number of hash table entrie which contains valid data */
74         int valid_num;  /* number of valid data including those on the chain */
75         int (*hash_func) (blkkey_t * key, int size);    
76                 /*  it's not C++ class, so we have to get size from outside */
77         blk_hash_ent_t * buf;
78 } blk_hash_tbl_t;
79
80 int blk_hash_tbl_init (blk_hash_tbl_t * hash_tbl);
81 int blk_hash_tbl_insert (blk_hash_tbl_t * hash_tbl, blkkey_t * key, int entry, int mode);
82 //int blk_hash_tbl_delete (blk_hash_tbl_t * hash_tbl, blkkey_t * key);
83 int blk_hash_tbl_lookup (blk_hash_tbl_t * hash_tbl, blkkey_t * key);
84
85 #endif
86
87 #endif