|
@@ -218,7 +218,7 @@ static struct page *dio_get_page(struct dio *dio)
|
|
|
* filesystems can use it to hold additional state between get_block calls and
|
|
|
* dio_complete.
|
|
|
*/
|
|
|
-static int dio_complete(struct dio *dio, loff_t offset, int ret)
|
|
|
+static int dio_complete(struct dio *dio, loff_t offset, int ret, bool is_async)
|
|
|
{
|
|
|
ssize_t transferred = 0;
|
|
|
|
|
@@ -239,14 +239,6 @@ static int dio_complete(struct dio *dio, loff_t offset, int ret)
|
|
|
transferred = dio->i_size - offset;
|
|
|
}
|
|
|
|
|
|
- if (dio->end_io && dio->result)
|
|
|
- dio->end_io(dio->iocb, offset, transferred,
|
|
|
- dio->map_bh.b_private);
|
|
|
-
|
|
|
- if (dio->flags & DIO_LOCKING)
|
|
|
- /* lockdep: non-owner release */
|
|
|
- up_read_non_owner(&dio->inode->i_alloc_sem);
|
|
|
-
|
|
|
if (ret == 0)
|
|
|
ret = dio->page_errors;
|
|
|
if (ret == 0)
|
|
@@ -254,6 +246,17 @@ static int dio_complete(struct dio *dio, loff_t offset, int ret)
|
|
|
if (ret == 0)
|
|
|
ret = transferred;
|
|
|
|
|
|
+ if (dio->end_io && dio->result) {
|
|
|
+ dio->end_io(dio->iocb, offset, transferred,
|
|
|
+ dio->map_bh.b_private, ret, is_async);
|
|
|
+ } else if (is_async) {
|
|
|
+ aio_complete(dio->iocb, ret, 0);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (dio->flags & DIO_LOCKING)
|
|
|
+ /* lockdep: non-owner release */
|
|
|
+ up_read_non_owner(&dio->inode->i_alloc_sem);
|
|
|
+
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
@@ -277,8 +280,7 @@ static void dio_bio_end_aio(struct bio *bio, int error)
|
|
|
spin_unlock_irqrestore(&dio->bio_lock, flags);
|
|
|
|
|
|
if (remaining == 0) {
|
|
|
- int ret = dio_complete(dio, dio->iocb->ki_pos, 0);
|
|
|
- aio_complete(dio->iocb, ret, 0);
|
|
|
+ dio_complete(dio, dio->iocb->ki_pos, 0, true);
|
|
|
kfree(dio);
|
|
|
}
|
|
|
}
|
|
@@ -1126,7 +1128,7 @@ direct_io_worker(int rw, struct kiocb *iocb, struct inode *inode,
|
|
|
spin_unlock_irqrestore(&dio->bio_lock, flags);
|
|
|
|
|
|
if (ret2 == 0) {
|
|
|
- ret = dio_complete(dio, offset, ret);
|
|
|
+ ret = dio_complete(dio, offset, ret, false);
|
|
|
kfree(dio);
|
|
|
} else
|
|
|
BUG_ON(ret != -EIOCBQUEUED);
|