summaryrefslogtreecommitdiffstats
path: root/fs/btrfs/delayed-ref.h
diff options
context:
space:
mode:
authorJan Schmidt <list.btrfs@jan-o-sch.net>2011-12-12 16:10:07 +0100
committerJan Schmidt <list.btrfs@jan-o-sch.net>2012-01-04 16:12:48 +0100
commita168650c08300434e1456abe7b6451f1448230d3 (patch)
treeaddddb060b018eb569e97c11e1a1451feef11c7a /fs/btrfs/delayed-ref.h
parentd1270cd91f308c9d22b2804720c36ccd32dbc35e (diff)
downloadlinux-0-day-a168650c08300434e1456abe7b6451f1448230d3.tar.gz
linux-0-day-a168650c08300434e1456abe7b6451f1448230d3.tar.xz
Btrfs: add waitqueue instead of doing busy waiting for more delayed refs
Now that we may be holding back delayed refs for a limited period, we might end up having no runnable delayed refs. Without this commit, we'd do busy waiting in that thread until another (runnable) ref arives. Instead, we're detecting this situation and use a waitqueue, such that we only try to run more refs after a) another runnable ref was added or b) delayed refs are no longer held back Signed-off-by: Jan Schmidt <list.btrfs@jan-o-sch.net>
Diffstat (limited to 'fs/btrfs/delayed-ref.h')
-rw-r--r--fs/btrfs/delayed-ref.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/fs/btrfs/delayed-ref.h b/fs/btrfs/delayed-ref.h
index 174416f7882b2..d8f244d949251 100644
--- a/fs/btrfs/delayed-ref.h
+++ b/fs/btrfs/delayed-ref.h
@@ -153,6 +153,12 @@ struct btrfs_delayed_ref_root {
* as it might influence the outcome of the walk.
*/
struct list_head seq_head;
+
+ /*
+ * when the only refs we have in the list must not be processed, we want
+ * to wait for more refs to show up or for the end of backref walking.
+ */
+ wait_queue_head_t seq_wait;
};
static inline void btrfs_put_delayed_ref(struct btrfs_delayed_ref_node *ref)
@@ -216,6 +222,7 @@ btrfs_put_delayed_seq(struct btrfs_delayed_ref_root *delayed_refs,
{
spin_lock(&delayed_refs->lock);
list_del(&elem->list);
+ wake_up(&delayed_refs->seq_wait);
spin_unlock(&delayed_refs->lock);
}