This source file includes following definitions.
- nnfs_init_head
- xfs_node_purge
- xfs_node_find
- xfs_remove_node
- xfs_insert
- xfs_update_handle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 #include <xfs/xfs_locl.h>
35 #include <xfs/xfs_common.h>
36 #include <xfs/xfs_fs.h>
37 #include <xfs/xfs_deb.h>
38 #include <xfs/xfs_node.h>
39 #include <xfs/xfs_vnodeops.h>
40 #include <xfs/xfs_queue.h>
41
42 RCSID("$arla: xfs_node.c,v 1.3 2003/02/06 12:56:09 lha Exp $");
43
44 #define xfs_hash(node) \
45 (((node)->a+(node)->b+(node)->c+(node)->d) % XN_HASHSIZE)
46
47
48
49
50
51 void
52 nnfs_init_head(struct xfs_nodelist_head *head)
53 {
54 int i;
55
56 for (i = 0; i < XN_HASHSIZE; i++)
57 NNPQUEUE_INIT(&head->nh_nodelist[i]);
58 }
59
60
61
62
63
64
65
66 void
67 xfs_node_purge(struct xfs_nodelist_head *head,
68 void (*func)(struct xfs_node *))
69 {
70 panic("xfs_node_purge");
71 }
72
73
74
75
76
77 struct xfs_node *
78 xfs_node_find(struct xfs_nodelist_head *head, xfs_handle *handlep)
79 {
80 struct nh_node_list *h;
81 struct xfs_node *nn;
82
83 h = &head->nh_nodelist[xfs_hash(handlep)];
84
85 NNPQUEUE_FOREACH(nn, h, nn_hash) {
86 if (xfs_handle_eq(handlep, &nn->handle))
87 break;
88 }
89
90 return nn;
91 }
92
93
94
95
96
97 void
98 xfs_remove_node(struct xfs_nodelist_head *head, struct xfs_node *node)
99 {
100 struct nh_node_list *h;
101
102 h = &head->nh_nodelist[xfs_hash(&node->handle)];
103 NNPQUEUE_REMOVE(node, h, nn_hash);
104 }
105
106
107
108
109
110 void
111 xfs_insert(struct xfs_nodelist_head *head, struct xfs_node *node)
112 {
113 struct nh_node_list *h;
114
115 h = &head->nh_nodelist[xfs_hash(&node->handle)];
116 NNPQUEUE_INSERT_HEAD(h, node, nn_hash);
117 }
118
119
120
121
122
123 int
124 xfs_update_handle(struct xfs_nodelist_head *head,
125 xfs_handle *old_handlep, xfs_handle *new_handlep)
126 {
127 struct xfs_node *node;
128
129 node = xfs_node_find(head, new_handlep);
130 if (node)
131 return EEXIST;
132 node = xfs_node_find(head, old_handlep);
133 if (node == NULL)
134 return ENOENT;
135 xfs_remove_node(head, node);
136 node->handle = *new_handlep;
137 xfs_insert(head, node);
138
139 return 0;
140 }