diff options
| author | Michael Ellerman <mpe@ellerman.id.au> | 2017-07-31 20:20:29 +1000 | 
|---|---|---|
| committer | Michael Ellerman <mpe@ellerman.id.au> | 2017-07-31 20:20:29 +1000 | 
| commit | bb272221e9db79f13d454e1f3fb6b05013be985e (patch) | |
| tree | 36f4acc50e3fabac71fadd34c720c0a6011db470 /mm/page_io.c | |
| parent | 253fd51e2f533552ae35a0c661705da6c4842c1b (diff) | |
| parent | 5771a8c08880cdca3bfb4a3fc6d309d6bba20877 (diff) | |
Merge tag 'v4.13-rc1' into fixes
The fixes branch is based off a random pre-rc1 commit, because we had
some fixes that needed to go in before rc1 was released.
However we now need to fix some code that went in after that point, but
before rc1, so merge rc1 to get that code into fixes so we can fix it!
Diffstat (limited to 'mm/page_io.c')
| -rw-r--r-- | mm/page_io.c | 23 | 
1 files changed, 21 insertions, 2 deletions
diff --git a/mm/page_io.c b/mm/page_io.c index 2da71e627812..b6c4ac388209 100644 --- a/mm/page_io.c +++ b/mm/page_io.c @@ -117,6 +117,7 @@ static void swap_slot_free_notify(struct page *page)  static void end_swap_bio_read(struct bio *bio)  {  	struct page *page = bio->bi_io_vec[0].bv_page; +	struct task_struct *waiter = bio->bi_private;  	if (bio->bi_status) {  		SetPageError(page); @@ -132,7 +133,9 @@ static void end_swap_bio_read(struct bio *bio)  	swap_slot_free_notify(page);  out:  	unlock_page(page); +	WRITE_ONCE(bio->bi_private, NULL);  	bio_put(bio); +	wake_up_process(waiter);  }  int generic_swapfile_activate(struct swap_info_struct *sis, @@ -329,11 +332,13 @@ out:  	return ret;  } -int swap_readpage(struct page *page) +int swap_readpage(struct page *page, bool do_poll)  {  	struct bio *bio;  	int ret = 0;  	struct swap_info_struct *sis = page_swap_info(page); +	blk_qc_t qc; +	struct block_device *bdev;  	VM_BUG_ON_PAGE(!PageSwapCache(page), page);  	VM_BUG_ON_PAGE(!PageLocked(page), page); @@ -372,9 +377,23 @@ int swap_readpage(struct page *page)  		ret = -ENOMEM;  		goto out;  	} +	bdev = bio->bi_bdev; +	bio->bi_private = current;  	bio_set_op_attrs(bio, REQ_OP_READ, 0);  	count_vm_event(PSWPIN); -	submit_bio(bio); +	bio_get(bio); +	qc = submit_bio(bio); +	while (do_poll) { +		set_current_state(TASK_UNINTERRUPTIBLE); +		if (!READ_ONCE(bio->bi_private)) +			break; + +		if (!blk_mq_poll(bdev_get_queue(bdev), qc)) +			break; +	} +	__set_current_state(TASK_RUNNING); +	bio_put(bio); +  out:  	return ret;  }  | 
