linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch 6/11] btrfs: cleanup btrfs_dec_test_ordered_pending()
@ 2010-05-29  9:46 Dan Carpenter
  0 siblings, 0 replies; only message in thread
From: Dan Carpenter @ 2010-05-29  9:46 UTC (permalink / raw)
  To: linux-btrfs
  Cc: Josef Bacik, Yan Zheng, Jens Axboe, Tejun Heo, kernel-janitors,
	Chris Mason

"ret" was used in a confusing way because instead of returning "ret" we
returned the opposite of ret.  I refactored it.  Also if ret is non-zero
in the new code then entry is clearly non-null so I removed that check.

Signed-off-by: Dan Carpenter <error27@gmail.com>

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;
 }
 
 /*

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2010-05-29  9:46 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-05-29  9:46 [patch 6/11] btrfs: cleanup btrfs_dec_test_ordered_pending() Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).