Commit eae83ce1 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Jens Axboe

block: wire up block device iopoll method

Just call blk_poll on the iocb cookie, we can derive the block device
from the inode trivially.
Reviewed-by: default avatarHannes Reinecke <hare@suse.com>
Reviewed-by: default avatarJohannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent fb7e1600
...@@ -294,6 +294,14 @@ struct blkdev_dio { ...@@ -294,6 +294,14 @@ struct blkdev_dio {
static struct bio_set blkdev_dio_pool; static struct bio_set blkdev_dio_pool;
static int blkdev_iopoll(struct kiocb *kiocb, bool wait)
{
struct block_device *bdev = I_BDEV(kiocb->ki_filp->f_mapping->host);
struct request_queue *q = bdev_get_queue(bdev);
return blk_poll(q, READ_ONCE(kiocb->ki_cookie), wait);
}
static void blkdev_bio_end_io(struct bio *bio) static void blkdev_bio_end_io(struct bio *bio)
{ {
struct blkdev_dio *dio = bio->bi_private; struct blkdev_dio *dio = bio->bi_private;
...@@ -408,10 +416,17 @@ __blkdev_direct_IO(struct kiocb *iocb, struct iov_iter *iter, int nr_pages) ...@@ -408,10 +416,17 @@ __blkdev_direct_IO(struct kiocb *iocb, struct iov_iter *iter, int nr_pages)
nr_pages = iov_iter_npages(iter, BIO_MAX_PAGES); nr_pages = iov_iter_npages(iter, BIO_MAX_PAGES);
if (!nr_pages) { if (!nr_pages) {
if (iocb->ki_flags & IOCB_HIPRI) bool polled = false;
if (iocb->ki_flags & IOCB_HIPRI) {
bio->bi_opf |= REQ_HIPRI; bio->bi_opf |= REQ_HIPRI;
polled = true;
}
qc = submit_bio(bio); qc = submit_bio(bio);
if (polled)
WRITE_ONCE(iocb->ki_cookie, qc);
break; break;
} }
...@@ -2078,6 +2093,7 @@ const struct file_operations def_blk_fops = { ...@@ -2078,6 +2093,7 @@ const struct file_operations def_blk_fops = {
.llseek = block_llseek, .llseek = block_llseek,
.read_iter = blkdev_read_iter, .read_iter = blkdev_read_iter,
.write_iter = blkdev_write_iter, .write_iter = blkdev_write_iter,
.iopoll = blkdev_iopoll,
.mmap = generic_file_mmap, .mmap = generic_file_mmap,
.fsync = blkdev_fsync, .fsync = blkdev_fsync,
.unlocked_ioctl = block_ioctl, .unlocked_ioctl = block_ioctl,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment