diff options
author | Roland Dreier <roland@purestorage.com> | 2011-08-27 21:33:16 -0700 |
---|---|---|
committer | Nicholas A. Bellinger <nab@linux-iscsi.org> | 2011-09-16 09:29:20 +0000 |
commit | bcac364a24c894c4cf8cf219b7863c192cd34079 (patch) | |
tree | 121757157452bf6e546c53c0efd2a3d463f4aa2e /arch | |
parent | a7f934d4f16144cb9521b62e9b8c9ac0118097da (diff) |
target: Fix race between multiple invocations of target_qf_do_work()
When work is scheduled with schedule_work(), the work can end up
running on multiple CPUs at the same time -- this happens if
the work is already running on one CPU and schedule_work() is called
on another CPU. This leads to list corruption with target_qf_do_work(),
which is roughly doing:
spin_lock(...);
list_for_each_entry_safe(...) {
list_del(...);
spin_unlock(...);
// do stuff
spin_lock(...);
}
With multiple CPUs running this code, one CPU can end up deleting the
list entry that the other CPU is about to work on.
Fix this by splicing the list entries onto a local list and then
operating on that in the work function. This way, each invocation of
target_qf_do_work() operates on its own local list and so multiple
invocations don't corrupt each other's list. This also avoids dropping
and reacquiring the lock for each list entry.
Signed-off-by: Roland Dreier <roland@purestorage.com>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Diffstat (limited to 'arch')
0 files changed, 0 insertions, 0 deletions