summaryrefslogtreecommitdiffstats
path: root/mm/page_io.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2017-08-23 13:10:32 -0400
committerJens Axboe <axboe@kernel.dk>2017-08-23 14:49:55 -0400
commit74d46992e0d9dee7f1f376de0d56d31614c8a17a (patch)
tree399c316bb960541135e557bc1765caeec6d00084 /mm/page_io.c
parentc2ee070fb00365d7841f6661dcdc7fbe6620bdf8 (diff)
block: replace bi_bdev with a gendisk pointer and partitions index
This way we don't need a block_device structure to submit I/O. The block_device has different life time rules from the gendisk and request_queue and is usually only available when the block device node is open. Other callers need to explicitly create one (e.g. the lightnvm passthrough code, or the new nvme multipathing code). For the actual I/O path all that we need is the gendisk, which exists once per block device. But given that the block layer also does partition remapping we additionally need a partition index, which is used for said remapping in generic_make_request. Note that all the block drivers generally want request_queue or sometimes the gendisk, so this removes a layer of indirection all over the stack. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'mm/page_io.c')
-rw-r--r--mm/page_io.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/mm/page_io.c b/mm/page_io.c
index b6c4ac388209..9cf1bc751d79 100644
--- a/mm/page_io.c
+++ b/mm/page_io.c
@@ -31,7 +31,10 @@ static struct bio *get_swap_bio(gfp_t gfp_flags,
31 31
32 bio = bio_alloc(gfp_flags, 1); 32 bio = bio_alloc(gfp_flags, 1);
33 if (bio) { 33 if (bio) {
34 bio->bi_iter.bi_sector = map_swap_page(page, &bio->bi_bdev); 34 struct block_device *bdev;
35
36 bio->bi_iter.bi_sector = map_swap_page(page, &bdev);
37 bio_set_dev(bio, bdev);
35 bio->bi_iter.bi_sector <<= PAGE_SHIFT - 9; 38 bio->bi_iter.bi_sector <<= PAGE_SHIFT - 9;
36 bio->bi_end_io = end_io; 39 bio->bi_end_io = end_io;
37 40
@@ -57,8 +60,7 @@ void end_swap_bio_write(struct bio *bio)
57 */ 60 */
58 set_page_dirty(page); 61 set_page_dirty(page);
59 pr_alert("Write-error on swap-device (%u:%u:%llu)\n", 62 pr_alert("Write-error on swap-device (%u:%u:%llu)\n",
60 imajor(bio->bi_bdev->bd_inode), 63 MAJOR(bio_dev(bio)), MINOR(bio_dev(bio)),
61 iminor(bio->bi_bdev->bd_inode),
62 (unsigned long long)bio->bi_iter.bi_sector); 64 (unsigned long long)bio->bi_iter.bi_sector);
63 ClearPageReclaim(page); 65 ClearPageReclaim(page);
64 } 66 }
@@ -123,8 +125,7 @@ static void end_swap_bio_read(struct bio *bio)
123 SetPageError(page); 125 SetPageError(page);
124 ClearPageUptodate(page); 126 ClearPageUptodate(page);
125 pr_alert("Read-error on swap-device (%u:%u:%llu)\n", 127 pr_alert("Read-error on swap-device (%u:%u:%llu)\n",
126 imajor(bio->bi_bdev->bd_inode), 128 MAJOR(bio_dev(bio)), MINOR(bio_dev(bio)),
127 iminor(bio->bi_bdev->bd_inode),
128 (unsigned long long)bio->bi_iter.bi_sector); 129 (unsigned long long)bio->bi_iter.bi_sector);
129 goto out; 130 goto out;
130 } 131 }
@@ -338,7 +339,7 @@ int swap_readpage(struct page *page, bool do_poll)
338 int ret = 0; 339 int ret = 0;
339 struct swap_info_struct *sis = page_swap_info(page); 340 struct swap_info_struct *sis = page_swap_info(page);
340 blk_qc_t qc; 341 blk_qc_t qc;
341 struct block_device *bdev; 342 struct gendisk *disk;
342 343
343 VM_BUG_ON_PAGE(!PageSwapCache(page), page); 344 VM_BUG_ON_PAGE(!PageSwapCache(page), page);
344 VM_BUG_ON_PAGE(!PageLocked(page), page); 345 VM_BUG_ON_PAGE(!PageLocked(page), page);
@@ -377,7 +378,7 @@ int swap_readpage(struct page *page, bool do_poll)
377 ret = -ENOMEM; 378 ret = -ENOMEM;
378 goto out; 379 goto out;
379 } 380 }
380 bdev = bio->bi_bdev; 381 disk = bio->bi_disk;
381 bio->bi_private = current; 382 bio->bi_private = current;
382 bio_set_op_attrs(bio, REQ_OP_READ, 0); 383 bio_set_op_attrs(bio, REQ_OP_READ, 0);
383 count_vm_event(PSWPIN); 384 count_vm_event(PSWPIN);
@@ -388,7 +389,7 @@ int swap_readpage(struct page *page, bool do_poll)
388 if (!READ_ONCE(bio->bi_private)) 389 if (!READ_ONCE(bio->bi_private))
389 break; 390 break;
390 391
391 if (!blk_mq_poll(bdev_get_queue(bdev), qc)) 392 if (!blk_mq_poll(disk->queue, qc))
392 break; 393 break;
393 } 394 }
394 __set_current_state(TASK_RUNNING); 395 __set_current_state(TASK_RUNNING);