diff options
Diffstat (limited to 'fs/aio.c')
-rw-r--r-- | fs/aio.c | 48 |
1 files changed, 36 insertions, 12 deletions
@@ -712,8 +712,16 @@ static ssize_t aio_run_iocb(struct kiocb *iocb) | |||
712 | */ | 712 | */ |
713 | ret = retry(iocb); | 713 | ret = retry(iocb); |
714 | 714 | ||
715 | if (ret != -EIOCBRETRY && ret != -EIOCBQUEUED) | 715 | if (ret != -EIOCBRETRY && ret != -EIOCBQUEUED) { |
716 | /* | ||
717 | * There's no easy way to restart the syscall since other AIO's | ||
718 | * may be already running. Just fail this IO with EINTR. | ||
719 | */ | ||
720 | if (unlikely(ret == -ERESTARTSYS || ret == -ERESTARTNOINTR || | ||
721 | ret == -ERESTARTNOHAND || ret == -ERESTART_RESTARTBLOCK)) | ||
722 | ret = -EINTR; | ||
716 | aio_complete(iocb, ret, 0); | 723 | aio_complete(iocb, ret, 0); |
724 | } | ||
717 | out: | 725 | out: |
718 | spin_lock_irq(&ctx->ctx_lock); | 726 | spin_lock_irq(&ctx->ctx_lock); |
719 | 727 | ||
@@ -1277,7 +1285,7 @@ out: | |||
1277 | /* sys_io_destroy: | 1285 | /* sys_io_destroy: |
1278 | * Destroy the aio_context specified. May cancel any outstanding | 1286 | * Destroy the aio_context specified. May cancel any outstanding |
1279 | * AIOs and block on completion. Will fail with -ENOSYS if not | 1287 | * AIOs and block on completion. Will fail with -ENOSYS if not |
1280 | * implemented. May fail with -EFAULT if the context pointed to | 1288 | * implemented. May fail with -EINVAL if the context pointed to |
1281 | * is invalid. | 1289 | * is invalid. |
1282 | */ | 1290 | */ |
1283 | SYSCALL_DEFINE1(io_destroy, aio_context_t, ctx) | 1291 | SYSCALL_DEFINE1(io_destroy, aio_context_t, ctx) |
@@ -1535,7 +1543,19 @@ static void aio_batch_add(struct address_space *mapping, | |||
1535 | } | 1543 | } |
1536 | 1544 | ||
1537 | abe = mempool_alloc(abe_pool, GFP_KERNEL); | 1545 | abe = mempool_alloc(abe_pool, GFP_KERNEL); |
1538 | BUG_ON(!igrab(mapping->host)); | 1546 | |
1547 | /* | ||
1548 | * we should be using igrab here, but | ||
1549 | * we don't want to hammer on the global | ||
1550 | * inode spinlock just to take an extra | ||
1551 | * reference on a file that we must already | ||
1552 | * have a reference to. | ||
1553 | * | ||
1554 | * When we're called, we always have a reference | ||
1555 | * on the file, so we must always have a reference | ||
1556 | * on the inode, so ihold() is safe here. | ||
1557 | */ | ||
1558 | ihold(mapping->host); | ||
1539 | abe->mapping = mapping; | 1559 | abe->mapping = mapping; |
1540 | hlist_add_head(&abe->list, &batch_hash[bucket]); | 1560 | hlist_add_head(&abe->list, &batch_hash[bucket]); |
1541 | return; | 1561 | return; |
@@ -1659,6 +1679,9 @@ long do_io_submit(aio_context_t ctx_id, long nr, | |||
1659 | if (unlikely(nr < 0)) | 1679 | if (unlikely(nr < 0)) |
1660 | return -EINVAL; | 1680 | return -EINVAL; |
1661 | 1681 | ||
1682 | if (unlikely(nr > LONG_MAX/sizeof(*iocbpp))) | ||
1683 | nr = LONG_MAX/sizeof(*iocbpp); | ||
1684 | |||
1662 | if (unlikely(!access_ok(VERIFY_READ, iocbpp, (nr*sizeof(*iocbpp))))) | 1685 | if (unlikely(!access_ok(VERIFY_READ, iocbpp, (nr*sizeof(*iocbpp))))) |
1663 | return -EFAULT; | 1686 | return -EFAULT; |
1664 | 1687 | ||
@@ -1795,15 +1818,16 @@ SYSCALL_DEFINE3(io_cancel, aio_context_t, ctx_id, struct iocb __user *, iocb, | |||
1795 | 1818 | ||
1796 | /* io_getevents: | 1819 | /* io_getevents: |
1797 | * Attempts to read at least min_nr events and up to nr events from | 1820 | * Attempts to read at least min_nr events and up to nr events from |
1798 | * the completion queue for the aio_context specified by ctx_id. May | 1821 | * the completion queue for the aio_context specified by ctx_id. If |
1799 | * fail with -EINVAL if ctx_id is invalid, if min_nr is out of range, | 1822 | * it succeeds, the number of read events is returned. May fail with |
1800 | * if nr is out of range, if when is out of range. May fail with | 1823 | * -EINVAL if ctx_id is invalid, if min_nr is out of range, if nr is |
1801 | * -EFAULT if any of the memory specified to is invalid. May return | 1824 | * out of range, if timeout is out of range. May fail with -EFAULT |
1802 | * 0 or < min_nr if no events are available and the timeout specified | 1825 | * if any of the memory specified is invalid. May return 0 or |
1803 | * by when has elapsed, where when == NULL specifies an infinite | 1826 | * < min_nr if the timeout specified by timeout has elapsed |
1804 | * timeout. Note that the timeout pointed to by when is relative and | 1827 | * before sufficient events are available, where timeout == NULL |
1805 | * will be updated if not NULL and the operation blocks. Will fail | 1828 | * specifies an infinite timeout. Note that the timeout pointed to by |
1806 | * with -ENOSYS if not implemented. | 1829 | * timeout is relative and will be updated if not NULL and the |
1830 | * operation blocks. Will fail with -ENOSYS if not implemented. | ||
1807 | */ | 1831 | */ |
1808 | SYSCALL_DEFINE5(io_getevents, aio_context_t, ctx_id, | 1832 | SYSCALL_DEFINE5(io_getevents, aio_context_t, ctx_id, |
1809 | long, min_nr, | 1833 | long, min_nr, |