All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Sterba <dsterba@suse.com>
To: linux-btrfs@vger.kernel.org
Cc: David Sterba <dsterba@suse.com>
Subject: [PATCH 2/7] btrfs: use simpler readahead zone lookups
Date: Wed, 15 Mar 2017 17:02:26 +0100	[thread overview]
Message-ID: <28edb65e1e98d9f815f3b64cdd2489d4be78e681.1489593696.git.dsterba@suse.com> (raw)
In-Reply-To: <cover.1489593696.git.dsterba@suse.com>

No point using radix_tree_gang_lookup if we're looking up just one slot.

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/reada.c | 52 ++++++++++++++++++++++------------------------------
 1 file changed, 22 insertions(+), 30 deletions(-)

diff --git a/fs/btrfs/reada.c b/fs/btrfs/reada.c
index fdae8ca79401..dd78af5d265d 100644
--- a/fs/btrfs/reada.c
+++ b/fs/btrfs/reada.c
@@ -246,11 +246,9 @@ static struct reada_zone *reada_find_zone(struct btrfs_fs_info *fs_info,
 	u64 end;
 	int i;
 
-	zone = NULL;
 	spin_lock(&fs_info->reada_lock);
-	ret = radix_tree_gang_lookup(&dev->reada_zones, (void **)&zone,
-				     logical >> PAGE_SHIFT, 1);
-	if (ret == 1 && logical >= zone->start && logical <= zone->end) {
+	zone = radix_tree_lookup(&dev->reada_zones, logical >> PAGE_SHIFT);
+	if (zone && logical >= zone->start && logical <= zone->end) {
 		kref_get(&zone->refcnt);
 		spin_unlock(&fs_info->reada_lock);
 		return zone;
@@ -297,9 +295,9 @@ static struct reada_zone *reada_find_zone(struct btrfs_fs_info *fs_info,
 
 	if (ret == -EEXIST) {
 		kfree(zone);
-		ret = radix_tree_gang_lookup(&dev->reada_zones, (void **)&zone,
-					     logical >> PAGE_SHIFT, 1);
-		if (ret == 1 && logical >= zone->start && logical <= zone->end)
+		zone = radix_tree_lookup(&dev->reada_zones,
+				logical >> PAGE_SHIFT);
+		if (zone && logical >= zone->start && logical <= zone->end)
 			kref_get(&zone->refcnt);
 		else
 			zone = NULL;
@@ -604,7 +602,6 @@ static int reada_pick_zone(struct btrfs_device *dev)
 	u64 top_elems = 0;
 	u64 top_locked_elems = 0;
 	unsigned long index = 0;
-	int ret;
 
 	if (dev->reada_curr_zone) {
 		reada_peer_zones_set_lock(dev->reada_curr_zone, 0);
@@ -615,9 +612,8 @@ static int reada_pick_zone(struct btrfs_device *dev)
 	while (1) {
 		struct reada_zone *zone;
 
-		ret = radix_tree_gang_lookup(&dev->reada_zones,
-					     (void **)&zone, index, 1);
-		if (ret == 0)
+		zone = radix_tree_lookup(&dev->reada_zones, index);
+		if (!zone)
 			break;
 		index = (zone->end >> PAGE_SHIFT) + 1;
 		if (zone->locked) {
@@ -669,19 +665,18 @@ static int reada_start_machine_dev(struct btrfs_fs_info *fs_info,
 	 * a contiguous block of extents, we could also coagulate them or use
 	 * plugging to speed things up
 	 */
-	ret = radix_tree_gang_lookup(&dev->reada_extents, (void **)&re,
-				     dev->reada_next >> PAGE_SHIFT, 1);
-	if (ret == 0 || re->logical > dev->reada_curr_zone->end) {
+	re = radix_tree_lookup(&dev->reada_extents,
+			dev->reada_next >> PAGE_SHIFT);
+	if (!re || re->logical > dev->reada_curr_zone->end) {
 		ret = reada_pick_zone(dev);
 		if (!ret) {
 			spin_unlock(&fs_info->reada_lock);
 			return 0;
 		}
-		re = NULL;
-		ret = radix_tree_gang_lookup(&dev->reada_extents, (void **)&re,
-					dev->reada_next >> PAGE_SHIFT, 1);
+		re = radix_tree_lookup(&dev->reada_extents,
+				dev->reada_next >> PAGE_SHIFT);
 	}
-	if (ret == 0) {
+	if (!re) {
 		spin_unlock(&fs_info->reada_lock);
 		return 0;
 	}
@@ -809,7 +804,6 @@ static void dump_devs(struct btrfs_fs_info *fs_info, int all)
 	struct btrfs_device *device;
 	struct btrfs_fs_devices *fs_devices = fs_info->fs_devices;
 	unsigned long index;
-	int ret;
 	int i;
 	int j;
 	int cnt;
@@ -821,9 +815,9 @@ static void dump_devs(struct btrfs_fs_info *fs_info, int all)
 		index = 0;
 		while (1) {
 			struct reada_zone *zone;
-			ret = radix_tree_gang_lookup(&device->reada_zones,
-						     (void **)&zone, index, 1);
-			if (ret == 0)
+
+			zone = radix_tree_lookup(&device->reada_zones, index);
+			if (!zone)
 				break;
 			pr_debug("  zone %llu-%llu elems %llu locked %d devs",
 				    zone->start, zone->end, zone->elems,
@@ -841,11 +835,10 @@ static void dump_devs(struct btrfs_fs_info *fs_info, int all)
 		cnt = 0;
 		index = 0;
 		while (all) {
-			struct reada_extent *re = NULL;
+			struct reada_extent *re;
 
-			ret = radix_tree_gang_lookup(&device->reada_extents,
-						     (void **)&re, index, 1);
-			if (ret == 0)
+			re = radix_tree_lookup(&device->reada_extents, index);
+			if (!re)
 				break;
 			pr_debug("  re: logical %llu size %u empty %d scheduled %d",
 				re->logical, fs_info->nodesize,
@@ -870,11 +863,10 @@ static void dump_devs(struct btrfs_fs_info *fs_info, int all)
 	index = 0;
 	cnt = 0;
 	while (all) {
-		struct reada_extent *re = NULL;
+		struct reada_extent *re;
 
-		ret = radix_tree_gang_lookup(&fs_info->reada_tree, (void **)&re,
-					     index, 1);
-		if (ret == 0)
+		re = radix_tree_lookup(&fs_info->reada_tree, index);
+		if (!re)
 			break;
 		if (!re->scheduled) {
 			index = (re->logical >> PAGE_SHIFT) + 1;
-- 
2.12.0


  parent reply	other threads:[~2017-03-15 16:03 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-15 16:02 [PATCH 0/7] Readahead clenups David Sterba
2017-03-15 16:02 ` [PATCH 1/7] btrfs: preallocate radix tree node for readahead David Sterba
2017-03-20 20:40   ` Liu Bo
2017-03-15 16:02 ` David Sterba [this message]
2017-03-20 20:44   ` [PATCH 2/7] btrfs: use simpler readahead zone lookups Liu Bo
2017-03-31 17:33   ` David Sterba
2017-03-15 16:02 ` [PATCH 3/7] btrfs: preallocate radix tree node for global readahead tree David Sterba
2017-03-20 20:58   ` Liu Bo
2017-03-15 16:02 ` [PATCH 4/7] btrfs: remove redundant parameter from btree_readahead_hook David Sterba
2017-03-20 21:00   ` Liu Bo
2017-03-15 16:02 ` [PATCH 5/7] btrfs: remove redundant parameter from reada_find_zone David Sterba
2017-03-20 21:03   ` Liu Bo
2017-03-15 16:02 ` [PATCH 6/7] btrfs: remove redundant parameter from reada_start_machine_dev David Sterba
2017-03-20 21:04   ` Liu Bo
2017-03-15 16:02 ` [PATCH 7/7] btrfs: remove local blocksize variable in reada_find_extent David Sterba
2017-03-20 21:04   ` Liu Bo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=28edb65e1e98d9f815f3b64cdd2489d4be78e681.1489593696.git.dsterba@suse.com \
    --to=dsterba@suse.com \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.