diff options
author | Jens Axboe <axboe@fb.com> | 2015-10-27 01:09:51 -0400 |
---|---|---|
committer | Jens Axboe <axboe@fb.com> | 2015-11-07 12:40:47 -0500 |
commit | 15c4f638f3d41bae52105ca4c0c8760afbcbeaab (patch) | |
tree | 4de68193b0c318d6b1b00ec2a06ae40c8ec8069e /fs/direct-io.c | |
parent | a0fa9647a54e81883abd57c5c865d1747f68a577 (diff) |
directio: add block polling support
This adds support for sync O_DIRECT read/write poll support.
Signed-off-by: Jens Axboe <axboe@fb.com>
[hch: split from a larger patch, minor updates]
Signed-off-by: Christoph Hellwig <hch@lst.de>
Acked-by: Keith Busch <keith.busch@intel.com>
Diffstat (limited to 'fs/direct-io.c')
-rw-r--r-- | fs/direct-io.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/fs/direct-io.c b/fs/direct-io.c index 3ae0e0427191..7025029c666f 100644 --- a/fs/direct-io.c +++ b/fs/direct-io.c | |||
@@ -109,6 +109,8 @@ struct dio_submit { | |||
109 | struct dio { | 109 | struct dio { |
110 | int flags; /* doesn't change */ | 110 | int flags; /* doesn't change */ |
111 | int rw; | 111 | int rw; |
112 | blk_qc_t bio_cookie; | ||
113 | struct block_device *bio_bdev; | ||
112 | struct inode *inode; | 114 | struct inode *inode; |
113 | loff_t i_size; /* i_size when submitted */ | 115 | loff_t i_size; /* i_size when submitted */ |
114 | dio_iodone_t *end_io; /* IO completion function */ | 116 | dio_iodone_t *end_io; /* IO completion function */ |
@@ -397,11 +399,14 @@ static inline void dio_bio_submit(struct dio *dio, struct dio_submit *sdio) | |||
397 | if (dio->is_async && dio->rw == READ && dio->should_dirty) | 399 | if (dio->is_async && dio->rw == READ && dio->should_dirty) |
398 | bio_set_pages_dirty(bio); | 400 | bio_set_pages_dirty(bio); |
399 | 401 | ||
400 | if (sdio->submit_io) | 402 | if (sdio->submit_io) { |
401 | sdio->submit_io(dio->rw, bio, dio->inode, | 403 | sdio->submit_io(dio->rw, bio, dio->inode, |
402 | sdio->logical_offset_in_bio); | 404 | sdio->logical_offset_in_bio); |
403 | else | 405 | dio->bio_cookie = BLK_QC_T_NONE; |
404 | submit_bio(dio->rw, bio); | 406 | } else { |
407 | dio->bio_cookie = submit_bio(dio->rw, bio); | ||
408 | dio->bio_bdev = bio->bi_bdev; | ||
409 | } | ||
405 | 410 | ||
406 | sdio->bio = NULL; | 411 | sdio->bio = NULL; |
407 | sdio->boundary = 0; | 412 | sdio->boundary = 0; |
@@ -440,7 +445,8 @@ static struct bio *dio_await_one(struct dio *dio) | |||
440 | __set_current_state(TASK_UNINTERRUPTIBLE); | 445 | __set_current_state(TASK_UNINTERRUPTIBLE); |
441 | dio->waiter = current; | 446 | dio->waiter = current; |
442 | spin_unlock_irqrestore(&dio->bio_lock, flags); | 447 | spin_unlock_irqrestore(&dio->bio_lock, flags); |
443 | io_schedule(); | 448 | if (!blk_poll(bdev_get_queue(dio->bio_bdev), dio->bio_cookie)) |
449 | io_schedule(); | ||
444 | /* wake up sets us TASK_RUNNING */ | 450 | /* wake up sets us TASK_RUNNING */ |
445 | spin_lock_irqsave(&dio->bio_lock, flags); | 451 | spin_lock_irqsave(&dio->bio_lock, flags); |
446 | dio->waiter = NULL; | 452 | dio->waiter = NULL; |