Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

aio: remove retry-based AIO

This removes the retry-based AIO infrastructure now that nothing in tree
is using it.

We want to remove retry-based AIO because it is fundemantally unsafe.
It retries IO submission from a kernel thread that has only assumed the
mm of the submitting task. All other task_struct references in the IO
submission path will see the kernel thread, not the submitting task.
This design flaw means that nothing of any meaningful complexity can use
retry-based AIO.

This removes all the code and data associated with the retry machinery.
The most significant benefit of this is the removal of the locking
around the unused run list in the submission path.

[akpm@linux-foundation.org: coding-style fixes]
Signed-off-by: Kent Overstreet <koverstreet@google.com>
Signed-off-by: Zach Brown <zab@redhat.com>
Cc: Zach Brown <zab@redhat.com>
Cc: Felipe Balbi <balbi@ti.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Mark Fasheh <mfasheh@suse.com>
Cc: Joel Becker <jlbec@evilplan.org>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Asai Thambi S P <asamymuthupa@micron.com>
Cc: Selvan Mani <smani@micron.com>
Cc: Sam Bradshaw <sbradshaw@micron.com>
Acked-by: Jeff Moyer <jmoyer@redhat.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Benjamin LaHaise <bcrl@kvack.org>
Reviewed-by: "Theodore Ts'o" <tytso@mit.edu>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Zach Brown and committed by
Linus Torvalds
41003a7b a80bf61e

+32 -380
+28 -325
fs/aio.c
··· 54 54 static struct kmem_cache *kiocb_cachep; 55 55 static struct kmem_cache *kioctx_cachep; 56 56 57 - static struct workqueue_struct *aio_wq; 58 - 59 - static void aio_kick_handler(struct work_struct *); 60 - static void aio_queue_work(struct kioctx *); 61 - 62 57 /* aio_setup 63 58 * Creates the slab caches used by the aio routines, panic on 64 59 * failure as this is done early during the boot sequence. ··· 62 67 { 63 68 kiocb_cachep = KMEM_CACHE(kiocb, SLAB_HWCACHE_ALIGN|SLAB_PANIC); 64 69 kioctx_cachep = KMEM_CACHE(kioctx,SLAB_HWCACHE_ALIGN|SLAB_PANIC); 65 - 66 - aio_wq = alloc_workqueue("aio", 0, 1); /* used to limit concurrency */ 67 - BUG_ON(!aio_wq); 68 70 69 71 pr_debug("aio_setup: sizeof(struct page) = %d\n", (int)sizeof(struct page)); 70 72 ··· 78 86 put_page(info->ring_pages[i]); 79 87 80 88 if (info->mmap_size) { 81 - BUG_ON(ctx->mm != current->mm); 82 89 vm_munmap(info->mmap_base, info->mmap_size); 83 90 } 84 91 ··· 92 101 struct aio_ring *ring; 93 102 struct aio_ring_info *info = &ctx->ring_info; 94 103 unsigned nr_events = ctx->max_reqs; 104 + struct mm_struct *mm = current->mm; 95 105 unsigned long size, populate; 96 106 int nr_pages; 97 107 ··· 118 126 119 127 info->mmap_size = nr_pages * PAGE_SIZE; 120 128 dprintk("attempting mmap of %lu bytes\n", info->mmap_size); 121 - down_write(&ctx->mm->mmap_sem); 129 + down_write(&mm->mmap_sem); 122 130 info->mmap_base = do_mmap_pgoff(NULL, 0, info->mmap_size, 123 131 PROT_READ|PROT_WRITE, 124 132 MAP_ANONYMOUS|MAP_PRIVATE, 0, 125 133 &populate); 126 134 if (IS_ERR((void *)info->mmap_base)) { 127 - up_write(&ctx->mm->mmap_sem); 135 + up_write(&mm->mmap_sem); 128 136 info->mmap_size = 0; 129 137 aio_free_ring(ctx); 130 138 return -EAGAIN; 131 139 } 132 140 133 141 dprintk("mmap address: 0x%08lx\n", info->mmap_base); 134 - info->nr_pages = get_user_pages(current, ctx->mm, 135 - info->mmap_base, nr_pages, 142 + info->nr_pages = get_user_pages(current, mm, info->mmap_base, nr_pages, 136 143 1, 0, info->ring_pages, NULL); 137 - up_write(&ctx->mm->mmap_sem); 144 + up_write(&mm->mmap_sem); 138 145 139 146 if (unlikely(info->nr_pages != nr_pages)) { 140 147 aio_free_ring(ctx); ··· 197 206 unsigned nr_events = ctx->max_reqs; 198 207 BUG_ON(ctx->reqs_active); 199 208 200 - cancel_delayed_work_sync(&ctx->wq); 201 209 aio_free_ring(ctx); 202 - mmdrop(ctx->mm); 203 - ctx->mm = NULL; 204 210 if (nr_events) { 205 211 spin_lock(&aio_nr_lock); 206 212 BUG_ON(aio_nr - nr_events > aio_nr); ··· 225 237 */ 226 238 static struct kioctx *ioctx_alloc(unsigned nr_events) 227 239 { 228 - struct mm_struct *mm; 240 + struct mm_struct *mm = current->mm; 229 241 struct kioctx *ctx; 230 242 int err = -ENOMEM; 231 243 ··· 244 256 return ERR_PTR(-ENOMEM); 245 257 246 258 ctx->max_reqs = nr_events; 247 - mm = ctx->mm = current->mm; 248 - atomic_inc(&mm->mm_count); 249 259 250 260 atomic_set(&ctx->users, 2); 251 261 spin_lock_init(&ctx->ctx_lock); ··· 251 265 init_waitqueue_head(&ctx->wait); 252 266 253 267 INIT_LIST_HEAD(&ctx->active_reqs); 254 - INIT_LIST_HEAD(&ctx->run_list); 255 - INIT_DELAYED_WORK(&ctx->wq, aio_kick_handler); 256 268 257 269 if (aio_setup_ring(ctx) < 0) 258 270 goto out_freectx; ··· 271 287 spin_unlock(&mm->ioctx_lock); 272 288 273 289 dprintk("aio: allocated ioctx %p[%ld]: mm=%p mask=0x%x\n", 274 - ctx, ctx->user_id, current->mm, ctx->ring_info.nr); 290 + ctx, ctx->user_id, mm, ctx->ring_info.nr); 275 291 return ctx; 276 292 277 293 out_cleanup: 278 294 err = -EAGAIN; 279 295 aio_free_ring(ctx); 280 296 out_freectx: 281 - mmdrop(mm); 282 297 kmem_cache_free(kioctx_cachep, ctx); 283 298 dprintk("aio: error allocating ioctx %d\n", err); 284 299 return ERR_PTR(err); ··· 374 391 * as indicator that it needs to unmap the area, 375 392 * just set it to 0; aio_free_ring() is the only 376 393 * place that uses ->mmap_size, so it's safe. 377 - * That way we get all munmap done to current->mm - 378 - * all other callers have ctx->mm == current->mm. 379 394 */ 380 395 ctx->ring_info.mmap_size = 0; 381 396 put_ioctx(ctx); ··· 407 426 req->ki_dtor = NULL; 408 427 req->private = NULL; 409 428 req->ki_iovec = NULL; 410 - INIT_LIST_HEAD(&req->ki_run_list); 411 429 req->ki_eventfd = NULL; 412 430 413 431 return req; ··· 591 611 return ret; 592 612 } 593 613 594 - /* 595 - * Queue up a kiocb to be retried. Assumes that the kiocb 596 - * has already been marked as kicked, and places it on 597 - * the retry run list for the corresponding ioctx, if it 598 - * isn't already queued. Returns 1 if it actually queued 599 - * the kiocb (to tell the caller to activate the work 600 - * queue to process it), or 0, if it found that it was 601 - * already queued. 602 - */ 603 - static inline int __queue_kicked_iocb(struct kiocb *iocb) 604 - { 605 - struct kioctx *ctx = iocb->ki_ctx; 606 - 607 - assert_spin_locked(&ctx->ctx_lock); 608 - 609 - if (list_empty(&iocb->ki_run_list)) { 610 - list_add_tail(&iocb->ki_run_list, 611 - &ctx->run_list); 612 - return 1; 613 - } 614 - return 0; 615 - } 616 - 617 - /* aio_run_iocb 618 - * This is the core aio execution routine. It is 619 - * invoked both for initial i/o submission and 620 - * subsequent retries via the aio_kick_handler. 621 - * Expects to be invoked with iocb->ki_ctx->lock 622 - * already held. The lock is released and reacquired 623 - * as needed during processing. 624 - * 625 - * Calls the iocb retry method (already setup for the 626 - * iocb on initial submission) for operation specific 627 - * handling, but takes care of most of common retry 628 - * execution details for a given iocb. The retry method 629 - * needs to be non-blocking as far as possible, to avoid 630 - * holding up other iocbs waiting to be serviced by the 631 - * retry kernel thread. 632 - * 633 - * The trickier parts in this code have to do with 634 - * ensuring that only one retry instance is in progress 635 - * for a given iocb at any time. Providing that guarantee 636 - * simplifies the coding of individual aio operations as 637 - * it avoids various potential races. 638 - */ 639 - static ssize_t aio_run_iocb(struct kiocb *iocb) 640 - { 641 - struct kioctx *ctx = iocb->ki_ctx; 642 - ssize_t (*retry)(struct kiocb *); 643 - ssize_t ret; 644 - 645 - if (!(retry = iocb->ki_retry)) { 646 - printk("aio_run_iocb: iocb->ki_retry = NULL\n"); 647 - return 0; 648 - } 649 - 650 - /* 651 - * We don't want the next retry iteration for this 652 - * operation to start until this one has returned and 653 - * updated the iocb state. However, wait_queue functions 654 - * can trigger a kick_iocb from interrupt context in the 655 - * meantime, indicating that data is available for the next 656 - * iteration. We want to remember that and enable the 657 - * next retry iteration _after_ we are through with 658 - * this one. 659 - * 660 - * So, in order to be able to register a "kick", but 661 - * prevent it from being queued now, we clear the kick 662 - * flag, but make the kick code *think* that the iocb is 663 - * still on the run list until we are actually done. 664 - * When we are done with this iteration, we check if 665 - * the iocb was kicked in the meantime and if so, queue 666 - * it up afresh. 667 - */ 668 - 669 - kiocbClearKicked(iocb); 670 - 671 - /* 672 - * This is so that aio_complete knows it doesn't need to 673 - * pull the iocb off the run list (We can't just call 674 - * INIT_LIST_HEAD because we don't want a kick_iocb to 675 - * queue this on the run list yet) 676 - */ 677 - iocb->ki_run_list.next = iocb->ki_run_list.prev = NULL; 678 - spin_unlock_irq(&ctx->ctx_lock); 679 - 680 - /* Quit retrying if the i/o has been cancelled */ 681 - if (kiocbIsCancelled(iocb)) { 682 - ret = -EINTR; 683 - aio_complete(iocb, ret, 0); 684 - /* must not access the iocb after this */ 685 - goto out; 686 - } 687 - 688 - /* 689 - * Now we are all set to call the retry method in async 690 - * context. 691 - */ 692 - ret = retry(iocb); 693 - 694 - if (ret != -EIOCBRETRY && ret != -EIOCBQUEUED) { 695 - /* 696 - * There's no easy way to restart the syscall since other AIO's 697 - * may be already running. Just fail this IO with EINTR. 698 - */ 699 - if (unlikely(ret == -ERESTARTSYS || ret == -ERESTARTNOINTR || 700 - ret == -ERESTARTNOHAND || ret == -ERESTART_RESTARTBLOCK)) 701 - ret = -EINTR; 702 - aio_complete(iocb, ret, 0); 703 - } 704 - out: 705 - spin_lock_irq(&ctx->ctx_lock); 706 - 707 - if (-EIOCBRETRY == ret) { 708 - /* 709 - * OK, now that we are done with this iteration 710 - * and know that there is more left to go, 711 - * this is where we let go so that a subsequent 712 - * "kick" can start the next iteration 713 - */ 714 - 715 - /* will make __queue_kicked_iocb succeed from here on */ 716 - INIT_LIST_HEAD(&iocb->ki_run_list); 717 - /* we must queue the next iteration ourselves, if it 718 - * has already been kicked */ 719 - if (kiocbIsKicked(iocb)) { 720 - __queue_kicked_iocb(iocb); 721 - 722 - /* 723 - * __queue_kicked_iocb will always return 1 here, because 724 - * iocb->ki_run_list is empty at this point so it should 725 - * be safe to unconditionally queue the context into the 726 - * work queue. 727 - */ 728 - aio_queue_work(ctx); 729 - } 730 - } 731 - return ret; 732 - } 733 - 734 - /* 735 - * __aio_run_iocbs: 736 - * Process all pending retries queued on the ioctx 737 - * run list. 738 - * Assumes it is operating within the aio issuer's mm 739 - * context. 740 - */ 741 - static int __aio_run_iocbs(struct kioctx *ctx) 742 - { 743 - struct kiocb *iocb; 744 - struct list_head run_list; 745 - 746 - assert_spin_locked(&ctx->ctx_lock); 747 - 748 - list_replace_init(&ctx->run_list, &run_list); 749 - while (!list_empty(&run_list)) { 750 - iocb = list_entry(run_list.next, struct kiocb, 751 - ki_run_list); 752 - list_del(&iocb->ki_run_list); 753 - /* 754 - * Hold an extra reference while retrying i/o. 755 - */ 756 - iocb->ki_users++; /* grab extra reference */ 757 - aio_run_iocb(iocb); 758 - __aio_put_req(ctx, iocb); 759 - } 760 - if (!list_empty(&ctx->run_list)) 761 - return 1; 762 - return 0; 763 - } 764 - 765 - static void aio_queue_work(struct kioctx * ctx) 766 - { 767 - unsigned long timeout; 768 - /* 769 - * if someone is waiting, get the work started right 770 - * away, otherwise, use a longer delay 771 - */ 772 - smp_mb(); 773 - if (waitqueue_active(&ctx->wait)) 774 - timeout = 1; 775 - else 776 - timeout = HZ/10; 777 - queue_delayed_work(aio_wq, &ctx->wq, timeout); 778 - } 779 - 780 - /* 781 - * aio_run_all_iocbs: 782 - * Process all pending retries queued on the ioctx 783 - * run list, and keep running them until the list 784 - * stays empty. 785 - * Assumes it is operating within the aio issuer's mm context. 786 - */ 787 - static inline void aio_run_all_iocbs(struct kioctx *ctx) 788 - { 789 - spin_lock_irq(&ctx->ctx_lock); 790 - while (__aio_run_iocbs(ctx)) 791 - ; 792 - spin_unlock_irq(&ctx->ctx_lock); 793 - } 794 - 795 - /* 796 - * aio_kick_handler: 797 - * Work queue handler triggered to process pending 798 - * retries on an ioctx. Takes on the aio issuer's 799 - * mm context before running the iocbs, so that 800 - * copy_xxx_user operates on the issuer's address 801 - * space. 802 - * Run on aiod's context. 803 - */ 804 - static void aio_kick_handler(struct work_struct *work) 805 - { 806 - struct kioctx *ctx = container_of(work, struct kioctx, wq.work); 807 - mm_segment_t oldfs = get_fs(); 808 - struct mm_struct *mm; 809 - int requeue; 810 - 811 - set_fs(USER_DS); 812 - use_mm(ctx->mm); 813 - spin_lock_irq(&ctx->ctx_lock); 814 - requeue =__aio_run_iocbs(ctx); 815 - mm = ctx->mm; 816 - spin_unlock_irq(&ctx->ctx_lock); 817 - unuse_mm(mm); 818 - set_fs(oldfs); 819 - /* 820 - * we're in a worker thread already; no point using non-zero delay 821 - */ 822 - if (requeue) 823 - queue_delayed_work(aio_wq, &ctx->wq, 0); 824 - } 825 - 826 - 827 - /* 828 - * Called by kick_iocb to queue the kiocb for retry 829 - * and if required activate the aio work queue to process 830 - * it 831 - */ 832 - static void try_queue_kicked_iocb(struct kiocb *iocb) 833 - { 834 - struct kioctx *ctx = iocb->ki_ctx; 835 - unsigned long flags; 836 - int run = 0; 837 - 838 - spin_lock_irqsave(&ctx->ctx_lock, flags); 839 - /* set this inside the lock so that we can't race with aio_run_iocb() 840 - * testing it and putting the iocb on the run list under the lock */ 841 - if (!kiocbTryKick(iocb)) 842 - run = __queue_kicked_iocb(iocb); 843 - spin_unlock_irqrestore(&ctx->ctx_lock, flags); 844 - if (run) 845 - aio_queue_work(ctx); 846 - } 847 - 848 - /* 849 - * kick_iocb: 850 - * Called typically from a wait queue callback context 851 - * to trigger a retry of the iocb. 852 - * The retry is usually executed by aio workqueue 853 - * threads (See aio_kick_handler). 854 - */ 855 - void kick_iocb(struct kiocb *iocb) 856 - { 857 - /* sync iocbs are easy: they can only ever be executing from a 858 - * single context. */ 859 - if (is_sync_kiocb(iocb)) { 860 - kiocbSetKicked(iocb); 861 - wake_up_process(iocb->ki_obj.tsk); 862 - return; 863 - } 864 - 865 - try_queue_kicked_iocb(iocb); 866 - } 867 - EXPORT_SYMBOL(kick_iocb); 868 - 869 614 /* aio_complete 870 615 * Called when the io request on the given iocb is complete. 871 616 * Returns true if this is the last user of the request. The ··· 630 925 * context. 631 926 */ 632 927 spin_lock_irqsave(&ctx->ctx_lock, flags); 633 - 634 - if (iocb->ki_run_list.prev && !list_empty(&iocb->ki_run_list)) 635 - list_del_init(&iocb->ki_run_list); 636 928 637 929 /* 638 930 * cancelled requests don't get events, userland was given one ··· 785 1083 int i = 0; 786 1084 struct io_event ent; 787 1085 struct aio_timeout to; 788 - int retry = 0; 789 1086 790 1087 /* needed to zero any padding within an entry (there shouldn't be 791 1088 * any, but C is fun! 792 1089 */ 793 1090 memset(&ent, 0, sizeof(ent)); 794 - retry: 795 1091 ret = 0; 796 1092 while (likely(i < nr)) { 797 1093 ret = aio_read_evt(ctx, &ent); ··· 818 1118 return ret; 819 1119 820 1120 /* End fast path */ 821 - 822 - /* racey check, but it gets redone */ 823 - if (!retry && unlikely(!list_empty(&ctx->run_list))) { 824 - retry = 1; 825 - aio_run_all_iocbs(ctx); 826 - goto retry; 827 - } 828 1121 829 1122 init_timeout(&to); 830 1123 if (timeout) { ··· 1042 1349 /* If we managed to write some out we return that, rather than 1043 1350 * the eventual error. */ 1044 1351 if (opcode == IOCB_CMD_PWRITEV 1045 - && ret < 0 && ret != -EIOCBQUEUED && ret != -EIOCBRETRY 1352 + && ret < 0 && ret != -EIOCBQUEUED 1046 1353 && iocb->ki_nbytes - iocb->ki_left) 1047 1354 ret = iocb->ki_nbytes - iocb->ki_left; 1048 1355 ··· 1284 1591 * don't see ctx->dead set here, io_destroy() waits for our IO to 1285 1592 * finish. 1286 1593 */ 1287 - if (ctx->dead) { 1288 - spin_unlock_irq(&ctx->ctx_lock); 1594 + if (ctx->dead) 1289 1595 ret = -EINVAL; 1290 - goto out_put_req; 1291 - } 1292 - aio_run_iocb(req); 1293 - if (!list_empty(&ctx->run_list)) { 1294 - /* drain the run list */ 1295 - while (__aio_run_iocbs(ctx)) 1296 - ; 1297 - } 1298 1596 spin_unlock_irq(&ctx->ctx_lock); 1597 + if (ret) 1598 + goto out_put_req; 1599 + 1600 + if (unlikely(kiocbIsCancelled(req))) 1601 + ret = -EINTR; 1602 + else 1603 + ret = req->ki_retry(req); 1604 + 1605 + if (ret != -EIOCBQUEUED) { 1606 + /* 1607 + * There's no easy way to restart the syscall since other AIO's 1608 + * may be already running. Just fail this IO with EINTR. 1609 + */ 1610 + if (unlikely(ret == -ERESTARTSYS || ret == -ERESTARTNOINTR || 1611 + ret == -ERESTARTNOHAND || 1612 + ret == -ERESTART_RESTARTBLOCK)) 1613 + ret = -EINTR; 1614 + aio_complete(req, ret, 0); 1615 + } 1299 1616 1300 1617 aio_put_req(req); /* drop extra ref to req */ 1301 1618 return 0;
+1 -1
fs/ocfs2/dlmglue.c
··· 2322 2322 status = __ocfs2_cluster_lock(osb, lockres, level, dlm_flags, 2323 2323 arg_flags, subclass, _RET_IP_); 2324 2324 if (status < 0) { 2325 - if (status != -EAGAIN && status != -EIOCBRETRY) 2325 + if (status != -EAGAIN) 2326 2326 mlog_errno(status); 2327 2327 goto bail; 2328 2328 }
+3 -31
fs/read_write.c
··· 329 329 return count > MAX_RW_COUNT ? MAX_RW_COUNT : count; 330 330 } 331 331 332 - static void wait_on_retry_sync_kiocb(struct kiocb *iocb) 333 - { 334 - set_current_state(TASK_UNINTERRUPTIBLE); 335 - if (!kiocbIsKicked(iocb)) 336 - schedule(); 337 - else 338 - kiocbClearKicked(iocb); 339 - __set_current_state(TASK_RUNNING); 340 - } 341 - 342 332 ssize_t do_sync_read(struct file *filp, char __user *buf, size_t len, loff_t *ppos) 343 333 { 344 334 struct iovec iov = { .iov_base = buf, .iov_len = len }; ··· 340 350 kiocb.ki_left = len; 341 351 kiocb.ki_nbytes = len; 342 352 343 - for (;;) { 344 - ret = filp->f_op->aio_read(&kiocb, &iov, 1, kiocb.ki_pos); 345 - if (ret != -EIOCBRETRY) 346 - break; 347 - wait_on_retry_sync_kiocb(&kiocb); 348 - } 349 - 353 + ret = filp->f_op->aio_read(&kiocb, &iov, 1, kiocb.ki_pos); 350 354 if (-EIOCBQUEUED == ret) 351 355 ret = wait_on_sync_kiocb(&kiocb); 352 356 *ppos = kiocb.ki_pos; ··· 390 406 kiocb.ki_left = len; 391 407 kiocb.ki_nbytes = len; 392 408 393 - for (;;) { 394 - ret = filp->f_op->aio_write(&kiocb, &iov, 1, kiocb.ki_pos); 395 - if (ret != -EIOCBRETRY) 396 - break; 397 - wait_on_retry_sync_kiocb(&kiocb); 398 - } 399 - 409 + ret = filp->f_op->aio_write(&kiocb, &iov, 1, kiocb.ki_pos); 400 410 if (-EIOCBQUEUED == ret) 401 411 ret = wait_on_sync_kiocb(&kiocb); 402 412 *ppos = kiocb.ki_pos; ··· 570 592 kiocb.ki_left = len; 571 593 kiocb.ki_nbytes = len; 572 594 573 - for (;;) { 574 - ret = fn(&kiocb, iov, nr_segs, kiocb.ki_pos); 575 - if (ret != -EIOCBRETRY) 576 - break; 577 - wait_on_retry_sync_kiocb(&kiocb); 578 - } 579 - 595 + ret = fn(&kiocb, iov, nr_segs, kiocb.ki_pos); 580 596 if (ret == -EIOCBQUEUED) 581 597 ret = wait_on_sync_kiocb(&kiocb); 582 598 *ppos = kiocb.ki_pos;
-22
include/linux/aio.h
··· 14 14 #define KIOCB_SYNC_KEY (~0U) 15 15 16 16 /* ki_flags bits */ 17 - #define KIF_KICKED 1 18 17 #define KIF_CANCELLED 2 19 18 20 - #define kiocbTryKick(iocb) test_and_set_bit(KIF_KICKED, &(iocb)->ki_flags) 21 - 22 - #define kiocbSetKicked(iocb) set_bit(KIF_KICKED, &(iocb)->ki_flags) 23 19 #define kiocbSetCancelled(iocb) set_bit(KIF_CANCELLED, &(iocb)->ki_flags) 24 20 25 - #define kiocbClearKicked(iocb) clear_bit(KIF_KICKED, &(iocb)->ki_flags) 26 21 #define kiocbClearCancelled(iocb) clear_bit(KIF_CANCELLED, &(iocb)->ki_flags) 27 22 28 - #define kiocbIsKicked(iocb) test_bit(KIF_KICKED, &(iocb)->ki_flags) 29 23 #define kiocbIsCancelled(iocb) test_bit(KIF_CANCELLED, &(iocb)->ki_flags) 30 24 31 25 /* is there a better place to document function pointer methods? */ ··· 46 52 * not ask the method again -- ki_retry must ensure forward progress. 47 53 * aio_complete() must be called once and only once in the future, multiple 48 54 * calls may result in undefined behaviour. 49 - * 50 - * If ki_retry returns -EIOCBRETRY it has made a promise that kick_iocb() 51 - * will be called on the kiocb pointer in the future. This may happen 52 - * through generic helpers that associate kiocb->ki_wait with a wait 53 - * queue head that ki_retry uses via current->io_wait. It can also happen 54 - * with custom tracking and manual calls to kick_iocb(), though that is 55 - * discouraged. In either case, kick_iocb() must be called once and only 56 - * once. ki_retry must ensure forward progress, the AIO core will wait 57 - * indefinitely for kick_iocb() to be called. 58 55 */ 59 56 struct kiocb { 60 - struct list_head ki_run_list; 61 57 unsigned long ki_flags; 62 58 int ki_users; 63 59 unsigned ki_key; /* id of this request */ ··· 144 160 struct kioctx { 145 161 atomic_t users; 146 162 int dead; 147 - struct mm_struct *mm; 148 163 149 164 /* This needs improving */ 150 165 unsigned long user_id; ··· 155 172 156 173 int reqs_active; 157 174 struct list_head active_reqs; /* used for cancellation */ 158 - struct list_head run_list; /* used for kicked reqs */ 159 175 160 176 /* sys_io_setup currently limits this to an unsigned int */ 161 177 unsigned max_reqs; 162 178 163 179 struct aio_ring_info ring_info; 164 - 165 - struct delayed_work wq; 166 180 167 181 struct rcu_head rcu_head; 168 182 }; ··· 168 188 #ifdef CONFIG_AIO 169 189 extern ssize_t wait_on_sync_kiocb(struct kiocb *iocb); 170 190 extern int aio_put_req(struct kiocb *iocb); 171 - extern void kick_iocb(struct kiocb *iocb); 172 191 extern int aio_complete(struct kiocb *iocb, long res, long res2); 173 192 struct mm_struct; 174 193 extern void exit_aio(struct mm_struct *mm); ··· 176 197 #else 177 198 static inline ssize_t wait_on_sync_kiocb(struct kiocb *iocb) { return 0; } 178 199 static inline int aio_put_req(struct kiocb *iocb) { return 0; } 179 - static inline void kick_iocb(struct kiocb *iocb) { } 180 200 static inline int aio_complete(struct kiocb *iocb, long res, long res2) { return 0; } 181 201 struct mm_struct; 182 202 static inline void exit_aio(struct mm_struct *mm) { }
-1
include/linux/errno.h
··· 28 28 #define EBADTYPE 527 /* Type not supported by server */ 29 29 #define EJUKEBOX 528 /* Request initiated, but will not complete before timeout */ 30 30 #define EIOCBQUEUED 529 /* iocb queued, will get completion event */ 31 - #define EIOCBRETRY 530 /* iocb queued, will trigger a retry */ 32 31 33 32 #endif