diff options
Diffstat (limited to 'fs/btrfs/ulist.h')
-rw-r--r-- | fs/btrfs/ulist.h | 38 |
1 files changed, 11 insertions, 27 deletions
diff --git a/fs/btrfs/ulist.h b/fs/btrfs/ulist.h index fb36731074b5..2be7102d8073 100644 --- a/fs/btrfs/ulist.h +++ b/fs/btrfs/ulist.h | |||
@@ -17,18 +17,12 @@ | |||
17 | * enumerating it. | 17 | * enumerating it. |
18 | * It is possible to store an auxiliary value along with the key. | 18 | * It is possible to store an auxiliary value along with the key. |
19 | * | 19 | * |
20 | * The implementation is preliminary and can probably be sped up | ||
21 | * significantly. A first step would be to store the values in an rbtree | ||
22 | * as soon as ULIST_SIZE is exceeded. | ||
23 | */ | 20 | */ |
24 | |||
25 | /* | ||
26 | * number of elements statically allocated inside struct ulist | ||
27 | */ | ||
28 | #define ULIST_SIZE 16 | ||
29 | |||
30 | struct ulist_iterator { | 21 | struct ulist_iterator { |
22 | #ifdef CONFIG_BTRFS_DEBUG | ||
31 | int i; | 23 | int i; |
24 | #endif | ||
25 | struct list_head *cur_list; /* hint to start search */ | ||
32 | }; | 26 | }; |
33 | 27 | ||
34 | /* | 28 | /* |
@@ -37,6 +31,12 @@ struct ulist_iterator { | |||
37 | struct ulist_node { | 31 | struct ulist_node { |
38 | u64 val; /* value to store */ | 32 | u64 val; /* value to store */ |
39 | u64 aux; /* auxiliary value saved along with the val */ | 33 | u64 aux; /* auxiliary value saved along with the val */ |
34 | |||
35 | #ifdef CONFIG_BTRFS_DEBUG | ||
36 | int seqnum; /* sequence number this node is added */ | ||
37 | #endif | ||
38 | |||
39 | struct list_head list; /* used to link node */ | ||
40 | struct rb_node rb_node; /* used to speed up search */ | 40 | struct rb_node rb_node; /* used to speed up search */ |
41 | }; | 41 | }; |
42 | 42 | ||
@@ -46,24 +46,8 @@ struct ulist { | |||
46 | */ | 46 | */ |
47 | unsigned long nnodes; | 47 | unsigned long nnodes; |
48 | 48 | ||
49 | /* | 49 | struct list_head nodes; |
50 | * number of nodes we already have room for | ||
51 | */ | ||
52 | unsigned long nodes_alloced; | ||
53 | |||
54 | /* | ||
55 | * pointer to the array storing the elements. The first ULIST_SIZE | ||
56 | * elements are stored inline. In this case the it points to int_nodes. | ||
57 | * After exceeding ULIST_SIZE, dynamic memory is allocated. | ||
58 | */ | ||
59 | struct ulist_node *nodes; | ||
60 | |||
61 | struct rb_root root; | 50 | struct rb_root root; |
62 | |||
63 | /* | ||
64 | * inline storage space for the first ULIST_SIZE entries | ||
65 | */ | ||
66 | struct ulist_node int_nodes[ULIST_SIZE]; | ||
67 | }; | 51 | }; |
68 | 52 | ||
69 | void ulist_init(struct ulist *ulist); | 53 | void ulist_init(struct ulist *ulist); |
@@ -77,6 +61,6 @@ int ulist_add_merge(struct ulist *ulist, u64 val, u64 aux, | |||
77 | struct ulist_node *ulist_next(struct ulist *ulist, | 61 | struct ulist_node *ulist_next(struct ulist *ulist, |
78 | struct ulist_iterator *uiter); | 62 | struct ulist_iterator *uiter); |
79 | 63 | ||
80 | #define ULIST_ITER_INIT(uiter) ((uiter)->i = 0) | 64 | #define ULIST_ITER_INIT(uiter) ((uiter)->cur_list = NULL) |
81 | 65 | ||
82 | #endif | 66 | #endif |