From: Stanislaw Gruszka <stf_xl@wp.pl>
To: linux-btrfs@vger.kernel.org
Subject: [PATCH] btrfs: always choose work from prio_head first
Date: Sat, 8 Feb 2014 23:18:43 +0100 [thread overview]
Message-ID: <20140208221843.GA12866@localhost.localdomain> (raw)
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.
Signed-off-by: Stanislaw Gruszka <stf_xl@wp.pl>
---
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(-)
diff --git a/fs/btrfs/async-thread.c b/fs/btrfs/async-thread.c
index c1e0b0c..0b78bf2 100644
--- a/fs/btrfs/async-thread.c
+++ b/fs/btrfs/async-thread.c
@@ -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);
--
1.7.4.4
reply other threads:[~2014-02-08 22:23 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20140208221843.GA12866@localhost.localdomain \
--to=stf_xl@wp.pl \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.