Skip to contentSkip to conversation

btrfs: always choose work from prio_head first

PATCH New Stanislaw Gruszka 1 participant 1 message Feb 8, 2014 Btrfs file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 btrfs: always choose work from prio_head first

In case we do not refill, we can overwrite cur pointer from prio_head by one from not prioritized head, what looks as something that was not intended.

This change make we always take works from prio_head first until it's not empty.

---
I found this by reading code, not sure if change is correct. Patch is only compile tested.

 fs/btrfs/async-thread.c |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)
fs/btrfs/async-thread.c +5 -4
index c1e0b0c..0b78bf2 100644
@@ -262,18 +262,19 @@ static struct btrfs_work *get_next_work(struct btrfs_worker_thread *worker,
 	struct btrfs_work *work = NULL;
 	struct list_head *cur = NULL;
 
-	if (!list_empty(prio_head))
+	if (!list_empty(prio_head)) {
 		cur = prio_head->next;
+		goto out;
+	}
 
 	smp_mb();
 	if (!list_empty(&worker->prio_pending))
 		goto refill;
 
-	if (!list_empty(head))
+	if (!list_empty(head)) {
 		cur = head->next;
-
-	if (cur)
 		goto out;
+	}
 
 refill:
 	spin_lock_irq(&worker->lock);
Signature · 1 line
1.7.4.4