Commit e017d304 authored by Jan Kara's avatar Jan Kara Committed by Christian Brauner

PM: hibernate: Convert to bdev_open_by_dev()

Convert hibernation code to use bdev_open_by_dev().

CC: linux-pm@vger.kernel.org
Acked-by: default avatarChristoph Hellwig <hch@lst.de>
Acked-by: default avatar"Rafael J. Wysocki" <rafael@kernel.org>
Acked-by: default avatarChristian Brauner <brauner@kernel.org>
Signed-off-by: default avatarJan Kara <jack@suse.cz>
Link: https://lore.kernel.org/r/20230927093442.25915-16-jack@suse.czSigned-off-by: default avatarChristian Brauner <brauner@kernel.org>
parent e6aafdc8
...@@ -222,7 +222,7 @@ int swsusp_swap_in_use(void) ...@@ -222,7 +222,7 @@ int swsusp_swap_in_use(void)
*/ */
static unsigned short root_swap = 0xffff; static unsigned short root_swap = 0xffff;
static struct block_device *hib_resume_bdev; static struct bdev_handle *hib_resume_bdev_handle;
struct hib_bio_batch { struct hib_bio_batch {
atomic_t count; atomic_t count;
...@@ -276,7 +276,8 @@ static int hib_submit_io(blk_opf_t opf, pgoff_t page_off, void *addr, ...@@ -276,7 +276,8 @@ static int hib_submit_io(blk_opf_t opf, pgoff_t page_off, void *addr,
struct bio *bio; struct bio *bio;
int error = 0; int error = 0;
bio = bio_alloc(hib_resume_bdev, 1, opf, GFP_NOIO | __GFP_HIGH); bio = bio_alloc(hib_resume_bdev_handle->bdev, 1, opf,
GFP_NOIO | __GFP_HIGH);
bio->bi_iter.bi_sector = page_off * (PAGE_SIZE >> 9); bio->bi_iter.bi_sector = page_off * (PAGE_SIZE >> 9);
if (bio_add_page(bio, page, PAGE_SIZE, 0) < PAGE_SIZE) { if (bio_add_page(bio, page, PAGE_SIZE, 0) < PAGE_SIZE) {
...@@ -356,14 +357,14 @@ static int swsusp_swap_check(void) ...@@ -356,14 +357,14 @@ static int swsusp_swap_check(void)
return res; return res;
root_swap = res; root_swap = res;
hib_resume_bdev = blkdev_get_by_dev(swsusp_resume_device, hib_resume_bdev_handle = bdev_open_by_dev(swsusp_resume_device,
BLK_OPEN_WRITE, NULL, NULL); BLK_OPEN_WRITE, NULL, NULL);
if (IS_ERR(hib_resume_bdev)) if (IS_ERR(hib_resume_bdev_handle))
return PTR_ERR(hib_resume_bdev); return PTR_ERR(hib_resume_bdev_handle);
res = set_blocksize(hib_resume_bdev, PAGE_SIZE); res = set_blocksize(hib_resume_bdev_handle->bdev, PAGE_SIZE);
if (res < 0) if (res < 0)
blkdev_put(hib_resume_bdev, NULL); bdev_release(hib_resume_bdev_handle);
return res; return res;
} }
...@@ -1522,10 +1523,10 @@ int swsusp_check(bool exclusive) ...@@ -1522,10 +1523,10 @@ int swsusp_check(bool exclusive)
void *holder = exclusive ? &swsusp_holder : NULL; void *holder = exclusive ? &swsusp_holder : NULL;
int error; int error;
hib_resume_bdev = blkdev_get_by_dev(swsusp_resume_device, BLK_OPEN_READ, hib_resume_bdev_handle = bdev_open_by_dev(swsusp_resume_device,
holder, NULL); BLK_OPEN_READ, holder, NULL);
if (!IS_ERR(hib_resume_bdev)) { if (!IS_ERR(hib_resume_bdev_handle)) {
set_blocksize(hib_resume_bdev, PAGE_SIZE); set_blocksize(hib_resume_bdev_handle->bdev, PAGE_SIZE);
clear_page(swsusp_header); clear_page(swsusp_header);
error = hib_submit_io(REQ_OP_READ, swsusp_resume_block, error = hib_submit_io(REQ_OP_READ, swsusp_resume_block,
swsusp_header, NULL); swsusp_header, NULL);
...@@ -1550,11 +1551,11 @@ int swsusp_check(bool exclusive) ...@@ -1550,11 +1551,11 @@ int swsusp_check(bool exclusive)
put: put:
if (error) if (error)
blkdev_put(hib_resume_bdev, holder); bdev_release(hib_resume_bdev_handle);
else else
pr_debug("Image signature found, resuming\n"); pr_debug("Image signature found, resuming\n");
} else { } else {
error = PTR_ERR(hib_resume_bdev); error = PTR_ERR(hib_resume_bdev_handle);
} }
if (error) if (error)
...@@ -1570,12 +1571,12 @@ int swsusp_check(bool exclusive) ...@@ -1570,12 +1571,12 @@ int swsusp_check(bool exclusive)
void swsusp_close(bool exclusive) void swsusp_close(bool exclusive)
{ {
if (IS_ERR(hib_resume_bdev)) { if (IS_ERR(hib_resume_bdev_handle)) {
pr_debug("Image device not initialised\n"); pr_debug("Image device not initialised\n");
return; return;
} }
blkdev_put(hib_resume_bdev, exclusive ? &swsusp_holder : NULL); bdev_release(hib_resume_bdev_handle);
} }
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment