Skip to content

Commit cca2c6a

Browse files
ntsironsnitm
authored andcommitted
dm era: only resize metadata in preresume
Metadata resize shouldn't happen in the ctr. The ctr loads a temporary (inactive) table that will only become active upon resume. That is why resize should always be done in terms of resume. Otherwise a load (ctr) whose inactive table never becomes active will incorrectly resize the metadata. Also, perform the resize directly in preresume, instead of using the worker to do it. The worker might run other metadata operations, e.g., it could start digestion, before resizing the metadata. These operations will end up using the old size. This could lead to errors, like: device-mapper: era: metadata_digest_transcribe_writeset: dm_array_set_value failed device-mapper: era: process_old_eras: digest step failed, stopping digestion The reason of the above error is that the worker started the digestion of the archived writeset using the old, larger size. As a result, metadata_digest_transcribe_writeset tried to write beyond the end of the era array. Fixes: eec4057 ("dm: add era target") Cc: [email protected] # v3.15+ Signed-off-by: Nikos Tsironis <[email protected]> Signed-off-by: Mike Snitzer <[email protected]>
1 parent 64f2d15 commit cca2c6a

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

drivers/md/dm-era-target.c

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1501,15 +1501,6 @@ static int era_ctr(struct dm_target *ti, unsigned argc, char **argv)
15011501
}
15021502
era->md = md;
15031503

1504-
era->nr_blocks = calc_nr_blocks(era);
1505-
1506-
r = metadata_resize(era->md, &era->nr_blocks);
1507-
if (r) {
1508-
ti->error = "couldn't resize metadata";
1509-
era_destroy(era);
1510-
return -ENOMEM;
1511-
}
1512-
15131504
era->wq = alloc_ordered_workqueue("dm-" DM_MSG_PREFIX, WQ_MEM_RECLAIM);
15141505
if (!era->wq) {
15151506
ti->error = "could not create workqueue for metadata object";
@@ -1584,9 +1575,17 @@ static int era_preresume(struct dm_target *ti)
15841575
dm_block_t new_size = calc_nr_blocks(era);
15851576

15861577
if (era->nr_blocks != new_size) {
1587-
r = in_worker1(era, metadata_resize, &new_size);
1588-
if (r)
1578+
r = metadata_resize(era->md, &new_size);
1579+
if (r) {
1580+
DMERR("%s: metadata_resize failed", __func__);
15891581
return r;
1582+
}
1583+
1584+
r = metadata_commit(era->md);
1585+
if (r) {
1586+
DMERR("%s: metadata_commit failed", __func__);
1587+
return r;
1588+
}
15901589

15911590
era->nr_blocks = new_size;
15921591
}

0 commit comments

Comments
 (0)