Thread (3 messages) 3 messages, 2 authors, 2021-11-24

Re: [PATCH] PM: hibernate: use correct mode for swsusp_close()

From: "Rafael J. Wysocki" <rafael@kernel.org>
Date: 2021-11-24 12:51:21

On Tue, Nov 23, 2021 at 8:18 PM Thomas Zeitlhofer
[off-list ref] wrote:
quoted hunk ↗ jump to hunk
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 <redacted>
diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c
index 559acef3fddb..b0888e9224da 100644
--- a/kernel/power/hibernate.c
+++ b/kernel/power/hibernate.c
@@ -691,7 +691,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);
@@ -981,7 +981,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;
        }
@@ -1016,7 +1016,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;
 }
Applied as 5.16-rc material, thanks!
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help