copy: safeguard allocation barriers

This commit is contained in:
Thomas Schoebel-Theuer 2022-02-23 08:30:20 +01:00 committed by Thomas Schoebel-Theuer
parent 7caf2341ea
commit b53b3777d4
1 changed files with 7 additions and 0 deletions

View File

@ -1351,10 +1351,15 @@ void _free_pages(struct copy_brick *brick)
void **st;
unsigned i;
/* For maximum safety against any potentially defective hardware.
* Anyway, allocs / frees are not performance critical.
*/
smp_mb();
st = (void **)brick->st;
if (!st)
return;
brick->st = NULL;
smp_mb();
for (i = 0; i < MAX_SUB_TABLES; i++) {
void *sub_table = st[i];
@ -1373,6 +1378,7 @@ static int copy_brick_construct(struct copy_brick *brick)
void **st;
unsigned i;
smp_mb();
if (unlikely(brick->st)) {
MARS_ERR("Re-initialize state table\n");
}
@ -1396,6 +1402,7 @@ static int copy_brick_construct(struct copy_brick *brick)
init_waitqueue_head(&brick->event);
brick->st = st;
smp_mb();
return 0;
}