From: Kent Overstreet <kmo@xxxxxxxxxxxxx> Increase bio->bi_remaining instead of calling bio_get(), and call bio_end() instead of bio_put() upon buffer_head submission. Also make bio submission in kernel/power/block_io.c to properly submit bios by checking whether bio_chain is available or not. Doing that, some codes that have been still using the older API can be converted in order to use the immutable biovecs API. Signed-off-by: Kent Overstreet <kmo@xxxxxxxxxxxxx> [dpark: add more description in commit message] Signed-off-by: Dongsu Park <dongsu.park@xxxxxxxxxxxxxxxx> Cc: Al Viro <viro@xxxxxxxxxxxxxxxxxx> Cc: linux-fsdevel@xxxxxxxxxxxxxxx Cc: linux-pm@xxxxxxxxxxxxxxx --- fs/buffer.c | 4 ++-- kernel/power/block_io.c | 23 ++++++++++++++++++----- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/fs/buffer.c b/fs/buffer.c index 35ac0ec..78e63e3 100644 --- a/fs/buffer.c +++ b/fs/buffer.c @@ -3038,13 +3038,13 @@ int _submit_bh(int rw, struct buffer_head *bh, unsigned long bio_flags) if (buffer_prio(bh)) rw |= REQ_PRIO; - bio_get(bio); + atomic_inc(&bio->bi_remaining); submit_bio(rw, bio); if (bio_flagged(bio, BIO_EOPNOTSUPP)) ret = -EOPNOTSUPP; - bio_put(bio); + bio_endio(bio, 0); return ret; } EXPORT_SYMBOL_GPL(_submit_bh); diff --git a/kernel/power/block_io.c b/kernel/power/block_io.c index 9a58bc2..7206408 100644 --- a/kernel/power/block_io.c +++ b/kernel/power/block_io.c @@ -34,7 +34,6 @@ static int submit(int rw, struct block_device *bdev, sector_t sector, bio = bio_alloc(__GFP_WAIT | __GFP_HIGH, 1); bio->bi_iter.bi_sector = sector; bio->bi_bdev = bdev; - bio->bi_end_io = end_swap_bio_read; if (bio_add_page(bio, page, PAGE_SIZE, 0) < PAGE_SIZE) { printk(KERN_ERR "PM: Adding page to bio failed at %llu\n", @@ -44,15 +43,29 @@ static int submit(int rw, struct block_device *bdev, sector_t sector, } lock_page(page); - bio_get(bio); if (bio_chain == NULL) { - submit_bio(bio_rw, bio); - wait_on_page_locked(page); + int err = submit_bio_wait(bio_rw, bio); + + if (err) { + SetPageError(page); + ClearPageUptodate(page); + pr_alert("Read-error on swap-device (%u:%u:%llu)\n", + imajor(bio->bi_bdev->bd_inode), + iminor(bio->bi_bdev->bd_inode), + (unsigned long long)bio->bi_iter.bi_sector); + } else { + SetPageUptodate(page); + } + if (rw == READ) - bio_set_pages_dirty(bio); + set_page_dirty_lock(page); + unlock_page(page); bio_put(bio); } else { + bio->bi_end_io = end_swap_bio_read; + bio_get(bio); + if (rw == READ) get_page(page); /* These pages are freed later */ bio->bi_private = *bio_chain; -- 2.1.0 -- To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html