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>
This commit is contained in:

gecommit door
Jens Axboe

bovenliggende
bb3247a399
commit
21bd900572
@@ -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;
|
||||
}
|
||||
|
||||
|
Verwijs in nieuw issue
Block a user