diff mbox

[6/11] btrfs: cleanup btrfs_dec_test_ordered_pending()

Message ID 20100529094606.GG5483@bicker (mailing list archive)
State New, archived
Headers show

Commit Message

Dan Carpenter May 29, 2010, 9:46 a.m. UTC
None
diff mbox

Patch

diff --git a/fs/btrfs/ordered-data.c b/fs/btrfs/ordered-data.c
index e56c72b..0a37019 100644
--- a/fs/btrfs/ordered-data.c
+++ b/fs/btrfs/ordered-data.c
@@ -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;
 }
 
 /*