Commit f3ff6683 authored by Susan LeGendre-McGhee's avatar Susan LeGendre-McGhee Committed by Mikulas Patocka

dm vdo: abort loading dirty VDO with the old recovery journal format

Abort the load process with status code VDO_UNSUPPORTED_VERSION
without forcing read-only mode when a journal block with the
old format version is detected.

Forcing the VDO volume into read-only mode and thus requiring
a read-only rebuild should only be done when absolutely necessary.
Signed-off-by: default avatarSusan LeGendre-McGhee <slegendr@redhat.com>
Signed-off-by: default avatarMatthew Sakai <msakai@redhat.com>
Signed-off-by: default avatarMikulas Patocka <mpatocka@redhat.com>
parent 47874c98
...@@ -2296,6 +2296,14 @@ static void handle_load_error(struct vdo_completion *completion) ...@@ -2296,6 +2296,14 @@ static void handle_load_error(struct vdo_completion *completion)
return; return;
} }
if ((completion->result == VDO_UNSUPPORTED_VERSION) &&
(vdo->admin.phase == LOAD_PHASE_MAKE_DIRTY)) {
vdo_log_error("Aborting load due to unsupported version");
vdo->admin.phase = LOAD_PHASE_FINISHED;
load_callback(completion);
return;
}
vdo_log_error_strerror(completion->result, vdo_log_error_strerror(completion->result,
"Entering read-only mode due to load error"); "Entering read-only mode due to load error");
vdo->admin.phase = LOAD_PHASE_WAIT_FOR_READ_ONLY; vdo->admin.phase = LOAD_PHASE_WAIT_FOR_READ_ONLY;
...@@ -2740,6 +2748,19 @@ static int vdo_preresume_registered(struct dm_target *ti, struct vdo *vdo) ...@@ -2740,6 +2748,19 @@ static int vdo_preresume_registered(struct dm_target *ti, struct vdo *vdo)
vdo_log_info("starting device '%s'", device_name); vdo_log_info("starting device '%s'", device_name);
result = perform_admin_operation(vdo, LOAD_PHASE_START, load_callback, result = perform_admin_operation(vdo, LOAD_PHASE_START, load_callback,
handle_load_error, "load"); handle_load_error, "load");
if (result == VDO_UNSUPPORTED_VERSION) {
/*
* A component version is not supported. This can happen when the
* recovery journal metadata is in an old version format. Abort the
* load without saving the state.
*/
vdo->suspend_type = VDO_ADMIN_STATE_SUSPENDING;
perform_admin_operation(vdo, SUSPEND_PHASE_START,
suspend_callback, suspend_callback,
"suspend");
return result;
}
if ((result != VDO_SUCCESS) && (result != VDO_READ_ONLY)) { if ((result != VDO_SUCCESS) && (result != VDO_READ_ONLY)) {
/* /*
* Something has gone very wrong. Make sure everything has drained and * Something has gone very wrong. Make sure everything has drained and
...@@ -2811,7 +2832,8 @@ static int vdo_preresume(struct dm_target *ti) ...@@ -2811,7 +2832,8 @@ static int vdo_preresume(struct dm_target *ti)
vdo_register_thread_device_id(&instance_thread, &vdo->instance); vdo_register_thread_device_id(&instance_thread, &vdo->instance);
result = vdo_preresume_registered(ti, vdo); result = vdo_preresume_registered(ti, vdo);
if ((result == VDO_PARAMETER_MISMATCH) || (result == VDO_INVALID_ADMIN_STATE)) if ((result == VDO_PARAMETER_MISMATCH) || (result == VDO_INVALID_ADMIN_STATE) ||
(result == VDO_UNSUPPORTED_VERSION))
result = -EINVAL; result = -EINVAL;
vdo_unregister_thread_device_id(); vdo_unregister_thread_device_id();
return vdo_status_to_errno(result); return vdo_status_to_errno(result);
......
...@@ -1575,9 +1575,7 @@ static int parse_journal_for_recovery(struct repair_completion *repair) ...@@ -1575,9 +1575,7 @@ static int parse_journal_for_recovery(struct repair_completion *repair)
if (header.metadata_type == VDO_METADATA_RECOVERY_JOURNAL) { if (header.metadata_type == VDO_METADATA_RECOVERY_JOURNAL) {
/* This is an old format block, so we need to upgrade */ /* This is an old format block, so we need to upgrade */
vdo_log_error_strerror(VDO_UNSUPPORTED_VERSION, vdo_log_error_strerror(VDO_UNSUPPORTED_VERSION,
"Recovery journal is in the old format, a read-only rebuild is required."); "Recovery journal is in the old format. Downgrade and complete recovery, then upgrade with a clean volume");
vdo_enter_read_only_mode(repair->completion.vdo,
VDO_UNSUPPORTED_VERSION);
return VDO_UNSUPPORTED_VERSION; return VDO_UNSUPPORTED_VERSION;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment