copy: fix potential mref trashing

This commit is contained in:
Thomas Schoebel-Theuer 2012-12-20 17:54:22 +01:00 committed by Thomas Schoebel-Theuer
parent e6c401d01a
commit a9d0339771
1 changed files with 9 additions and 7 deletions

View File

@ -113,8 +113,13 @@ void __clear_mref(struct copy_brick *brick, struct mref_object *mref, int queue)
static static
void _clear_mref(struct copy_brick *brick, int index, int queue) void _clear_mref(struct copy_brick *brick, int index, int queue)
{ {
struct mref_object *mref = brick->st[index].table[queue]; struct copy_state *st = &brick->st[index];
struct mref_object *mref = st->table[queue];
if (mref) { if (mref) {
if (unlikely(st->active[queue])) {
MARS_ERR("clearing active mref, index = %d queue = %d\n", index, queue);
st->active[queue] = false;
}
__clear_mref(brick, mref, queue); __clear_mref(brick, mref, queue);
brick->st[index].table[queue] = NULL; brick->st[index].table[queue] = NULL;
} }
@ -159,6 +164,7 @@ void copy_endio(struct generic_callback *cb)
error = -EINVAL; error = -EINVAL;
goto exit; goto exit;
} }
st->active[queue] = false;
if (unlikely(st->table[queue])) { if (unlikely(st->table[queue])) {
MARS_ERR("table corruption at %d %d (%p => %p)\n", index, queue, st->table[queue], mref); MARS_ERR("table corruption at %d %d (%p => %p)\n", index, queue, st->table[queue], mref);
error = -EEXIST; error = -EEXIST;
@ -186,7 +192,6 @@ exit:
st->error = error; st->error = error;
_clash(brick); _clash(brick);
} }
st->active[queue] = false;
atomic_dec(&brick->copy_flight); atomic_dec(&brick->copy_flight);
brick->trigger = true; brick->trigger = true;
wake_up_interruptible(&brick->event); wake_up_interruptible(&brick->event);
@ -323,13 +328,10 @@ restart:
goto idle; goto idle;
} }
st->active[0] = false;
st->active[1] = false;
st->writeout = false;
st->error = 0;
_clear_mref(brick, index, 1); _clear_mref(brick, index, 1);
_clear_mref(brick, index, 0); _clear_mref(brick, index, 0);
st->writeout = false;
st->error = 0;
if (brick->is_aborting) if (brick->is_aborting)
goto idle; goto idle;