PM: hibernate: use correct mode for swsusp_close()

JIRA: https://issues.redhat.com/browse/RHEL-1516

commit cefcf24b4d351daf70ecd945324e200d3736821e
Author: Thomas Zeitlhofer <thomas.zeitlhofer+lkml@ze-it.at>
Date:   Tue Nov 23 20:18:43 2021 +0100

    PM: hibernate: use correct mode for swsusp_close()

    Commit 39fbef4b0f77 ("PM: hibernate: Get block device exclusively in
    swsusp_check()") changed the opening mode of the block device to
    (FMODE_READ | FMODE_EXCL).

    In the corresponding calls to swsusp_close(), the mode is still just
    FMODE_READ which triggers the warning in blkdev_flush_mapping() on
    resume from hibernate.

    So, use the mode (FMODE_READ | FMODE_EXCL) also when closing the
    device.

    Fixes: 39fbef4b0f77 ("PM: hibernate: Get block device exclusively in swsusp_check()")
    Signed-off-by: Thomas Zeitlhofer <thomas.zeitlhofer+lkml@ze-it.at>
    Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

Signed-off-by: Ming Lei <ming.lei@redhat.com>
This commit is contained in:
Ming Lei 2021-11-23 20:18:43 +01:00
parent 5863056141
commit ef81934901
1 changed files with 3 additions and 3 deletions

View File

@ -692,7 +692,7 @@ static int load_image_and_restore(void)
goto Unlock;
error = swsusp_read(&flags);
swsusp_close(FMODE_READ);
swsusp_close(FMODE_READ | FMODE_EXCL);
if (!error)
error = hibernation_restore(flags & SF_PLATFORM_MODE);
@ -982,7 +982,7 @@ static int software_resume(void)
/* The snapshot device should not be opened while we're running */
if (!hibernate_acquire()) {
error = -EBUSY;
swsusp_close(FMODE_READ);
swsusp_close(FMODE_READ | FMODE_EXCL);
goto Unlock;
}
@ -1017,7 +1017,7 @@ static int software_resume(void)
pm_pr_dbg("Hibernation image not present or could not be loaded.\n");
return error;
Close_Finish:
swsusp_close(FMODE_READ);
swsusp_close(FMODE_READ | FMODE_EXCL);
goto Finish;
}