Skip to content

Commit 162b99e

Browse files
Mike Christieaxboe
authored andcommitted
pm: use bio op accessors
Separate the op from the rq_flag_bits and have the pm code set/get the bio using bio_set_op_attrs/bio_op. Signed-off-by: Mike Christie <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Reviewed-by: Hannes Reinecke <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent 0d16dcf commit 162b99e

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

kernel/power/swap.c

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ static void hib_end_io(struct bio *bio)
261261
bio_put(bio);
262262
}
263263

264-
static int hib_submit_io(int rw, pgoff_t page_off, void *addr,
264+
static int hib_submit_io(int op, int op_flags, pgoff_t page_off, void *addr,
265265
struct hib_bio_batch *hb)
266266
{
267267
struct page *page = virt_to_page(addr);
@@ -271,7 +271,7 @@ static int hib_submit_io(int rw, pgoff_t page_off, void *addr,
271271
bio = bio_alloc(__GFP_RECLAIM | __GFP_HIGH, 1);
272272
bio->bi_iter.bi_sector = page_off * (PAGE_SIZE >> 9);
273273
bio->bi_bdev = hib_resume_bdev;
274-
bio->bi_rw = rw;
274+
bio_set_op_attrs(bio, op, op_flags);
275275

276276
if (bio_add_page(bio, page, PAGE_SIZE, 0) < PAGE_SIZE) {
277277
printk(KERN_ERR "PM: Adding page to bio failed at %llu\n",
@@ -307,7 +307,8 @@ static int mark_swapfiles(struct swap_map_handle *handle, unsigned int flags)
307307
{
308308
int error;
309309

310-
hib_submit_io(READ_SYNC, swsusp_resume_block, swsusp_header, NULL);
310+
hib_submit_io(REQ_OP_READ, READ_SYNC, swsusp_resume_block,
311+
swsusp_header, NULL);
311312
if (!memcmp("SWAP-SPACE",swsusp_header->sig, 10) ||
312313
!memcmp("SWAPSPACE2",swsusp_header->sig, 10)) {
313314
memcpy(swsusp_header->orig_sig,swsusp_header->sig, 10);
@@ -316,8 +317,8 @@ static int mark_swapfiles(struct swap_map_handle *handle, unsigned int flags)
316317
swsusp_header->flags = flags;
317318
if (flags & SF_CRC32_MODE)
318319
swsusp_header->crc32 = handle->crc32;
319-
error = hib_submit_io(WRITE_SYNC, swsusp_resume_block,
320-
swsusp_header, NULL);
320+
error = hib_submit_io(REQ_OP_WRITE, WRITE_SYNC,
321+
swsusp_resume_block, swsusp_header, NULL);
321322
} else {
322323
printk(KERN_ERR "PM: Swap header not found!\n");
323324
error = -ENODEV;
@@ -390,7 +391,7 @@ static int write_page(void *buf, sector_t offset, struct hib_bio_batch *hb)
390391
} else {
391392
src = buf;
392393
}
393-
return hib_submit_io(WRITE_SYNC, offset, src, hb);
394+
return hib_submit_io(REQ_OP_WRITE, WRITE_SYNC, offset, src, hb);
394395
}
395396

396397
static void release_swap_writer(struct swap_map_handle *handle)
@@ -993,7 +994,8 @@ static int get_swap_reader(struct swap_map_handle *handle,
993994
return -ENOMEM;
994995
}
995996

996-
error = hib_submit_io(READ_SYNC, offset, tmp->map, NULL);
997+
error = hib_submit_io(REQ_OP_READ, READ_SYNC, offset,
998+
tmp->map, NULL);
997999
if (error) {
9981000
release_swap_reader(handle);
9991001
return error;
@@ -1017,7 +1019,7 @@ static int swap_read_page(struct swap_map_handle *handle, void *buf,
10171019
offset = handle->cur->entries[handle->k];
10181020
if (!offset)
10191021
return -EFAULT;
1020-
error = hib_submit_io(READ_SYNC, offset, buf, hb);
1022+
error = hib_submit_io(REQ_OP_READ, READ_SYNC, offset, buf, hb);
10211023
if (error)
10221024
return error;
10231025
if (++handle->k >= MAP_PAGE_ENTRIES) {
@@ -1526,15 +1528,17 @@ int swsusp_check(void)
15261528
if (!IS_ERR(hib_resume_bdev)) {
15271529
set_blocksize(hib_resume_bdev, PAGE_SIZE);
15281530
clear_page(swsusp_header);
1529-
error = hib_submit_io(READ_SYNC, swsusp_resume_block,
1531+
error = hib_submit_io(REQ_OP_READ, READ_SYNC,
1532+
swsusp_resume_block,
15301533
swsusp_header, NULL);
15311534
if (error)
15321535
goto put;
15331536

15341537
if (!memcmp(HIBERNATE_SIG, swsusp_header->sig, 10)) {
15351538
memcpy(swsusp_header->sig, swsusp_header->orig_sig, 10);
15361539
/* Reset swap signature now */
1537-
error = hib_submit_io(WRITE_SYNC, swsusp_resume_block,
1540+
error = hib_submit_io(REQ_OP_WRITE, WRITE_SYNC,
1541+
swsusp_resume_block,
15381542
swsusp_header, NULL);
15391543
} else {
15401544
error = -EINVAL;
@@ -1578,10 +1582,12 @@ int swsusp_unmark(void)
15781582
{
15791583
int error;
15801584

1581-
hib_submit_io(READ_SYNC, swsusp_resume_block, swsusp_header, NULL);
1585+
hib_submit_io(REQ_OP_READ, READ_SYNC, swsusp_resume_block,
1586+
swsusp_header, NULL);
15821587
if (!memcmp(HIBERNATE_SIG,swsusp_header->sig, 10)) {
15831588
memcpy(swsusp_header->sig,swsusp_header->orig_sig, 10);
1584-
error = hib_submit_io(WRITE_SYNC, swsusp_resume_block,
1589+
error = hib_submit_io(REQ_OP_WRITE, WRITE_SYNC,
1590+
swsusp_resume_block,
15851591
swsusp_header, NULL);
15861592
} else {
15871593
printk(KERN_ERR "PM: Cannot find swsusp signature!\n");

0 commit comments

Comments
 (0)