@@ -270,13 +270,13 @@ int btrfs_dec_test_ordered_pending(struct inode *inode,
spin_lock(&tree->lock);
node = tree_search(tree, file_offset);
if (!node) {
- ret = 1;
+ ret = 0;
goto out;
}
entry = rb_entry(node, struct btrfs_ordered_extent, rb_node);
if (!offset_in_entry(entry, file_offset)) {
- ret = 1;
+ ret = 0;
goto out;
}
@@ -286,17 +286,19 @@ int btrfs_dec_test_ordered_pending(struct inode *inode,
(unsigned long long)io_size);
}
entry->bytes_left -= io_size;
- if (entry->bytes_left == 0)
+ if (entry->bytes_left == 0) {
ret = test_and_set_bit(BTRFS_ORDERED_IO_DONE, &entry->flags);
- else
- ret = 1;
+ ret = !ret;
+ } else {
+ ret = 0;
+ }
out:
- if (!ret && cached && entry) {
+ if (ret && cached) {
*cached = entry;
atomic_inc(&entry->refs);
}
spin_unlock(&tree->lock);
- return ret == 0;
+ return ret;
}
/*