diff options
Diffstat (limited to 'fs/nilfs2')
-rw-r--r-- | fs/nilfs2/btree.c | 41 |
1 files changed, 19 insertions, 22 deletions
diff --git a/fs/nilfs2/btree.c b/fs/nilfs2/btree.c index 7089d9041146..6462c7026479 100644 --- a/fs/nilfs2/btree.c +++ b/fs/nilfs2/btree.c | |||
@@ -106,48 +106,45 @@ static int nilfs_btree_get_new_block(const struct nilfs_bmap *btree, | |||
106 | return 0; | 106 | return 0; |
107 | } | 107 | } |
108 | 108 | ||
109 | static inline int | 109 | static int nilfs_btree_node_get_flags(const struct nilfs_btree_node *node) |
110 | nilfs_btree_node_get_flags(const struct nilfs_btree_node *node) | ||
111 | { | 110 | { |
112 | return node->bn_flags; | 111 | return node->bn_flags; |
113 | } | 112 | } |
114 | 113 | ||
115 | static inline void | 114 | static void |
116 | nilfs_btree_node_set_flags(struct nilfs_btree_node *node, int flags) | 115 | nilfs_btree_node_set_flags(struct nilfs_btree_node *node, int flags) |
117 | { | 116 | { |
118 | node->bn_flags = flags; | 117 | node->bn_flags = flags; |
119 | } | 118 | } |
120 | 119 | ||
121 | static inline int nilfs_btree_node_root(const struct nilfs_btree_node *node) | 120 | static int nilfs_btree_node_root(const struct nilfs_btree_node *node) |
122 | { | 121 | { |
123 | return nilfs_btree_node_get_flags(node) & NILFS_BTREE_NODE_ROOT; | 122 | return nilfs_btree_node_get_flags(node) & NILFS_BTREE_NODE_ROOT; |
124 | } | 123 | } |
125 | 124 | ||
126 | static inline int | 125 | static int nilfs_btree_node_get_level(const struct nilfs_btree_node *node) |
127 | nilfs_btree_node_get_level(const struct nilfs_btree_node *node) | ||
128 | { | 126 | { |
129 | return node->bn_level; | 127 | return node->bn_level; |
130 | } | 128 | } |
131 | 129 | ||
132 | static inline void | 130 | static void |
133 | nilfs_btree_node_set_level(struct nilfs_btree_node *node, int level) | 131 | nilfs_btree_node_set_level(struct nilfs_btree_node *node, int level) |
134 | { | 132 | { |
135 | node->bn_level = level; | 133 | node->bn_level = level; |
136 | } | 134 | } |
137 | 135 | ||
138 | static inline int | 136 | static int nilfs_btree_node_get_nchildren(const struct nilfs_btree_node *node) |
139 | nilfs_btree_node_get_nchildren(const struct nilfs_btree_node *node) | ||
140 | { | 137 | { |
141 | return le16_to_cpu(node->bn_nchildren); | 138 | return le16_to_cpu(node->bn_nchildren); |
142 | } | 139 | } |
143 | 140 | ||
144 | static inline void | 141 | static void |
145 | nilfs_btree_node_set_nchildren(struct nilfs_btree_node *node, int nchildren) | 142 | nilfs_btree_node_set_nchildren(struct nilfs_btree_node *node, int nchildren) |
146 | { | 143 | { |
147 | node->bn_nchildren = cpu_to_le16(nchildren); | 144 | node->bn_nchildren = cpu_to_le16(nchildren); |
148 | } | 145 | } |
149 | 146 | ||
150 | static inline int nilfs_btree_node_size(const struct nilfs_bmap *btree) | 147 | static int nilfs_btree_node_size(const struct nilfs_bmap *btree) |
151 | { | 148 | { |
152 | return 1 << btree->b_inode->i_blkbits; | 149 | return 1 << btree->b_inode->i_blkbits; |
153 | } | 150 | } |
@@ -157,7 +154,7 @@ static int nilfs_btree_nchildren_per_block(const struct nilfs_bmap *btree) | |||
157 | return btree->b_nchildren_per_block; | 154 | return btree->b_nchildren_per_block; |
158 | } | 155 | } |
159 | 156 | ||
160 | static inline __le64 * | 157 | static __le64 * |
161 | nilfs_btree_node_dkeys(const struct nilfs_btree_node *node) | 158 | nilfs_btree_node_dkeys(const struct nilfs_btree_node *node) |
162 | { | 159 | { |
163 | return (__le64 *)((char *)(node + 1) + | 160 | return (__le64 *)((char *)(node + 1) + |
@@ -165,32 +162,32 @@ nilfs_btree_node_dkeys(const struct nilfs_btree_node *node) | |||
165 | 0 : NILFS_BTREE_NODE_EXTRA_PAD_SIZE)); | 162 | 0 : NILFS_BTREE_NODE_EXTRA_PAD_SIZE)); |
166 | } | 163 | } |
167 | 164 | ||
168 | static inline __le64 * | 165 | static __le64 * |
169 | nilfs_btree_node_dptrs(const struct nilfs_btree_node *node, int ncmax) | 166 | nilfs_btree_node_dptrs(const struct nilfs_btree_node *node, int ncmax) |
170 | { | 167 | { |
171 | return (__le64 *)(nilfs_btree_node_dkeys(node) + ncmax); | 168 | return (__le64 *)(nilfs_btree_node_dkeys(node) + ncmax); |
172 | } | 169 | } |
173 | 170 | ||
174 | static inline __u64 | 171 | static __u64 |
175 | nilfs_btree_node_get_key(const struct nilfs_btree_node *node, int index) | 172 | nilfs_btree_node_get_key(const struct nilfs_btree_node *node, int index) |
176 | { | 173 | { |
177 | return le64_to_cpu(*(nilfs_btree_node_dkeys(node) + index)); | 174 | return le64_to_cpu(*(nilfs_btree_node_dkeys(node) + index)); |
178 | } | 175 | } |
179 | 176 | ||
180 | static inline void | 177 | static void |
181 | nilfs_btree_node_set_key(struct nilfs_btree_node *node, int index, __u64 key) | 178 | nilfs_btree_node_set_key(struct nilfs_btree_node *node, int index, __u64 key) |
182 | { | 179 | { |
183 | *(nilfs_btree_node_dkeys(node) + index) = cpu_to_le64(key); | 180 | *(nilfs_btree_node_dkeys(node) + index) = cpu_to_le64(key); |
184 | } | 181 | } |
185 | 182 | ||
186 | static inline __u64 | 183 | static __u64 |
187 | nilfs_btree_node_get_ptr(const struct nilfs_btree_node *node, int index, | 184 | nilfs_btree_node_get_ptr(const struct nilfs_btree_node *node, int index, |
188 | int ncmax) | 185 | int ncmax) |
189 | { | 186 | { |
190 | return le64_to_cpu(*(nilfs_btree_node_dptrs(node, ncmax) + index)); | 187 | return le64_to_cpu(*(nilfs_btree_node_dptrs(node, ncmax) + index)); |
191 | } | 188 | } |
192 | 189 | ||
193 | static inline void | 190 | static void |
194 | nilfs_btree_node_set_ptr(struct nilfs_btree_node *node, int index, __u64 ptr, | 191 | nilfs_btree_node_set_ptr(struct nilfs_btree_node *node, int index, __u64 ptr, |
195 | int ncmax) | 192 | int ncmax) |
196 | { | 193 | { |
@@ -402,25 +399,25 @@ int nilfs_btree_broken_node_block(struct buffer_head *bh) | |||
402 | bh->b_size, bh->b_blocknr); | 399 | bh->b_size, bh->b_blocknr); |
403 | } | 400 | } |
404 | 401 | ||
405 | static inline struct nilfs_btree_node * | 402 | static struct nilfs_btree_node * |
406 | nilfs_btree_get_root(const struct nilfs_bmap *btree) | 403 | nilfs_btree_get_root(const struct nilfs_bmap *btree) |
407 | { | 404 | { |
408 | return (struct nilfs_btree_node *)btree->b_u.u_data; | 405 | return (struct nilfs_btree_node *)btree->b_u.u_data; |
409 | } | 406 | } |
410 | 407 | ||
411 | static inline struct nilfs_btree_node * | 408 | static struct nilfs_btree_node * |
412 | nilfs_btree_get_nonroot_node(const struct nilfs_btree_path *path, int level) | 409 | nilfs_btree_get_nonroot_node(const struct nilfs_btree_path *path, int level) |
413 | { | 410 | { |
414 | return (struct nilfs_btree_node *)path[level].bp_bh->b_data; | 411 | return (struct nilfs_btree_node *)path[level].bp_bh->b_data; |
415 | } | 412 | } |
416 | 413 | ||
417 | static inline struct nilfs_btree_node * | 414 | static struct nilfs_btree_node * |
418 | nilfs_btree_get_sib_node(const struct nilfs_btree_path *path, int level) | 415 | nilfs_btree_get_sib_node(const struct nilfs_btree_path *path, int level) |
419 | { | 416 | { |
420 | return (struct nilfs_btree_node *)path[level].bp_sib_bh->b_data; | 417 | return (struct nilfs_btree_node *)path[level].bp_sib_bh->b_data; |
421 | } | 418 | } |
422 | 419 | ||
423 | static inline int nilfs_btree_height(const struct nilfs_bmap *btree) | 420 | static int nilfs_btree_height(const struct nilfs_bmap *btree) |
424 | { | 421 | { |
425 | return nilfs_btree_node_get_level(nilfs_btree_get_root(btree)) + 1; | 422 | return nilfs_btree_node_get_level(nilfs_btree_get_root(btree)) + 1; |
426 | } | 423 | } |
@@ -442,7 +439,7 @@ nilfs_btree_get_node(const struct nilfs_bmap *btree, | |||
442 | return node; | 439 | return node; |
443 | } | 440 | } |
444 | 441 | ||
445 | static inline int | 442 | static int |
446 | nilfs_btree_bad_node(struct nilfs_btree_node *node, int level) | 443 | nilfs_btree_bad_node(struct nilfs_btree_node *node, int level) |
447 | { | 444 | { |
448 | if (unlikely(nilfs_btree_node_get_level(node) != level)) { | 445 | if (unlikely(nilfs_btree_node_get_level(node) != level)) { |