Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 131054
b: refs/heads/master
c: b51912c
h: refs/heads/master
v: v3
  • Loading branch information
Chris Mason committed Feb 4, 2009
1 parent 5f10739 commit ae53bad
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 7 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 0279b4cd86685b5eea467c1b74ce94f0add2c0a3
refs/heads/master: b51912c91fcf7581cc7b4550f1bb96422809d9ed
50 changes: 44 additions & 6 deletions trunk/fs/btrfs/async-thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
#include <linux/kthread.h>
#include <linux/list.h>
#include <linux/spinlock.h>
# include <linux/freezer.h>
#include <linux/freezer.h>
#include <linux/ftrace.h>
#include "async-thread.h"

#define WORK_QUEUED_BIT 0
Expand Down Expand Up @@ -142,6 +143,7 @@ static int worker_loop(void *arg)
struct btrfs_work *work;
do {
spin_lock_irq(&worker->lock);
again_locked:
while (!list_empty(&worker->pending)) {
cur = worker->pending.next;
work = list_entry(cur, struct btrfs_work, list);
Expand All @@ -164,14 +166,50 @@ static int worker_loop(void *arg)
check_idle_worker(worker);

}
worker->working = 0;
if (freezing(current)) {
worker->working = 0;
spin_unlock_irq(&worker->lock);
refrigerator();
} else {
set_current_state(TASK_INTERRUPTIBLE);
spin_unlock_irq(&worker->lock);
if (!kthread_should_stop())
if (!kthread_should_stop()) {
cpu_relax();
/*
* we've dropped the lock, did someone else
* jump_in?
*/
smp_mb();
if (!list_empty(&worker->pending))
continue;

/*
* this short schedule allows more work to
* come in without the queue functions
* needing to go through wake_up_process()
*
* worker->working is still 1, so nobody
* is going to try and wake us up
*/
schedule_timeout(1);
smp_mb();
if (!list_empty(&worker->pending))
continue;

/* still no more work?, sleep for real */
spin_lock_irq(&worker->lock);
set_current_state(TASK_INTERRUPTIBLE);
if (!list_empty(&worker->pending))
goto again_locked;

/*
* this makes sure we get a wakeup when someone
* adds something new to the queue
*/
worker->working = 0;
spin_unlock_irq(&worker->lock);

schedule();
}
__set_current_state(TASK_RUNNING);
}
} while (!kthread_should_stop());
Expand Down Expand Up @@ -355,8 +393,8 @@ int btrfs_requeue_work(struct btrfs_work *work)
goto out;

spin_lock_irqsave(&worker->lock, flags);
atomic_inc(&worker->num_pending);
list_add_tail(&work->list, &worker->pending);
atomic_inc(&worker->num_pending);

/* by definition we're busy, take ourselves off the idle
* list
Expand Down Expand Up @@ -405,9 +443,9 @@ int btrfs_queue_worker(struct btrfs_workers *workers, struct btrfs_work *work)

spin_lock_irqsave(&worker->lock, flags);

list_add_tail(&work->list, &worker->pending);
atomic_inc(&worker->num_pending);
check_busy_worker(worker);
list_add_tail(&work->list, &worker->pending);

/*
* avoid calling into wake_up_process if this thread has already
Expand Down
2 changes: 2 additions & 0 deletions trunk/fs/btrfs/disk-io.c
Original file line number Diff line number Diff line change
Expand Up @@ -1679,6 +1679,8 @@ struct btrfs_root *open_ctree(struct super_block *sb,
* low idle thresh
*/
fs_info->endio_workers.idle_thresh = 4;
fs_info->endio_meta_workers.idle_thresh = 4;

fs_info->endio_write_workers.idle_thresh = 64;
fs_info->endio_meta_write_workers.idle_thresh = 64;

Expand Down

0 comments on commit ae53bad

Please sign in to comment.