* [PATCH] btrfs: Fix busyloops in transaction waiting code
@ 2012-01-25 14:31 Jan Kara
0 siblings, 0 replies; 3+ messages in thread
From: Jan Kara @ 2012-01-25 14:31 UTC (permalink / raw)
To: Chris Mason; +Cc: linux-btrfs, Jan Kara, stable
wait_log_commit() and wait_for_writer() were using slightly different
conditions for deciding whether they should call schedule() and whether they
should continue in the wait loop. Thus it could happen that we busylooped when
the first condition was not true while the second one was. That is burning CPU
cycles needlessly and is deadly on UP machines...
CC: stable@kernel.org
Signed-off-by: Jan Kara <jack@suse.cz>
---
fs/btrfs/tree-log.c | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
index cb877e0..966cc74 100644
--- a/fs/btrfs/tree-log.c
+++ b/fs/btrfs/tree-log.c
@@ -1957,7 +1957,8 @@ static int wait_log_commit(struct btrfs_trans_handle *trans,
finish_wait(&root->log_commit_wait[index], &wait);
mutex_lock(&root->log_mutex);
- } while (root->log_transid < transid + 2 &&
+ } while (root->fs_info->last_trans_log_full_commit !=
+ trans->transid && root->log_transid < transid + 2 &&
atomic_read(&root->log_commit[index]));
return 0;
}
@@ -1966,7 +1967,8 @@ static int wait_for_writer(struct btrfs_trans_handle *trans,
struct btrfs_root *root)
{
DEFINE_WAIT(wait);
- while (atomic_read(&root->log_writers)) {
+ while (root->fs_info->last_trans_log_full_commit !=
+ trans->transid && atomic_read(&root->log_writers)) {
prepare_to_wait(&root->log_writer_wait,
&wait, TASK_UNINTERRUPTIBLE);
mutex_unlock(&root->log_mutex);
--
1.7.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH] btrfs: Fix busyloops in transaction waiting code
@ 2012-01-26 16:11 Jan Kara
2012-01-26 17:38 ` Chris Mason
0 siblings, 1 reply; 3+ messages in thread
From: Jan Kara @ 2012-01-26 16:11 UTC (permalink / raw)
To: Chris Mason; +Cc: linux-btrfs, Jan Kara
wait_log_commit() and wait_for_writer() were using slightly different
conditions for deciding whether they should call schedule() and whether they
should continue in the wait loop. Thus it could happen that we busylooped when
the first condition was not true while the second one was. That is burning CPU
cycles needlessly and is deadly on UP machines...
Signed-off-by: Jan Kara <jack@suse.cz>
---
fs/btrfs/tree-log.c | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
index cb877e0..966cc74 100644
--- a/fs/btrfs/tree-log.c
+++ b/fs/btrfs/tree-log.c
@@ -1957,7 +1957,8 @@ static int wait_log_commit(struct btrfs_trans_handle *trans,
finish_wait(&root->log_commit_wait[index], &wait);
mutex_lock(&root->log_mutex);
- } while (root->log_transid < transid + 2 &&
+ } while (root->fs_info->last_trans_log_full_commit !=
+ trans->transid && root->log_transid < transid + 2 &&
atomic_read(&root->log_commit[index]));
return 0;
}
@@ -1966,7 +1967,8 @@ static int wait_for_writer(struct btrfs_trans_handle *trans,
struct btrfs_root *root)
{
DEFINE_WAIT(wait);
- while (atomic_read(&root->log_writers)) {
+ while (root->fs_info->last_trans_log_full_commit !=
+ trans->transid && atomic_read(&root->log_writers)) {
prepare_to_wait(&root->log_writer_wait,
&wait, TASK_UNINTERRUPTIBLE);
mutex_unlock(&root->log_mutex);
--
1.7.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] btrfs: Fix busyloops in transaction waiting code
2012-01-26 16:11 [PATCH] btrfs: Fix busyloops in transaction waiting code Jan Kara
@ 2012-01-26 17:38 ` Chris Mason
0 siblings, 0 replies; 3+ messages in thread
From: Chris Mason @ 2012-01-26 17:38 UTC (permalink / raw)
To: Jan Kara; +Cc: linux-btrfs
On Thu, Jan 26, 2012 at 05:11:36PM +0100, Jan Kara wrote:
> wait_log_commit() and wait_for_writer() were using slightly different
> conditions for deciding whether they should call schedule() and whether they
> should continue in the wait loop. Thus it could happen that we busylooped when
> the first condition was not true while the second one was. That is burning CPU
> cycles needlessly and is deadly on UP machines...
Thanks Jan, I'll pull this in.
-chris
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-01-26 17:38 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-26 16:11 [PATCH] btrfs: Fix busyloops in transaction waiting code Jan Kara
2012-01-26 17:38 ` Chris Mason
-- strict thread matches above, loose matches on Subject: below --
2012-01-25 14:31 Jan Kara
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).