copy: safeguard advance on concluded states

This commit is contained in:
Thomas Schoebel-Theuer 2022-06-15 21:44:57 +02:00
parent 1e551e624b
commit 2d5b708ff6
1 changed files with 11 additions and 0 deletions

View File

@ -846,6 +846,7 @@ int _run_copy(struct copy_brick *brick, loff_t this_start)
unsigned len; unsigned len;
unsigned index = GET_INDEX(pos); unsigned index = GET_INDEX(pos);
struct copy_state *st = &GET_STATE(brick, index); struct copy_state *st = &GET_STATE(brick, index);
bool is_active;
if (st->state != COPY_STATE_FINISHED) { if (st->state != COPY_STATE_FINISHED) {
break; break;
@ -870,6 +871,16 @@ int _run_copy(struct copy_brick *brick, loff_t this_start)
} }
break; break;
} }
is_active =
(READ_ONCE(st->active[0]) |
READ_ONCE(st->active[1])) != 0;
if (is_active) {
break;
}
if (READ_ONCE(st->table[0]) ||
READ_ONCE(st->table[1])) {
break;
}
// rollover // rollover
st->state = COPY_STATE_START; st->state = COPY_STATE_START;
len = st->len; len = st->len;