summaryrefslogtreecommitdiffstats
path: root/kernel/power/swap.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2020-09-21 09:19:56 +0200
committerJens Axboe <axboe@kernel.dk>2020-09-23 18:43:19 +0200
commit21bd900572f3708e281ea25f051fc92462eb1193 (patch)
tree6a35266ebc9c5c5c49d7245861a80f391900934c /kernel/power/swap.c
parentPM: rewrite is_hibernate_resume_dev to not require an inode (diff)
downloadlinux-21bd900572f3708e281ea25f051fc92462eb1193.tar.xz
linux-21bd900572f3708e281ea25f051fc92462eb1193.zip
mm: split swap_type_of
swap_type_of is used for two entirely different purposes: (1) check what swap type a given device/offset corresponds to (2) find the first available swap device that can be written to Mixing both in a single function creates an unreadable mess. Create two separate functions instead, and switch both to pass a dev_t instead of a struct block_device to further simplify the code. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to '')
-rw-r--r--kernel/power/swap.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/kernel/power/swap.c b/kernel/power/swap.c
index 01e2858b5fe3..9d3ffbfe08db 100644
--- a/kernel/power/swap.c
+++ b/kernel/power/swap.c
@@ -335,12 +335,17 @@ static int swsusp_swap_check(void)
{
int res;
- res = swap_type_of(swsusp_resume_device, swsusp_resume_block,
- &hib_resume_bdev);
+ if (swsusp_resume_device)
+ res = swap_type_of(swsusp_resume_device, swsusp_resume_block);
+ else
+ res = find_first_swap(&swsusp_resume_device);
if (res < 0)
return res;
-
root_swap = res;
+
+ hib_resume_bdev = bdget(swsusp_resume_device);
+ if (!hib_resume_bdev)
+ return -ENOMEM;
res = blkdev_get(hib_resume_bdev, FMODE_WRITE, NULL);
if (res)
return res;
@@ -349,12 +354,6 @@ static int swsusp_swap_check(void)
if (res < 0)
blkdev_put(hib_resume_bdev, FMODE_WRITE);
- /*
- * Update the resume device to the one actually used,
- * so the test_resume mode can use it in case it is
- * invoked from hibernate() to test the snapshot.
- */
- swsusp_resume_device = hib_resume_bdev->bd_dev;
return res;
}