diff options
author | Zheng Liu <wenqing.lz@taobao.com> | 2013-02-18 00:27:26 -0500 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2013-02-18 00:27:26 -0500 |
commit | be401363ac5ec652c706263a59b0bd0acc3612e8 (patch) | |
tree | 64a7f85c2e1a0157a3ca740e4afc99260d8938c9 /fs/ext4/extents_status.c | |
parent | fdc0212e86ca15c5cfed77088af7cc5eb79ccbc7 (diff) |
ext4: rename and improbe ext4_es_find_extent()
This commit renames ext4_es_find_extent with ext4_es_find_delayed_extent
and improve this function. First, we split input and output parameter.
Second, this function never return the first block of the next delayed
extent after 'es'.
Signed-off-by: Zheng Liu <wenqing.lz@taobao.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Cc: Jan kara <jack@suse.cz>
Diffstat (limited to 'fs/ext4/extents_status.c')
-rw-r--r-- | fs/ext4/extents_status.c | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/fs/ext4/extents_status.c b/fs/ext4/extents_status.c index 1f5fd44993e9..76f4351ea821 100644 --- a/fs/ext4/extents_status.c +++ b/fs/ext4/extents_status.c | |||
@@ -229,59 +229,59 @@ static struct extent_status *__es_tree_search(struct rb_root *root, | |||
229 | } | 229 | } |
230 | 230 | ||
231 | /* | 231 | /* |
232 | * ext4_es_find_extent: find the 1st delayed extent covering @es->lblk | 232 | * ext4_es_find_delayed_extent: find the 1st delayed extent covering @es->lblk |
233 | * if it exists, otherwise, the next extent after @es->lblk. | 233 | * if it exists, otherwise, the next extent after @es->lblk. |
234 | * | 234 | * |
235 | * @inode: the inode which owns delayed extents | 235 | * @inode: the inode which owns delayed extents |
236 | * @lblk: the offset where we start to search | ||
236 | * @es: delayed extent that we found | 237 | * @es: delayed extent that we found |
237 | * | ||
238 | * Returns the first block of the next extent after es, otherwise | ||
239 | * EXT_MAX_BLOCKS if no extent is found. | ||
240 | * Delayed extent is returned via @es. | ||
241 | */ | 238 | */ |
242 | ext4_lblk_t ext4_es_find_extent(struct inode *inode, struct extent_status *es) | 239 | void ext4_es_find_delayed_extent(struct inode *inode, ext4_lblk_t lblk, |
240 | struct extent_status *es) | ||
243 | { | 241 | { |
244 | struct ext4_es_tree *tree = NULL; | 242 | struct ext4_es_tree *tree = NULL; |
245 | struct extent_status *es1 = NULL; | 243 | struct extent_status *es1 = NULL; |
246 | struct rb_node *node; | 244 | struct rb_node *node; |
247 | ext4_lblk_t ret = EXT_MAX_BLOCKS; | ||
248 | 245 | ||
249 | trace_ext4_es_find_extent_enter(inode, es->es_lblk); | 246 | BUG_ON(es == NULL); |
247 | trace_ext4_es_find_delayed_extent_enter(inode, lblk); | ||
250 | 248 | ||
251 | read_lock(&EXT4_I(inode)->i_es_lock); | 249 | read_lock(&EXT4_I(inode)->i_es_lock); |
252 | tree = &EXT4_I(inode)->i_es_tree; | 250 | tree = &EXT4_I(inode)->i_es_tree; |
253 | 251 | ||
254 | /* find extent in cache firstly */ | 252 | /* find extent in cache firstly */ |
255 | es->es_len = es->es_pblk = 0; | 253 | es->es_lblk = es->es_len = es->es_pblk = 0; |
256 | if (tree->cache_es) { | 254 | if (tree->cache_es) { |
257 | es1 = tree->cache_es; | 255 | es1 = tree->cache_es; |
258 | if (in_range(es->es_lblk, es1->es_lblk, es1->es_len)) { | 256 | if (in_range(lblk, es1->es_lblk, es1->es_len)) { |
259 | es_debug("%u cached by [%u/%u) %llu %llx\n", | 257 | es_debug("%u cached by [%u/%u) %llu %llx\n", |
260 | es->es_lblk, es1->es_lblk, es1->es_len, | 258 | lblk, es1->es_lblk, es1->es_len, |
261 | ext4_es_pblock(es1), ext4_es_status(es1)); | 259 | ext4_es_pblock(es1), ext4_es_status(es1)); |
262 | goto out; | 260 | goto out; |
263 | } | 261 | } |
264 | } | 262 | } |
265 | 263 | ||
266 | es1 = __es_tree_search(&tree->root, es->es_lblk); | 264 | es1 = __es_tree_search(&tree->root, lblk); |
267 | 265 | ||
268 | out: | 266 | out: |
269 | if (es1) { | 267 | if (es1 && !ext4_es_is_delayed(es1)) { |
268 | while ((node = rb_next(&es1->rb_node)) != NULL) { | ||
269 | es1 = rb_entry(node, struct extent_status, rb_node); | ||
270 | if (ext4_es_is_delayed(es1)) | ||
271 | break; | ||
272 | } | ||
273 | } | ||
274 | |||
275 | if (es1 && ext4_es_is_delayed(es1)) { | ||
270 | tree->cache_es = es1; | 276 | tree->cache_es = es1; |
271 | es->es_lblk = es1->es_lblk; | 277 | es->es_lblk = es1->es_lblk; |
272 | es->es_len = es1->es_len; | 278 | es->es_len = es1->es_len; |
273 | es->es_pblk = es1->es_pblk; | 279 | es->es_pblk = es1->es_pblk; |
274 | node = rb_next(&es1->rb_node); | ||
275 | if (node) { | ||
276 | es1 = rb_entry(node, struct extent_status, rb_node); | ||
277 | ret = es1->es_lblk; | ||
278 | } | ||
279 | } | 280 | } |
280 | 281 | ||
281 | read_unlock(&EXT4_I(inode)->i_es_lock); | 282 | read_unlock(&EXT4_I(inode)->i_es_lock); |
282 | 283 | ||
283 | trace_ext4_es_find_extent_exit(inode, es, ret); | 284 | trace_ext4_es_find_delayed_extent_exit(inode, es); |
284 | return ret; | ||
285 | } | 285 | } |
286 | 286 | ||
287 | static struct extent_status * | 287 | static struct extent_status * |