From: David Sterba <dsterba@suse.cz>
To: linux-btrfs@vger.kernel.org
Cc: David Sterba <dsterba@suse.cz>
Subject: [PATCH 02/11] btrfs: use cond_resched_lock where possible
Date: Wed, 25 Feb 2015 19:24:38 +0100 [thread overview]
Message-ID: <14cc5298649a1fee36a8ff2a99cac4ef28dc8be5.1424880058.git.dsterba@suse.cz> (raw)
In-Reply-To: <cover.1424880058.git.dsterba@suse.cz>
Clean the opencoded variant, cond_resched_lock also checks the lock for
contention so it might help in some cases that were not covered by
simple need_resched().
Signed-off-by: David Sterba <dsterba@suse.cz>
---
fs/btrfs/file.c | 6 +-----
fs/btrfs/free-space-cache.c | 14 ++++----------
fs/btrfs/transaction.c | 7 ++-----
3 files changed, 7 insertions(+), 20 deletions(-)
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index e4090259569b..1e34bc00249f 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -273,11 +273,7 @@ void btrfs_cleanup_defrag_inodes(struct btrfs_fs_info *fs_info)
defrag = rb_entry(node, struct inode_defrag, rb_node);
kmem_cache_free(btrfs_inode_defrag_cachep, defrag);
- if (need_resched()) {
- spin_unlock(&fs_info->defrag_inodes_lock);
- cond_resched();
- spin_lock(&fs_info->defrag_inodes_lock);
- }
+ cond_resched_lock(&fs_info->defrag_inodes_lock);
node = rb_first(&fs_info->defrag_inodes);
}
diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c
index a71978578fa7..96611fed552f 100644
--- a/fs/btrfs/free-space-cache.c
+++ b/fs/btrfs/free-space-cache.c
@@ -2402,11 +2402,8 @@ static void __btrfs_remove_free_space_cache_locked(
} else {
free_bitmap(ctl, info);
}
- if (need_resched()) {
- spin_unlock(&ctl->tree_lock);
- cond_resched();
- spin_lock(&ctl->tree_lock);
- }
+
+ cond_resched_lock(&ctl->tree_lock);
}
}
@@ -2431,11 +2428,8 @@ void btrfs_remove_free_space_cache(struct btrfs_block_group_cache *block_group)
WARN_ON(cluster->block_group != block_group);
__btrfs_return_cluster_to_free_space(block_group, cluster);
- if (need_resched()) {
- spin_unlock(&ctl->tree_lock);
- cond_resched();
- spin_lock(&ctl->tree_lock);
- }
+
+ cond_resched_lock(&ctl->tree_lock);
}
__btrfs_remove_free_space_cache_locked(ctl);
spin_unlock(&ctl->tree_lock);
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
index 038fcf6051e0..efc5ebffa7ea 100644
--- a/fs/btrfs/transaction.c
+++ b/fs/btrfs/transaction.c
@@ -93,11 +93,8 @@ static void clear_btree_io_tree(struct extent_io_tree *tree)
*/
ASSERT(!waitqueue_active(&state->wq));
free_extent_state(state);
- if (need_resched()) {
- spin_unlock(&tree->lock);
- cond_resched();
- spin_lock(&tree->lock);
- }
+
+ cond_resched_lock(&tree->lock);
}
spin_unlock(&tree->lock);
}
--
2.1.3
next prev parent reply other threads:[~2015-02-25 18:24 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-25 18:24 [PULL] [PATCH 00/11] Cleanups for 4.1 David Sterba
2015-02-25 18:24 ` [PATCH 01/11] btrfs: need_resched not needed with cond_resched David Sterba
2015-02-25 18:24 ` David Sterba [this message]
2015-02-25 18:24 ` [PATCH 03/11] btrfs: cleanup 64bit/32bit divs, compile time constants David Sterba
2015-02-25 18:24 ` [PATCH 04/11] btrfs: cleanup 64bit/32bit divs, provably bounded values David Sterba
2015-02-25 18:24 ` [PATCH 05/11] btrfs: replace remaining do_div calls with div_u64 variants David Sterba
2015-02-25 18:24 ` [PATCH 06/11] btrfs: cleanup, use correct type in div_u64_rem David Sterba
2015-02-25 18:24 ` [PATCH 07/11] btrfs: cleanup, use kmalloc_array/kcalloc array helpers David Sterba
2015-02-25 18:24 ` [PATCH 08/11] btrfs: remove shadowing variables in __btrfs_buffered_write David Sterba
2015-02-25 18:25 ` [PATCH 09/11] btrfs: switch helper macros to static inlines in sysfs.h David Sterba
2015-02-25 18:25 ` [PATCH 10/11] btrfs: remove shadowing variables in __btrfs_map_block David Sterba
2015-02-25 18:25 ` [PATCH 11/11] btrfs: use explicit initializer for seq_elem David Sterba
2015-02-26 1:39 ` [PULL] [PATCH 00/11] Cleanups for 4.1 Zhao Lei
2015-02-26 17:46 ` David Sterba
2015-03-03 16:30 ` David Sterba
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=14cc5298649a1fee36a8ff2a99cac4ef28dc8be5.1424880058.git.dsterba@suse.cz \
--to=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).