Thread (12 messages) 12 messages, 5 authors, 2023-08-28

Re: [PATCH 16/29] PM: hibernate: Convert to bdev_open_by_dev()

From: "Rafael J. Wysocki" <rafael@kernel.org>
Date: 2023-08-11 16:57:25
Also in: linux-block, linux-fsdevel

On Fri, Aug 11, 2023 at 1:05 PM Jan Kara [off-list ref] wrote:
Convert hibernation code to use bdev_open_by_dev().

CC: linux-pm@vger.kernel.org
Signed-off-by: Jan Kara <jack@suse.cz>
Acked-by: Rafael J. Wysocki <rafael@kernel.org>
quoted hunk ↗ jump to hunk
---
 kernel/power/swap.c | 31 ++++++++++++++++---------------
 1 file changed, 16 insertions(+), 15 deletions(-)
diff --git a/kernel/power/swap.c b/kernel/power/swap.c
index f6ebcd00c410..b475bee282ff 100644
--- a/kernel/power/swap.c
+++ b/kernel/power/swap.c
@@ -222,7 +222,7 @@ int swsusp_swap_in_use(void)
  */

 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 {
        atomic_t                count;
@@ -276,7 +276,8 @@ static int hib_submit_io(blk_opf_t opf, pgoff_t page_off, void *addr,
        struct bio *bio;
        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);

        if (bio_add_page(bio, page, PAGE_SIZE, 0) < PAGE_SIZE) {
@@ -356,14 +357,14 @@ static int swsusp_swap_check(void)
                return 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);
-       if (IS_ERR(hib_resume_bdev))
-               return PTR_ERR(hib_resume_bdev);
+       if (IS_ERR(hib_resume_bdev_handle))
+               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)
-               blkdev_put(hib_resume_bdev, NULL);
+               bdev_release(hib_resume_bdev_handle);

        return res;
 }
@@ -1521,10 +1522,10 @@ int swsusp_check(bool snapshot_test)
        void *holder = snapshot_test ? &swsusp_holder : NULL;
        int error;

-       hib_resume_bdev = blkdev_get_by_dev(swsusp_resume_device, BLK_OPEN_READ,
-                                           holder, NULL);
-       if (!IS_ERR(hib_resume_bdev)) {
-               set_blocksize(hib_resume_bdev, PAGE_SIZE);
+       hib_resume_bdev_handle = bdev_open_by_dev(swsusp_resume_device,
+                               BLK_OPEN_READ, holder, NULL);
+       if (!IS_ERR(hib_resume_bdev_handle)) {
+               set_blocksize(hib_resume_bdev_handle->bdev, PAGE_SIZE);
                clear_page(swsusp_header);
                error = hib_submit_io(REQ_OP_READ, swsusp_resume_block,
                                        swsusp_header, NULL);
@@ -1549,11 +1550,11 @@ int swsusp_check(bool snapshot_test)

 put:
                if (error)
-                       blkdev_put(hib_resume_bdev, holder);
+                       bdev_release(hib_resume_bdev_handle);
                else
                        pr_debug("Image signature found, resuming\n");
        } else {
-               error = PTR_ERR(hib_resume_bdev);
+               error = PTR_ERR(hib_resume_bdev_handle);
        }

        if (error)
@@ -1568,12 +1569,12 @@ int swsusp_check(bool snapshot_test)

 void swsusp_close(bool snapshot_test)
 {
-       if (IS_ERR(hib_resume_bdev)) {
+       if (IS_ERR(hib_resume_bdev_handle)) {
                pr_debug("Image device not initialised\n");
                return;
        }

-       blkdev_put(hib_resume_bdev, snapshot_test ? &swsusp_holder : NULL);
+       bdev_release(hib_resume_bdev_handle);
 }

 /**
--
2.35.3
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help