Skip to content

Commit 148b6f4

Browse files
yu-chen-surfrafaeljw
authored andcommitted
PM: hibernate: Fix the exclusive get block device in test_resume mode
Commit 5904de0 ("PM: hibernate: Do not get block device exclusively in test_resume mode") fixes a hibernation issue under test_resume mode. That commit is supposed to open the block device in non-exclusive mode when in test_resume. However the code does the opposite, which is against its description. In summary, the swap device is only opened exclusively by swsusp_check() with its corresponding *close(), and must be in non test_resume mode. This is to avoid the race condition that different processes scribble the device at the same time. All the other cases should use non-exclusive mode. Fix it by really disabling exclusive mode under test_resume. Fixes: 5904de0 ("PM: hibernate: Do not get block device exclusively in test_resume mode") Closes: https://lore.kernel.org/lkml/000000000000761f5f0603324129@google.com/ Reported-by: Pengfei Xu <pengfei.xu@intel.com> Signed-off-by: Chen Yu <yu.c.chen@intel.com> Tested-by: Chenzhou Feng <chenzhoux.feng@intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent 40d84e1 commit 148b6f4

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

kernel/power/hibernate.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -786,9 +786,9 @@ int hibernate(void)
786786
unlock_device_hotplug();
787787
if (snapshot_test) {
788788
pm_pr_dbg("Checking hibernation image\n");
789-
error = swsusp_check(snapshot_test);
789+
error = swsusp_check(false);
790790
if (!error)
791-
error = load_image_and_restore(snapshot_test);
791+
error = load_image_and_restore(false);
792792
}
793793
thaw_processes();
794794

@@ -945,14 +945,14 @@ static int software_resume(void)
945945
pm_pr_dbg("Looking for hibernation image.\n");
946946

947947
mutex_lock(&system_transition_mutex);
948-
error = swsusp_check(false);
948+
error = swsusp_check(true);
949949
if (error)
950950
goto Unlock;
951951

952952
/* The snapshot device should not be opened while we're running */
953953
if (!hibernate_acquire()) {
954954
error = -EBUSY;
955-
swsusp_close(false);
955+
swsusp_close(true);
956956
goto Unlock;
957957
}
958958

@@ -973,7 +973,7 @@ static int software_resume(void)
973973
goto Close_Finish;
974974
}
975975

976-
error = load_image_and_restore(false);
976+
error = load_image_and_restore(true);
977977
thaw_processes();
978978
Finish:
979979
pm_notifier_call_chain(PM_POST_RESTORE);
@@ -987,7 +987,7 @@ static int software_resume(void)
987987
pm_pr_dbg("Hibernation image not present or could not be loaded.\n");
988988
return error;
989989
Close_Finish:
990-
swsusp_close(false);
990+
swsusp_close(true);
991991
goto Finish;
992992
}
993993

0 commit comments

Comments
 (0)