[patch 6/11] btrfs: cleanup btrfs_dec_test_ordered_pending()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



"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@xxxxxxxxx>

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;
 }
 
 /*
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux