copy: fix indirect race from index wraparound

This commit is contained in:
Thomas Schoebel-Theuer 2023-08-03 13:19:41 +02:00
parent d3e70f11da
commit 976857a9d7
1 changed files with 2 additions and 2 deletions

View File

@ -743,8 +743,8 @@ restart:
*/
if (mars_copy_strict_write_order &&
!is_first) {
unsigned mask = COPY_CHUNK - 1;
unsigned prev_index = (index + mask) & mask;
const unsigned wrap = STATES_PER_PAGE * MAX_SUB_TABLES;
unsigned prev_index = (index + (wrap - 1)) % wrap;
struct copy_state *prev_st;
prev_st = &GET_STATE(brick, prev_index);