]> asedeno.scripts.mit.edu Git - linux.git/blobdiff - mm/page_io.c
Merge tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi
[linux.git] / mm / page_io.c
index 2e8019d0e048dde3ea8a7507f085bb1570553604..a39aac2f8c8d6dad03535dbf46f34e6fbfda2752 100644 (file)
 static struct bio *get_swap_bio(gfp_t gfp_flags,
                                struct page *page, bio_end_io_t end_io)
 {
-       int i, nr = hpage_nr_pages(page);
        struct bio *bio;
 
-       bio = bio_alloc(gfp_flags, nr);
+       bio = bio_alloc(gfp_flags, 1);
        if (bio) {
                struct block_device *bdev;
 
@@ -41,9 +40,7 @@ static struct bio *get_swap_bio(gfp_t gfp_flags,
                bio->bi_iter.bi_sector <<= PAGE_SHIFT - 9;
                bio->bi_end_io = end_io;
 
-               for (i = 0; i < nr; i++)
-                       bio_add_page(bio, page + i, PAGE_SIZE, 0);
-               VM_BUG_ON(bio->bi_iter.bi_size != PAGE_SIZE * nr);
+               bio_add_page(bio, page, PAGE_SIZE * hpage_nr_pages(page), 0);
        }
        return bio;
 }
@@ -140,8 +137,10 @@ static void end_swap_bio_read(struct bio *bio)
        unlock_page(page);
        WRITE_ONCE(bio->bi_private, NULL);
        bio_put(bio);
-       blk_wake_io_task(waiter);
-       put_task_struct(waiter);
+       if (waiter) {
+               blk_wake_io_task(waiter);
+               put_task_struct(waiter);
+       }
 }
 
 int generic_swapfile_activate(struct swap_info_struct *sis,
@@ -398,11 +397,12 @@ int swap_readpage(struct page *page, bool synchronous)
         * Keep this task valid during swap readpage because the oom killer may
         * attempt to access it in the page fault retry time check.
         */
-       get_task_struct(current);
-       bio->bi_private = current;
        bio_set_op_attrs(bio, REQ_OP_READ, 0);
-       if (synchronous)
+       if (synchronous) {
                bio->bi_opf |= REQ_HIPRI;
+               get_task_struct(current);
+               bio->bi_private = current;
+       }
        count_vm_event(PSWPIN);
        bio_get(bio);
        qc = submit_bio(bio);