提交 b25f0d00 编写于 作者: N Nikolay Borisov 提交者: David Sterba

btrfs: Use while loop instead of labels in __endio_write_update_ordered

Currently __endio_write_update_ordered uses labels to implement
what is essentially a simple while loop. This makes the code more
cumbersome to follow than it actually has to be. No functional
changes. No xfstest regressions were found during testing.
Signed-off-by: NNikolay Borisov <nborisov@suse.com>
Reviewed-by: NDavid Sterba <dsterba@suse.com>
Signed-off-by: NDavid Sterba <dsterba@suse.com>
上级 89595e80
......@@ -8131,7 +8131,6 @@ static void __endio_write_update_ordered(struct inode *inode,
u64 ordered_offset = offset;
u64 ordered_bytes = bytes;
u64 last_offset;
int ret;
if (btrfs_is_free_space_inode(BTRFS_I(inode))) {
wq = fs_info->endio_freespace_worker;
......@@ -8141,32 +8140,31 @@ static void __endio_write_update_ordered(struct inode *inode,
func = btrfs_endio_write_helper;
}
again:
while (ordered_offset < offset + bytes) {
last_offset = ordered_offset;
ret = btrfs_dec_test_first_ordered_pending(inode, &ordered,
if (btrfs_dec_test_first_ordered_pending(inode, &ordered,
&ordered_offset,
ordered_bytes,
uptodate);
if (!ret)
goto out_test;
btrfs_init_work(&ordered->work, func, finish_ordered_fn, NULL, NULL);
uptodate)) {
btrfs_init_work(&ordered->work, func,
finish_ordered_fn,
NULL, NULL);
btrfs_queue_work(wq, &ordered->work);
out_test:
}
/*
* If btrfs_dec_test_ordered_pending does not find any ordered extent
* in the range, we can exit.
* If btrfs_dec_test_ordered_pending does not find any ordered
* extent in the range, we can exit.
*/
if (ordered_offset == last_offset)
return;
/*
* our bio might span multiple ordered extents. If we haven't
* completed the accounting for the whole dio, go back and try again
* Our bio might span multiple ordered extents. In this case
* we keep goin until we have accounted the whole dio.
*/
if (ordered_offset < offset + bytes) {
ordered_bytes = offset + bytes - ordered_offset;
ordered = NULL;
goto again;
}
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册