From: David Sterba <dsterba@suse.com>
To: linux-btrfs@vger.kernel.org
Cc: David Sterba <dsterba@suse.com>
Subject: [PATCH 3/7] btrfs: preallocate radix tree node for global readahead tree
Date: Wed, 15 Mar 2017 17:02:30 +0100 [thread overview]
Message-ID: <47dc4887b9954bd94e3926354ca85067a9fa86ff.1489593696.git.dsterba@suse.com> (raw)
In-Reply-To: <cover.1489593696.git.dsterba@suse.com>
We can preallocate the node so insertion does not have to do that under
the lock. The GFP flags for the global radix tree are initialized to
GFP_NOFS & ~__GFP_DIRECT_RECLAIM
but we can use GFP_KERNEL, because readahead is optional and not on any
critical writeout path.
Signed-off-by: David Sterba <dsterba@suse.com>
---
fs/btrfs/disk-io.c | 2 +-
fs/btrfs/reada.c | 7 +++++++
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 08b74daf35d0..1d4c30327247 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -2693,7 +2693,7 @@ int open_ctree(struct super_block *sb,
fs_info->commit_interval = BTRFS_DEFAULT_COMMIT_INTERVAL;
fs_info->avg_delayed_ref_runtime = NSEC_PER_SEC >> 6; /* div by 64 */
/* readahead state */
- INIT_RADIX_TREE(&fs_info->reada_tree, GFP_NOFS & ~__GFP_DIRECT_RECLAIM);
+ INIT_RADIX_TREE(&fs_info->reada_tree, GFP_KERNEL);
spin_lock_init(&fs_info->reada_lock);
fs_info->thread_pool_size = min_t(unsigned long,
diff --git a/fs/btrfs/reada.c b/fs/btrfs/reada.c
index dd78af5d265d..4c5a9b241cab 100644
--- a/fs/btrfs/reada.c
+++ b/fs/btrfs/reada.c
@@ -391,6 +391,10 @@ static struct reada_extent *reada_find_extent(struct btrfs_fs_info *fs_info,
goto error;
}
+ ret = radix_tree_preload(GFP_KERNEL);
+ if (ret)
+ goto error;
+
/* insert extent in reada_tree + all per-device trees, all or nothing */
btrfs_dev_replace_lock(&fs_info->dev_replace, 0);
spin_lock(&fs_info->reada_lock);
@@ -400,13 +404,16 @@ static struct reada_extent *reada_find_extent(struct btrfs_fs_info *fs_info,
re_exist->refcnt++;
spin_unlock(&fs_info->reada_lock);
btrfs_dev_replace_unlock(&fs_info->dev_replace, 0);
+ radix_tree_preload_end();
goto error;
}
if (ret) {
spin_unlock(&fs_info->reada_lock);
btrfs_dev_replace_unlock(&fs_info->dev_replace, 0);
+ radix_tree_preload_end();
goto error;
}
+ radix_tree_preload_end();
prev_dev = NULL;
dev_replace_is_ongoing = btrfs_dev_replace_is_ongoing(
&fs_info->dev_replace);
--
2.12.0
next prev 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 ` [PATCH 2/7] btrfs: use simpler readahead zone lookups David Sterba
2017-03-20 20:44 ` Liu Bo
2017-03-31 17:33 ` David Sterba
2017-03-15 16:02 ` David Sterba [this message]
2017-03-20 20:58 ` [PATCH 3/7] btrfs: preallocate radix tree node for global readahead tree 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=47dc4887b9954bd94e3926354ca85067a9fa86ff.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 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).