linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Gu Jinxiang <gujx@cn.fujitsu.com>
To: <dsterba@suse.cz>
Cc: <linux-btrfs@vger.kernel.org>, Gu JinXiang <gujx@cn.fujitsu.com>
Subject: [PATCH v2 1/2] btrfs-progs: do less aggressive btree readahead
Date: Thu, 11 Jan 2018 18:11:07 +0800	[thread overview]
Message-ID: <1515665468-7450-2-git-send-email-gujx@cn.fujitsu.com> (raw)
In-Reply-To: <1515665468-7450-1-git-send-email-gujx@cn.fujitsu.com>

Update btrfs-progs to match kernel sources.
Reference:
commit a717531942f4 ("Btrfs: do less aggressive btree readahead")

Signed-off-by: Gu JinXiang <gujx@cn.fujitsu.com>
---
 ctree.c | 20 +++++---------------
 1 file changed, 5 insertions(+), 15 deletions(-)

diff --git a/ctree.c b/ctree.c
index 4fc33b14..361e53a8 100644
--- a/ctree.c
+++ b/ctree.c
@@ -972,8 +972,7 @@ void reada_for_search(struct btrfs_root *root, struct btrfs_path *path,
 	struct btrfs_disk_key disk_key;
 	u32 nritems;
 	u64 search;
-	u64 lowest_read;
-	u64 highest_read;
+	u64 target;
 	u64 nread = 0;
 	int direction = path->reada;
 	struct extent_buffer *eb;
@@ -994,8 +993,7 @@ void reada_for_search(struct btrfs_root *root, struct btrfs_path *path,
 		return;
 	}
 
-	highest_read = search;
-	lowest_read = search;
+	target = search;
 
 	nritems = btrfs_header_nritems(node);
 	nr = slot;
@@ -1015,23 +1013,15 @@ void reada_for_search(struct btrfs_root *root, struct btrfs_path *path,
 				break;
 		}
 		search = btrfs_node_blockptr(node, nr);
-		if ((search >= lowest_read && search <= highest_read) ||
-		    (search < lowest_read && lowest_read - search <= 32768) ||
-		    (search > highest_read && search - highest_read <= 32768)) {
+		if ((search <= target && target - search <= 65536) ||
+		    (search > target && search - target <= 65536)) {
 			readahead_tree_block(fs_info, search,
 				     btrfs_node_ptr_generation(node, nr));
 			nread += fs_info->nodesize;
 		}
 		nscan++;
-		if (path->reada < 2 && (nread > SZ_256K || nscan > 32))
+		if ((nread > 65536 || nscan > 32))
 			break;
-		if(nread > SZ_1M || nscan > 128)
-			break;
-
-		if (search < lowest_read)
-			lowest_read = search;
-		if (search > highest_read)
-			highest_read = search;
 	}
 }
 
-- 
2.14.3




  reply	other threads:[~2018-01-11 10:11 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-05 11:01 [PATCH] btrfs-progs: use enum instead of constant value Gu Jinxiang
2018-01-11 10:11 ` [PATCH v2 0/2] btrfs-progs: Update btrfs-progs to match kernel sources Gu Jinxiang
2018-01-11 10:11   ` Gu Jinxiang [this message]
2018-01-11 10:11   ` [PATCH v2 2/2] btrfs-progs: cleanup, use enum values for btrfs_path reada Gu Jinxiang

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=1515665468-7450-2-git-send-email-gujx@cn.fujitsu.com \
    --to=gujx@cn.fujitsu.com \
    --cc=dsterba@suse.cz \
    --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 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).